apply correctly policing on the MultiInterface topo

This commit is contained in:
Quentin De Coninck 2019-11-28 09:32:49 +01:00
parent 897b7ebf7f
commit 71010be455
4 changed files with 59 additions and 18 deletions

View File

@ -156,6 +156,15 @@ class MpExperience:
cmd = l.buildNetemCmd(rif)
print(cmd)
self.mpTopo.commandTo(rbox, cmd)
ilif = self.mpConfig.getMidL2RIncomingInterface(i)
irif = self.mpConfig.getMidR2LIncomingInterface(i)
cmd = l.buildPolicingCmd(ilif)
print(cmd)
self.mpTopo.commandTo(lbox, cmd)
cmd = l.buildPolicingCmd(irif)
print(cmd)
self.mpTopo.commandTo(rbox, cmd)
i = i + 1
def run(self):

View File

@ -54,14 +54,23 @@ class MpLinkCharacteristics:
cmd = cmd + "sleep " + str(n.delta)
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 {} 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 qdisc add dev {} parent 5:0 handle 10: netem {} delay {}ms limit 1000000 &&".format(ifname, n.cmd, self.delay)
cmd = cmd + " true &"
return cmd
def buildPolicingCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname)
cmd = cmd + " && tc qdisc add dev {} handle ffff: ingress".format(ifname)
cmd = cmd + " && tc filter add dev {} parent fff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.queueSize) * 1500)
cmd = cmd + " true &"
return cmd
def asDict(self):
d = {}
d['bw'] = float(self.bandwidth)

View File

@ -9,7 +9,7 @@ class MpMultiInterfaceConfig(MpConfig):
def configureRoute(self):
i = 0
for l in self.topo.switch:
for l in self.topo.switchClient:
cmd = self.addRouteTableCommand(self.getClientIP(i), i)
self.topo.commandTo(self.client, cmd)
@ -39,7 +39,7 @@ class MpMultiInterfaceConfig(MpConfig):
i = 0
netmask = "255.255.255.0"
links = self.topo.getLinkCharacteristics()
for l in self.topo.switch:
for l in self.topo.switchClient:
cmd = self.interfaceUpCommand(
self.getClientInterface(i),
self.getClientIP(i), netmask)
@ -52,6 +52,10 @@ class MpMultiInterfaceConfig(MpConfig):
self.getClientInterface(i))
self.topo.commandTo(self.client, cmd)
i = i + 1
i = 0
for l in self.topo.switchServer:
cmd = self.interfaceUpCommand(
self.getRouterInterfaceSwitch(i),
self.getRouterIPSwitch(i), netmask)
@ -99,10 +103,10 @@ class MpMultiInterfaceConfig(MpConfig):
return serverIP
def getClientInterfaceCount(self):
return len(self.topo.switch)
return len(self.topo.switchClient)
def getRouterInterfaceServer(self):
return self.getRouterInterfaceSwitch(len(self.topo.switch))
return self.getRouterInterfaceSwitch(len(self.topo.switchServer))
def getClientInterface(self, interfaceID):
return MpTopo.clientName + "-eth" + str(interfaceID)
@ -113,14 +117,26 @@ class MpMultiInterfaceConfig(MpConfig):
def getServerInterface(self):
return MpTopo.serverName + "-eth0"
def getSwitchClientName(self, id):
return MpTopo.switchNamePrefix + str(2 * id)
def getSwitchServerName(self, id):
return MpTopo.switchNamePrefix + str(2 * id + 1)
def getMidLeftName(self, id):
return MpTopo.switchNamePrefix + str(id)
return self.getSwitchClientName(id)
def getMidRightName(self, id):
return MpTopo.routerName
return self.getSwitchServerName(id)
def getMidL2RInterface(self, id):
return self.getMidLeftName(id) + "-eth2"
def getMidR2LInterface(self, id):
return self.getMidRightName(id) + "-eth" + str(id)
return self.getMidRightName(id) + "-eth1"
def getMidL2RIncomingInterface(self, id):
return self.getMidLeftName(id) + "-eth1"
def getMidR2LIncomingInterface(self, id):
return self.getMidRightName(id) + "-eth2"

View File

@ -7,16 +7,23 @@ class MpMultiInterfaceTopo(MpTopo):
self.client = self.addHost(MpTopo.clientName)
self.server = self.addHost(MpTopo.serverName)
self.router = self.addHost(MpTopo.routerName)
self.switch = []
self.switchClient = []
self.switchServer = []
for l in self.topoParam.linkCharacteristics:
self.switch.append(self.addOneSwitchPerLink(l))
self.addLink(self.client,self.switch[-1])
self.addLink(self.switch[-1],self.router, **l.asDict())
self.switchClient.append(self.addSwitch1ForLink(l))
self.addLink(self.client,self.switchClient[-1])
self.switchServer.append(self.addSwitch2ForLink(l))
self.addLink(self.switchClient[-1], self.switchServer[-1], **l.asDict())
self.addLink(self.switchServer[-1],self.router)
self.addLink(self.router, self.server)
def addOneSwitchPerLink(self, link):
def addSwitch1ForLink(self, link):
return self.addSwitch(MpMultiInterfaceTopo.switchNamePrefix +
str(link.id))
str(2 * link.id))
def addSwitch2ForLink(self, link):
return self.addSwitch(MpMultiInterfaceTopo.switchNamePrefix +
str(2 * link.id + 1))
def __str__(self):
s = "Simple multiple interface topolgy \n"
@ -26,11 +33,11 @@ class MpMultiInterfaceTopo(MpTopo):
if i == n // 2:
if n % 2 == 0:
s = s + "c r-----s\n"
s = s + "|-----sw-----|\n"
s = s + "|--sw----sw--|\n"
else:
s = s + "c-----sw-----r-----s\n"
s = s + "c--sw----sw--r-----s\n"
else:
s = s + "|-----sw-----|\n"
s = s + "|--sw----sw--|\n"
i = i + 1
return s