diff --git a/src/mpConfig.py b/src/mpConfig.py index ec6900a..cd3135e 100644 --- a/src/mpConfig.py +++ b/src/mpConfig.py @@ -31,6 +31,11 @@ class MpConfig: def getClientInterfaceCount(self): raise Exception("To be implemented") + def interfaceBUPCommand(self, interfaceName): + s = "/home/mininet/git/iproute-mptcp/ip/ip link set dev " + interfaceName + " multipath backup " + print(s) + return s + def interfaceUpCommand(self, interfaceName, ip, subnet): s = "ifconfig " + interfaceName + " " + ip + " netmask " + \ subnet diff --git a/src/mpLinkCharacteristics.py b/src/mpLinkCharacteristics.py index b4e81fa..bbb3801 100644 --- a/src/mpLinkCharacteristics.py +++ b/src/mpLinkCharacteristics.py @@ -6,12 +6,13 @@ class MpLinkCharacteristics: tcNetemParent = "5:1" tcNetemHandle = "10:" - def __init__(self, id, delay, queueSize, bandwidth): + def __init__(self, id, delay, queueSize, bandwidth, back_up=False): self.id = id self.delay = delay self.queueSize = queueSize self.bandwidth = bandwidth self.netemAt = [] + self.back_up = back_up def addNetemAt(self, n): if len(self.netemAt) == 0: @@ -50,6 +51,7 @@ class MpLinkCharacteristics: s = s + "\tDelay : " + str(self.delay) + "\n" s = s + "\tQueue Size : " + str(self.queueSize) + "\n" s = s + "\tBandwidth : " + str(self.bandwidth) + "\n" + s = s + "\tBack up : " + str(self.back_up) + "\n" for l in self.netemAt: s = s + "\t" + l.__str__() + "\n" return s diff --git a/src/mpMultiInterfaceConfig.py b/src/mpMultiInterfaceConfig.py index 701462b..ff08277 100644 --- a/src/mpMultiInterfaceConfig.py +++ b/src/mpMultiInterfaceConfig.py @@ -38,16 +38,23 @@ class MpMultiInterfaceConfig(MpConfig): self.router = self.topo.getHost(MpTopo.routerName) i = 0 netmask = "255.255.255.0" + links = self.topo.getLinkCharacteristics() for l in self.topo.switch: cmd = self.interfaceUpCommand( self.getClientInterface(i), self.getClientIP(i), netmask) self.topo.commandTo(self.client, cmd) + if(links[i].back_up): + cmd = self.interfaceBUPCommand( + self.getClientInterface(i)) + self.topo.commandTo(self.client, cmd) + cmd = self.interfaceUpCommand( self.getRouterInterfaceSwitch(i), self.getRouterIPSwitch(i), netmask) self.topo.commandTo(self.router, cmd) + print(str(links[i])) i = i + 1 cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(), diff --git a/src/mpParamTopo.py b/src/mpParamTopo.py index 9f96320..0d58e69 100644 --- a/src/mpParamTopo.py +++ b/src/mpParamTopo.py @@ -50,9 +50,12 @@ class MpParamTopo(MpParam): for k in sorted(self.paramDic): if k.startswith("path"): tab = self.paramDic[k].split(",") - if len(tab) == 3: + bup = False + if len(tab) == 4: + bup = tab[3] == 'True' + if len(tab) == 3 or len(tab) == 4: path = MpLinkCharacteristics(i,tab[0], - tab[1], tab[2]) + tab[1], tab[2], bup) self.linkCharacteristics.append(path) i = i + 1 else: