first implem of netem change,

only implemented for para topo, for now.

example:

sudo ./mpPerf.py -t conf/topo/0_para_2  -x conf/xp/3_ncpv

after two seconds, delay goes to 100ms
after five seconds, delay goes to 2ms but loss rate goes to 10%

Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
Benjamin Hesmans 2015-01-20 12:23:57 +01:00
parent 56c7196245
commit ca49762bd4
5 changed files with 31 additions and 6 deletions

View File

@ -7,3 +7,7 @@ error
path_0:10,15,5 path_0:10,15,5
path_1:40,10,5 path_1:40,10,5
topoType:MultiIf 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%

View File

@ -1,4 +1,3 @@
xpType:ncpv xpType:ncpv
ncClientPort_0:33400 ncClientPort_0:33400
ncClientPort_1:33401
clientPcap:yes clientPcap:yes

View File

@ -26,9 +26,24 @@ class MpExperience:
return return
print("Will change netem config on the fly") print("Will change netem config on the fly")
links = self.mpTopo.getLinkCharacteristics() links = self.mpTopo.getLinkCharacteristics()
i = 0
for l in links: 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) print(cmd)
self.mpTopo.commandTo(lbox, cmd)
cmd = l.buildNetemCmd(rif)
print(cmd)
self.mpTopo.commandTo(rbox, cmd)
i = i + 1
def run(self): def run(self):
pass pass

View File

@ -2,6 +2,10 @@
class MpLinkCharacteristics: class MpLinkCharacteristics:
tcNetemParent = "5:1"
tcNetemHandle = "10:"
def __init__(self, id, delay, queueSize, bandwidth): def __init__(self, id, delay, queueSize, bandwidth):
self.id = id self.id = id
self.delay = delay self.delay = delay
@ -11,7 +15,7 @@ class MpLinkCharacteristics:
def addNetemAt(self, n): def addNetemAt(self, n):
if len(self.netemAt) == 0: if len(self.netemAt) == 0:
n.delay = n.at n.delta = n.at
self.netemAt.append(n) self.netemAt.append(n)
else: else:
if n.at > self.netemAt[-1].at: if n.at > self.netemAt[-1].at:
@ -22,12 +26,15 @@ class MpLinkCharacteristics:
"because ooo !") "because ooo !")
pass pass
def buildNetemCmd(self): def buildNetemCmd(self, ifname):
cmd = "" cmd = ""
for n in self.netemAt: for n in self.netemAt:
cmd = cmd + "sleep " + str(n.delta) cmd = cmd + "sleep " + str(n.delta)
cmd = cmd + " && " 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 &" cmd = cmd + " true &"
return cmd return cmd

View File

@ -105,7 +105,7 @@ class MpMultiInterfaceConfig(MpConfig):
return MpTopo.routerName return MpTopo.routerName
def getMidL2RInterface(self, id): def getMidL2RInterface(self, id):
return self.getMidLeftName(id) + "-eth1" return self.getMidLeftName(id) + "-eth2"
def getMidR2LInterface(self, id): def getMidR2LInterface(self, id):
return self.getMidRightName(id) + "-eth" + str(id) return self.getMidRightName(id) + "-eth" + str(id)