2017-06-12 07:34:28 +00:00
|
|
|
from mpTopo import MpTopo
|
|
|
|
|
|
|
|
class MpMultiInterfaceCongTopo(MpTopo):
|
2020-06-23 11:20:07 +00:00
|
|
|
congClientName = "CCli"
|
|
|
|
congServerName = "CSer"
|
2017-06-12 07:53:30 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
def __init__(self, topoBuilder, parameterFile):
|
|
|
|
MpTopo.__init__(self,topoBuilder, parameterFile)
|
|
|
|
print("Hello from topo multi if")
|
|
|
|
self.client = self.addHost(MpTopo.clientName)
|
|
|
|
self.server = self.addHost(MpTopo.serverName)
|
|
|
|
self.router = self.addHost(MpTopo.routerName)
|
|
|
|
self.cong_clients = []
|
|
|
|
self.cong_servers = []
|
|
|
|
self.switch = []
|
|
|
|
for l in self.topoParam.linkCharacteristics:
|
|
|
|
self.switch.append(self.addOneSwitchPerLink(l))
|
|
|
|
self.addLink(self.client,self.switch[-1])
|
|
|
|
self.cong_clients.append(self.addHost(MpMultiInterfaceCongTopo.congClientName + str(len(self.cong_clients))))
|
|
|
|
self.addLink(self.cong_clients[-1], self.switch[-1])
|
|
|
|
self.addLink(self.switch[-1],self.router, **l.asDict())
|
|
|
|
self.addLink(self.router, self.server)
|
|
|
|
for i in range(len(self.cong_clients)):
|
|
|
|
self.cong_servers.append(self.addHost(MpMultiInterfaceCongTopo.congServerName + str(len(self.cong_servers))))
|
|
|
|
self.addLink(self.router, self.cong_servers[-1])
|
2017-06-12 07:34:28 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
def getCongClients(self):
|
|
|
|
return self.cong_clients
|
2017-06-12 07:34:28 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
def getCongServers(self):
|
|
|
|
return self.cong_servers
|
2017-06-12 07:34:28 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
def addOneSwitchPerLink(self, link):
|
|
|
|
return self.addSwitch(MpMultiInterfaceCongTopo.switchNamePrefix +
|
|
|
|
str(link.id))
|
2017-06-12 07:34:28 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
def __str__(self):
|
|
|
|
s = "Simple multiple interface topology with congestion \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 r-----s\n"
|
|
|
|
s = s + "|-----sw-----|\n"
|
|
|
|
else:
|
|
|
|
s = s + "c-----sw-----r-----s\n"
|
|
|
|
else:
|
|
|
|
s = s + "|-----sw-----|\n"
|
2017-06-12 07:34:28 +00:00
|
|
|
|
2020-06-23 11:20:07 +00:00
|
|
|
i = i + 1
|
|
|
|
return s
|