2015-01-12 11:26:54 +00:00
|
|
|
from mpTopo import MpTopo
|
|
|
|
|
|
|
|
class MpECMPSingleInterfaceTopo(MpTopo):
|
|
|
|
def __init__(self, topoBuilder, parameterFile):
|
|
|
|
MpTopo.__init__(self,topoBuilder, parameterFile)
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-12 11:26:54 +00:00
|
|
|
print("Hello ECMP topo")
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-12 11:26:54 +00:00
|
|
|
self.client = self.addHost(MpTopo.clientName)
|
|
|
|
self.server = self.addHost(MpTopo.serverName)
|
|
|
|
self.lswitch = self.addSwitch(MpTopo.switchNamePrefix + "0")
|
|
|
|
self.rswitch = self.addSwitch(MpTopo.switchNamePrefix + "1")
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-12 11:26:54 +00:00
|
|
|
self.addLink( self.client, self.lswitch)
|
|
|
|
self.addLink( self.server, self.rswitch)
|
|
|
|
|
|
|
|
self.routers = []
|
|
|
|
for l in self.topoParam.linkCharacteristics:
|
|
|
|
self.routers.append(self.addOneRouterPerLink(l))
|
|
|
|
print("added : " + self.routers[-1])
|
|
|
|
self.addLink(self.lswitch, self.routers[-1])
|
|
|
|
self.addLink(self.rswitch, self.routers[-1], **l.asDict())
|
|
|
|
|
|
|
|
def addOneRouterPerLink(self, link):
|
|
|
|
return self.addHost(MpTopo.routerNamePrefix +
|
|
|
|
str(link.id))
|
|
|
|
|
|
|
|
def __str__(self):
|
2015-01-14 10:46:33 +00:00
|
|
|
s = "Single if ECMP like env\n"
|
2015-01-12 11:26:54 +00:00
|
|
|
i = 0
|
|
|
|
n = len(self.topoParam.linkCharacteristics)
|
|
|
|
for p in self.topoParam.linkCharacteristics:
|
|
|
|
if i == n // 2:
|
|
|
|
if n % 2 == 0:
|
2015-01-14 10:46:33 +00:00
|
|
|
s = s + "c---sw sw-----s\n"
|
|
|
|
s = s + " |-----R-----|\n"
|
2015-01-12 11:26:54 +00:00
|
|
|
else:
|
2015-01-14 10:46:33 +00:00
|
|
|
s = s + "c---sw----R-----sw-----s\n"
|
2015-01-12 11:26:54 +00:00
|
|
|
else:
|
2015-01-14 10:46:33 +00:00
|
|
|
s = s + " |-----R-----|\n"
|
2015-01-12 11:26:54 +00:00
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
return s
|
|
|
|
|