30 #include <IRoutingTable.h>
31 #include <IInterfaceTable.h>
32 #include <IPAddressResolver.h>
33 #include <IPv4InterfaceData.h>
37 using namespace ::std;
54 channelTypesTx = cStringTokenizer(par(
"channelTypes"),
" ").asVector();
55 channelTypesRx = cStringTokenizer(par(
"channelTypesRx"),
" ").asVector();
77 cTopology tempTopology(
"tempTopo");
81 tempTopology.extractByProperty(
"AS");
90 if (tempTopology.getNumNodes() == 0) {
94 tempTopology.extractByProperty(
"RL");
96 if (tempTopology.getNumNodes() == 0)
99 opp_error(
"ConnectReaSE: Neither an AS topology nor a router topology was detected.");
107 std::vector<cModule*> Modules;
108 for (
int i=0; i<tempTopology.getNumNodes(); i++) {
110 tempModule = tempTopology.getNode(i)->getModule();
111 Modules.push_back(tempModule);
114 for (uint32 i=0; i< Modules.size(); i++) {
120 for (uint32 i=0; i<
AS_Pool.size(); i++) {
121 for (uint32 j=0; j<
AS_Pool[i].edgeRouter.size(); j++) {
139 Enter_Method(
"getAccessNode()");
141 bool candidateOK =
false;
146 uint32 tempIndex, tempASindex;
148 while ((numTries > 0)&&(!candidateOK)) {
155 if (connectionCandidate->IPAddresses.size() >= ((uint32_t) 1 <<
AS_Pool[tempASindex].edgeShift))
176 test_IP = ++connectionCandidate->lastIP;
177 connectionCandidate->IPAddresses.push_back(test_IP);
184 opp_error(
"Error creating node: No available IP found after four tries!");
186 EV <<
"Found available IP: " << test_IP;
190 node.
edge = connectionCandidate;
196 Enter_Method(
"addOverlayNode()");
198 cModule* node = overlayNode->
terminal;
202 terminal.
interfaceTable = IPAddressResolver().interfaceTableOf(node);
204 terminal.
routingTable = IPAddressResolver().routingTableOf(node);
213 const char* ip_disp =
const_cast<char*
>
214 (IPAddress(terminal.
IPAddress).str().c_str());
215 terminal.
module->getDisplayString().insertTag(
"t", 0);
216 terminal.
module->getDisplayString().setTagArg(
"t", 0, ip_disp);
217 terminal.
module->getDisplayString().setTagArg(
"t", 1,
"l");
222 while ( overlayNode->
edge->
Router->findSubmodule(
"ppp", k) != -1 )
226 cModuleType* pppInterfaceModuleType = cModuleType::get(
"inet.linklayer.ppp.PPPInterface");
228 create(
"ppp", overlayNode->
edge->
Router, 0, k);
237 cChannelType* channelTypeRx = cChannelType::find( overlayNode->
edge->
channelTypeRxStr.c_str() );
238 cChannelType* channelTypeTx = cChannelType::find( overlayNode->
edge->
channelTypeTxStr.c_str() );
239 if (!channelTypeRx || !channelTypeTx)
240 opp_error(
"Could not find Channel or ChannelRx Type. Most likely "
241 "parameter channelTypes does not match the channels defined "
245 cDatarateChannel* channelRx = check_and_cast<cDatarateChannel*>(channelTypeRx->create(overlayNode->
edge->
channelTypeRxStr.c_str()));
246 cDatarateChannel* channelTx = check_and_cast<cDatarateChannel*>(channelTypeTx->create(overlayNode->
edge->
channelTypeTxStr.c_str()));
249 terminal.
module->gate(
"pppg$o", 0)->connectTo(routerInGate,channelRx);
250 routerOutGate->connectTo(terminal.
module->gate(
"pppg$i", 0),channelTx);
257 cModule* netwModule = overlayNode->
edge->
Router->getSubmodule(
"networkLayer");
266 cModule* ipModule = overlayNode->
edge->
Router->getSubmodule(
"networkLayer")->
270 netwInGate->connectTo(ipIn);
285 terminal.
module->callInitialize(i);
293 channelRx->setDelay(SIMTIME_DBL(channelRx->getDelay()*diversityFactor));
294 channelTx->setDelay(SIMTIME_DBL(channelTx->getDelay()*diversityFactor));
306 IPv4InterfaceData* interfaceData =
new IPv4InterfaceData;
308 interfaceData->setNetmask(IPAddress::ALLONES_ADDRESS);
313 terminal.
interfaceEntry->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
322 IPRoute*
re =
new IPRoute();
323 re->setHost(IPAddress(terminal.
IPAddress));
324 re->setNetmask(IPAddress::ALLONES_ADDRESS);
326 re->setType(IPRoute::DIRECT);
327 re->setSource(IPRoute::MANUAL);
333 IPRoute* te =
new IPRoute();
334 te->setHost(IPAddress::UNSPECIFIED_ADDRESS);
335 te->setNetmask(IPAddress::UNSPECIFIED_ADDRESS);
338 te->setType(IPRoute::REMOTE);
339 te->setSource(IPRoute::MANUAL);
346 int ID = node->getId();
352 Enter_Method(
"removeOverlayNode()");
354 cModule* node = NULL;
369 if (node == NULL)
return NULL;
372 releasedIP = IPAddressResolver().addressOf(terminal.
module).get4().getInt();;
387 node->gate(
"pppg$o", 0)->disconnect();
388 node->gate(
"pppg$i", 0)->getPreviousGate()->disconnect();
391 ppp->gate(
"netwIn")->getPathStartGate()->disconnect();
392 ppp->gate(
"netwOut")->getNextGate()->disconnect();
421 Enter_Method(
"getOverlayNode()");
423 cModule* node = NULL;
431 opp_error(
"Node was not found in global list of overlay terminals");
438 Enter_Method(
"migrateNode()");
450 if (terminal.
module == NULL) opp_error(
"ConnectReaSE: Cannot find migrating node");
457 return newEdgeRouter;
462 error(
"this module doesn't handle messages, it runs only in initialize()");
470 sprintf(buf,
"1 terminal connected");
474 getDisplayString().setTagArg(
"t", 0, buf);
475 getDisplayString().setTagArg(
"t", 2,
"blue");
478 cerr <<
"ConnectReaSE: " <<
overlayTerminal.size() <<
" Terminals connected in network." <<endl;
486 for (index = 0; index < owner->gateSize(name); index++) {
487 cGate *gate = type ==
cGate::NONE ? owner->gate(name, index) : owner->gateHalf(name, type, index);
488 if (!gate->isConnectedOutside()) {
493 owner->setGateSize(name, index + 2);
494 return type ==
cGate::NONE ? owner->gate(name, index + 1) : owner->gateHalf(name, type, index + 1);
501 if (currModule->getParentModule() == currProp->
pModule) {
502 if (currModule->getProperties()->get(currProp->
property)) {
512 cTopology edgeTopo(
"Edges");
513 cTopology Topo(
"All nodes");
533 while ((1 <<
nextPow) < edgeTopo.getNumNodes() + 2) {
540 for (
int i=0; i< edgeTopo.getNumNodes(); i++) {
542 tempEdge.
Router = edgeTopo.getNode(i)->getModule();
543 tempEdge.
IPAddress = IPAddressResolver().addressOf(tempEdge.
Router).get4().getInt();
544 tempEdge.
IPAddresses.push_back(IPAddressResolver().addressOf(tempEdge.
Router).get4().getInt());
549 while ( tempEdge.
Router->findSubmodule(
"ppp", k) != -1 )
558 Topo.calculateUnweightedSingleShortestPathsTo(Topo.getNodeFor(edgeTopo.getNode(i)->getModule()));
560 for (
int j=0; j< Topo.getNumNodes(); j++) {
561 tempNode = Topo.getNode(j)->getModule();
562 if (tempNode->getProperties()->get(
"CoreRouter"))
564 if (tempNode->getProperties()->get(
"GatewayRouter"))
566 if (tempNode->getProperties()->get(
"EdgeRouter"))
568 if (Topo.getNode(j)->getPath(0)->getRemoteNode()->getModule() != edgeTopo.getNode(i)->getModule())
572 tempIP = IPAddressResolver().addressOf(Topo.getNode(j)->getModule()).get4().getInt();