32 using namespace RUNetConf;
49 cTopology tempTopology(
"tempTopo");
50 tempTopology.extractByProperty(
"AS");
52 noAS = tempTopology.getNumNodes();
55 while ((1 << nextPow) < noAS + 1) {
58 IP_NET_SHIFT = 32 - nextPow;
59 NET_MASK = 0xffffffff << IP_NET_SHIFT;
66 for (
unsigned int i = 0; i < asNodeVec.size(); i++) {
67 if ((
unsigned int) rlTopology[i]->getNumNodes() > (0xffffffff - NET_MASK))
68 opp_error(
"to many nodes in current topology");
69 cerr << asNodeVec[i].module->getFullPath() << endl;
73 for (
int j = 0; j < rlTopology[i]->getNumNodes(); j++) {
74 nodeInfoRL curRLNode(rlTopology[i]->getNode(j));
79 assignAddressAndSetDefaultRoutes(asNodeVec[i]);
84 for (
unsigned int i = 0; i < asNodeVec.size(); i++)
85 setIntraASRoutes(*rlTopology[i], asNodeVec[i]);
92 for (
int i = 0; i < noAS; i++) {
93 rlTopology[i]->clear();
95 asNodeVec[i].nodeMap.clear();
104 IPAddress netmask(NET_MASK);
106 unsigned int tmpAddr = 0;
107 for (
int i = 0; i < asTopology.getNumNodes(); i++) {
110 tmpAddr = destCore.
addr.getInt() >> IP_NET_SHIFT;
111 tmpAddr = tmpAddr << IP_NET_SHIFT;
112 destCore.addr = IPAddress(tmpAddr);
114 for (
int j = 0; j < asTopology.getNumNodes(); j++) {
118 tmpAddr = srcCore.
addr.getInt() >> IP_NET_SHIFT;
119 tmpAddr = tmpAddr << IP_NET_SHIFT;
120 srcCore.addr = IPAddress(tmpAddr);
123 if (destCore.asId == srcCore.asId)
128 if (asIdHistory != srcCore.asId) {
129 disableStubLinks(destCore, srcCore);
130 asTopology.calculateUnweightedSingleShortestPathsTo(destCore.node);
133 InterfaceEntry *ie = srcCore.ift->getInterfaceByNodeOutputGateId(srcCore.node->getPath(0)->getLocalGate()->getId());
134 IPRoute *e =
new IPRoute();
135 e->setHost(destCore.addr);
136 e->setNetmask(netmask);
138 e->setType(IPRoute::DIRECT);
139 e->setSource(IPRoute::MANUAL);
140 srcCore.rt->addRoute(e);
143 if (asIdHistory != srcCore.asId) {
146 asIdHistory = srcCore.asId;
153 for (
unsigned int i = 0; i < asNodeVec.size(); i++) {
154 if ((asNodeVec[i].
id == dst.
asId) || (asNodeVec[i].id == src.
asId))
159 for (
unsigned int j = 0; j < asNodeVec[i].coreNode.size(); j++) {
160 for (
int k = 0; k < asNodeVec[i].coreNode[j].node->getNumInLinks(); k++)
161 asNodeVec[i].coreNode[j].node->getLinkIn(k)->disable();
168 for (
unsigned int i = 0; i < asNodeVec.size(); i++) {
171 for (
unsigned int j = 0; j < asNodeVec[i].coreNode.size(); j++) {
172 for (
int k = 0; k < asNodeVec[i].coreNode[j].node->getNumInLinks(); k++)
173 asNodeVec[i].coreNode[j].node->getLinkIn(k)->enable();
184 currentAS.extractByProperty(
"AS");
185 if (currentAS.getNumNodes() != noAS)
186 opp_error(
"Error: AS-Topology contains %u elements - expected %u\n", currentAS.getNumNodes(), noAS);
188 else if (noAS == 0) {
190 currentAS.extractByProperty(
"Internet");
191 if (currentAS.getNumNodes() != 1)
192 opp_error(
"Error: tried to extract router-level only topology, but found more than 1 Inet module\n");
196 unsigned int netIP = 1 << IP_NET_SHIFT;
197 for (
int i = 0; i < currentAS.getNumNodes(); i++) {
198 cTopology *tmpTopo =
new cTopology();
200 tmpTopo->extractFromNetwork(
getRouterLevelNodes, (
void *) currentAS.getNode(i)->getModule()->getName());
201 rlTopology.push_back(tmpTopo);
203 asNodeVec.push_back(
nodeInfoAS(currentAS.getNode(i), IPAddress(netIP), IPAddress(NET_MASK)));
204 netIP += 1 << IP_NET_SHIFT;
215 char *curName = (
char*) name;
217 opp_error(
"Error while casting void* name to char*\n");
219 string sCurName = curName;
221 string curModPath = curMod->getFullPath();
222 if (curModPath.find(sCurName) == string::npos)
225 const char*
property =
"RL";
226 cProperty *prop = curMod->getProperties()->get(property);
229 const char *value = prop->getValue(cProperty::DEFAULTKEY, 0);
230 return opp_strcmp(value,
"false")!=0;
236 const char*
property =
"CoreRouter";
237 cProperty *prop = curMod->getProperties()->get(property);
240 const char *value = prop->getValue(cProperty::DEFAULTKEY, 0);
241 return opp_strcmp(value,
"false")!=0;
246 unsigned int currentIP = asInfo.
addr.getInt() + 1;
247 int countEdgeRouter = 2;
251 NODE_MAP::iterator mapIt = asInfo.
nodeMap.begin();
252 while (mapIt != asInfo.
nodeMap.end()) {
253 if (mapIt->second.routerType ==
EDGE) {
260 while ((1 << nextPow) < countEdgeRouter) {
264 edgeShift = IP_NET_SHIFT - nextPow;
265 asInfo.
subnetmask = IPAddress(0xffffffff << edgeShift);
268 mapIt = asInfo.
nodeMap.begin();
269 while (mapIt != asInfo.
nodeMap.end()) {
270 if (mapIt->second.routerType ==
ENDSYS) {
275 if (mapIt->second.routerType ==
EDGE) {
276 currentIP = asInfo.
addr.getInt() + 1 + (countEdgeRouter++ << edgeShift);
280 temp.
module = mapIt->second.module;
284 currentIP = asInfo.
addr.getInt() + countRouter++;
287 for (
int j = 0; j < mapIt->second.ift->getNumInterfaces(); j++) {
291 InterfaceEntry *ie = mapIt->second.ift->getInterface(j);
292 if (!ie->isLoopback()) {
293 ie->ipv4Data()->setIPAddress(IPAddress(currentIP));
294 ie->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
297 if (mapIt->second.rt->getRouterId().isUnspecified())
298 mapIt->second.rt->setRouterId(IPAddress(currentIP));
299 mapIt->second.addr.set(currentIP);
303 if (mapIt->second.routerType ==
CORE)
304 asInfo.
coreNode.push_back(mapIt->second);
309 IPRoute *e =
new IPRoute();
310 e->setHost(IPAddress());
311 e->setNetmask(IPAddress());
312 e->setInterface(mapIt->second.defaultRouteIE);
313 e->setType(IPRoute::REMOTE);
314 e->setSource(IPRoute::MANUAL);
316 mapIt->second.rt->addRoute(e);
329 for (
int i = 0; i < topology.getNumNodes(); i++) {
334 topology.calculateUnweightedSingleShortestPathsTo(destNode.
node);
335 for (
int j = 0; j < topology.getNumNodes(); j++) {
340 if (srcNode.
node->getNumPaths() == 0)
348 InterfaceEntry *ie = srcNode.
ift->getInterfaceByNodeOutputGateId(srcNode.
node->getPath(0)->getLocalGate()->getId());
352 for (uint32 i = 0; i < asInfo.
edgeRouter.size(); i++) {
361 for (
int j = 0; j < destNode.
ift->getNumInterfaces(); j++) {
365 InterfaceEntry *ie = destNode.
ift->getInterface(j);
366 if (!ie->isLoopback()) {
367 ie->ipv4Data()->setIPAddress(destNode.
addr);
368 ie->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
371 IPRoute *e =
new IPRoute();
372 e->setHost(IPAddress());
373 e->setNetmask(IPAddress());
375 e->setType(IPRoute::REMOTE);
376 e->setSource(IPRoute::MANUAL);
377 destNode.
rt->addRoute(e);
379 ie = srcNode.
ift->getInterfaceByNodeOutputGateId(srcNode.
node->getPath(0)->getLocalGate()->getId());
381 e->setHost(destNode.
addr);
382 e->setNetmask(IPAddress(255, 255, 255, 255));
384 e->setType(IPRoute::DIRECT);
385 e->setSource(IPRoute::MANUAL);
386 srcNode.
rt->addRoute(e);
392 InterfaceEntry *ie = srcNode.
ift->getInterfaceByNodeOutputGateId(srcNode.
node->getPath(0)->getLocalGate()->getId());
397 IPRoute *e =
new IPRoute();
398 e->setHost(destNode.
addr);
402 e->setNetmask(IPAddress(255, 255, 255, 255));
404 e->setType(IPRoute::DIRECT);
405 e->setSource(IPRoute::MANUAL);
406 srcNode.
rt->addRoute(e);