diff --git a/src/conf/topo/0_para_2 b/src/conf/topo/0_para_2 index 1b0d913..b7d475e 100644 --- a/src/conf/topo/0_para_2 +++ b/src/conf/topo/0_para_2 @@ -7,3 +7,7 @@ error path_0:10,15,5 path_1:40,10,5 topoType:MultiIf +changeNetem:yes +#netem_{path_id}:at,cmd +netemAt_0:2,delay 100ms limit 15 +netemAt_0:5,delay 2ms limit 15 loss 10% diff --git a/src/conf/xp/3_ncpv b/src/conf/xp/3_ncpv index 5842569..eb87432 100644 --- a/src/conf/xp/3_ncpv +++ b/src/conf/xp/3_ncpv @@ -1,4 +1,3 @@ xpType:ncpv ncClientPort_0:33400 -ncClientPort_1:33401 clientPcap:yes diff --git a/src/mpExperience.py b/src/mpExperience.py index 9d1372f..80ed614 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -26,9 +26,24 @@ class MpExperience: return print("Will change netem config on the fly") links = self.mpTopo.getLinkCharacteristics() + i = 0 for l in links: - cmd = l.buildNetemCmd() + lname = self.mpConfig.getMidLeftName(i) + rname = self.mpConfig.getMidRightName(i) + lbox = self.mpTopo.getHost(lname) + lif = self.mpConfig.getMidL2RInterface(i) + rif = self.mpConfig.getMidR2LInterface(i) + rbox = self.mpTopo.getHost(rname) + print(str(lname) + " " + str(lif)) + print(str(rname) + " " + str(rif)) + print("boxes " + str(lbox) + " " + str(rbox)) + cmd = l.buildNetemCmd(lif) print(cmd) + self.mpTopo.commandTo(lbox, cmd) + cmd = l.buildNetemCmd(rif) + print(cmd) + self.mpTopo.commandTo(rbox, cmd) + i = i + 1 def run(self): pass diff --git a/src/mpLinkCharacteristics.py b/src/mpLinkCharacteristics.py index 8da38bb..b13fa38 100644 --- a/src/mpLinkCharacteristics.py +++ b/src/mpLinkCharacteristics.py @@ -2,6 +2,10 @@ class MpLinkCharacteristics: + + tcNetemParent = "5:1" + tcNetemHandle = "10:" + def __init__(self, id, delay, queueSize, bandwidth): self.id = id self.delay = delay @@ -11,7 +15,7 @@ class MpLinkCharacteristics: def addNetemAt(self, n): if len(self.netemAt) == 0: - n.delay = n.at + n.delta = n.at self.netemAt.append(n) else: if n.at > self.netemAt[-1].at: @@ -22,12 +26,15 @@ class MpLinkCharacteristics: "because ooo !") pass - def buildNetemCmd(self): + def buildNetemCmd(self, ifname): cmd = "" for n in self.netemAt: cmd = cmd + "sleep " + str(n.delta) cmd = cmd + " && " - cmd = cmd + " echo " + n.cmd + " && " + cmd = cmd + " tc qdisc change dev " + ifname + " " + cmd = cmd + " parent " + MpLinkCharacteristics.tcNetemParent + cmd = cmd + " handle " + MpLinkCharacteristics.tcNetemHandle + cmd = cmd + " netem " + n.cmd + " && " cmd = cmd + " true &" return cmd diff --git a/src/mpMultiInterfaceConfig.py b/src/mpMultiInterfaceConfig.py index 8305cff..adfde2a 100644 --- a/src/mpMultiInterfaceConfig.py +++ b/src/mpMultiInterfaceConfig.py @@ -105,7 +105,7 @@ class MpMultiInterfaceConfig(MpConfig): return MpTopo.routerName def getMidL2RInterface(self, id): - return self.getMidLeftName(id) + "-eth1" + return self.getMidLeftName(id) + "-eth2" def getMidR2LInterface(self, id): return self.getMidRightName(id) + "-eth" + str(id)