start refactor functions' name and documentation

This commit is contained in:
Quentin De Coninck 2020-06-25 10:53:56 +02:00
parent 902d088c45
commit 4fba49baf9
28 changed files with 839 additions and 767 deletions

View File

@ -7,156 +7,181 @@ class Experience(object):
This class is not instantiable as it. You must define a child class with the This class is not instantiable as it. You must define a child class with the
`NAME` attribute. `NAME` attribute.
Attributes:
experience_parameter Instance of ExperienceParameter
topo Instance of Topo
topo_config Instance of TopoConfig
""" """
def __init__(self, xpParam, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
self.xpParam = xpParam self.experience_parameter = experience_parameter
self.mpTopo = mpTopo self.topo = topo
self.mpConfig = mpConfig self.topo_config = topo_config
print(self.xpParam)
def classicRun(self): def classic_run(self):
"""
Default function to perform the experiment. It consists into three phases:
- A preparation phase through `prepare()` (generating experiment files,...)
- A running phase through `run()` (where the actual experience takes place)
- A cleaning phase through `clean()` (stopping traffic, removing generated files,...)
Typically, this function is called in the constructor of child classes.
"""
self.prepare() self.prepare()
self.run() self.run()
self.clean() self.clean()
def prepare(self): def prepare(self):
self.setupSysctl() """
self.runUserspacePM() Prepare the environment to run the experience.
self.mpConfig.configureNetwork() Typically, when you inherit from this class, you want to extend this
self.changeMetric() method, while still calling this parent function.
self.putPriorityOnPaths()
self.disableTSO() TODO: split experience traffic and protocol configuration
"""
self.setup_sysctl()
self.run_userspace_path_manager() # TODO to move elsewhere
self.topo_config.configure_network()
self.change_metric() # TODO to move elsewhere
self.put_priority_on_paths() # TODO to move elsewhere
self.disable_tso()
self.runTcpDump() self.runTcpDump()
self.runNetemAt() self.runNetemAt()
pass
def changeMetric(self): def change_metric(self):
metric = self.xpParam.getParam(ExperienceParameter.METRIC) """
Function only meaningful for MPTCP and its specific scheduler
"""
metric = self.experience_parameter.get(ExperienceParameter.METRIC)
if int(metric) >= 0: if int(metric) >= 0:
self.mpTopo.notNSCommand("echo " + metric + " > /sys/module/mptcp_sched_metric/parameters/metric") self.topo.command_global(
"echo {} > /sys/module/mptcp_sched_metric/parameters/metric".format(metric))
def putPriorityOnPaths(self): def put_priority_on_paths(self):
"""
Function only meaningful for MPTCP
"""
# Only meaningful if mpTopo is instance of MultiInterfaceTopo # Only meaningful if mpTopo is instance of MultiInterfaceTopo
if isinstance(self.mpTopo, MultiInterfaceTopo): if isinstance(self.topo, MultiInterfaceTopo):
prioPath0 = self.xpParam.getParam(ExperienceParameter.PRIOPATH0) prioPath0 = self.experience_parameter.get(ExperienceParameter.PRIOPATH0)
prioPath1 = self.xpParam.getParam(ExperienceParameter.PRIOPATH1) prioPath1 = self.experience_parameter.get(ExperienceParameter.PRIOPATH1)
if not prioPath0 == prioPath1: if not prioPath0 == prioPath1:
self.mpTopo.commandTo(self.mpConfig.client, "/home/mininet/iproute/ip/ip link set dev " + self.topo.command_to(self.topo_config.client, "/home/mininet/iproute/ip/ip link set dev " +
self.mpConfig.getClientInterface(0) + " priority " + str(prioPath0)) self.topo_config.getClientInterface(0) + " priority " + str(prioPath0))
self.mpTopo.commandTo(self.mpConfig.router, "/home/mininet/iproute/ip/ip link set dev " + self.topo.command_to(self.topo_config.router, "/home/mininet/iproute/ip/ip link set dev " +
self.mpConfig.getRouterInterfaceSwitch(0) + " priority " + self.topo_config.getRouterInterfaceSwitch(0) + " priority " +
str(prioPath0)) str(prioPath0))
self.mpTopo.commandTo(self.mpConfig.client, "/home/mininet/iproute/ip/ip link set dev " + self.topo.command_to(self.topo_config.client, "/home/mininet/iproute/ip/ip link set dev " +
self.mpConfig.getClientInterface(1) + " priority " + str(prioPath1)) self.topo_config.getClientInterface(1) + " priority " + str(prioPath1))
self.mpTopo.commandTo(self.mpConfig.router, "/home/mininet/iproute/ip/ip link set dev " + self.topo.command_to(self.topo_config.router, "/home/mininet/iproute/ip/ip link set dev " +
self.mpConfig.getRouterInterfaceSwitch(1) + " priority " + self.topo_config.getRouterInterfaceSwitch(1) + " priority " +
str(prioPath1)) str(prioPath1))
backupPath0 = self.xpParam.getParam(ExperienceParameter.BACKUPPATH0) backupPath0 = self.experience_parameter.get(ExperienceParameter.BACKUPPATH0)
if int(backupPath0) > 0: if int(backupPath0) > 0:
self.mpTopo.commandTo(self.mpConfig.client, self.mpConfig.interfaceBUPCommand(self.mpConfig.getClientInterface(0))) self.topo.command_to(self.topo_config.client, self.topo_config.interfaceBUPCommand(self.topo_config.getClientInterface(0)))
self.mpTopo.commandTo(self.mpConfig.router, self.mpConfig.interfaceBUPCommand(self.mpConfig.getRouterInterfaceSwitch(0))) self.topo.command_to(self.topo_config.router, self.topo_config.interfaceBUPCommand(self.topo_config.getRouterInterfaceSwitch(0)))
backupPath1 = self.xpParam.getParam(ExperienceParameter.BACKUPPATH1) backupPath1 = self.experience_parameter.get(ExperienceParameter.BACKUPPATH1)
if int(backupPath1) > 0: if int(backupPath1) > 0:
self.mpTopo.commandTo(self.mpConfig.client, self.mpConfig.interfaceBUPCommand(self.mpConfig.getClientInterface(1))) self.topo.command_to(self.topo_config.client, self.topo_config.interfaceBUPCommand(self.topo_config.getClientInterface(1)))
self.mpTopo.commandTo(self.mpConfig.router, self.mpConfig.interfaceBUPCommand(self.mpConfig.getRouterInterfaceSwitch(1))) self.topo.command_to(self.topo_config.router, self.topo_config.interfaceBUPCommand(self.topo_config.getRouterInterfaceSwitch(1)))
def disableTSO(self): def disable_tso(self):
links = self.mpTopo.getLinkCharacteristics() links = self.topo.getLinkCharacteristics()
i = 0 i = 0
for l in links: for l in links:
lname = self.mpConfig.getMidLeftName(i) lname = self.topo_config.getMidLeftName(i)
rname = self.mpConfig.getMidRightName(i) rname = self.topo_config.getMidRightName(i)
lbox = self.mpTopo.getHost(lname) lbox = self.topo.get_host(lname)
lif = self.mpConfig.getMidL2RInterface(i) lif = self.topo_config.getMidL2RInterface(i)
rif = self.mpConfig.getMidR2LInterface(i) rif = self.topo_config.getMidR2LInterface(i)
rbox = self.mpTopo.getHost(rname) rbox = self.topo.get_host(rname)
print(str(lname) + " " + str(lif)) print(str(lname) + " " + str(lif))
print(str(rname) + " " + str(rif)) print(str(rname) + " " + str(rif))
print("boxes " + str(lbox) + " " + str(rbox)) print("boxes " + str(lbox) + " " + str(rbox))
cmd = "ethtool -K " + lif + " tso off" cmd = "ethtool -K " + lif + " tso off"
print(cmd) print(cmd)
self.mpTopo.commandTo(lbox, cmd) self.topo.command_to(lbox, cmd)
cmd = "ethtool -K " + rif + " tso off" cmd = "ethtool -K " + rif + " tso off"
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.topo.command_to(rbox, cmd)
i = i + 1 i = i + 1
# And for the server # And for the server
cmd = "ethtool -K " + self.mpConfig.getServerInterface() + " tso off" cmd = "ethtool -K " + self.topo_config.getServerInterface() + " tso off"
print(cmd) print(cmd)
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
cmd = "ethtool -K " + self.mpConfig.getRouterInterfaceSwitch(self.mpConfig.getClientInterfaceCount()) + " tso off" cmd = "ethtool -K " + self.topo_config.getRouterInterfaceSwitch(self.topo_config.getClientInterfaceCount()) + " tso off"
print(cmd) print(cmd)
self.mpTopo.commandTo(self.mpConfig.router, cmd) self.topo.command_to(self.topo_config.router, cmd)
def runUserspacePM(self): def run_userspace_path_manager(self):
if self.xpParam.getParam(ExperienceParameter.KERNELPMC) != "netlink": if self.experience_parameter.get(ExperienceParameter.KERNELPMC) != "netlink":
print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !") print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !")
else: else:
upmc = self.xpParam.getParam(ExperienceParameter.USERPMC) upmc = self.experience_parameter.get(ExperienceParameter.USERPMC)
upmca = self.xpParam.getParam(ExperienceParameter.USERPMCARGS) upmca = self.experience_parameter.get(ExperienceParameter.USERPMCARGS)
self.mpTopo.commandTo(self.mpConfig.client, upmc + \ self.topo.command_to(self.topo_config.client, upmc + \
" " + upmca + " &>upmc.log &") " " + upmca + " &>upmc.log &")
if self.xpParam.getParam(ExperienceParameter.KERNELPMS) != "netlink": if self.experience_parameter.get(ExperienceParameter.KERNELPMS) != "netlink":
print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !") print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !")
else: else:
upms = self.xpParam.getParam(ExperienceParameter.USERPMS) upms = self.experience_parameter.get(ExperienceParameter.USERPMS)
upmsa = self.xpParam.getParam(ExperienceParameter.USERPMSARGS) upmsa = self.experience_parameter.get(ExperienceParameter.USERPMSARGS)
self.mpTopo.commandTo(self.mpConfig.server, upms + \ self.topo.command_to(self.topo_config.server, upms + \
" " + upmsa + " &>upms.log &") " " + upmsa + " &>upms.log &")
def cleanUserspacePM(self): def cleanUserspacePM(self):
if self.xpParam.getParam(ExperienceParameter.KERNELPMC) != "netlink": if self.experience_parameter.get(ExperienceParameter.KERNELPMC) != "netlink":
print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !") print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !")
else: else:
upmc = self.xpParam.getParam(ExperienceParameter.USERPMC) upmc = self.experience_parameter.get(ExperienceParameter.USERPMC)
self.mpTopo.commandTo(self.mpConfig.client, "killall " + upmc) self.topo.command_to(self.topo_config.client, "killall " + upmc)
if self.xpParam.getParam(ExperienceParameter.KERNELPMS) != "netlink": if self.experience_parameter.get(ExperienceParameter.KERNELPMS) != "netlink":
print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !") print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !")
else: else:
upms = self.xpParam.getParam(ExperienceParameter.USERPMS) upms = self.experience_parameter.get(ExperienceParameter.USERPMS)
self.mpTopo.commandTo(self.mpConfig.server, "killall " + upms) self.topo.command_to(self.topo_config.server, "killall " + upms)
def runNetemAt(self): def runNetemAt(self):
if not self.mpTopo.changeNetem == "yes": if not self.topo.changeNetem == "yes":
print("I don't need to change netem") print("I don't need to change netem")
return return
print("Will change netem config on the fly") print("Will change netem config on the fly")
links = self.mpTopo.getLinkCharacteristics() links = self.topo.getLinkCharacteristics()
i = 0 i = 0
for l in links: for l in links:
lname = self.mpConfig.getMidLeftName(i) lname = self.topo_config.getMidLeftName(i)
rname = self.mpConfig.getMidRightName(i) rname = self.topo_config.getMidRightName(i)
lbox = self.mpTopo.getHost(lname) lbox = self.topo.get_host(lname)
lif = self.mpConfig.getMidL2RInterface(i) lif = self.topo_config.getMidL2RInterface(i)
rif = self.mpConfig.getMidR2LInterface(i) rif = self.topo_config.getMidR2LInterface(i)
rbox = self.mpTopo.getHost(rname) rbox = self.topo.get_host(rname)
print(str(lname) + " " + str(lif)) print(str(lname) + " " + str(lif))
print(str(rname) + " " + str(rif)) print(str(rname) + " " + str(rif))
print("boxes " + str(lbox) + " " + str(rbox)) print("boxes " + str(lbox) + " " + str(rbox))
cmd = l.buildBwCmd(lif) cmd = l.buildBwCmd(lif)
print(cmd) print(cmd)
self.mpTopo.commandTo(lbox, cmd) self.topo.command_to(lbox, cmd)
cmd = l.buildBwCmd(rif) cmd = l.buildBwCmd(rif)
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.topo.command_to(rbox, cmd)
ilif = self.mpConfig.getMidL2RIncomingInterface(i) ilif = self.topo_config.getMidL2RIncomingInterface(i)
irif = self.mpConfig.getMidR2LIncomingInterface(i) irif = self.topo_config.getMidR2LIncomingInterface(i)
cmd = l.buildPolicingCmd(ilif) cmd = l.buildPolicingCmd(ilif)
print(cmd) print(cmd)
self.mpTopo.commandTo(lbox, cmd) self.topo.command_to(lbox, cmd)
cmd = l.buildPolicingCmd(irif) cmd = l.buildPolicingCmd(irif)
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.topo.command_to(rbox, cmd)
cmd = l.buildNetemCmd(irif) cmd = l.buildNetemCmd(irif)
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.topo.command_to(rbox, cmd)
cmd = l.buildNetemCmd(ilif) cmd = l.buildNetemCmd(ilif)
print(cmd) print(cmd)
self.mpTopo.commandTo(lbox, cmd) self.topo.command_to(lbox, cmd)
i = i + 1 i = i + 1
@ -164,36 +189,36 @@ class Experience(object):
pass pass
def clean(self): def clean(self):
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"killall tcpdump") "killall tcpdump")
self.mpTopo.commandTo(self.mpConfig.server, self.topo.command_to(self.topo_config.server,
"killall tcpdump") "killall tcpdump")
self.backUpSysctl() self.backUpSysctl()
self.cleanUserspacePM() self.cleanUserspacePM()
pass pass
def setupSysctl(self): def setup_sysctl(self):
self.saveSysctl() self.save_sysctl()
self.writeSysctl() self.write_sysctl()
def saveSysctl(self): def save_sysctl(self):
self.sysctlBUP = {} self.sysctlBUP = {}
self._saveSysctl(ExperienceParameter.sysctlKey, self.sysctlBUP) self._save_sysctl(ExperienceParameter.sysctlKey, self.sysctlBUP)
self.sysctlBUPC = {} self.sysctlBUPC = {}
self._saveSysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC, self._save_sysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC,
ns = True, who = self.mpConfig.client) ns = True, who = self.topo_config.client)
self.sysctlBUPS = {} self.sysctlBUPS = {}
self._saveSysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS, self._save_sysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS,
ns = True, who = self.mpConfig.server) ns = True, who = self.topo_config.server)
def _saveSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): def _save_sysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
for k in sysctlDic: for k in sysctlDic:
sysctlKey = sysctlDic[k] sysctlKey = sysctlDic[k]
cmd = self.cmdReadSysctl(sysctlKey) cmd = self.cmdReadSysctl(sysctlKey)
if not ns: if not ns:
val = self.mpTopo.notNSCommand(cmd) val = self.topo.command_global(cmd)
else: else:
val = self.mpTopo.commandTo(who, cmd) val = self.topo.command_to(who, cmd)
if val == "Error": if val == "Error":
print("oooops can't get sysctl " + sysctlKey) print("oooops can't get sysctl " + sysctlKey)
else: else:
@ -207,27 +232,27 @@ class Experience(object):
s = "sysctl " + key s = "sysctl " + key
return s return s
def cmdWriteSysctl(self, key, value): def cmd_write_sysctl(self, key, value):
s = self.cmdReadSysctl(key) s = self.cmdReadSysctl(key)
s = s + "=\"" + str(value) + "\"" s = s + "=\"" + str(value) + "\""
return s return s
def writeSysctl(self): def write_sysctl(self):
self._writeSysctl(ExperienceParameter.sysctlKey, self.sysctlBUP) self._write_sysctl(ExperienceParameter.sysctlKey, self.sysctlBUP)
self._writeSysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC, self._write_sysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC,
ns = True, who = self.mpConfig.client) ns = True, who = self.topo_config.client)
self._writeSysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS, self._write_sysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS,
ns = True, who = self.mpConfig.server) ns = True, who = self.topo_config.server)
def _writeSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): def _write_sysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
for k in sysctlBUP: for k in sysctlBUP:
sysctlKey = sysctlDic[k] sysctlKey = sysctlDic[k]
sysctlValue = self.xpParam.getParam(k) sysctlValue = self.experience_parameter.get(k)
cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) cmd = self.cmd_write_sysctl(sysctlKey,sysctlValue)
if not ns: if not ns:
val = self.mpTopo.notNSCommand(cmd) val = self.topo.command_global(cmd)
else: else:
val = self.mpTopo.commandTo(who, cmd) val = self.topo.command_to(who, cmd)
if val == "Error": if val == "Error":
print("oooops can't set sysctl " + sysctlKey) print("oooops can't set sysctl " + sysctlKey)
@ -235,20 +260,20 @@ class Experience(object):
def backUpSysctl(self): def backUpSysctl(self):
self._backUpSysctl(ExperienceParameter.sysctlKey, self.sysctlBUP) self._backUpSysctl(ExperienceParameter.sysctlKey, self.sysctlBUP)
self._backUpSysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC, self._backUpSysctl(ExperienceParameter.sysctlKeyClient, self.sysctlBUPC,
ns = True, who = self.mpConfig.client) ns = True, who = self.topo_config.client)
self._backUpSysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS, self._backUpSysctl(ExperienceParameter.sysctlKeyServer, self.sysctlBUPS,
ns = True, who = self.mpConfig.server) ns = True, who = self.topo_config.server)
def _backUpSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): def _backUpSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
for k in sysctlBUP: for k in sysctlBUP:
sysctlKey = sysctlDic[k] sysctlKey = sysctlDic[k]
sysctlValue = sysctlBUP[k] sysctlValue = sysctlBUP[k]
cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) cmd = self.cmd_write_sysctl(sysctlKey,sysctlValue)
if not ns: if not ns:
val = self.mpTopo.notNSCommand(cmd) val = self.topo.command_global(cmd)
else: else:
val = self.mpTopo.commandTo(who, cmd) val = self.topo.command_to(who, cmd)
if val == "Error": if val == "Error":
print("oooops can't set sysctl " + sysctlKey) print("oooops can't set sysctl " + sysctlKey)
@ -256,14 +281,14 @@ class Experience(object):
def runTcpDump(self): def runTcpDump(self):
#todo : replace filename by cst #todo : replace filename by cst
cpcap = self.xpParam.getParam(ExperienceParameter.CLIENTPCAP) cpcap = self.experience_parameter.get(ExperienceParameter.CLIENTPCAP)
spcap = self.xpParam.getParam(ExperienceParameter.SERVERPCAP) spcap = self.experience_parameter.get(ExperienceParameter.SERVERPCAP)
snaplenpcap = self.xpParam.getParam(ExperienceParameter.SNAPLENPCAP) snaplenpcap = self.experience_parameter.get(ExperienceParameter.SNAPLENPCAP)
if cpcap == "yes" : if cpcap == "yes" :
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"tcpdump -i any -s " + snaplenpcap + " -w client.pcap &") "tcpdump -i any -s " + snaplenpcap + " -w client.pcap &")
if spcap == "yes" : if spcap == "yes" :
self.mpTopo.commandTo(self.mpConfig.server, self.topo.command_to(self.topo_config.server,
"tcpdump -i any -s " + snaplenpcap + " -w server.pcap &") "tcpdump -i any -s " + snaplenpcap + " -w server.pcap &")
if spcap == "yes" or cpcap == "yes": if spcap == "yes" or cpcap == "yes":
self.mpTopo.commandTo(self.mpConfig.client,"sleep 5") self.topo.command_to(self.topo_config.client,"sleep 5")

View File

@ -32,7 +32,7 @@ class Parameter(object):
print("In file " + paramFile) print("In file " + paramFile)
f.close() f.close()
def getParam(self, key): def get(self, key):
if key in self.paramDic: if key in self.paramDic:
return self.paramDic[key] return self.paramDic[key]
return None return None
@ -210,8 +210,8 @@ class ExperienceParameter(Parameter):
def __init__(self, paramFile): def __init__(self, paramFile):
super(ExperienceParameter, self).__init__(paramFile) super(ExperienceParameter, self).__init__(paramFile)
def getParam(self, key): def get(self, key):
val = super(ExperienceParameter, self).getParam(key) val = super(ExperienceParameter, self).get(key)
if val is None: if val is None:
if key in ExperienceParameter.defaultValue: if key in ExperienceParameter.defaultValue:
return ExperienceParameter.defaultValue[key] return ExperienceParameter.defaultValue[key]

View File

@ -132,7 +132,7 @@ class TopoParameter(Parameter):
print(self.__str__()) print(self.__str__())
def loadNetemAt(self): def loadNetemAt(self):
if not self.getParam(TopoParameter.changeNetem) == "yes": if not self.get(TopoParameter.changeNetem) == "yes":
return return
for k in sorted(self.paramDic): for k in sorted(self.paramDic):
if k.startswith(TopoParameter.netemAt): if k.startswith(TopoParameter.netemAt):
@ -182,8 +182,8 @@ class TopoParameter(Parameter):
print("Ignored path :") print("Ignored path :")
print(self.paramDic[k]) print(self.paramDic[k])
def getParam(self, key): def get(self, key):
val = Parameter.getParam(self, key) val = Parameter.get(self, key)
if val is None: if val is None:
if key in TopoParameter.defaultValue: if key in TopoParameter.defaultValue:
return TopoParameter.defaultValue[key] return TopoParameter.defaultValue[key]
@ -207,8 +207,8 @@ class Topo(object):
This class is not instantiable as it. You must define a child class with the This class is not instantiable as it. You must define a child class with the
`NAME` attribute. `NAME` attribute.
""" """
mininetBuilder = "mininet" MININET_BUILDER = "mininet"
topoAttr = "topoType" TOPO_ATTR = "topoType"
switchNamePrefix = "s" switchNamePrefix = "s"
routerNamePrefix = "r" routerNamePrefix = "r"
clientName = "Client" clientName = "Client"
@ -220,25 +220,25 @@ class Topo(object):
def __init__(self, topoBuilder, topoParam): def __init__(self, topoBuilder, topoParam):
self.topoBuilder = topoBuilder self.topoBuilder = topoBuilder
self.topoParam = topoParam self.topoParam = topoParam
self.changeNetem = topoParam.getParam(TopoParameter.changeNetem) self.changeNetem = topoParam.get(TopoParameter.changeNetem)
self.logFile = open(Topo.cmdLog, 'w') self.logFile = open(Topo.cmdLog, 'w')
def getLinkCharacteristics(self): def getLinkCharacteristics(self):
return self.topoParam.linkCharacteristics return self.topoParam.linkCharacteristics
def commandTo(self, who, cmd): def command_to(self, who, cmd):
self.logFile.write(who.__str__() + " : " + cmd + "\n") self.logFile.write(who.__str__() + " : " + cmd + "\n")
return self.topoBuilder.commandTo(who, cmd) return self.topoBuilder.command_to(who, cmd)
def notNSCommand(self, cmd): def command_global(self, cmd):
""" """
mainly use for not namespace sysctl. mainly use for not namespace sysctl.
""" """
self.logFile.write("Not_NS" + " : " + cmd + "\n") self.logFile.write("Not_NS" + " : " + cmd + "\n")
return self.topoBuilder.notNSCommand(cmd) return self.topoBuilder.command_global(cmd)
def getHost(self, who): def get_host(self, who):
return self.topoBuilder.getHost(who) return self.topoBuilder.get_host(who)
def addHost(self, host): def addHost(self, host):
return self.topoBuilder.addHost(host) return self.topoBuilder.addHost(host)
@ -249,17 +249,17 @@ class Topo(object):
def addLink(self, fromA, toB, **kwargs): def addLink(self, fromA, toB, **kwargs):
self.topoBuilder.addLink(fromA,toB,**kwargs) self.topoBuilder.addLink(fromA,toB,**kwargs)
def getCLI(self): def get_cli(self):
self.topoBuilder.getCLI() self.topoBuilder.get_cli()
def startNetwork(self): def start_network(self):
self.topoBuilder.startNetwork() self.topoBuilder.start_network()
def closeLogFile(self): def closeLogFile(self):
self.logFile.close() self.logFile.close()
def stopNetwork(self): def stop_network(self):
self.topoBuilder.stopNetwork() self.topoBuilder.stop_network()
class TopoConfig(object): class TopoConfig(object):
@ -276,7 +276,7 @@ class TopoConfig(object):
self.topo = topo self.topo = topo
self.param = param self.param = param
def configureNetwork(self): def configure_network(self):
print("Configure interfaces....Generic call ?") print("Configure interfaces....Generic call ?")
self.configureInterfaces() self.configureInterfaces()
self.configureRoute() self.configureRoute()

View File

@ -9,20 +9,20 @@ class AB(Experience):
AB_BIN = "ab" AB_BIN = "ab"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(AB, self).__init__(xpParamFile, mpTopo, mpConfig) super(AB, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(AB, self).classicRun() super(AB, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"rm " + AB.PING_OUTPUT) "rm " + AB.PING_OUTPUT)
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,19 +31,19 @@ class AB(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPRANDOMSIZE)
self.concurrent_requests = self.xpParam.getParam(ExperienceParameter.ABCONCURRENTREQUESTS) self.concurrent_requests = self.experience_parameter.get(ExperienceParameter.ABCONCURRENTREQUESTS)
self.timelimit = self.xpParam.getParam(ExperienceParameter.ABTIMELIMIT) self.timelimit = self.experience_parameter.get(ExperienceParameter.ABTIMELIMIT)
def prepare(self): def prepare(self):
Experience.prepare(self) Experience.prepare(self)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
AB.CLIENT_LOG ) AB.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
AB.SERVER_LOG ) AB.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -55,7 +55,7 @@ class AB(Experience):
def getAbClientCmd(self): def getAbClientCmd(self):
s = AB.AB_BIN + " -c " + self.concurrent_requests + " -t " + \ s = AB.AB_BIN + " -c " + self.concurrent_requests + " -t " + \
self.timelimit + " http://" + self.mpConfig.getServerIP() + "/" + self.file + \ self.timelimit + " http://" + self.topo_config.getServerIP() + "/" + self.file + \
" &>" + AB.CLIENT_LOG " &>" + AB.CLIENT_LOG
print(s) print(s)
return s return s
@ -63,16 +63,16 @@ class AB(Experience):
def clean(self): def clean(self):
Experience.clean(self) Experience.clean(self)
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
#todo use cst #todo use cst
#self.mpTopo.commandTo(self.mpConfig.server, "killall netcat") #self.topo.command_to(self.topo_config.server, "killall netcat")
def run(self): def run(self):
cmd = self.getAbServerCmd() cmd = self.getAbServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getAbClientCmd() cmd = self.getAbClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -14,20 +14,20 @@ class DITG(Experience):
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(DITG, self).__init__(xpParamFile, mpTopo, mpConfig) super(DITG, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(DITG, self).classicRun() super(DITG, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Experience.PING_OUTPUT) Experience.PING_OUTPUT)
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -36,21 +36,21 @@ class DITG(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.kbytes = self.xpParam.getParam(ExperienceParameter.DITGKBYTES) self.kbytes = self.experience_parameter.get(ExperienceParameter.DITGKBYTES)
self.constant_packet_size = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSIZE) self.constant_packet_size = self.experience_parameter.get(ExperienceParameter.DITGCONSTANTPACKETSIZE)
self.mean_poisson_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGMEANPOISSONPACKETSSEC) self.mean_poisson_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGMEANPOISSONPACKETSSEC)
self.constant_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSSEC) self.constant_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGCONSTANTPACKETSSEC)
self.bursts_on_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSONPACKETSSEC) self.bursts_on_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGBURSTSONPACKETSSEC)
self.bursts_off_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSOFFPACKETSSEC) self.bursts_off_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGBURSTSOFFPACKETSSEC)
def prepare(self): def prepare(self):
super(DITG, self).prepare() super(DITG, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + DITG.DITG_LOG) self.topo.command_to(self.topo_config.client, "rm " + DITG.DITG_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + DITG.DITG_SERVER_LOG) self.topo.command_to(self.topo_config.server, "rm " + DITG.DITG_SERVER_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + DITG.DITG_TEMP_LOG) self.topo.command_to(self.topo_config.client, "rm " + DITG.DITG_TEMP_LOG)
def getClientCmd(self): def getClientCmd(self):
s = DITG.ITGSEND_BIN + " -a " + self.mpConfig.getServerIP() + \ s = DITG.ITGSEND_BIN + " -a " + self.topo_config.getServerIP() + \
" -T TCP -k " + self.kbytes + " -l " + DITG.DITG_TEMP_LOG " -T TCP -k " + self.kbytes + " -l " + DITG.DITG_TEMP_LOG
if self.constant_packet_size != "0": if self.constant_packet_size != "0":
@ -76,11 +76,11 @@ class DITG(Experience):
def run(self): def run(self):
cmd = self.getServerCmd() cmd = self.getServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getClientCmd() cmd = self.getClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "pkill -9 -f ITGRecv") self.topo.command_to(self.topo_config.server, "pkill -9 -f ITGRecv")
self.mpTopo.commandTo(self.mpConfig.server, DITG.ITGDEC_BIN + " " + DITG.DITG_SERVER_TEMP_LOG + " &> " + DITG.DITG_SERVER_LOG) self.topo.command_to(self.topo_config.server, DITG.ITGDEC_BIN + " " + DITG.DITG_SERVER_TEMP_LOG + " &> " + DITG.DITG_SERVER_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -10,20 +10,20 @@ class Epload(Experience):
EPLOAD_EMULATOR="/home/mininet/epload/epload/emulator/run.js" EPLOAD_EMULATOR="/home/mininet/epload/epload/emulator/run.js"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(Epload, self).__init__(xpParamFile, mpTopo, mpConfig) super(Epload, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(Epload, self).classicRun() super(Epload, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Epload.PING_OUTPUT ) Epload.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -32,13 +32,13 @@ class Epload(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.epload_test_dir = self.xpParam.getParam(ExperienceParameter.EPLOADTESTDIR) self.epload_test_dir = self.experience_parameter.get(ExperienceParameter.EPLOADTESTDIR)
def prepare(self): def prepare(self):
super(Epload, self).prepare() super(Epload, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Epload.EPLOAD_LOG ) Epload.EPLOAD_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
Epload.SERVER_LOG ) Epload.SERVER_LOG )
def getHTTPServerCmd(self): def getHTTPServerCmd(self):
@ -60,14 +60,14 @@ class Epload(Experience):
def getSubHostCmd(self): def getSubHostCmd(self):
s = "for f in `ls " + self.epload_test_dir + "/*`; do " + \ s = "for f in `ls " + self.epload_test_dir + "/*`; do " + \
" sed -i 's/@host@/" + self.mpConfig.getServerIP() + "/' " + \ " sed -i 's/@host@/" + self.topo_config.getServerIP() + "/' " + \
"$f; done" "$f; done"
print(s) print(s)
return s return s
def getSubBackHostCmd(self): def getSubBackHostCmd(self):
s = "for f in `ls " + self.epload_test_dir + "/*`; do " + \ s = "for f in `ls " + self.epload_test_dir + "/*`; do " + \
" sed -i 's/" + self.mpConfig.getServerIP() + "/@host@/' " + \ " sed -i 's/" + self.topo_config.getServerIP() + "/@host@/' " + \
"$f; done" "$f; done"
print(s) print(s)
return s return s
@ -77,16 +77,16 @@ class Epload(Experience):
def run(self): def run(self):
cmd = self.getHTTPServerCmd() cmd = self.getHTTPServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getSubHostCmd() cmd = self.getSubHostCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
cmd = self.getEploadClientCmd() cmd = self.getEploadClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
cmd = self.getSubBackHostCmd() cmd = self.getSubBackHostCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getKillHTTPCmd() cmd = self.getKillHTTPCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)

View File

@ -9,20 +9,20 @@ class HTTP(Experience):
WGET_BIN = "wget" WGET_BIN = "wget"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(HTTP, self).__init__(xpParamFile, mpTopo, mpConfig) super(HTTP, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(HTTP, self).classicRun() super(HTTP, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
HTTP.PING_OUTPUT ) HTTP.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,17 +31,17 @@ class HTTP(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPRANDOMSIZE)
def prepare(self): def prepare(self):
super(HTTP, self).prepare() super(HTTP, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
HTTP.CLIENT_LOG ) HTTP.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
HTTP.SERVER_LOG ) HTTP.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -51,7 +51,7 @@ class HTTP(Experience):
return s return s
def getHTTPClientCmd(self): def getHTTPClientCmd(self):
s = "(time " + HTTP.WGET_BIN + " http://" + self.mpConfig.getServerIP() + \ s = "(time " + HTTP.WGET_BIN + " http://" + self.topo_config.getServerIP() + \
"/" + self.file + " --no-check-certificate) &>" + HTTP.CLIENT_LOG "/" + self.file + " --no-check-certificate) &>" + HTTP.CLIENT_LOG
print(s) print(s)
return s return s
@ -59,17 +59,17 @@ class HTTP(Experience):
def clean(self): def clean(self):
super(HTTP, self).clean() super(HTTP, self).clean()
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
def run(self): def run(self):
cmd = self.getHTTPServerCmd() cmd = self.getHTTPServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getHTTPClientCmd() cmd = self.getHTTPClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -9,20 +9,20 @@ class HTTPS(Experience):
WGET_BIN = "wget" WGET_BIN = "wget"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(HTTPS, self).__init__(xpParamFile, mpTopo, mpConfig) super(HTTPS, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(HTTPS, self).classicRun() super(HTTPS, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
HTTPS.PING_OUTPUT ) HTTPS.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,17 +31,17 @@ class HTTPS(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPSFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPSRANDOMSIZE)
def prepare(self): def prepare(self):
super(HTTPS, self).prepare() super(HTTPS, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
HTTPS.CLIENT_LOG ) HTTPS.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
HTTPS.SERVER_LOG ) HTTPS.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -52,7 +52,7 @@ class HTTPS(Experience):
return s return s
def getHTTPSClientCmd(self): def getHTTPSClientCmd(self):
s = "(time " + HTTPS.WGET_BIN + " https://" + self.mpConfig.getServerIP() + \ s = "(time " + HTTPS.WGET_BIN + " https://" + self.topo_config.getServerIP() + \
"/" + self.file + " --no-check-certificate) &>" + HTTPS.CLIENT_LOG "/" + self.file + " --no-check-certificate) &>" + HTTPS.CLIENT_LOG
print(s) print(s)
return s return s
@ -60,19 +60,19 @@ class HTTPS(Experience):
def clean(self): def clean(self):
super(HTTPS, self).clean() super(HTTPS, self).clean()
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
def run(self): def run(self):
cmd = self.getHTTPSServerCmd() cmd = self.getHTTPSServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
print("Waiting for the server to run") print("Waiting for the server to run")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 15") self.topo.command_to(self.topo_config.client, "sleep 15")
cmd = self.getHTTPSClientCmd() cmd = self.getHTTPSClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f https_server.py") self.topo.command_to(self.topo_config.server, "pkill -f https_server.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -9,20 +9,20 @@ class IPerf(Experience):
IPERF_BIN = "iperf3" IPERF_BIN = "iperf3"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(IPerf, self).__init__(xpParamFile, mpTopo, mpConfig) super(IPerf, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(IPerf, self).classicRun() super(IPerf, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
IPerf.PING_OUTPUT) IPerf.PING_OUTPUT)
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,18 +31,18 @@ class IPerf(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.time = self.xpParam.getParam(ExperienceParameter.IPERFTIME) self.time = self.experience_parameter.get(ExperienceParameter.IPERFTIME)
self.parallel = self.xpParam.getParam(ExperienceParameter.IPERFPARALLEL) self.parallel = self.experience_parameter.get(ExperienceParameter.IPERFPARALLEL)
def prepare(self): def prepare(self):
super(IPerf, self).prepare() super(IPerf, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + self.topo.command_to(self.topo_config.client, "rm " +
IPerf.IPERF_LOG) IPerf.IPERF_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + self.topo.command_to(self.topo_config.server, "rm " +
IPerf.SERVER_LOG) IPerf.SERVER_LOG)
def getClientCmd(self): def getClientCmd(self):
s = IPerf.IPERF_BIN + " -c " + self.mpConfig.getServerIP() + \ s = IPerf.IPERF_BIN + " -c " + self.topo_config.getServerIP() + \
" -t " + self.time + " -P " + self.parallel + " &>" + IPerf.IPERF_LOG " -t " + self.time + " -P " + self.parallel + " &>" + IPerf.IPERF_LOG
print(s) print(s)
return s return s
@ -58,9 +58,9 @@ class IPerf(Experience):
def run(self): def run(self):
cmd = self.getServerCmd() cmd = self.getServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getClientCmd() cmd = self.getClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -9,20 +9,20 @@ class Msg(Experience):
CLIENT_ERR = "msg_client.err" CLIENT_ERR = "msg_client.err"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(Msg, self).__init__(xpParamFile, mpTopo, mpConfig) super(Msg, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(Msg, self).classicRun() super(Msg, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Msg.PING_OUTPUT ) Msg.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,16 +31,16 @@ class Msg(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.client_sleep = self.xpParam.getParam(ExperienceParameter.MSGCLIENTSLEEP) self.client_sleep = self.experience_parameter.get(ExperienceParameter.MSGCLIENTSLEEP)
self.server_sleep = self.xpParam.getParam(ExperienceParameter.MSGSERVERSLEEP) self.server_sleep = self.experience_parameter.get(ExperienceParameter.MSGSERVERSLEEP)
self.nb_requests = self.xpParam.getParam(ExperienceParameter.MSGNBREQUESTS) self.nb_requests = self.experience_parameter.get(ExperienceParameter.MSGNBREQUESTS)
self.bytes = self.xpParam.getParam(ExperienceParameter.MSGBYTES) self.bytes = self.experience_parameter.get(ExperienceParameter.MSGBYTES)
def prepare(self): def prepare(self):
super(Msg, self).prepare() super(Msg, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Msg.CLIENT_LOG) Msg.CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
Msg.SERVER_LOG) Msg.SERVER_LOG)
def getMsgServerCmd(self): def getMsgServerCmd(self):
@ -61,14 +61,14 @@ class Msg(Experience):
def run(self): def run(self):
cmd = self.getMsgServerCmd() cmd = self.getMsgServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getMsgClientCmd() cmd = self.getMsgClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f msg_server.py") self.topo.command_to(self.topo_config.server, "pkill -f msg_server.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -12,30 +12,30 @@ class NC(Experience):
CLIENT_NC_LOG = "netcat_client" CLIENT_NC_LOG = "netcat_client"
NC_BIN = "netcat" NC_BIN = "netcat"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(NC, self).__init__(xpParamFile, mpTopo, mpConfig) super(NC, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
super(NC, self).classicRun() super(NC, self).classic_run()
def loadParam(self): def loadParam(self):
self.ddibs = self.xpParam.getParam(ExperienceParameter.DDIBS) self.ddibs = self.experience_parameter.get(ExperienceParameter.DDIBS)
self.ddobs = self.xpParam.getParam(ExperienceParameter.DDOBS) self.ddobs = self.experience_parameter.get(ExperienceParameter.DDOBS)
self.ddcount = self.xpParam.getParam(ExperienceParameter.DDCOUNT) self.ddcount = self.experience_parameter.get(ExperienceParameter.DDCOUNT)
self.ncServerPort = self.xpParam.getParam(ExperienceParameter.NCSERVERPORT) self.ncServerPort = self.experience_parameter.get(ExperienceParameter.NCSERVERPORT)
self.ncClientPort = [] self.ncClientPort = []
for k in sorted(self.xpParam.paramDic): for k in sorted(self.experience_parameter.paramDic):
if k.startswith(ExperienceParameter.NCCLIENTPORT): if k.startswith(ExperienceParameter.NCCLIENTPORT):
port = self.xpParam.paramDic[k] port = self.experience_parameter.paramDic[k]
self.ncClientPort.append(port) self.ncClientPort.append(port)
if len(self.ncClientPort) == 0: if len(self.ncClientPort) == 0:
d = self.xpParam.getParam(ExperienceParameter.NCCLIENTPORT) d = self.experience_parameter.get(ExperienceParameter.NCCLIENTPORT)
self.ncClientPort.append(d) self.ncClientPort.append(d)
def prepare(self): def prepare(self):
super(NC, self).prepare() super(NC, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
NC.CLIENT_NC_LOG ) NC.CLIENT_NC_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
NC.SERVER_NC_LOG ) NC.SERVER_NC_LOG )
def getNCServerCmd(self, id): def getNCServerCmd(self, id):
@ -53,7 +53,7 @@ class NC(Experience):
def getNCClientCmd(self, id): def getNCClientCmd(self, id):
s = NC.NC_BIN + " " + \ s = NC.NC_BIN + " " + \
" -p " + self.ncClientPort[id] + " " + \ " -p " + self.ncClientPort[id] + " " + \
self.mpConfig.getServerIP() + " " + \ self.topo_config.getServerIP() + " " + \
self.ncServerPort + " " + \ self.ncServerPort + " " + \
"&>" + NC.CLIENT_NC_LOG + \ "&>" + NC.CLIENT_NC_LOG + \
"_" + str(id) + ".log" "_" + str(id) + ".log"
@ -62,17 +62,17 @@ class NC(Experience):
def clean(self): def clean(self):
super(NC, self).clean() super(NC, self).clean()
self.mpTopo.commandTo(self.mpConfig.server, "killall netcat") self.topo.command_to(self.topo_config.server, "killall netcat")
def run(self): def run(self):
for i in range(0, len(self.ncClientPort)): for i in range(0, len(self.ncClientPort)):
cmd = self.getNCServerCmd(i) cmd = self.getNCServerCmd(i)
self.mpConfig.server.sendCmd(cmd) self.topo_config.server.sendCmd(cmd)
cmd = self.getNCClientCmd(i) cmd = self.getNCClientCmd(i)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpConfig.server.waitOutput() self.topo_config.server.waitOutput()
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1") self.topo.command_to(self.topo_config.client, "sleep 1")

View File

@ -24,20 +24,20 @@ class NCPV(Experience):
PV_BIN = "/usr/local/bin/pv" PV_BIN = "/usr/local/bin/pv"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(NCPV, self).__init__(xpParamFile, mpTopo, mpConfig) super(NCPV, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(NCPV, self).classicRun() super(NCPV, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
NCPV.PING_OUTPUT ) NCPV.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -46,31 +46,31 @@ class NCPV(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.pvg = self.xpParam.getParam(ExperienceParameter.PVG) self.pvg = self.experience_parameter.get(ExperienceParameter.PVG)
self.pvz = self.xpParam.getParam(ExperienceParameter.PVZ) self.pvz = self.experience_parameter.get(ExperienceParameter.PVZ)
self.pvRateLimit = self.xpParam.getParam(ExperienceParameter.PVRATELIMIT) self.pvRateLimit = self.experience_parameter.get(ExperienceParameter.PVRATELIMIT)
self.ddibs = self.xpParam.getParam(ExperienceParameter.DDIBS) self.ddibs = self.experience_parameter.get(ExperienceParameter.DDIBS)
self.ddobs = self.xpParam.getParam(ExperienceParameter.DDOBS) self.ddobs = self.experience_parameter.get(ExperienceParameter.DDOBS)
self.ddcount = self.xpParam.getParam(ExperienceParameter.DDCOUNT) self.ddcount = self.experience_parameter.get(ExperienceParameter.DDCOUNT)
self.ncServerPort = self.xpParam.getParam(ExperienceParameter.NCSERVERPORT) self.ncServerPort = self.experience_parameter.get(ExperienceParameter.NCSERVERPORT)
self.pvRateLimit = self.xpParam.getParam(ExperienceParameter.PVRATELIMIT) self.pvRateLimit = self.experience_parameter.get(ExperienceParameter.PVRATELIMIT)
self.ncClientPort = [] self.ncClientPort = []
for k in sorted(self.xpParam.paramDic): for k in sorted(self.experience_parameter.paramDic):
if k.startswith(ExperienceParameter.NCCLIENTPORT): if k.startswith(ExperienceParameter.NCCLIENTPORT):
port = self.xpParam.paramDic[k] port = self.experience_parameter.paramDic[k]
self.ncClientPort.append(port) self.ncClientPort.append(port)
if len(self.ncClientPort) == 0: if len(self.ncClientPort) == 0:
d = self.xpParam.getParam(ExperienceParameter.NCCLIENTPORT) d = self.experience_parameter.get(ExperienceParameter.NCCLIENTPORT)
self.ncClientPort.append(d) self.ncClientPort.append(d)
self.loadPvAt() self.loadPvAt()
def loadPvAt(self): def loadPvAt(self):
self.changePvAt = [] self.changePvAt = []
self.changePv = self.xpParam.getParam(ExperienceParameter.CHANGEPV) self.changePv = self.experience_parameter.get(ExperienceParameter.CHANGEPV)
if self.changePv != "yes": if self.changePv != "yes":
print("Don't change pv rate...") print("Don't change pv rate...")
return return
changePvAt = self.xpParam.getParam(ExperienceParameter.CHANGEPVAT) changePvAt = self.experience_parameter.get(ExperienceParameter.CHANGEPVAT)
if not isinstance(changePvAt, list): if not isinstance(changePvAt, list):
changePvAt = [changePvAt] changePvAt = [changePvAt]
for p in changePvAt: for p in changePvAt:
@ -106,9 +106,9 @@ class NCPV(Experience):
def prepare(self): def prepare(self):
super(NCPV, self).prepare() super(NCPV, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
NCPV.CLIENT_NC_LOG ) NCPV.CLIENT_NC_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
NCPV.SERVER_NC_LOG ) NCPV.SERVER_NC_LOG )
def getNCServerCmd(self, id): def getNCServerCmd(self, id):
@ -128,7 +128,7 @@ class NCPV(Experience):
" -q --rate-limit " + self.pvRateLimit + \ " -q --rate-limit " + self.pvRateLimit + \
" | " + NCPV.NC_BIN + " " + \ " | " + NCPV.NC_BIN + " " + \
" -p " + self.ncClientPort[id] + " " + \ " -p " + self.ncClientPort[id] + " " + \
self.mpConfig.getServerIP() + " " + \ self.topo_config.getServerIP() + " " + \
self.ncServerPort + " " + \ self.ncServerPort + " " + \
"&>" + NCPV.CLIENT_NC_LOG + \ "&>" + NCPV.CLIENT_NC_LOG + \
"_" + str(id) + ".log" "_" + str(id) + ".log"
@ -140,28 +140,28 @@ class NCPV(Experience):
def clean(self): def clean(self):
super(NCPV, self).clean() super(NCPV, self).clean()
self.mpTopo.commandTo(self.mpConfig.server, "killall netcat") self.topo.command_to(self.topo_config.server, "killall netcat")
def run(self): def run(self):
for i in range(0, len(self.ncClientPort)): for i in range(0, len(self.ncClientPort)):
cmd = self.getNCServerCmd(i) cmd = self.getNCServerCmd(i)
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
cmd = self.getNCClientCmd(i) cmd = self.getNCClientCmd(i)
self.mpConfig.client.sendCmd(cmd) self.topo_config.client.sendCmd(cmd)
cmd = self.getPvPidCmd() cmd = self.getPvPidCmd()
self.pvPid = None self.pvPid = None
while self.pvPid == None or self.pvPid == "": while self.pvPid == None or self.pvPid == "":
self.pvPid = self.mpTopo.commandTo(self.mpConfig.server, cmd)[:-1] self.pvPid = self.topo.command_to(self.topo_config.server, cmd)[:-1]
print("guessing pv pid ... :" + str(self.pvPid)) print("guessing pv pid ... :" + str(self.pvPid))
cmd = self.getPvChangeCmd() cmd = self.getPvChangeCmd()
print(cmd) print(cmd)
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpConfig.client.waitOutput() self.topo_config.client.waitOutput()
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1") self.topo.command_to(self.topo_config.client, "sleep 1")

View File

