trying something else

This commit is contained in:
Quentin De Coninck 2019-11-28 16:22:53 +01:00
parent 66de7f1a64
commit b70103d29f
2 changed files with 22 additions and 6 deletions

View File

@ -150,10 +150,10 @@ class MpExperience:
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.buildNetemCmd(lif) cmd = l.buildBwCmd(lif)
print(cmd) print(cmd)
self.mpTopo.commandTo(lbox, cmd) self.mpTopo.commandTo(lbox, cmd)
cmd = l.buildNetemCmd(rif) cmd = l.buildBwCmd(rif)
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.mpTopo.commandTo(rbox, cmd)
ilif = self.mpConfig.getMidL2RIncomingInterface(i) ilif = self.mpConfig.getMidL2RIncomingInterface(i)
@ -164,6 +164,12 @@ class MpExperience:
cmd = l.buildPolicingCmd(irif) cmd = l.buildPolicingCmd(irif)
print(cmd) print(cmd)
self.mpTopo.commandTo(rbox, cmd) self.mpTopo.commandTo(rbox, cmd)
cmd = l.buildNetemCmd(irif)
print(cmd)
self.mpTopo.commandTo(rbox, cmd)
cmd = l.buildNetemCmd(ilif)
print(cmd)
self.mpTopo.commandTo(lbox, cmd)
i = i + 1 i = i + 1

View File

@ -13,6 +13,9 @@ class MpLinkCharacteristics:
bandwidthDelayProduct = (float(self.bandwidth) * 125000.0) * (rtt / 1000.0) bandwidthDelayProduct = (float(self.bandwidth) * 125000.0) * (rtt / 1000.0)
return int(math.ceil(bandwidthDelayProduct * 1.0 / 1500.0)) return int(math.ceil(bandwidthDelayProduct * 1.0 / 1500.0))
def bufferSize(self):
return (1500.0 * self.bandwidthDelayProductDividedByMTU()) + (float(self.bandwidth) * 1000.0 * float(self.queuingDelay) / 8)
def extractQueuingDelay(self, queueSize, bandwidth, delay, mtu=1500): def extractQueuingDelay(self, queueSize, bandwidth, delay, mtu=1500):
rtt = 2 * float(delay) rtt = 2 * float(delay)
bdp_queue_size = int((float(rtt) * float(bandwidth) * 1024 * 1024) / (int(mtu) * 8 * 1000)) bdp_queue_size = int((float(rtt) * float(bandwidth) * 1024 * 1024) / (int(mtu) * 8 * 1000))
@ -48,14 +51,21 @@ class MpLinkCharacteristics:
"because ooo !") "because ooo !")
pass pass
def buildBwCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 limit {} &&".format(ifname, self.bandwidth, self.bufferSize())
cmd = cmd + " true &"
return cmd
def buildNetemCmd(self, ifname): 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 + " && tc qdisc del dev " + ifname + " root " cmd = cmd + " && tc qdisc del dev " + ifname + " root "
cmd = cmd + " && tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 latency {}ms".format(ifname, self.bandwidth, self.queuingDelay) cmd = cmd + " && tc qdisc add dev {} root handle 10: netem {} delay {}ms limit {} &&".format(ifname, n.cmd, self.delay, 2 * self.bufferSize() // 1500)
cmd = cmd + " && tc qdisc add dev {} parent 5:0 handle 10: netem {} delay {}ms limit 1000000 &&".format(ifname, n.cmd, self.delay)
cmd = cmd + " true &" cmd = cmd + " true &"
return cmd return cmd
@ -66,7 +76,7 @@ class MpLinkCharacteristics:
cmd = cmd + "sleep {}".format(n.delta) cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname) cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname)
cmd = cmd + " ; tc qdisc add dev {} handle ffff: ingress".format(ifname) cmd = cmd + " ; tc qdisc add dev {} handle ffff: ingress".format(ifname)
cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.queueSize) * 1500) cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, self.bufferSize())
cmd = cmd + " true &" cmd = cmd + " true &"
return cmd return cmd