OverSim
RUNetworkConfigurator Class Reference

Configures the nodes belonging to the topology before starting the actual simulation. More...

#include <RUNetworkConfigurator.h>

Public Member Functions

 RUNetworkConfigurator ()
virtual ~RUNetworkConfigurator ()

Protected Member Functions

virtual int numInitStages () const
virtual void initialize (int stage)
 Main method of the network configurator.
virtual void handleMessage (cMessage *msg)
void createInterASPaths ()
 Add Inter-AS routing paths between core nodes.
void disableStubLinks (nodeInfoRL &dst, nodeInfoRL &src)
 Disable all incoming links of Stub AS except to and from dst and src.
void enableStubLinks ()
 Enable all incoming links of Stub AS.
void extractTopology ()
 Extract topology from NED file.
void assignAddressAndSetDefaultRoutes (nodeInfoAS &asInfo)
 Assign IP address and add default route.
void setIntraASRoutes (cTopology &topology, nodeInfoAS &asInfo)
 Add explicit Intra-AS routing paths (except of default routes)

Protected Attributes

std::vector< cTopology * > rlTopology
cTopology asTopology
int noAS
int nextPow
NODE_INFO_AS_VEC asNodeVec
unsigned int IP_NET_SHIFT
uint32_t NET_MASK

Detailed Description

Configures the nodes belonging to the topology before starting the actual simulation.

This class is responsible for assignment of IP addresses to all nodes of the topology. Furthermore, routing tables have to be filled and default routing paths must be created. Routing is separated into Intra-AS and Inter-AS routing.

Definition at line 252 of file RUNetworkConfigurator.h.

Constructor & Destructor Documentation

RUNetworkConfigurator::RUNetworkConfigurator ( )

Definition at line 34 of file RUNetworkConfigurator.cc.

{
}
RUNetworkConfigurator::~RUNetworkConfigurator ( )
virtual

Definition at line 38 of file RUNetworkConfigurator.cc.

{
}

Member Function Documentation

void RUNetworkConfigurator::assignAddressAndSetDefaultRoutes ( nodeInfoAS asInfo)
protected

Assign IP address and add default route.

Assigns an IP address of the calculated prefix to each of the router-level nodes.

Additionally, default routes are added for gateway, edge, and host nodes. Core nodes are stored into an additional list for later processing.

Parameters
asInfoAS for which IP addresses should be assigned to router-level nodes.

Definition at line 244 of file RUNetworkConfigurator.cc.

{
unsigned int currentIP = asInfo.addr.getInt() + 1;
int countEdgeRouter = 2; // avoids IP address 127.0.0.1
int countRouter = 1;
int edgeShift = 0;
NODE_MAP::iterator mapIt = asInfo.nodeMap.begin();
while (mapIt != asInfo.nodeMap.end()) {
if (mapIt->second.routerType == EDGE) {
countEdgeRouter++;
}
mapIt++;
}
nextPow = 0;
while ((1 << nextPow) < countEdgeRouter) {
}
edgeShift = IP_NET_SHIFT - nextPow;
asInfo.subnetmask = IPAddress(0xffffffff << edgeShift);
countEdgeRouter = 1;
mapIt = asInfo.nodeMap.begin();
while (mapIt != asInfo.nodeMap.end()) {
if (mapIt->second.routerType == ENDSYS) {
mapIt++;
continue;
}
if (mapIt->second.routerType == EDGE) {
currentIP = asInfo.addr.getInt() + 1 + (countEdgeRouter++ << edgeShift);
edgeRouter temp;
temp.edgeIP = currentIP;
temp.usedIPs = 1;
temp.module = mapIt->second.module;
asInfo.edgeRouter.push_back(temp);
}
else {
currentIP = asInfo.addr.getInt() + countRouter++;
}
for (int j = 0; j < mapIt->second.ift->getNumInterfaces(); j++) {
//
// all interfaces except loopback get the same IP address
//
InterfaceEntry *ie = mapIt->second.ift->getInterface(j);
if (!ie->isLoopback()) {
ie->ipv4Data()->setIPAddress(IPAddress(currentIP));
ie->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
}
}
if (mapIt->second.rt->getRouterId().isUnspecified())
mapIt->second.rt->setRouterId(IPAddress(currentIP));
mapIt->second.addr.set(currentIP);
// remember core nodes of each AS in additional list for assignment
// of Inter-AS routing paths
if (mapIt->second.routerType == CORE)
asInfo.coreNode.push_back(mapIt->second);
else {
//
// add default route in case of gw, edge, or host
//
IPRoute *e = new IPRoute();
e->setHost(IPAddress());
e->setNetmask(IPAddress());
e->setInterface(mapIt->second.defaultRouteIE);
e->setType(IPRoute::REMOTE);
e->setSource(IPRoute::MANUAL);
//e->setMetric(1);
mapIt->second.rt->addRoute(e);
}
currentIP++;
mapIt++;
}
}
void RUNetworkConfigurator::createInterASPaths ( )
protected