@ -10,20 +10,20 @@ class Netperf(Experience):
NETSERVER_BIN = "netserver" NETSERVER_BIN = "netserver"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(Netperf, self).__init__(xpParamFile, mpTopo, mpConfig) super(Netperf, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(Netperf, self).classicRun() super(Netperf, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Netperf.PING_OUTPUT) Netperf.PING_OUTPUT)
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -32,19 +32,19 @@ class Netperf(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.testlen = self.xpParam.getParam(ExperienceParameter.NETPERFTESTLEN) self.testlen = self.experience_parameter.get(ExperienceParameter.NETPERFTESTLEN)
self.testname = self.xpParam.getParam(ExperienceParameter.NETPERFTESTNAME) self.testname = self.experience_parameter.get(ExperienceParameter.NETPERFTESTNAME)
self.reqres_size = self.xpParam.getParam(ExperienceParameter.NETPERFREQRESSIZE) self.reqres_size = self.experience_parameter.get(ExperienceParameter.NETPERFREQRESSIZE)
def prepare(self): def prepare(self):
super(Netperf, self).prepare() super(Netperf, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + self.topo.command_to(self.topo_config.client, "rm " +
Netperf.NETPERF_LOG) Netperf.NETPERF_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + self.topo.command_to(self.topo_config.server, "rm " +
Netperf.NETSERVER_LOG) Netperf.NETSERVER_LOG)
def getClientCmd(self): def getClientCmd(self):
s = Netperf.NETPERF_BIN + " -H " + self.mpConfig.getServerIP() + \ s = Netperf.NETPERF_BIN + " -H " + self.topo_config.getServerIP() + \
" -l " + self.testlen + " -t " + self.testname + " -- -r " + self.reqres_size + \ " -l " + self.testlen + " -t " + self.testname + " -- -r " + self.reqres_size + \
" &>" + Netperf.NETPERF_LOG " &>" + Netperf.NETPERF_LOG
print(s) print(s)
@ -61,9 +61,9 @@ class Netperf(Experience):
def run(self): def run(self):
cmd = self.getServerCmd() cmd = self.getServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getClientCmd() cmd = self.getClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -3,9 +3,9 @@ from core.experience import Experience, ExperienceParameter
class NoneExperience(Experience): class NoneExperience(Experience):
NAME = "none" NAME = "none"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(NoneExperience, self).__init__(xpParamFile, mpTopo, mpConfig) super(NoneExperience, self).__init__(experience_parameter, topo, topo_config)
super(NoneExperience, self).classicRun() super(NoneExperience, self).classic_run()
def prepare(self): def prepare(self):
Experience.prepare(self) Experience.prepare(self)
@ -14,4 +14,4 @@ class NoneExperience(Experience):
Experience.clean(self) Experience.clean(self)
def run(self): def run(self):
self.mpTopo.getCLI() self.topo.get_cli()

View File

@ -5,9 +5,9 @@ class Ping(Experience):
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(Ping, self).__init__(xpParamFile, mpTopo, mpConfig) super(Ping, self).__init__(experience_parameter, topo, topo_config)
super(Ping, self).classicRun() super(Ping, self).classic_run()
def prepare(self): def prepare(self):
super(Ping, self).prepare() super(Ping, self).prepare()
@ -16,13 +16,13 @@ class Ping(Experience):
super(Ping, self).clean() super(Ping, self).clean()
def run(self): def run(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Ping.PING_OUTPUT ) Ping.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \

View File

@ -15,20 +15,20 @@ class QUIC(Experience):
CERTPATH = "~/go/src/github.com/lucas-clemente/quic-go/example/" CERTPATH = "~/go/src/github.com/lucas-clemente/quic-go/example/"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(QUIC, self).__init__(xpParamFile, mpTopo, mpConfig) super(QUIC, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(QUIC, self).classicRun() super(QUIC, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
QUIC.PING_OUTPUT ) QUIC.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -37,18 +37,18 @@ class QUIC(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPSFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPSRANDOMSIZE)
self.multipath = self.xpParam.getParam(ExperienceParameter.QUICMULTIPATH) self.multipath = self.experience_parameter.get(ExperienceParameter.QUICMULTIPATH)
def prepare(self): def prepare(self):
super(QUIC, self).prepare() super(QUIC, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
QUIC.CLIENT_LOG ) QUIC.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
QUIC.SERVER_LOG ) QUIC.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -63,7 +63,7 @@ class QUIC(Experience):
s = QUIC.GO_BIN + " run " + QUIC.CLIENT_GO_FILE s = QUIC.GO_BIN + " run " + QUIC.CLIENT_GO_FILE
if int(self.multipath) > 0: if int(self.multipath) > 0:
s += " -m" s += " -m"
s += " https://" + self.mpConfig.getServerIP() + ":6121/random &>" + QUIC.CLIENT_LOG s += " https://" + self.topo_config.getServerIP() + ":6121/random &>" + QUIC.CLIENT_LOG
print(s) print(s)
return s return s
@ -74,7 +74,7 @@ class QUIC(Experience):
return s return s
def getCongClientCmd(self, congID): def getCongClientCmd(self, congID):
s = "(time " + QUIC.WGET + " https://" + self.mpConfig.getCongServerIP(congID) +\ s = "(time " + QUIC.WGET + " https://" + self.topo_config.getCongServerIP(congID) +\
"/" + self.file + " --no-check-certificate --disable-mptcp) &> https_client" + str(congID) + ".log &" "/" + self.file + " --no-check-certificate --disable-mptcp) &> https_client" + str(congID) + ".log &"
print(s) print(s)
return s return s
@ -82,47 +82,47 @@ class QUIC(Experience):
def clean(self): def clean(self):
super(QUIC, self).clean() super(QUIC, self).clean()
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
def run(self): def run(self):
cmd = self.getQUICServerCmd() cmd = self.getQUICServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
if isinstance(self.mpConfig, MultiInterfaceCongConfig): if isinstance(self.topo_config, MultiInterfaceCongConfig):
i = 0 i = 0
for cs in self.mpConfig.cong_servers: for cs in self.topo_config.cong_servers:
cmd = self.getCongServerCmd(i) cmd = self.getCongServerCmd(i)
self.mpTopo.commandTo(cs, cmd) self.topo.command_to(cs, cmd)
i = i + 1 i = i + 1
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.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, MultiInterfaceCongConfig): if isinstance(self.topo_config, MultiInterfaceCongConfig):
i = 0 i = 0
for cc in self.mpConfig.cong_clients: for cc in self.topo_config.cong_clients:
cmd = self.getCongClientCmd(i) cmd = self.getCongClientCmd(i)
self.mpTopo.commandTo(cc, cmd) self.topo.command_to(cc, cmd)
i = i + 1 i = i + 1
cmd = self.getQUICClientCmd() cmd = self.getQUICClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
# Wait for congestion traffic to end # Wait for congestion traffic to end
if isinstance(self.mpConfig, MultiInterfaceCongConfig): if isinstance(self.topo_config, MultiInterfaceCongConfig):
for cc in self.mpConfig.cong_clients: for cc in self.topo_config.cong_clients:
self.mpTopo.commandTo(cc, "while pkill -f wget -0; do sleep 0.5; done") self.topo.command_to(cc, "while pkill -f wget -0; do sleep 0.5; done")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + QUIC.SERVER_GO_FILE) self.topo.command_to(self.topo_config.server, "pkill -f " + QUIC.SERVER_GO_FILE)
if isinstance(self.mpConfig, MultiInterfaceCongConfig): if isinstance(self.topo_config, MultiInterfaceCongConfig):
for cs in self.mpConfig.cong_servers: for cs in self.topo_config.cong_servers:
self.mpTopo.commandTo(cs, "pkill -f https_server.py") self.topo.command_to(cs, "pkill -f https_server.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
# Need to delete the go-build directory in tmp; could lead to no more space left error # Need to delete the go-build directory in tmp; could lead to no more space left error
self.mpTopo.commandTo(self.mpConfig.client, "rm -r /tmp/go-build*") self.topo.command_to(self.topo_config.client, "rm -r /tmp/go-build*")
# Remove cache data # Remove cache data
self.mpTopo.commandTo(self.mpConfig.client, "rm cache_*") self.topo.command_to(self.topo_config.client, "rm cache_*")

View File

@ -12,20 +12,20 @@ class QUICSiri(Experience):
SERVER_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/siri/siri.go" SERVER_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/siri/siri.go"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(QUICSiri, self).__init__(xpParamFile, mpTopo, mpConfig) super(QUICSiri, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(QUICSiri, self).classicRun() super(QUICSiri, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
QUICSiri.PING_OUTPUT ) QUICSiri.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -34,14 +34,14 @@ class QUICSiri(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.run_time = self.xpParam.getParam(ExperienceParameter.QUICSIRIRUNTIME) self.run_time = self.experience_parameter.get(ExperienceParameter.QUICSIRIRUNTIME)
self.multipath = self.xpParam.getParam(ExperienceParameter.QUICMULTIPATH) self.multipath = self.experience_parameter.get(ExperienceParameter.QUICMULTIPATH)
def prepare(self): def prepare(self):
super(QUICSiri, self).prepare() super(QUICSiri, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
QUICSiri.CLIENT_LOG ) QUICSiri.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
QUICSiri.SERVER_LOG ) QUICSiri.SERVER_LOG )
def getQUICSiriServerCmd(self): def getQUICSiriServerCmd(self):
@ -52,7 +52,7 @@ class QUICSiri(Experience):
def getQUICSiriClientCmd(self): def getQUICSiriClientCmd(self):
s = QUICSiri.GO_BIN + " run " + QUICSiri.CLIENT_GO_FILE s = QUICSiri.GO_BIN + " run " + QUICSiri.CLIENT_GO_FILE
s += " -addr " + self.mpConfig.getServerIP() + ":8080 -runTime " + self.run_time + "s" s += " -addr " + self.topo_config.getServerIP() + ":8080 -runTime " + self.run_time + "s"
if int(self.multipath) > 0: if int(self.multipath) > 0:
s += " -m" s += " -m"
s += " &>" + QUICSiri.CLIENT_LOG s += " &>" + QUICSiri.CLIENT_LOG
@ -64,16 +64,16 @@ class QUICSiri(Experience):
def run(self): def run(self):
cmd = self.getQUICSiriServerCmd() cmd = self.getQUICSiriServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getQUICSiriClientCmd() cmd = self.getQUICSiriClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + QUICSiri.SERVER_GO_FILE) self.topo.command_to(self.topo_config.server, "pkill -f " + QUICSiri.SERVER_GO_FILE)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
# Need to delete the go-build directory in tmp; could lead to no more space left error # Need to delete the go-build directory in tmp; could lead to no more space left error
self.mpTopo.commandTo(self.mpConfig.client, "rm -r /tmp/go-build*") self.topo.command_to(self.topo_config.client, "rm -r /tmp/go-build*")

View File

@ -9,20 +9,20 @@ class SendFile(Experience):
WGET_BIN = "./client" WGET_BIN = "./client"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(SendFile, self).__init__(xpParamFile, mpTopo, mpConfig) super(SendFile, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(SendFile, self).classicRun() super(SendFile, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SendFile.PING_OUTPUT ) SendFile.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,17 +31,17 @@ class SendFile(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPSFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPSRANDOMSIZE)
def prepare(self): def prepare(self):
super(SendFile, self).prepare() super(SendFile, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SendFile.CLIENT_LOG ) SendFile.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
SendFile.SERVER_LOG ) SendFile.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -51,20 +51,20 @@ class SendFile(Experience):
return s return s
def getSendFileClientCmd(self): def getSendFileClientCmd(self):
s = SendFile.WGET_BIN + " " + self.mpConfig.getServerIP() + " &>" + SendFile.CLIENT_LOG s = SendFile.WGET_BIN + " " + self.topo_config.getServerIP() + " &>" + SendFile.CLIENT_LOG
print(s) print(s)
return s return s
def clean(self): def clean(self):
super(SendFile, self).clean() super(SendFile, self).clean()
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
def run(self): def run(self):
cmd = self.getSendFileServerCmd() cmd = self.getSendFileServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 0.1") self.topo.command_to(self.topo_config.client, "sleep 0.1")
cmd = self.getSendFileClientCmd() cmd = self.getSendFileClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -10,20 +10,20 @@ class Siri(Experience):
JAVA_BIN = "java" JAVA_BIN = "java"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(Siri, self).__init__(xpParamFile, mpTopo, mpConfig) super(Siri, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(Siri, self).classicRun() super(Siri, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Siri.PING_OUTPUT ) Siri.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -32,22 +32,22 @@ class Siri(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.run_time = self.xpParam.getParam(ExperienceParameter.SIRIRUNTIME) self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME)
self.query_size = self.xpParam.getParam(ExperienceParameter.SIRIQUERYSIZE) self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE)
self.response_size = self.xpParam.getParam(ExperienceParameter.SIRIRESPONSESIZE) self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE)
self.delay_query_response = self.xpParam.getParam(ExperienceParameter.SIRIDELAYQUERYRESPONSE) self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE)
self.min_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMINPAYLOADSIZE) self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE)
self.max_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMAXPAYLOADSIZE) self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE)
self.interval_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALTIMEMS) self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS)
self.buffer_size = self.xpParam.getParam(ExperienceParameter.SIRIBUFFERSIZE) self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE)
self.burst_size = self.xpParam.getParam(ExperienceParameter.SIRIBURSTSIZE) self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE)
self.interval_burst_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS)
def prepare(self): def prepare(self):
super(Siri, self).prepare() super(Siri, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
Siri.CLIENT_LOG) Siri.CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
Siri.SERVER_LOG) Siri.SERVER_LOG)
def getSiriServerCmd(self): def getSiriServerCmd(self):
@ -58,7 +58,7 @@ class Siri(Experience):
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = Siri.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ s = Siri.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.topo_config.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \
" >" + Siri.CLIENT_LOG + " 2>" + Siri.CLIENT_ERR " >" + Siri.CLIENT_LOG + " 2>" + Siri.CLIENT_ERR
@ -70,14 +70,14 @@ class Siri(Experience):
def run(self): def run(self):
cmd = self.getSiriServerCmd() cmd = self.getSiriServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
cmd = self.getSiriClientCmd() cmd = self.getSiriClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f siri_server.py") self.topo.command_to(self.topo_config.server, "pkill -f siri_server.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -13,20 +13,20 @@ class SiriHTTP(Experience):
JAVA_BIN = "java" JAVA_BIN = "java"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(SiriHTTP, self).__init__(xpParamFile, mpTopo, mpConfig) super(SiriHTTP, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(SiriHTTP, self).classicRun() super(SiriHTTP, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriHTTP.PING_OUTPUT ) SiriHTTP.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -35,31 +35,31 @@ class SiriHTTP(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.run_time = self.xpParam.getParam(ExperienceParameter.SIRIRUNTIME) self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME)
self.query_size = self.xpParam.getParam(ExperienceParameter.SIRIQUERYSIZE) self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE)
self.response_size = self.xpParam.getParam(ExperienceParameter.SIRIRESPONSESIZE) self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE)
self.delay_query_response = self.xpParam.getParam(ExperienceParameter.SIRIDELAYQUERYRESPONSE) self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE)
self.min_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMINPAYLOADSIZE) self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE)
self.max_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMAXPAYLOADSIZE) self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE)
self.interval_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALTIMEMS) self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS)
self.buffer_size = self.xpParam.getParam(ExperienceParameter.SIRIBUFFERSIZE) self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE)
self.burst_size = self.xpParam.getParam(ExperienceParameter.SIRIBURSTSIZE) self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE)
self.interval_burst_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS)
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE) self.file = self.experience_parameter.get(ExperienceParameter.HTTPFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE) self.random_size = self.experience_parameter.get(ExperienceParameter.HTTPRANDOMSIZE)
def prepare(self): def prepare(self):
super(SiriHTTP, self).prepare() super(SiriHTTP, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriHTTP.CLIENT_LOG) SiriHTTP.CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
SiriHTTP.SERVER_LOG) SiriHTTP.SERVER_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriHTTP.HTTP_CLIENT_LOG) SiriHTTP.HTTP_CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
SiriHTTP.HTTP_SERVER_LOG) SiriHTTP.HTTP_SERVER_LOG)
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -72,7 +72,7 @@ class SiriHTTP(Experience):
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = SiriHTTP.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ s = SiriHTTP.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.topo_config.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \
" >" + SiriHTTP.CLIENT_LOG + " 2>" + SiriHTTP.CLIENT_ERR " >" + SiriHTTP.CLIENT_LOG + " 2>" + SiriHTTP.CLIENT_ERR
@ -85,7 +85,7 @@ class SiriHTTP(Experience):
return s return s
def getHTTPClientCmd(self): def getHTTPClientCmd(self):
s = SiriHTTP.WGET_BIN + " http://" + self.mpConfig.getServerIP() + \ s = SiriHTTP.WGET_BIN + " http://" + self.topo_config.getServerIP() + \
"/" + self.file + " --no-check-certificate" "/" + self.file + " --no-check-certificate"
print(s) print(s)
return s return s
@ -93,22 +93,22 @@ class SiriHTTP(Experience):
def clean(self): def clean(self):
super(SiriHTTP, self).clean() super(SiriHTTP, self).clean()
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
def run(self): def run(self):
cmd = self.getSiriServerCmd() cmd = self.getSiriServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
cmd = self.getHTTPServerCmd() cmd = self.getHTTPServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
cmd = self.getHTTPClientCmd() cmd = self.getHTTPClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, "for i in {1..200}; do " + cmd + "; done &") self.topo.command_to(self.topo_config.client, "for i in {1..200}; do " + cmd + "; done &")
cmd = self.getSiriClientCmd() cmd = self.getSiriClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f siri_server.py") self.topo.command_to(self.topo_config.server, "pkill -f siri_server.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -13,20 +13,20 @@ class SiriMsg(Experience):
JAVA_BIN = "java" JAVA_BIN = "java"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(SiriMsg, self).__init__(xpParamFile, mpTopo, mpConfig) super(SiriMsg, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(SiriMsg, self).classicRun() super(SiriMsg, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriMsg.PING_OUTPUT ) SiriMsg.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -35,33 +35,33 @@ class SiriMsg(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.run_time = self.xpParam.getParam(ExperienceParameter.SIRIRUNTIME) self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME)
self.query_size = self.xpParam.getParam(ExperienceParameter.SIRIQUERYSIZE) self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE)
self.response_size = self.xpParam.getParam(ExperienceParameter.SIRIRESPONSESIZE) self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE)
self.delay_query_response = self.xpParam.getParam(ExperienceParameter.SIRIDELAYQUERYRESPONSE) self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE)
self.min_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMINPAYLOADSIZE) self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE)
self.max_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMAXPAYLOADSIZE) self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE)
self.interval_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALTIMEMS) self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS)
self.buffer_size = self.xpParam.getParam(ExperienceParameter.SIRIBUFFERSIZE) self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE)
self.burst_size = self.xpParam.getParam(ExperienceParameter.SIRIBURSTSIZE) self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE)
self.interval_burst_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS)
self.client_sleep = self.xpParam.getParam(ExperienceParameter.MSGCLIENTSLEEP) self.client_sleep = self.experience_parameter.get(ExperienceParameter.MSGCLIENTSLEEP)
self.server_sleep = self.xpParam.getParam(ExperienceParameter.MSGSERVERSLEEP) self.server_sleep = self.experience_parameter.get(ExperienceParameter.MSGSERVERSLEEP)
self.nb_requests = self.xpParam.getParam(ExperienceParameter.MSGNBREQUESTS) self.nb_requests = self.experience_parameter.get(ExperienceParameter.MSGNBREQUESTS)
def prepare(self): def prepare(self):
super(SiriMsg, self).prepare() super(SiriMsg, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriMsg.CLIENT_LOG) SiriMsg.CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriMsg.CLIENT_ERR) SiriMsg.CLIENT_ERR)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
SiriMsg.SERVER_LOG) SiriMsg.SERVER_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriMsg.MSG_CLIENT_LOG) SiriMsg.MSG_CLIENT_LOG)
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
SiriMsg.MSG_CLIENT_ERR) SiriMsg.MSG_CLIENT_ERR)
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
SiriMsg.MSG_SERVER_LOG) SiriMsg.MSG_SERVER_LOG)
def getSiriServerCmd(self): def getSiriServerCmd(self):
@ -72,7 +72,7 @@ class SiriMsg(Experience):
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = SiriMsg.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ s = SiriMsg.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.topo_config.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \
" >" + SiriMsg.CLIENT_LOG + " 2>" + SiriMsg.CLIENT_ERR " >" + SiriMsg.CLIENT_LOG + " 2>" + SiriMsg.CLIENT_ERR
@ -97,20 +97,20 @@ class SiriMsg(Experience):
def run(self): def run(self):
cmd = self.getSiriServerCmd() cmd = self.getSiriServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
cmd = self.getMsgServerCmd() cmd = self.getMsgServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
cmd = self.getMsgClientCmd() cmd = self.getMsgClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
cmd = self.getSiriClientCmd() cmd = self.getSiriClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f siri_server.py") self.topo.command_to(self.topo_config.server, "pkill -f siri_server.py")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f msg_server.py") self.topo.command_to(self.topo_config.server, "pkill -f msg_server.py")
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f msg_client.py") self.topo.command_to(self.topo_config.server, "pkill -f msg_client.py")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -9,20 +9,20 @@ class VLC(Experience):
VLC_BIN = "/home/mininet/vlc/vlc" VLC_BIN = "/home/mininet/vlc/vlc"
PING_OUTPUT = "ping.log" PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, experience_parameter, topo, topo_config):
super(VLC, self).__init__(xpParamFile, mpTopo, mpConfig) super(VLC, self).__init__(experience_parameter, topo, topo_config)
self.loadParam() self.loadParam()
self.ping() self.ping()
super(VLC, self).classicRun() super(VLC, self).classic_run()
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
VLC.PING_OUTPUT ) VLC.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.topo_config.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.topo_config.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.topo_config.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
def pingCommand(self, fromIP, toIP, n=5): def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
@ -31,18 +31,18 @@ class VLC(Experience):
return s return s
def loadParam(self): def loadParam(self):
self.file = self.xpParam.getParam(ExperienceParameter.VLCFILE) self.file = self.experience_parameter.get(ExperienceParameter.VLCFILE)
self.time = self.xpParam.getParam(ExperienceParameter.VLCTIME) self.time = self.experience_parameter.get(ExperienceParameter.VLCTIME)
def prepare(self): def prepare(self):
super(VLC, self).prepare() super(VLC, self).prepare()
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.topo.command_to(self.topo_config.client, "rm " + \
VLC.CLIENT_LOG ) VLC.CLIENT_LOG )
self.mpTopo.commandTo(self.mpConfig.client, "Xvfb :66 &") self.topo.command_to(self.topo_config.client, "Xvfb :66 &")
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ self.topo.command_to(self.topo_config.server, "rm " + \
VLC.SERVER_LOG ) VLC.SERVER_LOG )
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, self.topo.command_to(self.topo_config.client,
"dd if=/dev/urandom of=random bs=1K count=" + \ "dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size) self.random_size)
@ -55,7 +55,7 @@ class VLC(Experience):
s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && " \ s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && " \
+ VLC.VLC_BIN + " -I dummy --x11-display :66" + \ + VLC.VLC_BIN + " -I dummy --x11-display :66" + \
" --adaptive-logic 3 --no-loop --play-and-exit " + \ " --adaptive-logic 3 --no-loop --play-and-exit " + \
" http://" + self.mpConfig.getServerIP() + \ " http://" + self.topo_config.getServerIP() + \
"/" + self.file + " 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > " + VLC.CLIENT_LOG "/" + self.file + " 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > " + VLC.CLIENT_LOG
if self.time != "0" : if self.time != "0" :
s = s + " &" s = s + " &"
@ -65,19 +65,19 @@ class VLC(Experience):
def clean(self): def clean(self):
super(VLC, self).clean(self) super(VLC, self).clean(self)
if self.file == "random": if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*") self.topo.command_to(self.topo_config.client, "rm random*")
self.mpTopo.commandTo(self.mpConfig.client, "pkill Xvfb") self.topo.command_to(self.topo_config.client, "pkill Xvfb")
def run(self): def run(self):
cmd = self.getVLCServerCmd() cmd = self.getVLCServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, cmd) self.topo.command_to(self.topo_config.server, cmd)
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1") self.topo.command_to(self.topo_config.client, "sleep 1")
cmd = self.getVLCClientCmd() cmd = self.getVLCClientCmd()
self.mpTopo.commandTo(self.mpConfig.client, cmd) self.topo.command_to(self.topo_config.client, cmd)
if self.time != "0" : if self.time != "0" :
self.mpTopo.commandTo(self.mpConfig.client, "sleep " + self.time) self.topo.command_to(self.topo_config.client, "sleep " + self.time)
self.mpTopo.commandTo(self.mpConfig.client, "pkill -9 -f vlc") self.topo.command_to(self.topo_config.client, "pkill -9 -f vlc")
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") self.topo.command_to(self.topo_config.client, "sleep 2")

