2020-06-24 08:36:26 +00:00
|
|
|
from core.topo import Topo
|
2015-01-12 11:26:54 +00:00
|
|
|
|
2020-06-24 08:36:26 +00:00
|
|
|
class MpECMPSingleInterfaceTopo(Topo):
|
2020-06-23 11:20:07 +00:00
|
|
|
def __init__(self, topoBuilder, parameterFile):
|
2020-06-24 08:54:44 +00:00
|
|
|
super(MpECMPSingleInterfaceTopo, self).__init__(topoBuilder, parameterFile)
|
2020-06-23 11:20:07 +00:00
|
|
|
|
|
|
|
print("Hello ECMP topo")
|
|
|
|
|
2020-06-24 08:36:26 +00:00
|
|
|
self.client = self.addHost(Topo.clientName)
|
|
|
|
self.server = self.addHost(Topo.serverName)
|
|
|
|
self.lswitch = self.addSwitch(Topo.switchNamePrefix + "0")
|
|
|
|
self.rswitch = self.addSwitch(Topo.switchNamePrefix + "1")
|
2020-06-23 11:20:07 +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):
|
2020-06-24 08:36:26 +00:00
|
|
|
return self.addHost(Topo.routerNamePrefix +
|
2020-06-23 11:20:07 +00:00
|
|
|
str(link.id))
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
s = "Single if ECMP like env\n"
|
|
|
|
i = 0
|
|
|
|
n = len(self.topoParam.linkCharacteristics)
|
|
|
|
for p in self.topoParam.linkCharacteristics:
|
|
|
|
if i == n // 2:
|
|
|
|
if n % 2 == 0:
|
|
|
|
s = s + "c---sw sw-----s\n"
|
|
|
|
s = s + " |-----R-----|\n"
|
|
|
|
else:
|
|
|
|
s = s + "c---sw----R-----sw-----s\n"
|
|
|
|
else:
|
|
|
|
s = s + " |-----R-----|\n"
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
return s
|
2015-01-12 11:26:54 +00:00
|
|
|
|