diff --git a/src/conf/xp/1_ping b/src/conf/xp/1_ping index 9b7a9f7..79a7eb9 100644 --- a/src/conf/xp/1_ping +++ b/src/conf/xp/1_ping @@ -1,2 +1,3 @@ xpType:ping pingCount:16 +rmem:87380 87380 87380 diff --git a/src/mpExperience.py b/src/mpExperience.py index 772b230..7cafaac 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -15,6 +15,7 @@ class MpExperience: self.clean() def prepare(self): + self.setupSysctl() self.runTcpDump() pass @@ -26,8 +27,51 @@ class MpExperience: "killall tcpdump") self.mpTopo.commandTo(self.mpConfig.server, "killall tcpdump") + self.backUpSysctl() pass + def setupSysctl(self): + self.saveSysctl() + self.writeSysctl() + + def saveSysctl(self): + self.sysctlBUP = {} + for k in MpParamXp.sysctlKey: + sysctlKey = MpParamXp.sysctlKey[k] + cmd = self.cmdReadSysctl(sysctlKey) + val = self.mpTopo.notNSCommand(cmd) + if val == "Error": + print("oooops can't get sysctl " + sysctlKey) + else: + self.sysctlBUP[k] = val.split(" ",2)[2][:-1] + + def cmdReadSysctl(self, key): + s = "sysctl " + key + return s + + def cmdWriteSysctl(self, key, value): + s = self.cmdReadSysctl(key) + s = s + "=\"" + str(value) + "\"" + return s + + def writeSysctl(self): + for k in self.sysctlBUP: + sysctlKey = MpParamXp.sysctlKey[k] + sysctlValue = self.xpParam.getParam(k) + cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) + val = self.mpTopo.notNSCommand(cmd) + if val == "Error": + print("oooops can't set sysctl " + sysctlKey) + + def backUpSysctl(self): + for k in self.sysctlBUP: + sysctlKey = MpParamXp.sysctlKey[k] + sysctlValue = self.sysctlBUP[k] + cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) + val = self.mpTopo.notNSCommand(cmd) + if val == "Error": + print("oooops can't set sysctl " + sysctlKey) + def runTcpDump(self): #todo : replace filename by cst if self.xpParam.getParam(MpParamXp.CLIENTPCAP) == "yes" : diff --git a/src/mpMininetBuilder.py b/src/mpMininetBuilder.py index 0b5945b..4a5e30b 100644 --- a/src/mpMininetBuilder.py +++ b/src/mpMininetBuilder.py @@ -2,6 +2,7 @@ from mininet.topo import Topo from mininet.net import Mininet from mininet.link import TCLink from mininet.cli import CLI +from subprocess import Popen, PIPE class MpMininetBuilder(Topo): def __init__(self): @@ -10,6 +11,13 @@ class MpMininetBuilder(Topo): def commandTo(self, who, cmd): who.cmd(cmd) + + def notNSCommand(self, cmd): + p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) + stdout, stderr = p.communicate() + if stderr: + return "Error" + return stdout def startNetwork(self): self.net = Mininet(topo=self,link=TCLink) diff --git a/src/mpParamXp.py b/src/mpParamXp.py index 5d9addf..e0bb176 100644 --- a/src/mpParamXp.py +++ b/src/mpParamXp.py @@ -3,6 +3,7 @@ from mpParam import MpParam class MpParamXp(MpParam): RMEM = "rmem" + KERNELPM = "kpm" CLIENTPCAP = "clientPcap" SERVERPCAP = "serverPcap" XPTYPE = "xpType" @@ -16,9 +17,19 @@ class MpParamXp(MpParam): NCSERVERPORT = "ncServerPort" NCCLIENTPORT = "ncClientPort" + # global sysctl + sysctlKey = {} + sysctlKey[RMEM] = "net.ipv4.tcp_rmem" + sysctlKey[KERNELPM] = "net.mptcp.mptcp_path_manager" + + sysctlListClient = [] + sysctlListServer = [] + defaultValue = {} - defaultValue[RMEM] = "x y z" + defaultValue[RMEM] = "10240 87380 16777216" + defaultValue[KERNELPM] = "fullmesh" + defaultValue[CLIENTPCAP] = "no" defaultValue[SERVERPCAP] = "no" defaultValue[XPTYPE] = "ping" diff --git a/src/mpTopo.py b/src/mpTopo.py index 4b65081..a6d4e4a 100644 --- a/src/mpTopo.py +++ b/src/mpTopo.py @@ -20,6 +20,13 @@ class MpTopo: self.logFile.write(who.__str__() + " : " + cmd + "\n") self.topoBuilder.commandTo(who, cmd) + def notNSCommand(self, cmd): + """ + mainly use for not namespace sysctl. + """ + self.logFile.write("Not_NS" + " : " + cmd + "\n") + return self.topoBuilder.notNSCommand(cmd) + def getHost(self, who): return self.topoBuilder.getHost(who)