View File

@ -5,40 +5,57 @@ from mininet.node import OVSBridge
from mininet.cli import CLI from mininet.cli import CLI
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import logging
class MininetBuilder(Topo): class MininetBuilder(Topo):
def __init__(self): def __init__(self):
Topo.__init__( self ) Topo.__init__( self )
self.net = None self.net = None
def commandTo(self, who, cmd): def command_to(self, who, cmd):
"""
Launch command `cmd` to the specific name space of `who`
"""
return who.cmd(cmd) return who.cmd(cmd)
def notNSCommand(self, cmd): def command_global(self, cmd):
"""
Launch command `cmd` over the global system, i.e., not specific to a name space
"""
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if stderr: if stderr:
logging.error("Got error when running cmd: {}".format(cmd))
return "Error" return "Error"
return stdout return stdout
def startNetwork(self): def start_network(self):
"""
Start the network using Mininet
Note that the use of OVSBridge avoid facing issues with OVS controllers.
"""
self.net = Mininet(topo=self,link=TCLink,switch=OVSBridge) self.net = Mininet(topo=self,link=TCLink,switch=OVSBridge)
self.net.start() self.net.start()
def getCLI(self): def get_cli(self):
"""
Get the Mininet command line interface
"""
if self.net is None: if self.net is None:
print("Can not get the CLI") logging.error("Cannot get the CLI")
else: else:
CLI(self.net) CLI(self.net)
def getHost(self, who): def get_host(self, who):
if self.net is None: if self.net is None:
print("Network not available....") logging.error("Network not available...")
raise Exception("Network not ready"); raise Exception("Network not ready")
else: else:
return self.net.getNodeByName(who) return self.net.getNodeByName(who)
def stopNetwork(self): def stop_network(self):
if self.net is None: if self.net is None:
print("Could not stop network... Nothing to stop)") logging.warning("Unable to stop the network: net is None")
else: else:
self.net.stop() self.net.stop()

View File

@ -8,55 +8,82 @@ from mininet_builder import MininetBuilder
from experiences import EXPERIENCES from experiences import EXPERIENCES
from topos import TOPO_CONFIGS, TOPOS from topos import TOPO_CONFIGS, TOPOS
import logging
class Runner(object): class Runner(object):
def __init__(self, builderType, topoParamFile, xpParamFile): """
self.defParamXp(xpParamFile) Run an experiment described by `experience_parameter_file` in the topology
self.topoParam = TopoParameter(topoParamFile) described by `topo_parameter_file` in the network environment built by
self.defBuilder(builderType) `builder_type`.
self.defTopo()
self.defConfig()
self.startTopo()
self.runXp()
self.stopTopo()
def defParamXp(self, xpParamFile): All the operations are done when calling the constructor.
self.xpParam = ExperienceParameter(xpParamFile) """
def __init__(self, builder_type, topo_parameter_file, experience_parameter_file):
self.experience_parameter = ExperienceParameter(experience_parameter_file)
self.topo_parameter = TopoParameter(topo_parameter_file)
self.set_builder(builder_type)
self.set_topo()
self.set_topo_config()
self.start_topo()
self.run_experience()
self.stop_topo()
def defBuilder(self, builderType): def set_builder(self, builder_type):
if builderType == Topo.mininetBuilder: """
self.topoBuilder = MininetBuilder() Currently the only builder type supported is Mininet...
"""
if builder_type == Topo.MININET_BUILDER:
self.topo_builder = MininetBuilder()
else: else:
raise Exception("I can not find the builder " + raise Exception("I can not find the builder {}".format(builder_type))
builderType)
def defTopo(self): def set_topo(self):
t = self.topoParam.getParam(Topo.topoAttr) """
Matches the name of the topo and find the corresponding Topo class.
"""
t = self.topo_parameter.get(Topo.TOPO_ATTR)
if t in TOPOS: if t in TOPOS:
self.Topo = TOPOS[t](self.topoBuilder, self.topoParam) self.topo = TOPOS[t](self.topo_builder, self.topo_parameter)
else: else:
raise Exception("Unknown topo: {}".format(t)) raise Exception("Unknown topo: {}".format(t))
print(self.Topo)
def defConfig(self): logging.info("Using topo {}".format(self.topo))
t = self.topoParam.getParam(Topo.topoAttr)
def set_topo_config(self):
"""
Match the name of the topo and find the corresponding TopoConfig class.
"""
t = self.topo_parameter.get(Topo.TOPO_ATTR)
if t in TOPO_CONFIGS: if t in TOPO_CONFIGS:
self.TopoConfig = TOPO_CONFIGS[t](self.Topo, self.topoParam) self.topo_config = TOPO_CONFIGS[t](self.topo, self.topo_parameter)
else: else:
raise Exception("Unknown topo config: {}".format(t)) raise Exception("Unknown topo config: {}".format(t))
def startTopo(self): logging.info("Using topo config {}".format(self.topo_config))
self.Topo.startNetwork()
self.TopoConfig.configureNetwork()
def runXp(self): def start_topo(self):
xp = self.xpParam.getParam(ExperienceParameter.XPTYPE) """
Initialize the topology with its configuration
"""
self.topo.start_network()
self.topo_config.configure_network()
def run_experience(self):
"""
Match the name of the experiement and launch it
"""
xp = self.experience_parameter.get(ExperienceParameter.XPTYPE)
if xp in EXPERIENCES: if xp in EXPERIENCES:
EXPERIENCES[xp](self.xpParam, self.Topo, self.TopoConfig) EXPERIENCES[xp](self.experience_parameter, self.topo, self.topo_config)
else: else:
raise Exception("Unknown experience {}".format(xp)) raise Exception("Unknown experience {}".format(xp))
def stopTopo(self): def stop_topo(self):
self.Topo.stopNetwork() """
Stop the topology
"""
self.topo.stop_network()
if __name__ == '__main__': if __name__ == '__main__':
@ -71,5 +98,8 @@ if __name__ == '__main__':
help="path to the experience parameter file") help="path to the experience parameter file")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
# XXX Currently, there is no alternate topo builder... # XXX Currently, there is no alternate topo builder...
Runner(Topo.mininetBuilder, args.topo_param_file, args.experience_param_file) Runner(Topo.MININET_BUILDER, args.topo_param_file, args.experience_param_file)

View File