Add Inter-AS routing paths between core nodes.

Calculate all Inter-AS. This is achieved by calculating all shortest paths between all core routers of the whole topology. Temporarily disable all stub links during calculation of shortest paths to ensure that a stub AS is not crossed but may only be present at start or end of a routing path.

Definition at line 102 of file RUNetworkConfigurator.cc.

{
IPAddress netmask(NET_MASK);
int asIdHistory = 0;
unsigned int tmpAddr = 0;
for (int i = 0; i < asTopology.getNumNodes(); i++) {
// calculate prefix of current core node
nodeInfoRL destCore(asTopology.getNode(i));
tmpAddr = destCore.addr.getInt() >> IP_NET_SHIFT;
tmpAddr = tmpAddr << IP_NET_SHIFT;
destCore.addr = IPAddress(tmpAddr);
asIdHistory = -1;
for (int j = 0; j < asTopology.getNumNodes(); j++) {
if (i == j)
continue;
nodeInfoRL srcCore(asTopology.getNode(j));
tmpAddr = srcCore.addr.getInt() >> IP_NET_SHIFT;
tmpAddr = tmpAddr << IP_NET_SHIFT;
srcCore.addr = IPAddress(tmpAddr);
// do not calculate paths between nodes of the same AS
if (destCore.asId == srcCore.asId)
continue;
// cross only transit AS in order to reach destination core node
// therefore, temporarily disable all stub links
if (asIdHistory != srcCore.asId) {
disableStubLinks(destCore, srcCore);
asTopology.calculateUnweightedSingleShortestPathsTo(destCore.node);
}
// add routing entry from srcCore to destCore into routing table of srcCore
InterfaceEntry *ie = srcCore.ift->getInterfaceByNodeOutputGateId(srcCore.node->getPath(0)->getLocalGate()->getId());
IPRoute *e = new IPRoute();
e->setHost(destCore.addr);
e->setNetmask(netmask);
e->setInterface(ie);
e->setType(IPRoute::DIRECT);
e->setSource(IPRoute::MANUAL);
srcCore.rt->addRoute(e);
// re-enable all stub links
if (asIdHistory != srcCore.asId) {
}
asIdHistory = srcCore.asId;
}
}
}
void RUNetworkConfigurator::disableStubLinks ( nodeInfoRL dst,
nodeInfoRL src 
)
protected

Disable all incoming links of Stub AS except to and from dst and src.

Disable all incoming links to core nodes of each stub AS that do not match on given dst or src router-level node ID.

Definition at line 151 of file RUNetworkConfigurator.cc.

{
for (unsigned int i = 0; i < asNodeVec.size(); i++) {
if ((asNodeVec[i].id == dst.asId) || (asNodeVec[i].id == src.asId))
continue;
if (asNodeVec[i].asType == TRANSIT_AS)
continue;
for (unsigned int j = 0; j < asNodeVec[i].coreNode.size(); j++) {
for (int k = 0; k < asNodeVec[i].coreNode[j].node->getNumInLinks(); k++)
asNodeVec[i].coreNode[j].node->getLinkIn(k)->disable();
}
}
}
void RUNetworkConfigurator::enableStubLinks ( )
protected

Enable all incoming links of Stub AS.

Enable all incoming links to core nodes of each stub AS

Definition at line 166 of file RUNetworkConfigurator.cc.

{
for (unsigned int i = 0; i < asNodeVec.size(); i++) {
if (asNodeVec[i].asType == TRANSIT_AS)
continue;
for (unsigned int j = 0; j < asNodeVec[i].coreNode.size(); j++) {
for (int k = 0; k < asNodeVec[i].coreNode[j].node->getNumInLinks(); k++)
asNodeVec[i].coreNode[j].node->getLinkIn(k)->enable();
}
}
}
void RUNetworkConfigurator::extractTopology ( )
protected

