INET Framework for OMNeT++/OMNEST
|
Routing support. More...
#include <Topology.h>
Classes | |
class | Link |
Supporting class for Topology, represents a link in the graph. More... | |
class | LinkIn |
Supporting class for Topology. More... | |
class | LinkOut |
Supporting class for Topology. More... | |
class | Node |
Supporting class for Topology, represents a node in the graph. More... | |
class | Predicate |
Base class for selector objects used in extract...() methods of Topology. More... | |
Public Member Functions | |
Constructors, destructor, assignment | |
Topology (const char *name=nullptr) | |
Constructor. More... | |
Topology (const Topology &topo) | |
Copy constructor. More... | |
virtual | ~Topology () |
Destructor. More... | |
Topology & | operator= (const Topology &topo) |
Assignment operator. More... | |
Redefined cObject member functions. | |
virtual Topology * | dup () const override |
Creates and returns an exact copy of this object. More... | |
virtual std::string | info () const override |
Produces a one-line description of the object's contents. More... | |
virtual void | parsimPack (cCommBuffer *buffer) const override |
Serializes the object into an MPI send buffer. More... | |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. More... | |
Extracting the topology from a network. | |
extract...() functions build topology from the model. User can select which modules to include. All connections between those modules will be in the topology. Connections can cross compound module boundaries. | |
void | extractFromNetwork (bool(*selfunc)(cModule *, void *), void *userdata=nullptr) |
Extracts model topology by a user-defined criteria. More... | |
void | extractFromNetwork (Predicate *predicate) |
The type safe, object-oriented equivalent of extractFromNetwork(selfunc, userdata). More... | |
void | extractByModulePath (const std::vector< std::string > &fullPathPatterns) |
Extracts model topology by module full path. More... | |
void | extractByNedTypeName (const std::vector< std::string > &nedTypeNames) |
Extracts model topology by the fully qualified NED type name of the modules. More... | |
void | extractByProperty (const char *propertyName, const char *value=nullptr) |
Extracts model topology by a module property. More... | |
void | extractByParameter (const char *paramName, const char *paramValue=nullptr) |
Extracts model topology by a module parameter. More... | |
void | clear () |
Deletes the topology stored in the object. More... | |
Manipulating the graph. | |
int | addNode (Node *node) |
Adds the given node to the graph. More... | |
void | deleteNode (Node *node) |
Removes the given node from the graph, together with all of its links. More... | |
void | addLink (Link *link, Node *srcNode, Node *destNode) |
TODO Note: also serves as reconnectLink() More... | |
void | addLink (Link *link, cGate *srcGate, cGate *destGate) |
TODO Note: also serves as reconnectLink() More... | |
void | deleteLink (Link *link) |
Removes the given link from the graph. More... | |
Functions to examine topology by hand. | |
int | getNumNodes () const |
Returns the number of nodes in the graph. More... | |
Node * | getNode (int i) |
Returns pointer to the ith node in the graph. More... | |
Node * | getNodeFor (cModule *mod) |
Returns the graph node which corresponds to the given module in the network. More... | |
Algorithms to find shortest paths. | |
void | calculateUnweightedSingleShortestPathsTo (Node *target) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node. More... | |
void | calculateWeightedSingleShortestPathsTo (Node *target) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node. More... | |
Node * | getTargetNode () const |
Returns the node that was passed to the most recently called shortest path finding function. More... | |
Protected Member Functions | |
void | unlinkFromSourceNode (Link *link) |
void | unlinkFromDestNode (Link *link) |
virtual Node * | createNode (cModule *module) |
Node factory. More... | |
virtual Link * | createLink () |
Link factory. More... | |
Static Protected Member Functions | |
static bool | lessByModuleId (Node *a, Node *b) |
static bool | isModuleIdLess (Node *a, int moduleId) |
Protected Attributes | |
std::vector< Node * > | nodes |
Node * | target |
Routing support.
The Topology class was designed primarily to support routing in telecommunication or multiprocessor networks.
A Topology object stores an abstract representation of the network in graph form:
You can specify which modules (either simple or compound) you want to include in the graph. The graph will include all connections among the selected modules. In the graph, all nodes are at the same level, there is no submodule nesting. Connections which span across compound module boundaries are also represented as one graph edge. Graph edges are directed, just as module gates are.
|
explicit |
Constructor.
inet::Topology::Topology | ( | const Topology & | topo | ) |
|
virtual |
Destructor.
Reimplemented in inet::NetworkConfiguratorBase::Topology.
TODO Note: also serves as reconnectLink()
Referenced by inet::NetworkConfiguratorBase::extractTopology().
void inet::Topology::addLink | ( | Link * | link, |
cGate * | srcGate, | ||
cGate * | destGate | ||
) |
TODO Note: also serves as reconnectLink()
int inet::Topology::addNode | ( | Node * | node | ) |
Adds the given node to the graph.
Returns the index of the new graph node (see getNode(int)). Indices of existing graph nodes may change.
void inet::Topology::calculateUnweightedSingleShortestPathsTo | ( | Node * | target | ) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node.
The paths found can be extracted via Node's methods.
void inet::Topology::calculateWeightedSingleShortestPathsTo | ( | Node * | target | ) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node.
The paths found can be extracted via Node's methods. Uses weights in nodes and links.
Referenced by inet::GenericNetworkConfigurator::addStaticRoutes(), and inet::IPv4NetworkConfigurator::addStaticRoutes().
void inet::Topology::clear | ( | ) |
Deletes the topology stored in the object.
Referenced by inet::IPv4NetworkConfigurator::computeConfiguration(), extractFromNetwork(), and ~Topology().
|
inlineprotectedvirtual |
Link factory.
Reimplemented in inet::NetworkConfiguratorBase::Topology, and inet::L2NetworkConfigurator::L2Topology.
Referenced by extractFromNetwork().
|
inlineprotectedvirtual |
Node factory.
Reimplemented in inet::NetworkConfiguratorBase::Topology, inet::L2NetworkConfigurator::L2Topology, and inet::IPv4NetworkConfigurator::Topology.
Referenced by extractFromNetwork().
void inet::Topology::deleteLink | ( | Link * | link | ) |
Removes the given link from the graph.
Indices of existing links in the source and destination nodes may change.
void inet::Topology::deleteNode | ( | Node * | node | ) |
Removes the given node from the graph, together with all of its links.
Indices of existing graph nodes may change.
|
inlineoverridevirtual |
Creates and returns an exact copy of this object.
See cObject for more details.
void inet::Topology::extractByModulePath | ( | const std::vector< std::string > & | fullPathPatterns | ) |
Extracts model topology by module full path.
All modules whole getFullPath() matches one of the patterns in given string vector will get included. The patterns may contain wilcards in the same syntax as in ini files.
An example:
topo.extractByModulePath(cStringTokenizer("**.host[*] **.router*").asVector());
void inet::Topology::extractByNedTypeName | ( | const std::vector< std::string > & | nedTypeNames | ) |
Extracts model topology by the fully qualified NED type name of the modules.
All modules whose getNedTypeName() is listed in the given string vector will get included.
Note: If you have all class names as a single, space-separated string, you can use cStringTokenizer to turn it into a string vector:
topo.extractByNedTypeName(cStringTokenizer("some.package.Host other.package.Router").asVector());
void inet::Topology::extractByParameter | ( | const char * | paramName, |
const char * | paramValue = nullptr |
||
) |
Extracts model topology by a module parameter.
All modules get included that have a parameter with the given name, and the parameter's str() method returns the paramValue string. If paramValue is nullptr, only the parameter's existence is checked but not its value.
void inet::Topology::extractByProperty | ( | const char * | propertyName, |
const char * | value = nullptr |
||
) |
Extracts model topology by a module property.
All modules get included that have a property with the given name and the given value (more precisely, the first value of its default key being the specified value). If value is nullptr, the property's value may be anything except "false" (i.e. the first value of the default key may not be "false").
For example, topo.extractByProperty("networkNode");
would extract all modules that contain the @networkNode
property, like the following one:
module X { @networkNode; }
Referenced by inet::STPTester::depthFirstSearch(), inet::L2NetworkConfigurator::extractTopology(), and inet::NetworkConfiguratorBase::extractTopology().
void inet::Topology::extractFromNetwork | ( | bool(*)(cModule *, void *) | selfunc, |
void * | userdata = nullptr |
||
) |
Extracts model topology by a user-defined criteria.
Includes into the graph modules for which the passed selfunc() returns nonzero. The userdata parameter may take any value you like, and it is passed back to selfunc() in its second argument.
Referenced by extractByModulePath(), extractByNedTypeName(), extractByParameter(), extractByProperty(), and extractFromNetwork().
void inet::Topology::extractFromNetwork | ( | Predicate * | predicate | ) |
The type safe, object-oriented equivalent of extractFromNetwork(selfunc, userdata).
Topology::Node * inet::Topology::getNode | ( | int | i | ) |
Returns pointer to the ith node in the graph.
Node's methods can be used to further examine the node's connectivity, etc.
Referenced by inet::GenericNetworkConfigurator::addStaticRoutes(), inet::IPv4NetworkConfigurator::addStaticRoutes(), inet::IPv4NetworkConfigurator::configureAllInterfaces(), inet::IPv4NetworkConfigurator::configureAllRoutingTables(), inet::L2NetworkConfigurator::configureInterface(), inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::STPTester::depthFirstSearch(), inet::IPv4NetworkConfigurator::dumpConfig(), inet::GenericNetworkConfigurator::dumpRoutes(), inet::IPv4NetworkConfigurator::dumpRoutes(), inet::NetworkConfiguratorBase::dumpTopology(), inet::L2NetworkConfigurator::extractTopology(), inet::NetworkConfiguratorBase::extractTopology(), inet::NetworkConfiguratorBase::extractWirelessNeighbors(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::IPv4NetworkConfigurator::readManualRouteConfiguration().
Topology::Node * inet::Topology::getNodeFor | ( | cModule * | mod | ) |
Returns the graph node which corresponds to the given module in the network.
If no graph node corresponds to the module, the method returns nullptr. This method assumes that the topology corresponds to the network, that is, it was probably created with one of the extract...() functions.
Referenced by addLink(), and extractFromNetwork().
|
inline |
Returns the number of nodes in the graph.
Referenced by inet::GenericNetworkConfigurator::addStaticRoutes(), inet::IPv4NetworkConfigurator::addStaticRoutes(), inet::IPv4NetworkConfigurator::configureAllInterfaces(), inet::IPv4NetworkConfigurator::configureAllRoutingTables(), inet::L2NetworkConfigurator::configureInterface(), inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::STPTester::depthFirstSearch(), inet::IPv4NetworkConfigurator::dumpConfig(), inet::GenericNetworkConfigurator::dumpRoutes(), inet::IPv4NetworkConfigurator::dumpRoutes(), inet::NetworkConfiguratorBase::dumpTopology(), inet::L2NetworkConfigurator::ensureConfigurationComputed(), inet::IPv4NetworkConfigurator::ensureConfigurationComputed(), inet::L2NetworkConfigurator::extractTopology(), inet::NetworkConfiguratorBase::extractTopology(), inet::NetworkConfiguratorBase::extractWirelessNeighbors(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::IPv4NetworkConfigurator::readManualRouteConfiguration().
|
inline |
Returns the node that was passed to the most recently called shortest path finding function.
|
overridevirtual |
Produces a one-line description of the object's contents.
See cObject for more details.
|
inlinestaticprotected |
Referenced by addNode(), and getNodeFor().
Assignment operator.
The name member is not copied; see cNamedObject's operator=() for more details.
|
overridevirtual |
|
overridevirtual |
|
protected |
Referenced by addLink(), deleteLink(), and deleteNode().
|
protected |
Referenced by addLink(), deleteLink(), and deleteNode().
|
protected |
|
protected |
Referenced by calculateUnweightedSingleShortestPathsTo(), calculateWeightedSingleShortestPathsTo(), and Topology().