@ -57,36 +57,36 @@ class ECMPSingleInterfaceConfig(TopoConfig):
mask = len(self.topo.routers) - 1 mask = len(self.topo.routers) - 1
for l in self.topo.routers: for l in self.topo.routers:
cmd = self.getIptableRuleICMP(mask, i) cmd = self.getIptableRuleICMP(mask, i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
cmd = self.getIptableRuleTCPPortClient(mask, i) cmd = self.getIptableRuleTCPPortClient(mask, i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.getIptableRuleTCPPortServer(mask, i) cmd = self.getIptableRuleTCPPortServer(mask, i)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
cmd = self.getIpRuleCmd(i) cmd = self.getIpRuleCmd(i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
cmd = self.getDefaultRouteCmd(self.getRouterIPClient(i), cmd = self.getDefaultRouteCmd(self.getRouterIPClient(i),
i) i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.getDefaultRouteCmd(self.getRouterIPServer(i), cmd = self.getDefaultRouteCmd(self.getRouterIPServer(i),
i) i)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
i = i + 1 i = i + 1
### ###
cmd = self.addRouteDefaultSimple(self.getRouterIPServer(0)) cmd = self.addRouteDefaultSimple(self.getRouterIPServer(0))
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
cmd = self.addRouteDefaultSimple(self.getRouterIPClient(0)) cmd = self.addRouteDefaultSimple(self.getRouterIPClient(0))
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
self.topo.commandTo(self.client, "ip route flush cache") self.topo.command_to(self.client, "ip route flush cache")
self.topo.commandTo(self.server, "ip route flush cache") self.topo.command_to(self.server, "ip route flush cache")
def getIptableRuleICMP(self, mask, id): def getIptableRuleICMP(self, mask, id):
s = 'iptables -t mangle -A OUTPUT -m u32 --u32 ' + \ s = 'iptables -t mangle -A OUTPUT -m u32 --u32 ' + \
@ -130,56 +130,56 @@ class ECMPSingleInterfaceConfig(TopoConfig):
return s return s
def configureInterfaces(self): def configureInterfaces(self):
self.client = self.topo.getHost(Topo.clientName) self.client = self.topo.get_host(Topo.clientName)
self.server = self.topo.getHost(Topo.serverName) self.server = self.topo.get_host(Topo.serverName)
self.routers = [] self.routers = []
i = 0 i = 0
netmask = "255.255.255.0" netmask = "255.255.255.0"
for l in self.topo.routers: for l in self.topo.routers:
self.routers.append(self.topo.getHost( self.routers.append(self.topo.get_host(
Topo.routerNamePrefix + str(i))) Topo.routerNamePrefix + str(i)))
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getRouterInterfaceLSwitch(i), self.getRouterInterfaceLSwitch(i),
self.getRouterIPClient(i), netmask) self.getRouterIPClient(i), netmask)
self.topo.commandTo(self.routers[-1] , cmd) self.topo.command_to(self.routers[-1] , cmd)
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getRouterInterfaceRSwitch(i), self.getRouterInterfaceRSwitch(i),
self.getRouterIPServer(i), netmask) self.getRouterIPServer(i), netmask)
self.topo.commandTo(self.routers[-1] , cmd) self.topo.command_to(self.routers[-1] , cmd)
i = i + 1 i = i + 1
cmd = self.interfaceUpCommand(self.getClientInterface(0), cmd = self.interfaceUpCommand(self.getClientInterface(0),
self.getClientIP(0), netmask) self.getClientIP(0), netmask)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.interfaceUpCommand(self.getServerInterface(), cmd = self.interfaceUpCommand(self.getServerInterface(),
self.getServerIP(), netmask) self.getServerIP(), netmask)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
def getClientIP(self, interfaceID): def getClientIP(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientIP = lSubnet + str(interfaceID) + ".1" clientIP = lSubnet + str(interfaceID) + ".1"
return clientIP return clientIP
def getClientSubnet(self, interfaceID): def getClientSubnet(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientSubnet = lSubnet + str(interfaceID) + ".0/24" clientSubnet = lSubnet + str(interfaceID) + ".0/24"
return clientSubnet return clientSubnet
def getRouterIPClient(self, id): def getRouterIPClient(self, id):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
routerIP = lSubnet + "0." + str(id + 2) routerIP = lSubnet + "0." + str(id + 2)
return routerIP return routerIP
def getRouterIPServer(self, id): def getRouterIPServer(self, id):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
routerIP = rSubnet + "0." + str(id + 2) routerIP = rSubnet + "0." + str(id + 2)
return routerIP return routerIP
def getServerIP(self): def getServerIP(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
serverIP = rSubnet + "0.1" serverIP = rSubnet + "0.1"
return serverIP return serverIP

View File

@ -54,31 +54,31 @@ class MultiInterfaceConfig(TopoConfig):
i = 0 i = 0
for l in self.topo.switchClient: for l in self.topo.switchClient:
cmd = self.addRouteTableCommand(self.getClientIP(i), i) cmd = self.addRouteTableCommand(self.getClientIP(i), i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteScopeLinkCommand( cmd = self.addRouteScopeLinkCommand(
self.getClientSubnet(i), self.getClientSubnet(i),
self.getClientInterface(i), i) self.getClientInterface(i), i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteDefaultCommand(self.getRouterIPSwitch(i), cmd = self.addRouteDefaultCommand(self.getRouterIPSwitch(i),
i) i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
i = i + 1 i = i + 1
cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0), cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0),
self.getClientInterface(0)) self.getClientInterface(0))
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteDefaultSimple(self.getRouterIPServer()) cmd = self.addRouteDefaultSimple(self.getRouterIPServer())
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
def configureInterfaces(self): def configureInterfaces(self):
print("Configure interfaces for multi inf") print("Configure interfaces for multi inf")
self.client = self.topo.getHost(Topo.clientName) self.client = self.topo.get_host(Topo.clientName)
self.server = self.topo.getHost(Topo.serverName) self.server = self.topo.get_host(Topo.serverName)
self.router = self.topo.getHost(Topo.routerName) self.router = self.topo.get_host(Topo.routerName)
i = 0 i = 0
netmask = "255.255.255.0" netmask = "255.255.255.0"
links = self.topo.getLinkCharacteristics() links = self.topo.getLinkCharacteristics()
@ -86,14 +86,14 @@ class MultiInterfaceConfig(TopoConfig):
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getClientInterface(i), self.getClientInterface(i),
self.getClientIP(i), netmask) self.getClientIP(i), netmask)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC() clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac)
if(links[i].back_up): if(links[i].back_up):
cmd = self.interfaceBUPCommand( cmd = self.interfaceBUPCommand(
self.getClientInterface(i)) self.getClientInterface(i))
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
i = i + 1 i = i + 1
@ -102,46 +102,46 @@ class MultiInterfaceConfig(TopoConfig):
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getRouterInterfaceSwitch(i), self.getRouterInterfaceSwitch(i),
self.getRouterIPSwitch(i), netmask) self.getRouterIPSwitch(i), netmask)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC()
self.topo.commandTo(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) self.topo.command_to(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac)
print(str(links[i])) print(str(links[i]))
i = i + 1 i = i + 1
cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(), cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(),
self.getRouterIPServer(), netmask) self.getRouterIPServer(), netmask)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC()
self.topo.commandTo(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac) self.topo.command_to(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac)
cmd = self.interfaceUpCommand(self.getServerInterface(), cmd = self.interfaceUpCommand(self.getServerInterface(),
self.getServerIP(), netmask) self.getServerIP(), netmask)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
serverIntfMac = self.server.intf(self.getServerInterface()).MAC() serverIntfMac = self.server.intf(self.getServerInterface()).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac) self.topo.command_to(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac)
def getClientIP(self, interfaceID): def getClientIP(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientIP = lSubnet + str(interfaceID) + ".1" clientIP = lSubnet + str(interfaceID) + ".1"
return clientIP return clientIP
def getClientSubnet(self, interfaceID): def getClientSubnet(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientSubnet = lSubnet + str(interfaceID) + ".0/24" clientSubnet = lSubnet + str(interfaceID) + ".0/24"
return clientSubnet return clientSubnet
def getRouterIPSwitch(self, interfaceID): def getRouterIPSwitch(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
routerIP = lSubnet + str(interfaceID) + ".2" routerIP = lSubnet + str(interfaceID) + ".2"
return routerIP return routerIP
def getRouterIPServer(self): def getRouterIPServer(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
routerIP = rSubnet + "0.2" routerIP = rSubnet + "0.2"
return routerIP return routerIP
def getServerIP(self): def getServerIP(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
serverIP = rSubnet + "0.1" serverIP = rSubnet + "0.1"
return serverIP return serverIP

View File

@ -65,30 +65,30 @@ class MultiInterfaceCongConfig(TopoConfig):
i = 0 i = 0
for l in self.topo.switch: for l in self.topo.switch:
cmd = self.addRouteTableCommand(self.getClientIP(i), i) cmd = self.addRouteTableCommand(self.getClientIP(i), i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Congestion client # Congestion client
cmd = self.addRouteTableCommand(self.getCongClientIP(i), i) cmd = self.addRouteTableCommand(self.getCongClientIP(i), i)
self.topo.commandTo(self.cong_clients[i], cmd) self.topo.command_to(self.cong_clients[i], cmd)
cmd = self.addRouteScopeLinkCommand( cmd = self.addRouteScopeLinkCommand(
self.getClientSubnet(i), self.getClientSubnet(i),
self.getClientInterface(i), i) self.getClientInterface(i), i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Congestion client # Congestion client
cmd = self.addRouteScopeLinkCommand( cmd = self.addRouteScopeLinkCommand(
self.getClientSubnet(i), self.getClientSubnet(i),
self.getCongClientInterface(i), i) self.getCongClientInterface(i), i)
self.topo.commandTo(self.cong_clients[i], cmd) self.topo.command_to(self.cong_clients[i], cmd)
cmd = self.addRouteDefaultCommand(self.getRouterIPSwitch(i), cmd = self.addRouteDefaultCommand(self.getRouterIPSwitch(i),
i) i)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Congestion client # Congestion client
# Keep the same command # Keep the same command
self.topo.commandTo(self.cong_clients[i], cmd) self.topo.command_to(self.cong_clients[i], cmd)
# Congestion client # Congestion client
cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(i), cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(i),
@ -97,40 +97,40 @@ class MultiInterfaceCongConfig(TopoConfig):
cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0), cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0),
self.getClientInterface(0)) self.getClientInterface(0))
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Congestion Client # Congestion Client
i = 0 i = 0
for c in self.cong_clients: for c in self.cong_clients:
cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(i), cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(i),
self.getCongClientInterface(i)) self.getCongClientInterface(i))
self.topo.commandTo(c, cmd) self.topo.command_to(c, cmd)
i = i + 1 i = i + 1
cmd = self.addRouteDefaultSimple(self.getRouterIPServer()) cmd = self.addRouteDefaultSimple(self.getRouterIPServer())
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
# Congestion servers # Congestion servers
i = 0 i = 0
for s in self.cong_servers: for s in self.cong_servers:
cmd = self.addRouteDefaultSimple(self.getRouterIPCongServer(i)) cmd = self.addRouteDefaultSimple(self.getRouterIPCongServer(i))
self.topo.commandTo(s, cmd) self.topo.command_to(s, cmd)
i += 1 i += 1
def configureInterfaces(self): def configureInterfaces(self):
print("Configure interfaces for multi inf") print("Configure interfaces for multi inf")
self.client = self.topo.getHost(Topo.clientName) self.client = self.topo.get_host(Topo.clientName)
self.server = self.topo.getHost(Topo.serverName) self.server = self.topo.get_host(Topo.serverName)
self.router = self.topo.getHost(Topo.routerName) self.router = self.topo.get_host(Topo.routerName)
cong_client_names = self.topo.getCongClients() cong_client_names = self.topo.getCongClients()
self.cong_clients = [] self.cong_clients = []
for cn in cong_client_names: for cn in cong_client_names:
self.cong_clients.append(self.topo.getHost(cn)) self.cong_clients.append(self.topo.get_host(cn))
cong_server_names = self.topo.getCongServers() cong_server_names = self.topo.getCongServers()
self.cong_servers = [] self.cong_servers = []
for sn in cong_server_names: for sn in cong_server_names:
self.cong_servers.append(self.topo.getHost(sn)) self.cong_servers.append(self.topo.get_host(sn))
i = 0 i = 0
netmask = "255.255.255.0" netmask = "255.255.255.0"
@ -139,99 +139,99 @@ class MultiInterfaceCongConfig(TopoConfig):
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getClientInterface(i), self.getClientInterface(i),
self.getClientIP(i), netmask) self.getClientIP(i), netmask)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC() clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac)
if(links[i].back_up): if(links[i].back_up):
cmd = self.interfaceBUPCommand( cmd = self.interfaceBUPCommand(
self.getClientInterface(i)) self.getClientInterface(i))
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Congestion client # Congestion client
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getCongClientInterface(i), self.getCongClientInterface(i),
self.getCongClientIP(i), netmask) self.getCongClientIP(i), netmask)
self.topo.commandTo(self.cong_clients[i], cmd) self.topo.command_to(self.cong_clients[i], cmd)
congClientIntfMac = self.cong_clients[i].intf(self.getCongClientInterface(i)).MAC() congClientIntfMac = self.cong_clients[i].intf(self.getCongClientInterface(i)).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getCongClientIP(i) + " " + congClientIntfMac) self.topo.command_to(self.router, "arp -s " + self.getCongClientIP(i) + " " + congClientIntfMac)
cmd = self.interfaceUpCommand( cmd = self.interfaceUpCommand(
self.getRouterInterfaceSwitch(i), self.getRouterInterfaceSwitch(i),
self.getRouterIPSwitch(i), netmask) self.getRouterIPSwitch(i), netmask)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC()
self.topo.commandTo(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) self.topo.command_to(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac)
# Don't forget the congestion client # Don't forget the congestion client
self.topo.commandTo(self.cong_clients[i], "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) self.topo.command_to(self.cong_clients[i], "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac)
print(str(links[i])) print(str(links[i]))
i = i + 1 i = i + 1
cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(), cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(),
self.getRouterIPServer(), netmask) self.getRouterIPServer(), netmask)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC()
self.topo.commandTo(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac) self.topo.command_to(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac)
cmd = self.interfaceUpCommand(self.getServerInterface(), cmd = self.interfaceUpCommand(self.getServerInterface(),
self.getServerIP(), netmask) self.getServerIP(), netmask)
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
serverIntfMac = self.server.intf(self.getServerInterface()).MAC() serverIntfMac = self.server.intf(self.getServerInterface()).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac) self.topo.command_to(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac)
# Congestion servers # Congestion servers
i = 0 i = 0
for s in self.cong_servers: for s in self.cong_servers:
cmd = self.interfaceUpCommand(self.getRouterInterfaceCongServer(i), cmd = self.interfaceUpCommand(self.getRouterInterfaceCongServer(i),
self.getRouterIPCongServer(i), netmask) self.getRouterIPCongServer(i), netmask)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
routerIntfMac = self.router.intf(self.getRouterInterfaceCongServer(i)).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceCongServer(i)).MAC()
self.topo.commandTo(s, "arp -s " + self.getRouterIPCongServer(i) + " " + routerIntfMac) self.topo.command_to(s, "arp -s " + self.getRouterIPCongServer(i) + " " + routerIntfMac)
cmd = self.interfaceUpCommand(self.getCongServerInterface(i), cmd = self.interfaceUpCommand(self.getCongServerInterface(i),
self.getCongServerIP(i), netmask) self.getCongServerIP(i), netmask)
self.topo.commandTo(s, cmd) self.topo.command_to(s, cmd)
congServerIntfMac = s.intf(self.getCongServerInterface(i)).MAC() congServerIntfMac = s.intf(self.getCongServerInterface(i)).MAC()
self.topo.commandTo(self.router, "arp -s " + self.getCongServerIP(i) + " " + congServerIntfMac) self.topo.command_to(self.router, "arp -s " + self.getCongServerIP(i) + " " + congServerIntfMac)
i = i + 1 i = i + 1
def getClientIP(self, interfaceID): def getClientIP(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientIP = lSubnet + str(interfaceID) + ".1" clientIP = lSubnet + str(interfaceID) + ".1"
return clientIP return clientIP
def getCongClientIP(self, interfaceID): def getCongClientIP(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
congClientIP = lSubnet + str(interfaceID) + ".127" congClientIP = lSubnet + str(interfaceID) + ".127"
return congClientIP return congClientIP
def getClientSubnet(self, interfaceID): def getClientSubnet(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientSubnet = lSubnet + str(interfaceID) + ".0/24" clientSubnet = lSubnet + str(interfaceID) + ".0/24"
return clientSubnet return clientSubnet
def getRouterIPSwitch(self, interfaceID): def getRouterIPSwitch(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
routerIP = lSubnet + str(interfaceID) + ".2" routerIP = lSubnet + str(interfaceID) + ".2"
return routerIP return routerIP
def getRouterIPServer(self): def getRouterIPServer(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
routerIP = rSubnet + "0.2" routerIP = rSubnet + "0.2"
return routerIP return routerIP
def getRouterIPCongServer(self, congID): def getRouterIPCongServer(self, congID):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
routerIP = rSubnet + str(1 + congID) + ".2" routerIP = rSubnet + str(1 + congID) + ".2"
return routerIP return routerIP
def getServerIP(self): def getServerIP(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
serverIP = rSubnet + "0.1" serverIP = rSubnet + "0.1"
return serverIP return serverIP
def getCongServerIP(self, congID): def getCongServerIP(self, congID):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
serverIP = rSubnet + str(1 + congID) + ".1" serverIP = rSubnet + str(1 + congID) + ".1"
return serverIP return serverIP

View File

@ -67,83 +67,83 @@ class TwoInterfaceCongestionConfig(TopoConfig):
def configureRoute(self): def configureRoute(self):
# Client - Router # Client - Router
cmd = self.addRouteTableCommand("10.0.0.1", 0) cmd = self.addRouteTableCommand("10.0.0.1", 0)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteScopeLinkCommand("10.0.0.0/24", Topo.clientName + "-eth0", 0) cmd = self.addRouteScopeLinkCommand("10.0.0.0/24", Topo.clientName + "-eth0", 0)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteDefaultCommand("10.0.0.2", 0) cmd = self.addRouteDefaultCommand("10.0.0.2", 0)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Client -> Router cong # Client -> Router cong
cmd = self.addRouteTableCommand("10.0.1.1", 1) cmd = self.addRouteTableCommand("10.0.1.1", 1)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteScopeLinkCommand("10.0.1.0/24", Topo.clientName + "-eth1", 1) cmd = self.addRouteScopeLinkCommand("10.0.1.0/24", Topo.clientName + "-eth1", 1)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.addRouteDefaultCommand("10.0.1.2", 1) cmd = self.addRouteDefaultCommand("10.0.1.2", 1)
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Client cong -> Router cong # Client cong -> Router cong
cmd = self.addRouteTableCommand("10.0.2.1", 0) cmd = self.addRouteTableCommand("10.0.2.1", 0)
self.topo.commandTo(self.clientCong, cmd) self.topo.command_to(self.clientCong, cmd)
cmd = self.addRouteScopeLinkCommand("10.0.2.0/24", Topo.clientName + "Cong-eth0", 0) cmd = self.addRouteScopeLinkCommand("10.0.2.0/24", Topo.clientName + "Cong-eth0", 0)
self.topo.commandTo(self.clientCong, cmd) self.topo.command_to(self.clientCong, cmd)
cmd = self.addRouteDefaultCommand("10.0.2.2", 0) cmd = self.addRouteDefaultCommand("10.0.2.2", 0)
self.topo.commandTo(self.clientCong, cmd) self.topo.command_to(self.clientCong, cmd)
# Router cong -> Router # Router cong -> Router
cmd = self.addRouteTableCommand("10.0.3.1", 0) cmd = self.addRouteTableCommand("10.0.3.1", 0)
self.topo.commandTo(self.routerCong, cmd) self.topo.command_to(self.routerCong, cmd)
cmd = self.addRouteScopeLinkCommand("10.1.0.0/16", Topo.routerName + "Cong-eth2", 0) cmd = self.addRouteScopeLinkCommand("10.1.0.0/16", Topo.routerName + "Cong-eth2", 0)
self.topo.commandTo(self.routerCong, cmd) self.topo.command_to(self.routerCong, cmd)
cmd = self.addRouteDefaultCommand("10.0.3.2", 0) cmd = self.addRouteDefaultCommand("10.0.3.2", 0)
self.topo.commandTo(self.routerCong, cmd) self.topo.command_to(self.routerCong, cmd)
# Router -> Router cong # Router -> Router cong
cmd = self.addRouteTableCommand("10.0.3.2", 0) cmd = self.addRouteTableCommand("10.0.3.2", 0)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
cmd = self.addRouteScopeLinkCommand("10.0.0.0/16", Topo.routerName + "-eth1", 0) cmd = self.addRouteScopeLinkCommand("10.0.0.0/16", Topo.routerName + "-eth1", 0)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
cmd = self.addRouteDefaultCommand("10.0.3.1", 0) cmd = self.addRouteDefaultCommand("10.0.3.1", 0)
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
# Default route Client # Default route Client
cmd = self.addRouteDefaultGlobalCommand("10.0.0.2", Topo.clientName + "-eth0") cmd = self.addRouteDefaultGlobalCommand("10.0.0.2", Topo.clientName + "-eth0")
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
# Default route Client cong # Default route Client cong
cmd = self.addRouteDefaultGlobalCommand("10.0.2.2", Topo.clientName + "Cong-eth0") cmd = self.addRouteDefaultGlobalCommand("10.0.2.2", Topo.clientName + "Cong-eth0")
self.topo.commandTo(self.clientCong, cmd) self.topo.command_to(self.clientCong, cmd)
# Default route Router cong # Default route Router cong
cmd = self.addRouteDefaultGlobalCommand("10.0.3.2", Topo.routerName + "Cong-eth2") cmd = self.addRouteDefaultGlobalCommand("10.0.3.2", Topo.routerName + "Cong-eth2")
self.topo.commandTo(self.routerCong, cmd) self.topo.command_to(self.routerCong, cmd)
# Default route Router # Default route Router
cmd = self.addRouteDefaultGlobalCommand("10.0.3.1", Topo.routerName + "-eth1") cmd = self.addRouteDefaultGlobalCommand("10.0.3.1", Topo.routerName + "-eth1")
self.topo.commandTo(self.router, cmd) self.topo.command_to(self.router, cmd)
# Default route Server # Default route Server
cmd = self.addRouteDefaultGlobalCommand("10.1.0.2", Topo.serverName + "-eth0") cmd = self.addRouteDefaultGlobalCommand("10.1.0.2", Topo.serverName + "-eth0")
self.topo.commandTo(self.server, cmd) self.topo.command_to(self.server, cmd)
# Default route Server cong # Default route Server cong
cmd = self.addRouteDefaultGlobalCommand("10.1.1.2", Topo.serverName + "Cong-eth0") cmd = self.addRouteDefaultGlobalCommand("10.1.1.2", Topo.serverName + "Cong-eth0")
self.topo.commandTo(self.serverCong, cmd) self.topo.command_to(self.serverCong, cmd)
def configureInterface(self, srcHost, dstHost, srcInterfaceName, srcIP, netmask): def configureInterface(self, srcHost, dstHost, srcInterfaceName, srcIP, netmask):
cmd = self.interfaceUpCommand(srcInterfaceName, srcIP, netmask) cmd = self.interfaceUpCommand(srcInterfaceName, srcIP, netmask)
self.topo.commandTo(srcHost, cmd) self.topo.command_to(srcHost, cmd)
mac = srcHost.intf(srcInterfaceName).MAC() mac = srcHost.intf(srcInterfaceName).MAC()
cmd = self.arpCommand(srcIP, mac) cmd = self.arpCommand(srcIP, mac)
self.topo.commandTo(dstHost, cmd) self.topo.command_to(dstHost, cmd)
def configureInterfaces(self): def configureInterfaces(self):
print("Configure interfaces for two inf cong") print("Configure interfaces for two inf cong")
self.client = self.topo.getHost(Topo.clientName) self.client = self.topo.get_host(Topo.clientName)
self.clientCong = self.topo.getHost(Topo.clientName + "Cong") self.clientCong = self.topo.get_host(Topo.clientName + "Cong")
self.server = self.topo.getHost(Topo.serverName) self.server = self.topo.get_host(Topo.serverName)
self.serverCong = self.topo.getHost(Topo.serverName + "Cong") self.serverCong = self.topo.get_host(Topo.serverName + "Cong")
self.router = self.topo.getHost(Topo.routerName) self.router = self.topo.get_host(Topo.routerName)
self.routerCong = self.topo.getHost(Topo.routerName + "Cong") self.routerCong = self.topo.get_host(Topo.routerName + "Cong")
netmask = "255.255.255.0" netmask = "255.255.255.0"
links = self.topo.getLinkCharacteristics() links = self.topo.getLinkCharacteristics()
@ -152,7 +152,7 @@ class TwoInterfaceCongestionConfig(TopoConfig):
if(links[0].back_up): if(links[0].back_up):
cmd = self.interfaceBUPCommand(Topo.clientName + "-eth0") cmd = self.interfaceBUPCommand(Topo.clientName + "-eth0")
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
self.configureInterface(self.router, self.client, Topo.routerName + "-eth0", "10.0.0.2", netmask) self.configureInterface(self.router, self.client, Topo.routerName + "-eth0", "10.0.0.2", netmask)
print(str(links[0])) print(str(links[0]))
@ -162,7 +162,7 @@ class TwoInterfaceCongestionConfig(TopoConfig):
if(links[1].back_up): if(links[1].back_up):
cmd = self.interfaceBUPCommand(Topo.clientName + "-eth1") cmd = self.interfaceBUPCommand(Topo.clientName + "-eth1")
self.topo.commandTo(self.client, cmd) self.topo.command_to(self.client, cmd)
self.configureInterface(self.routerCong, self.client, Topo.routerName + "Cong-eth0", "10.0.1.2", netmask) self.configureInterface(self.routerCong, self.client, Topo.routerName + "Cong-eth0", "10.0.1.2", netmask)
@ -185,37 +185,37 @@ class TwoInterfaceCongestionConfig(TopoConfig):
self.configureInterface(self.router, self.serverCong, Topo.routerName + "-eth3", "10.1.1.2", netmask) self.configureInterface(self.router, self.serverCong, Topo.routerName + "-eth3", "10.1.1.2", netmask)
def getClientIP(self, interfaceID): def getClientIP(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientIP = lSubnet + str(interfaceID) + ".1" clientIP = lSubnet + str(interfaceID) + ".1"
return clientIP return clientIP
def getClientSubnet(self, interfaceID): def getClientSubnet(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientSubnet = lSubnet + str(interfaceID) + ".0/24" clientSubnet = lSubnet + str(interfaceID) + ".0/24"
return clientSubnet return clientSubnet
def getClientCongIP(self): def getClientCongIP(self):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientIP = lSubnet + str(2) + ".1" clientIP = lSubnet + str(2) + ".1"
return clientIP return clientIP
def getClientCongSubnet(self, interfaceID): def getClientCongSubnet(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
clientSubnet = lSubnet + str(128) + ".0/24" clientSubnet = lSubnet + str(128) + ".0/24"
return clientSubnet return clientSubnet
def getRouterIPSwitch(self, interfaceID): def getRouterIPSwitch(self, interfaceID):
lSubnet = self.param.getParam(TopoParameter.LSUBNET) lSubnet = self.param.get(TopoParameter.LSUBNET)
routerIP = lSubnet + str(interfaceID) + ".2" routerIP = lSubnet + str(interfaceID) + ".2"
return routerIP return routerIP
def getRouterIPServer(self): def getRouterIPServer(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
routerIP = rSubnet + "0.2" routerIP = rSubnet + "0.2"
return routerIP return routerIP
def getServerIP(self): def getServerIP(self):
rSubnet = self.param.getParam(TopoParameter.RSUBNET) rSubnet = self.param.get(TopoParameter.RSUBNET)
serverIP = rSubnet + "0.1" serverIP = rSubnet + "0.1"
return serverIP return serverIP