move topos in their own module
This commit is contained in:
parent
ac52cf7ddf
commit
bcd306b21d
@ -1,5 +1,5 @@
|
|||||||
from .parameter import ExperienceParameter
|
from .parameter import ExperienceParameter
|
||||||
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
|
from topos.multi_interface import MultiInterfaceTopo
|
||||||
|
|
||||||
class Experience(object):
|
class Experience(object):
|
||||||
PING = "ping"
|
PING = "ping"
|
||||||
@ -50,8 +50,8 @@ class Experience(object):
|
|||||||
self.mpTopo.notNSCommand("echo " + metric + " > /sys/module/mptcp_sched_metric/parameters/metric")
|
self.mpTopo.notNSCommand("echo " + metric + " > /sys/module/mptcp_sched_metric/parameters/metric")
|
||||||
|
|
||||||
def putPriorityOnPaths(self):
|
def putPriorityOnPaths(self):
|
||||||
# Only meaningful if mpTopo is instance of MpMultiInterfaceTopo
|
# Only meaningful if mpTopo is instance of MultiInterfaceTopo
|
||||||
if isinstance(self.mpTopo, MpMultiInterfaceTopo):
|
if isinstance(self.mpTopo, MultiInterfaceTopo):
|
||||||
prioPath0 = self.xpParam.getParam(ExperienceParameter.PRIOPATH0)
|
prioPath0 = self.xpParam.getParam(ExperienceParameter.PRIOPATH0)
|
||||||
prioPath1 = self.xpParam.getParam(ExperienceParameter.PRIOPATH1)
|
prioPath1 = self.xpParam.getParam(ExperienceParameter.PRIOPATH1)
|
||||||
if not prioPath0 == prioPath1:
|
if not prioPath0 == prioPath1:
|
||||||
|
16
core/topo.py
16
core/topo.py
@ -201,11 +201,13 @@ class TopoParameter(Parameter):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
class Topo(object):
|
class Topo(object):
|
||||||
|
"""
|
||||||
|
Base class to instantiate a topology.
|
||||||
|
|
||||||
|
This class is not instantiable as it. You must define a child class with the
|
||||||
|
`NAME` attribute.
|
||||||
|
"""
|
||||||
mininetBuilder = "mininet"
|
mininetBuilder = "mininet"
|
||||||
multiIfTopo = "MultiIf"
|
|
||||||
ECMPLikeTopo = "ECMPLike"
|
|
||||||
twoIfCongTopo = "twoIfCong"
|
|
||||||
multiIfCongTopo = "MultiIfCong"
|
|
||||||
topoAttr = "topoType"
|
topoAttr = "topoType"
|
||||||
switchNamePrefix = "s"
|
switchNamePrefix = "s"
|
||||||
routerNamePrefix = "r"
|
routerNamePrefix = "r"
|
||||||
@ -261,6 +263,12 @@ class Topo(object):
|
|||||||
|
|
||||||
|
|
||||||
class TopoConfig(object):
|
class TopoConfig(object):
|
||||||
|
"""
|
||||||
|
Base class to instantiate a topology.
|
||||||
|
|
||||||
|
This class is not instantiable as it. You must define a child class with the
|
||||||
|
`NAME` attribute.
|
||||||
|
"""
|
||||||
|
|
||||||
PING_OUTPUT = "ping.log"
|
PING_OUTPUT = "ping.log"
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
from core.topo import Topo
|
|
||||||
|
|
||||||
class MpECMPSingleInterfaceTopo(Topo):
|
|
||||||
def __init__(self, topoBuilder, parameterFile):
|
|
||||||
super(MpECMPSingleInterfaceTopo, self).__init__(topoBuilder, parameterFile)
|
|
||||||
|
|
||||||
print("Hello ECMP topo")
|
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
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(Topo.routerNamePrefix +
|
|
||||||
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
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
from core.experience import Experience, ExperienceParameter
|
from core.experience import Experience, ExperienceParameter
|
||||||
from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig
|
from topos.multi_interface_cong import MultiInterfaceCongConfig
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class ExperienceQUIC(Experience):
|
|||||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
||||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||||
|
|
||||||
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
|
if isinstance(self.mpConfig, MultiInterfaceCongConfig):
|
||||||
i = 0
|
i = 0
|
||||||
for cs in self.mpConfig.cong_servers:
|
for cs in self.mpConfig.cong_servers:
|
||||||
cmd = self.getCongServerCmd(i)
|
cmd = self.getCongServerCmd(i)
|
||||||
@ -104,7 +104,7 @@ class ExperienceQUIC(Experience):
|
|||||||
|
|
||||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
||||||
# First run congestion clients, then the main one
|
# First run congestion clients, then the main one
|
||||||
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
|
if isinstance(self.mpConfig, MultiInterfaceCongConfig):
|
||||||
i = 0
|
i = 0
|
||||||
for cc in self.mpConfig.cong_clients:
|
for cc in self.mpConfig.cong_clients:
|
||||||
cmd = self.getCongClientCmd(i)
|
cmd = self.getCongClientCmd(i)
|
||||||
@ -116,12 +116,12 @@ class ExperienceQUIC(Experience):
|
|||||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after")
|
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after")
|
||||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after")
|
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after")
|
||||||
# Wait for congestion traffic to end
|
# Wait for congestion traffic to end
|
||||||
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
|
if isinstance(self.mpConfig, MultiInterfaceCongConfig):
|
||||||
for cc in self.mpConfig.cong_clients:
|
for cc in self.mpConfig.cong_clients:
|
||||||
self.mpTopo.commandTo(cc, "while pkill -f wget -0; do sleep 0.5; done")
|
self.mpTopo.commandTo(cc, "while pkill -f wget -0; do sleep 0.5; done")
|
||||||
|
|
||||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + ExperienceQUIC.SERVER_GO_FILE)
|
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + ExperienceQUIC.SERVER_GO_FILE)
|
||||||
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
|
if isinstance(self.mpConfig, MultiInterfaceCongConfig):
|
||||||
for cs in self.mpConfig.cong_servers:
|
for cs in self.mpConfig.cong_servers:
|
||||||
self.mpTopo.commandTo(cs, "pkill -f https.py")
|
self.mpTopo.commandTo(cs, "pkill -f https.py")
|
||||||
|
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
from core.topo import Topo
|
|
||||||
|
|
||||||
class MpMultiInterfaceCongTopo(Topo):
|
|
||||||
congClientName = "CCli"
|
|
||||||
congServerName = "CSer"
|
|
||||||
|
|
||||||
def __init__(self, topoBuilder, parameterFile):
|
|
||||||
super(MpMultiInterfaceCongTopo, self).__init__(topoBuilder, parameterFile)
|
|
||||||
print("Hello from topo multi if")
|
|
||||||
self.client = self.addHost(Topo.clientName)
|
|
||||||
self.server = self.addHost(Topo.serverName)
|
|
||||||
self.router = self.addHost(Topo.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])
|
|
||||||
|
|
||||||
def getCongClients(self):
|
|
||||||
return self.cong_clients
|
|
||||||
|
|
||||||
def getCongServers(self):
|
|
||||||
return self.cong_servers
|
|
||||||
|
|
||||||
def addOneSwitchPerLink(self, link):
|
|
||||||
return self.addSwitch(MpMultiInterfaceCongTopo.switchNamePrefix +
|
|
||||||
str(link.id))
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
return s
|
|
@ -1,44 +0,0 @@
|
|||||||
from core.topo import Topo
|
|
||||||
|
|
||||||
class MpMultiInterfaceTopo(Topo):
|
|
||||||
def __init__(self, topoBuilder, parameterFile):
|
|
||||||
super(MpMultiInterfaceTopo, self).__init__(topoBuilder, parameterFile)
|
|
||||||
print("Hello from topo multi if")
|
|
||||||
self.client = self.addHost(Topo.clientName)
|
|
||||||
self.server = self.addHost(Topo.serverName)
|
|
||||||
self.router = self.addHost(Topo.routerName)
|
|
||||||
self.switchClient = []
|
|
||||||
self.switchServer = []
|
|
||||||
for l in self.topoParam.linkCharacteristics:
|
|
||||||
self.switchClient.append(self.addSwitch1ForLink(l))
|
|
||||||
self.addLink(self.client,self.switchClient[-1])
|
|
||||||
self.switchServer.append(self.addSwitch2ForLink(l))
|
|
||||||
self.addLink(self.switchClient[-1], self.switchServer[-1], **l.asDict())
|
|
||||||
self.addLink(self.switchServer[-1],self.router)
|
|
||||||
self.addLink(self.router, self.server)
|
|
||||||
|
|
||||||
def addSwitch1ForLink(self, link):
|
|
||||||
return self.addSwitch(MpMultiInterfaceTopo.switchNamePrefix +
|
|
||||||
str(2 * link.id))
|
|
||||||
|
|
||||||
def addSwitch2ForLink(self, link):
|
|
||||||
return self.addSwitch(MpMultiInterfaceTopo.switchNamePrefix +
|
|
||||||
str(2 * link.id + 1))
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
s = "Simple multiple interface topolgy \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----sw--|\n"
|
|
||||||
else:
|
|
||||||
s = s + "c--sw----sw--r-----s\n"
|
|
||||||
else:
|
|
||||||
s = s + "|--sw----sw--|\n"
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
return s
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
|||||||
from core.topo import Topo
|
|
||||||
|
|
||||||
class MpTwoInterfaceCongestionTopo(Topo):
|
|
||||||
def __init__(self, topoBuilder, parameterFile):
|
|
||||||
super(MpTwoInterfaceCongestionTopo, self).__init__(topoBuilder, parameterFile)
|
|
||||||
|
|
||||||
print("Hello from topo two ifs cong")
|
|
||||||
print("Expected topo:")
|
|
||||||
print("c1----link0--------------|")
|
|
||||||
print("|-------------r1--link1--r2-----s1")
|
|
||||||
print(" | |------s2")
|
|
||||||
print("c2----link2----")
|
|
||||||
|
|
||||||
self.client = self.addHost(Topo.clientName)
|
|
||||||
self.clientCong = self.addHost(Topo.clientName + "Cong")
|
|
||||||
self.server = self.addHost(Topo.serverName)
|
|
||||||
self.serverCong = self.addHost(Topo.serverName + "Cong")
|
|
||||||
self.router = self.addHost(Topo.routerName)
|
|
||||||
self.routerCong = self.addHost(Topo.routerName + "Cong")
|
|
||||||
self.switch = []
|
|
||||||
|
|
||||||
# Link between c1 and r2
|
|
||||||
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[0]))
|
|
||||||
self.addLink(self.client, self.switch[-1])
|
|
||||||
self.addLink(self.switch[-1], self.router, **self.topoParam.linkCharacteristics[0].asDict())
|
|
||||||
|
|
||||||
# Link between c1 and r1
|
|
||||||
self.addLink(self.client, self.routerCong)
|
|
||||||
|
|
||||||
# Link between c2 and r1
|
|
||||||
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[2]))
|
|
||||||
self.addLink(self.clientCong, self.switch[-1])
|
|
||||||
self.addLink(self.switch[-1], self.routerCong, **self.topoParam.linkCharacteristics[2].asDict())
|
|
||||||
|
|
||||||
# Link between r1 and r2
|
|
||||||
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[1]))
|
|
||||||
self.addLink(self.routerCong, self.switch[-1])
|
|
||||||
self.addLink(self.switch[-1], self.router, **self.topoParam.linkCharacteristics[1].asDict())
|
|
||||||
|
|
||||||
# Link between r2 and s1
|
|
||||||
self.addLink(self.router, self.server)
|
|
||||||
|
|
||||||
# Link between r2 and s2
|
|
||||||
self.addLink(self.router, self.serverCong)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
s = "Hello from topo two ifs cong \n"
|
|
||||||
s = s + "c1----link0--------------| \n"
|
|
||||||
s = s + "|-------------r1--link1--r2-----s1 \n"
|
|
||||||
s = s + " | |------s2 \n"
|
|
||||||
s = s + "c2----link2---- \n"
|
|
||||||
return s
|
|
||||||
|
|
||||||
def addOneSwitchPerLink(self, link):
|
|
||||||
return self.addSwitch(Topo.switchNamePrefix + str(link.id))
|
|
@ -3,12 +3,8 @@ from core.topo import Topo, TopoParameter
|
|||||||
|
|
||||||
from mininet_builder import MininetBuilder
|
from mininet_builder import MininetBuilder
|
||||||
|
|
||||||
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
|
import topos
|
||||||
from mpMultiInterfaceConfig import MpMultiInterfaceConfig
|
|
||||||
from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig
|
|
||||||
from mpMultiInterfaceCongTopo import MpMultiInterfaceCongTopo
|
|
||||||
from mpECMPSingleInterfaceConfig import MpECMPSingleInterfaceConfig
|
|
||||||
from mpTwoInterfaceCongestionConfig import MpTwoInterfaceCongestionConfig
|
|
||||||
from mpExperiencePing import ExperiencePing
|
from mpExperiencePing import ExperiencePing
|
||||||
from mpExperienceNCPV import ExperienceNCPV
|
from mpExperienceNCPV import ExperienceNCPV
|
||||||
from mpExperienceNC import ExperienceNC
|
from mpExperienceNC import ExperienceNC
|
||||||
@ -28,8 +24,6 @@ from mpExperienceSiriMsg import ExperienceSiriMsg
|
|||||||
from mpExperienceQUIC import ExperienceQUIC
|
from mpExperienceQUIC import ExperienceQUIC
|
||||||
from mpExperienceQUICSiri import ExperienceQUICSiri
|
from mpExperienceQUICSiri import ExperienceQUICSiri
|
||||||
from mpExperienceNone import ExperienceNone
|
from mpExperienceNone import ExperienceNone
|
||||||
from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo
|
|
||||||
from mpTwoInterfaceCongestionTopo import MpTwoInterfaceCongestionTopo
|
|
||||||
|
|
||||||
class MpXpRunner:
|
class MpXpRunner:
|
||||||
def __init__(self, builderType, topoParamFile, xpParamFile):
|
def __init__(self, builderType, topoParamFile, xpParamFile):
|
||||||
@ -53,40 +47,18 @@ class MpXpRunner:
|
|||||||
builderType)
|
builderType)
|
||||||
def defTopo(self):
|
def defTopo(self):
|
||||||
t = self.topoParam.getParam(Topo.topoAttr)
|
t = self.topoParam.getParam(Topo.topoAttr)
|
||||||
if t == Topo.multiIfTopo:
|
if t in topos.topos:
|
||||||
self.Topo = MpMultiInterfaceTopo(self.topoBuilder,
|
self.Topo = topos.topos[t](self.topoBuilder, self.topoParam)
|
||||||
self.topoParam)
|
|
||||||
elif t == Topo.ECMPLikeTopo:
|
|
||||||
self.Topo = MpECMPSingleInterfaceTopo(
|
|
||||||
self.topoBuilder,
|
|
||||||
self.topoParam)
|
|
||||||
elif t == Topo.twoIfCongTopo:
|
|
||||||
self.Topo = MpTwoInterfaceCongestionTopo(
|
|
||||||
self.topoBuilder, self.topoParam)
|
|
||||||
elif t == Topo.multiIfCongTopo:
|
|
||||||
self.Topo = MpMultiInterfaceCongTopo(self.topoBuilder,
|
|
||||||
self.topoParam)
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unfound Topo" + t)
|
raise Exception("Unknown topo: {}".format(t))
|
||||||
print(self.Topo)
|
print(self.Topo)
|
||||||
|
|
||||||
def defConfig(self):
|
def defConfig(self):
|
||||||
t = self.topoParam.getParam(Topo.topoAttr)
|
t = self.topoParam.getParam(Topo.topoAttr)
|
||||||
if t == Topo.multiIfTopo:
|
if t in topos.configs:
|
||||||
self.TopoConfig = MpMultiInterfaceConfig(self.Topo,
|
self.TopoConfig = topos.configs[t](self.Topo, self.topoParam)
|
||||||
self.topoParam)
|
|
||||||
elif t == Topo.ECMPLikeTopo:
|
|
||||||
self.TopoConfig = MpECMPSingleInterfaceConfig(
|
|
||||||
self.Topo,
|
|
||||||
self.topoParam)
|
|
||||||
elif t == Topo.twoIfCongTopo:
|
|
||||||
self.TopoConfig = MpTwoInterfaceCongestionConfig(
|
|
||||||
self.Topo, self.topoParam)
|
|
||||||
elif t == Topo.multiIfCongTopo:
|
|
||||||
self.TopoConfig = MpMultiInterfaceCongConfig(self.Topo,
|
|
||||||
self.topoParam)
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unfound Topo" + t)
|
raise Exception("Unknown topo config: {}".format(t))
|
||||||
|
|
||||||
def startTopo(self):
|
def startTopo(self):
|
||||||
self.Topo.startNetwork()
|
self.Topo.startNetwork()
|
||||||
|
12
topos/__init__.py
Normal file
12
topos/__init__.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import importlib
|
||||||
|
import pkgutil
|
||||||
|
import os
|
||||||
|
|
||||||
|
from core.topo import Topo, TopoConfig
|
||||||
|
|
||||||
|
pkg_dir = os.path.dirname(__file__)
|
||||||
|
for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]):
|
||||||
|
importlib.import_module('.' + name, __package__)
|
||||||
|
|
||||||
|
configs = {cls.NAME: cls for cls in TopoConfig.__subclasses__()}
|
||||||
|
topos = {cls.NAME: cls for cls in Topo.__subclasses__()}
|
@ -1,10 +1,56 @@
|
|||||||
from core.topo import Topo, TopoConfig, TopoParameter
|
from core.topo import Topo, TopoConfig, TopoParameter
|
||||||
from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo
|
|
||||||
from struct import *
|
from struct import *
|
||||||
|
|
||||||
class MpECMPSingleInterfaceConfig(TopoConfig):
|
class ECMPSingleInterfaceTopo(Topo):
|
||||||
|
NAME = "ECMPLike"
|
||||||
|
|
||||||
|
def __init__(self, topoBuilder, parameterFile):
|
||||||
|
super(ECMPSingleInterfaceTopo, self).__init__(topoBuilder, parameterFile)
|
||||||
|
|
||||||
|
print("Hello ECMP topo")
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
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(Topo.routerNamePrefix +
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
class ECMPSingleInterfaceConfig(TopoConfig):
|
||||||
|
NAME = "ECMPLike"
|
||||||
|
|
||||||
def __init__(self, topo, param):
|
def __init__(self, topo, param):
|
||||||
super(MpECMPSingleInterfaceConfig, self).__init__(topo, param)
|
super(ECMPSingleInterfaceConfig, self).__init__(topo, param)
|
||||||
|
|
||||||
def configureRoute(self):
|
def configureRoute(self):
|
||||||
i = 0
|
i = 0
|
@ -1,9 +1,54 @@
|
|||||||
from core.topo import Topo, TopoConfig, TopoParameter
|
from core.topo import Topo, TopoConfig, TopoParameter
|
||||||
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
|
|
||||||
|
|
||||||
class MpMultiInterfaceConfig(TopoConfig):
|
class MultiInterfaceTopo(Topo):
|
||||||
|
NAME = "MultiIf"
|
||||||
|
|
||||||
|
def __init__(self, topoBuilder, parameterFile):
|
||||||
|
super(MultiInterfaceTopo, self).__init__(topoBuilder, parameterFile)
|
||||||
|
print("Hello from topo multi if")
|
||||||
|
self.client = self.addHost(Topo.clientName)
|
||||||
|
self.server = self.addHost(Topo.serverName)
|
||||||
|
self.router = self.addHost(Topo.routerName)
|
||||||
|
self.switchClient = []
|
||||||
|
self.switchServer = []
|
||||||
|
for l in self.topoParam.linkCharacteristics:
|
||||||
|
self.switchClient.append(self.addSwitch1ForLink(l))
|
||||||
|
self.addLink(self.client,self.switchClient[-1])
|
||||||
|
self.switchServer.append(self.addSwitch2ForLink(l))
|
||||||
|
self.addLink(self.switchClient[-1], self.switchServer[-1], **l.asDict())
|
||||||
|
self.addLink(self.switchServer[-1],self.router)
|
||||||
|
self.addLink(self.router, self.server)
|
||||||
|
|
||||||
|
def addSwitch1ForLink(self, link):
|
||||||
|
return self.addSwitch(MultiInterfaceTopo.switchNamePrefix +
|
||||||
|
str(2 * link.id))
|
||||||
|
|
||||||
|
def addSwitch2ForLink(self, link):
|
||||||
|
return self.addSwitch(MultiInterfaceTopo.switchNamePrefix +
|
||||||
|
str(2 * link.id + 1))
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = "Simple multiple interface topolgy \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----sw--|\n"
|
||||||
|
else:
|
||||||
|
s = s + "c--sw----sw--r-----s\n"
|
||||||
|
else:
|
||||||
|
s = s + "|--sw----sw--|\n"
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
return s
|
||||||
|
|
||||||
|
class MultiInterfaceConfig(TopoConfig):
|
||||||
|
NAME = "MultiIf"
|
||||||
|
|
||||||
def __init__(self, topo, param):
|
def __init__(self, topo, param):
|
||||||
super(MpMultiInterfaceConfig, self).__init__(topo, param)
|
super(MultiInterfaceConfig, self).__init__(topo, param)
|
||||||
|
|
||||||
def configureRoute(self):
|
def configureRoute(self):
|
||||||
i = 0
|
i = 0
|
@ -1,9 +1,65 @@
|
|||||||
from mpMultiInterfaceCongTopo import MpMultiInterfaceCongTopo
|
|
||||||
from core.topo import TopoConfig, Topo, TopoParameter
|
from core.topo import TopoConfig, Topo, TopoParameter
|
||||||
|
|
||||||
class MpMultiInterfaceCongConfig(TopoConfig):
|
|
||||||
|
class MultiInterfaceCongTopo(Topo):
|
||||||
|
NAME = "MultiIfCong"
|
||||||
|
|
||||||
|
congClientName = "CCli"
|
||||||
|
congServerName = "CSer"
|
||||||
|
|
||||||
|
def __init__(self, topoBuilder, parameterFile):
|
||||||
|
super(MultiInterfaceCongTopo, self).__init__(topoBuilder, parameterFile)
|
||||||
|
print("Hello from topo multi if")
|
||||||
|
self.client = self.addHost(Topo.clientName)
|
||||||
|
self.server = self.addHost(Topo.serverName)
|
||||||
|
self.router = self.addHost(Topo.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(MultiInterfaceCongTopo.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(MultiInterfaceCongTopo.congServerName + str(len(self.cong_servers))))
|
||||||
|
self.addLink(self.router, self.cong_servers[-1])
|
||||||
|
|
||||||
|
def getCongClients(self):
|
||||||
|
return self.cong_clients
|
||||||
|
|
||||||
|
def getCongServers(self):
|
||||||
|
return self.cong_servers
|
||||||
|
|
||||||
|
def addOneSwitchPerLink(self, link):
|
||||||
|
return self.addSwitch(MultiInterfaceCongTopo.switchNamePrefix +
|
||||||
|
str(link.id))
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
class MultiInterfaceCongConfig(TopoConfig):
|
||||||
|
NAME = "MultiIfCong"
|
||||||
|
|
||||||
def __init__(self, topo, param):
|
def __init__(self, topo, param):
|
||||||
super(MpMultiInterfaceCongConfig, self).__init__(topo, param)
|
super(MultiInterfaceCongConfig, self).__init__(topo, param)
|
||||||
|
|
||||||
def configureRoute(self):
|
def configureRoute(self):
|
||||||
i = 0
|
i = 0
|
||||||
@ -192,7 +248,7 @@ class MpMultiInterfaceCongConfig(TopoConfig):
|
|||||||
return Topo.clientName + "-eth" + str(interfaceID)
|
return Topo.clientName + "-eth" + str(interfaceID)
|
||||||
|
|
||||||
def getCongClientInterface(self, interfaceID):
|
def getCongClientInterface(self, interfaceID):
|
||||||
return MpMultiInterfaceCongTopo.congClientName + str(interfaceID) + "-eth0"
|
return MultiInterfaceCongConfig.congClientName + str(interfaceID) + "-eth0"
|
||||||
|
|
||||||
def getRouterInterfaceSwitch(self, interfaceID):
|
def getRouterInterfaceSwitch(self, interfaceID):
|
||||||
return Topo.routerName + "-eth" + str(interfaceID)
|
return Topo.routerName + "-eth" + str(interfaceID)
|
||||||
@ -201,7 +257,7 @@ class MpMultiInterfaceCongConfig(TopoConfig):
|
|||||||
return Topo.serverName + "-eth0"
|
return Topo.serverName + "-eth0"
|
||||||
|
|
||||||
def getCongServerInterface(self, interfaceID):
|
def getCongServerInterface(self, interfaceID):
|
||||||
return MpMultiInterfaceCongTopo.congServerName + str(interfaceID) + "-eth0"
|
return MultiInterfaceCongConfig.congServerName + str(interfaceID) + "-eth0"
|
||||||
|
|
||||||
def getMidLeftName(self, id):
|
def getMidLeftName(self, id):
|
||||||
return Topo.switchNamePrefix + str(id)
|
return Topo.switchNamePrefix + str(id)
|
@ -1,9 +1,68 @@
|
|||||||
from core.topo import Topo, TopoConfig, TopoParameter
|
from core.topo import Topo, TopoConfig, TopoParameter
|
||||||
from mpTwoInterfaceCongestionTopo import MpTwoInterfaceCongestionTopo
|
|
||||||
|
|
||||||
class MpTwoInterfaceCongestionConfig(TopoConfig):
|
|
||||||
|
class TwoInterfaceCongestionTopo(Topo):
|
||||||
|
NAME = "twoIfCong"
|
||||||
|
|
||||||
|
def __init__(self, topoBuilder, parameterFile):
|
||||||
|
super(TwoInterfaceCongestionTopo, self).__init__(topoBuilder, parameterFile)
|
||||||
|
|
||||||
|
print("Hello from topo two ifs cong")
|
||||||
|
print("Expected topo:")
|
||||||
|
print("c1----link0--------------|")
|
||||||
|
print("|-------------r1--link1--r2-----s1")
|
||||||
|
print(" | |------s2")
|
||||||
|
print("c2----link2----")
|
||||||
|
|
||||||
|
self.client = self.addHost(Topo.clientName)
|
||||||
|
self.clientCong = self.addHost(Topo.clientName + "Cong")
|
||||||
|
self.server = self.addHost(Topo.serverName)
|
||||||
|
self.serverCong = self.addHost(Topo.serverName + "Cong")
|
||||||
|
self.router = self.addHost(Topo.routerName)
|
||||||
|
self.routerCong = self.addHost(Topo.routerName + "Cong")
|
||||||
|
self.switch = []
|
||||||
|
|
||||||
|
# Link between c1 and r2
|
||||||
|
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[0]))
|
||||||
|
self.addLink(self.client, self.switch[-1])
|
||||||
|
self.addLink(self.switch[-1], self.router, **self.topoParam.linkCharacteristics[0].asDict())
|
||||||
|
|
||||||
|
# Link between c1 and r1
|
||||||
|
self.addLink(self.client, self.routerCong)
|
||||||
|
|
||||||
|
# Link between c2 and r1
|
||||||
|
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[2]))
|
||||||
|
self.addLink(self.clientCong, self.switch[-1])
|
||||||
|
self.addLink(self.switch[-1], self.routerCong, **self.topoParam.linkCharacteristics[2].asDict())
|
||||||
|
|
||||||
|
# Link between r1 and r2
|
||||||
|
self.switch.append(self.addOneSwitchPerLink(self.topoParam.linkCharacteristics[1]))
|
||||||
|
self.addLink(self.routerCong, self.switch[-1])
|
||||||
|
self.addLink(self.switch[-1], self.router, **self.topoParam.linkCharacteristics[1].asDict())
|
||||||
|
|
||||||
|
# Link between r2 and s1
|
||||||
|
self.addLink(self.router, self.server)
|
||||||
|
|
||||||
|
# Link between r2 and s2
|
||||||
|
self.addLink(self.router, self.serverCong)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = "Hello from topo two ifs cong \n"
|
||||||
|
s = s + "c1----link0--------------| \n"
|
||||||
|
s = s + "|-------------r1--link1--r2-----s1 \n"
|
||||||
|
s = s + " | |------s2 \n"
|
||||||
|
s = s + "c2----link2---- \n"
|
||||||
|
return s
|
||||||
|
|
||||||
|
def addOneSwitchPerLink(self, link):
|
||||||
|
return self.addSwitch(Topo.switchNamePrefix + str(link.id))
|
||||||
|
|
||||||
|
|
||||||
|
class TwoInterfaceCongestionConfig(TopoConfig):
|
||||||
|
NAME = "twoIfCong"
|
||||||
|
|
||||||
def __init__(self, topo, param):
|
def __init__(self, topo, param):
|
||||||
super(MpTwoInterfaceCongestionConfig, self).__init__(topo, param)
|
super(TwoInterfaceCongestionConfig, self).__init__(topo, param)
|
||||||
|
|
||||||
def configureRoute(self):
|
def configureRoute(self):
|
||||||
# Client - Router
|
# Client - Router
|
Loading…
Reference in New Issue
Block a user