INET Framework for OMNeT++/OMNEST
inet::NetworkConfiguratorBase Class Reference

#include <NetworkConfiguratorBase.h>

Inheritance diagram for inet::NetworkConfiguratorBase:
inet::FailureProtectionConfigurator inet::GateScheduleConfiguratorBase inet::MacForwardingTableConfigurator inet::StreamRedundancyConfigurator inet::AlwaysOpenGateScheduleConfigurator inet::EagerGateScheduleConfigurator inet::TSNschedGateScheduleConfigurator inet::Z3GateScheduleConfigurator

Classes

class  Interface
 Represents an interface in the network. More...
 
class  Link
 
class  Node
 Represents a node in the network. More...
 
class  Topology
 

Protected Member Functions

virtual ~NetworkConfiguratorBase ()
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void extractTopology (Topology &topology)
 Extracts network topology by walking through the module hierarchy. More...
 
virtual std::vector< Node * > computeShortestNodePath (Node *source, Node *destination) const
 
virtual std::vector< Link * > computeShortestLinkPath (Node *source, Node *destination) const
 
virtual bool isBridgeNode (Node *node) const
 
virtual LinkfindLinkIn (const Node *node, const char *neighbor) const
 
virtual LinkfindLinkOut (const Node *node, const char *neighbor) const
 
virtual LinkfindLinkOut (const Node *node, const Node *neighbor) const
 
virtual LinkfindLinkOut (const Interface *interface) const
 
virtual Topology::LinkfindLinkOut (const Node *node, int gateId) const
 
virtual InterfacefindInterface (const Node *node, NetworkInterface *networkInterface) const
 

Protected Attributes

Topologytopology = nullptr
 

Constructor & Destructor Documentation

◆ ~NetworkConfiguratorBase()

virtual inet::NetworkConfiguratorBase::~NetworkConfiguratorBase ( )
inlineprotectedvirtual
70 { delete topology; }

Member Function Documentation

◆ computeShortestLinkPath()

std::vector< NetworkConfiguratorBase::Link * > inet::NetworkConfiguratorBase::computeShortestLinkPath ( Node source,
Node destination 
) const
protectedvirtual
91 {
92  std::vector<Link *> path;
94  auto node = source;
95  while (node != destination) {
96  auto link = (Link *)node->getPath(0);
97  path.push_back(link);
98  node = (Node *)node->getPath(0)->getLinkOutRemoteNode();
99  }
100  return path;
101 }

◆ computeShortestNodePath()

std::vector< NetworkConfiguratorBase::Node * > inet::NetworkConfiguratorBase::computeShortestNodePath ( Node source,
Node destination 
) const
protectedvirtual
78 {
79  std::vector<Node *> path;
81  auto node = source;
82  while (node != destination) {
83  path.push_back(node);
84  node = (Node *)node->getPath(0)->getLinkOutRemoteNode();
85  }
86  path.push_back(destination);
87  return path;
88 }

Referenced by inet::GateScheduleConfiguratorBase::addFlows().

◆ extractTopology()

void inet::NetworkConfiguratorBase::extractTopology ( Topology topology)
protectedvirtual

Extracts network topology by walking through the module hierarchy.

Creates nodes from modules having @networkNode property. Creates links from connections (wired and wireless) between network interfaces.

20 {
21  topology.extractByProperty("networkNode");
22  EV_DEBUG << "Topology found " << topology.getNumNodes() << " nodes\n";
23  if (topology.getNumNodes() == 0)
24  throw cRuntimeError("Empty network!");
25  // extract nodes, fill in interfaceTable and routingTable members in node
26  L3AddressResolver addressResolver;
27  for (int i = 0; i < topology.getNumNodes(); i++) {
28  Node *node = (Node *)topology.getNode(i);
29  node->module = node->getModule();
30  node->interfaceTable = addressResolver.findInterfaceTableOf(node->module);
31  node->routingTable = addressResolver.findIpv4RoutingTableOf(node->module);
32  }
33  // extract links and interfaces
34  std::set<NetworkInterface *> interfacesSeen;
35  std::queue<Node *> unvisited; // unvisited nodes in the graph
36  auto rootNode = (Node *)topology.getNode(0);
37  unvisited.push(rootNode);
38  while (!unvisited.empty()) {
39  Node *node = unvisited.front();
40  unvisited.pop();
41  IInterfaceTable *interfaceTable = node->interfaceTable;
42  if (interfaceTable) {
43  // push neighbors to the queue
44  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++) {
45  NetworkInterface *networkInterface = interfaceTable->getInterface(i);
46  if (interfacesSeen.count(networkInterface) == 0) {
47  // visiting this interface
48  interfacesSeen.insert(networkInterface);
49  Topology::Link *linkOut = findLinkOut(node, networkInterface->getNodeOutputGateId());
50  Node *childNode = nullptr;
51  if (linkOut) {
52  childNode = (Node *)linkOut->getLinkOutRemoteNode();
53  unvisited.push(childNode);
54  }
55  Interface *interface = new Interface(node, networkInterface);
56  node->interfaces.push_back(interface);
57  }
58  }
59  }
60  }
61  // annotate links with interfaces
62  for (int i = 0; i < topology.getNumNodes(); i++) {
63  Node *node = (Node *)topology.getNode(i);
64  for (int j = 0; j < node->getNumOutLinks(); j++) {
65  Topology::Link *linkOut = node->getLinkOut(j);
66  Link *link = (Link *)linkOut;
67  Node *localNode = (Node *)linkOut->getLinkOutLocalNode();
68  if (localNode->interfaceTable)
69  link->sourceInterface = findInterface(localNode, localNode->interfaceTable->findInterfaceByNodeOutputGateId(linkOut->getLinkOutLocalGateId()));
70  Node *remoteNode = (Node *)linkOut->getLinkOutRemoteNode();
71  if (remoteNode->interfaceTable)
72  link->destinationInterface = findInterface(remoteNode, remoteNode->interfaceTable->findInterfaceByNodeInputGateId(linkOut->getLinkOutRemoteGateId()));
73  }
74  }
75 }

Referenced by inet::MacForwardingTableConfigurator::computeConfiguration(), inet::FailureProtectionConfigurator::computeConfiguration(), inet::StreamRedundancyConfigurator::computeConfiguration(), and inet::GateScheduleConfiguratorBase::computeConfiguration().

◆ findInterface()

NetworkConfiguratorBase::Interface * inet::NetworkConfiguratorBase::findInterface ( const Node node,
NetworkInterface networkInterface 
) const
protectedvirtual
151 {
152  if (networkInterface == nullptr)
153  return nullptr;
154  for (auto& interface : node->interfaces)
155  if (interface->networkInterface == networkInterface)
156  return interface;
157  return nullptr;
158 }

Referenced by inet::GateScheduleConfiguratorBase::addPorts(), extractTopology(), and inet::MacForwardingTableConfigurator::receiveSignal().

◆ findLinkIn()

NetworkConfiguratorBase::Link * inet::NetworkConfiguratorBase::findLinkIn ( const Node node,
const char *  neighbor 
) const
protectedvirtual
109 {
110  for (int i = 0; i < node->getNumInLinks(); i++)
111  if (!strcmp(node->getLinkIn(i)->getLinkInRemoteNode()->getModule()->getFullName(), neighbor))
112  return check_and_cast<Link *>(static_cast<Topology::Link *>(node->getLinkIn(i)));
113  return nullptr;
114 }

Referenced by inet::StreamRedundancyConfigurator::computeStreamPolicyConfigurations().

◆ findLinkOut() [1/4]

NetworkConfiguratorBase::Link * inet::NetworkConfiguratorBase::findLinkOut ( const Interface interface) const
protectedvirtual
133 {
134  for (int i = 0; i < interface->node->getNumOutLinks(); i++) {
135  auto link = check_and_cast<Link *>(static_cast<Topology::Link *>(interface->node->getLinkOut(i)));
136  if (link->sourceInterface == interface)
137  return link;
138  }
139  return nullptr;
140 }

◆ findLinkOut() [2/4]

NetworkConfiguratorBase::Link * inet::NetworkConfiguratorBase::findLinkOut ( const Node node,
const char *  neighbor 
) const
protectedvirtual
117 {
118  for (int i = 0; i < node->getNumOutLinks(); i++)
119  if (!strcmp(node->getLinkOut(i)->getLinkOutRemoteNode()->getModule()->getFullName(), neighbor))
120  return check_and_cast<Link *>(static_cast<Topology::Link *>(node->getLinkOut(i)));
121  return nullptr;
122 }

Referenced by inet::GateScheduleConfiguratorBase::addPorts(), inet::EagerGateScheduleConfigurator::computeStartOffsetForPathFragments(), inet::StreamRedundancyConfigurator::computeStreamSendersAndReceivers(), and extractTopology().

◆ findLinkOut() [3/4]

NetworkConfiguratorBase::Link * inet::NetworkConfiguratorBase::findLinkOut ( const Node node,
const Node neighbor 
) const
protectedvirtual
125 {
126  for (int i = 0; i < node->getNumOutLinks(); i++)
127  if (node->getLinkOut(i)->getLinkOutRemoteNode() == neighbor)
128  return check_and_cast<Link *>(static_cast<Topology::Link *>(node->getLinkOut(i)));
129  return nullptr;
130 }

◆ findLinkOut() [4/4]

Topology::Link * inet::NetworkConfiguratorBase::findLinkOut ( const Node node,
int  gateId 
) const
protectedvirtual
143 {
144  for (int i = 0; i < node->getNumOutLinks(); i++)
145  if (node->getLinkOut(i)->getLinkOutLocalGateId() == gateId)
146  return node->getLinkOut(i);
147  return nullptr;
148 }

◆ handleMessage()

virtual void inet::NetworkConfiguratorBase::handleMessage ( cMessage *  msg)
inlineoverrideprotectedvirtual

Reimplemented in inet::GateScheduleConfiguratorBase.

72 { throw cRuntimeError("Invalid operation"); }

◆ isBridgeNode()

bool inet::NetworkConfiguratorBase::isBridgeNode ( Node node) const
protectedvirtual

◆ numInitStages()

virtual int inet::NetworkConfiguratorBase::numInitStages ( ) const
inlineoverrideprotectedvirtual
71 { return NUM_INIT_STAGES; }

Member Data Documentation

◆ topology


The documentation for this class was generated from the following files:
inet::NetworkConfiguratorBase::findLinkOut
virtual Link * findLinkOut(const Node *node, const char *neighbor) const
Definition: NetworkConfiguratorBase.cc:116
inet::NetworkConfiguratorBase::Node::module
cModule * module
Definition: NetworkConfiguratorBase.h:28
inet::NetworkConfiguratorBase::Node::interfaceTable
IInterfaceTable * interfaceTable
Definition: NetworkConfiguratorBase.h:29
inet::Topology::Node::getLinkOut
Link * getLinkOut(int i) const
Returns ith outgoing link of graph node.
Definition: Topology.cc:33
inet::Topology::getNode
Node * getNode(int i) const
Returns pointer to the ith node in the graph.
Definition: Topology.cc:348
inet::Topology::calculateUnweightedSingleShortestPathsTo
void calculateUnweightedSingleShortestPathsTo(Node *target) const
Apply the Dijkstra algorithm to find all shortest paths to the given graph node.
Definition: Topology.cc:364
inet::Topology::extractByProperty
void extractByProperty(const char *propertyName, const char *value=nullptr)
Extracts model topology by a module property.
Definition: Topology.cc:149
inet::NetworkConfiguratorBase::findInterface
virtual Interface * findInterface(const Node *node, NetworkInterface *networkInterface) const
Definition: NetworkConfiguratorBase.cc:150
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::Topology::getNumNodes
int getNumNodes() const
Returns the number of nodes in the graph.
Definition: Topology.h:516
inet::NetworkConfiguratorBase::topology
Topology * topology
Definition: NetworkConfiguratorBase.h:67
inet::IInterfaceTable::getInterface
virtual NetworkInterface * getInterface(int pos) const =0
Returns the NetworkInterface specified by an index 0..numInterfaces-1.