Extract topology from NED file.

Extracts AS-level topology and each router-level topology into asTopology and rlTopology. Additionally, each AS gets assigned a unique calculated prefix

Definition at line 178 of file RUNetworkConfigurator.cc.

{
cTopology currentAS;
// get the AS-level topology
if (noAS > 0) {
currentAS.extractByProperty("AS"); //TODO: check if this is acceptable
if (currentAS.getNumNodes() != noAS)
opp_error("Error: AS-Topology contains %u elements - expected %u\n", currentAS.getNumNodes(), noAS);
}
else if (noAS == 0) {
// Network is router-level only
currentAS.extractByProperty("Internet"); //TODO: check if this is acceptable
if (currentAS.getNumNodes() != 1)
opp_error("Error: tried to extract router-level only topology, but found more than 1 Inet module\n");
}
// get each router-level topology
unsigned int netIP = 1 << IP_NET_SHIFT;
for (int i = 0; i < currentAS.getNumNodes(); i++) {
cTopology *tmpTopo = new cTopology();
// extract router-level nodes from NED file
tmpTopo->extractFromNetwork(getRouterLevelNodes, (void *) currentAS.getNode(i)->getModule()->getName());
rlTopology.push_back(tmpTopo);
// assign unique /16 IP address prefix to each AS
asNodeVec.push_back(nodeInfoAS(currentAS.getNode(i), IPAddress(netIP), IPAddress(NET_MASK)));
netIP += 1 << IP_NET_SHIFT;
}
asTopology.extractFromNetwork(getCoreNodes); //TODO: the extra function may be superfuous. extraction could be probably be done via asTopology.extractByProperty("CoreRouter"); -Claus
//free memory
currentAS.clear();
}
virtual void RUNetworkConfigurator::handleMessage ( cMessage *  msg)
inlineprotectedvirtual

Definition at line 278 of file RUNetworkConfigurator.h.

{opp_error("message received");};
void RUNetworkConfigurator::initialize ( int  stage)
protectedvirtual

Main method of the network configurator.

Topology is extracted from NED file, IP addresses are assigned, and routing paths are established.

Definition at line 42 of file RUNetworkConfigurator.cc.

{
if (stage != 2)
return;
//TODO: read number of AS
cTopology tempTopology("tempTopo");
tempTopology.extractByProperty("AS");
noAS = tempTopology.getNumNodes();
cout << noAS <<endl;
nextPow = 1;
while ((1 << nextPow) < noAS + 1) {
}
NET_MASK = 0xffffffff << IP_NET_SHIFT;
// extract topology nodes and assign IP addresses
// assign an IPAddress to all nodes in the network
//FIXME: does asNodeVec.size() work as intended? may need to use noAS instead
for (unsigned int i = 0; i < asNodeVec.size(); i++) {
if ((unsigned int) rlTopology[i]->getNumNodes() > (0xffffffff - NET_MASK))
opp_error("to many nodes in current topology");
cerr << asNodeVec[i].module->getFullPath() << endl;
//
// insert each router-level node into a node map
//
for (int j = 0; j < rlTopology[i]->getNumNodes(); j++) {
nodeInfoRL curRLNode(rlTopology[i]->getNode(j));
asNodeVec[i].nodeMap.insert(NODE_MAP_PAIR(curRLNode.moduleId, curRLNode));
}
// assign IP address and add default route
}
// add all further routes in router-level topology
// (unequal to default route)
for (unsigned int i = 0; i < asNodeVec.size(); i++)
// Having configured all router topologies, add Inter-AS routing paths
if (noAS > 0)
// free Memory
for (int i = 0; i < noAS; i++) {
rlTopology[i]->clear();
delete rlTopology[i];
asNodeVec[i].nodeMap.clear();
}
asTopology.clear();
asNodeVec.clear();
tempTopology.clear();
}
virtual int RUNetworkConfigurator::numInitStages ( void  ) const
inlineprotectedvirtual

Definition at line 270 of file RUNetworkConfigurator.h.

{return 3;}
void RUNetworkConfigurator::setIntraASRoutes ( cTopology &  topology,
nodeInfoAS asInfo 
)
protected

Add explicit Intra-AS routing paths (except of default routes)

Calculate all Intra-AS routes that are unequal to the default routes. Therefore, all shortest paths between all router-level nodes are calculated. If the first hop is unequal to the default route, a new specific route is added.

