Extracts network topology by walking through the module hierarchy.
Creates vertices from modules having property. Creates edges from connections (wired and wireless) between network interfaces.
66 topology.extractByProperty(
"networkNode");
67 EV_DEBUG <<
"Topology found " << topology.getNumNodes() <<
" nodes\n";
70 for (
int i = 0; i < topology.getNumNodes(); i++) {
71 Node *node = (Node *)topology.getNode(i);
72 cModule *module = node->getModule();
73 node->module = module;
79 std::set<InterfaceEntry *> interfacesSeen;
80 for (
int i = 0; i < topology.getNumNodes(); i++) {
81 Node *node = (Node *)topology.getNode(i);
82 IInterfaceTable *interfaceTable = node->interfaceTable;
84 for (
int j = 0; j < interfaceTable->getNumInterfaces(); j++) {
85 InterfaceEntry *interfaceEntry = interfaceTable->getInterface(j);
86 if (!interfaceEntry->isLoopback() && interfacesSeen.count(interfaceEntry) == 0) {
90 interfacesSeen.insert(interfaceEntry);
92 LinkInfo *linkInfo =
new LinkInfo();
93 topology.linkInfos.push_back(linkInfo);
96 linkInfo->interfaceInfos.push_back(interfaceInfo);
99 std::vector<Node *>
empty;
104 Topology::LinkOut *linkOut =
findLinkOut(node, interfaceEntry->getNodeOutputGateId());
106 std::vector<Node *>
empty;
117 for (
int i = 0; i < topology.getNumNodes(); i++) {
118 Node *node = (Node *)topology.getNode(i);
119 for (
int j = 0; j < node->getNumOutLinks(); j++) {
120 Topology::LinkOut *linkOut = node->getLinkOut(j);
121 Link *link = (Link *)linkOut;
122 Node *localNode = (Node *)linkOut->getLocalNode();
123 if (localNode->interfaceTable)
124 link->sourceInterfaceInfo =
findInterfaceInfo(localNode, localNode->interfaceTable->getInterfaceByNodeOutputGateId(linkOut->getLocalGateId()));
125 Node *remoteNode = (Node *)linkOut->getRemoteNode();
126 if (remoteNode->interfaceTable)
127 link->destinationInterfaceInfo =
findInterfaceInfo(remoteNode, remoteNode->interfaceTable->getInterfaceByNodeInputGateId(linkOut->getRemoteGateId()));
132 std::map<std::string, std::vector<InterfaceInfo *> > wirelessIdToInterfaceInfosMap;
133 for (
auto & entry : topology.interfaceInfos) {
134 InterfaceInfo *interfaceInfo = entry.second;
135 InterfaceEntry *interfaceEntry = interfaceInfo->interfaceEntry;
138 wirelessIdToInterfaceInfosMap[wirelessId].push_back(interfaceInfo);
143 for (
auto & entry : wirelessIdToInterfaceInfosMap) {
144 std::vector<InterfaceInfo *>& interfaceInfos = entry.second;
145 for (
int i = 0; i < (int)interfaceInfos.size(); i++) {
146 InterfaceInfo *interfaceInfoI = interfaceInfos.at(i);
147 for (
int j = i + 1; j < (int)interfaceInfos.size(); j++) {
149 InterfaceInfo *interfaceInfoJ = interfaceInfos.at(j);
150 Link *linkIJ =
new Link();
151 linkIJ->sourceInterfaceInfo = interfaceInfoI;
152 linkIJ->destinationInterfaceInfo = interfaceInfoJ;
153 topology.addLink(linkIJ, interfaceInfoI->node, interfaceInfoJ->node);
154 Link *linkJI =
new Link();
155 linkJI->sourceInterfaceInfo = interfaceInfoJ;
156 linkJI->destinationInterfaceInfo = interfaceInfoI;
157 topology.addLink(linkJI, interfaceInfoJ->node, interfaceInfoI->node);
163 for (
auto & linkInfo : topology.linkInfos)
virtual const char * getWirelessId(InterfaceEntry *interfaceEntry)
If this function returns the same string for two wireless interfaces, they will be regarded as being ...
Definition: NetworkConfiguratorBase.cc:423
virtual void extractWiredNeighbors(Topology &topology, Topology::LinkOut *linkOut, LinkInfo *linkInfo, std::set< InterfaceEntry * > &interfacesSeen, std::vector< Node * > &nodesVisited)
Definition: NetworkConfiguratorBase.cc:167
virtual IInterfaceTable * findInterfaceTable(Node *node)
Definition: NetworkConfiguratorBase.cc:505
virtual bool isWirelessInterface(InterfaceEntry *interfaceEntry)
Definition: NetworkConfiguratorBase.cc:250
virtual Topology::LinkOut * findLinkOut(Node *node, int gateId)
Definition: NetworkConfiguratorBase.cc:255
virtual bool isBridgeNode(Node *node)
Definition: NetworkConfiguratorBase.cc:245
virtual InterfaceInfo * createInterfaceInfo(Topology &topology, Node *node, LinkInfo *linkInfo, InterfaceEntry *interfaceEntry)
Definition: NetworkConfiguratorBase.cc:515
virtual InterfaceInfo * determineGatewayForLink(LinkInfo *linkInfo)
If this link has exactly one node that connects to other links as well, we can assume it is a "gatewa...
Definition: NetworkConfiguratorBase.cc:480
const char empty[]
Definition: ConstType.h:37
virtual IRoutingTable * findRoutingTable(Node *node)
Definition: NetworkConfiguratorBase.cc:510
virtual void extractWirelessNeighbors(Topology &topology, const char *wirelessId, LinkInfo *linkInfo, std::set< InterfaceEntry * > &interfacesSeen, std::vector< Node * > &nodesVisited)
Definition: NetworkConfiguratorBase.cc:189
virtual InterfaceInfo * findInterfaceInfo(Node *node, InterfaceEntry *interfaceEntry)
Definition: NetworkConfiguratorBase.cc:264