Parameters
topology
asInfoAS for which Intra-AS routes should be determined

Definition at line 324 of file RUNetworkConfigurator.cc.

{
// calculate static routes from each of the AS's router-level nodes to all
// other nodes of the AS
for (int i = 0; i < topology.getNumNodes(); i++) {
nodeInfoRL destNode = asInfo.nodeMap[topology.getNode(i)->getModule()->getId()];
//
// calculate shortest path form everywhere toward destNode
//
topology.calculateUnweightedSingleShortestPathsTo(destNode.node);
for (int j = 0; j < topology.getNumNodes(); j++) {
if (j == i)
continue;
nodeInfoRL srcNode = asInfo.nodeMap[topology.getNode(j)->getModule()->getId()];
// no route exists at all
if (srcNode.node->getNumPaths() == 0)
continue;
// end systems only know a default route to the edge router
else if (srcNode.routerType == ENDSYS)
continue;
else if (destNode.routerType == ENDSYS) {
if (srcNode.routerType != EDGE)
continue;
InterfaceEntry *ie = srcNode.ift->getInterfaceByNodeOutputGateId(srcNode.node->getPath(0)->getLocalGate()->getId());
if (ie == srcNode.defaultRouteIE)
continue;
for (uint32 i = 0; i < asInfo.edgeRouter.size(); i++) {
if (srcNode.module == asInfo.edgeRouter[i].module) {
destNode.addr = IPAddress(asInfo.edgeRouter[i].edgeIP + asInfo.edgeRouter[i].usedIPs);
asInfo.edgeRouter[i].usedIPs++;
}
}
for (int j = 0; j < destNode.ift->getNumInterfaces(); j++) {
//
// all interfaces except loopback get the same IP address
//
InterfaceEntry *ie = destNode.ift->getInterface(j);
if (!ie->isLoopback()) {
ie->ipv4Data()->setIPAddress(destNode.addr);
ie->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
}
}
IPRoute *e = new IPRoute();
e->setHost(IPAddress());
e->setNetmask(IPAddress());
e->setInterface(destNode.defaultRouteIE);
e->setType(IPRoute::REMOTE);
e->setSource(IPRoute::MANUAL);
destNode.rt->addRoute(e);
ie = srcNode.ift->getInterfaceByNodeOutputGateId(srcNode.node->getPath(0)->getLocalGate()->getId());
e = new IPRoute();
e->setHost(destNode.addr);
e->setNetmask(IPAddress(255, 255, 255, 255));
e->setInterface(ie);
e->setType(IPRoute::DIRECT);
e->setSource(IPRoute::MANUAL);
srcNode.rt->addRoute(e);
}
else {
//
// if destination is reachable through default route, no routing entry is necessary
//
InterfaceEntry *ie = srcNode.ift->getInterfaceByNodeOutputGateId(srcNode.node->getPath(0)->getLocalGate()->getId());
if (ie == srcNode.defaultRouteIE)
continue;
else {
// add specific routing entry into routing table
IPRoute *e = new IPRoute();
e->setHost(destNode.addr);
if (destNode.routerType == EDGE)
e->setNetmask(asInfo.subnetmask);
else
e->setNetmask(IPAddress(255, 255, 255, 255));
e->setInterface(ie);
e->setType(IPRoute::DIRECT);
e->setSource(IPRoute::MANUAL);
srcNode.rt->addRoute(e);
}
}
}
}
}

Member Data Documentation

NODE_INFO_AS_VEC RUNetworkConfigurator::asNodeVec
protected

Definition at line 259 of file RUNetworkConfigurator.h.

cTopology RUNetworkConfigurator::asTopology
protected

Definition at line 256 of file RUNetworkConfigurator.h.

unsigned int RUNetworkConfigurator::IP_NET_SHIFT
protected

Definition at line 260 of file RUNetworkConfigurator.h.

uint32_t RUNetworkConfigurator::NET_MASK
protected

Definition at line 261 of file RUNetworkConfigurator.h.

int RUNetworkConfigurator::nextPow
protected

Definition at line 258 of file RUNetworkConfigurator.h.

int RUNetworkConfigurator::noAS
protected

Definition at line 257 of file RUNetworkConfigurator.h.

std::vector<cTopology*> RUNetworkConfigurator::rlTopology
protected

Definition at line 255 of file RUNetworkConfigurator.h.


The documentation for this class was generated from the following files: