support for sysctl

Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
Benjamin Hesmans 2015-01-14 15:19:39 +01:00
parent 88e92a76d6
commit c20c9238ac
5 changed files with 72 additions and 1 deletions

View File

@ -1,2 +1,3 @@
xpType:ping xpType:ping
pingCount:16 pingCount:16
rmem:87380 87380 87380

View File

@ -15,6 +15,7 @@ class MpExperience:
self.clean() self.clean()
def prepare(self): def prepare(self):
self.setupSysctl()
self.runTcpDump() self.runTcpDump()
pass pass
@ -26,8 +27,51 @@ class MpExperience:
"killall tcpdump") "killall tcpdump")
self.mpTopo.commandTo(self.mpConfig.server, self.mpTopo.commandTo(self.mpConfig.server,
"killall tcpdump") "killall tcpdump")
self.backUpSysctl()
pass 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): def runTcpDump(self):
#todo : replace filename by cst #todo : replace filename by cst
if self.xpParam.getParam(MpParamXp.CLIENTPCAP) == "yes" : if self.xpParam.getParam(MpParamXp.CLIENTPCAP) == "yes" :

View File

@ -2,6 +2,7 @@ from mininet.topo import Topo
from mininet.net import Mininet from mininet.net import Mininet
from mininet.link import TCLink from mininet.link import TCLink
from mininet.cli import CLI from mininet.cli import CLI
from subprocess import Popen, PIPE
class MpMininetBuilder(Topo): class MpMininetBuilder(Topo):
def __init__(self): def __init__(self):
@ -11,6 +12,13 @@ class MpMininetBuilder(Topo):
def commandTo(self, who, cmd): def commandTo(self, who, cmd):
who.cmd(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): def startNetwork(self):
self.net = Mininet(topo=self,link=TCLink) self.net = Mininet(topo=self,link=TCLink)
self.net.start() self.net.start()

View File

@ -3,6 +3,7 @@ from mpParam import MpParam
class MpParamXp(MpParam): class MpParamXp(MpParam):
RMEM = "rmem" RMEM = "rmem"
KERNELPM = "kpm"
CLIENTPCAP = "clientPcap" CLIENTPCAP = "clientPcap"
SERVERPCAP = "serverPcap" SERVERPCAP = "serverPcap"
XPTYPE = "xpType" XPTYPE = "xpType"
@ -16,9 +17,19 @@ class MpParamXp(MpParam):
NCSERVERPORT = "ncServerPort" NCSERVERPORT = "ncServerPort"
NCCLIENTPORT = "ncClientPort" NCCLIENTPORT = "ncClientPort"
# global sysctl
sysctlKey = {}
sysctlKey[RMEM] = "net.ipv4.tcp_rmem"
sysctlKey[KERNELPM] = "net.mptcp.mptcp_path_manager"
sysctlListClient = []
sysctlListServer = []
defaultValue = {} defaultValue = {}
defaultValue[RMEM] = "x y z" defaultValue[RMEM] = "10240 87380 16777216"
defaultValue[KERNELPM] = "fullmesh"
defaultValue[CLIENTPCAP] = "no" defaultValue[CLIENTPCAP] = "no"
defaultValue[SERVERPCAP] = "no" defaultValue[SERVERPCAP] = "no"
defaultValue[XPTYPE] = "ping" defaultValue[XPTYPE] = "ping"

View File

@ -20,6 +20,13 @@ class MpTopo:
self.logFile.write(who.__str__() + " : " + cmd + "\n") self.logFile.write(who.__str__() + " : " + cmd + "\n")
self.topoBuilder.commandTo(who, cmd) 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): def getHost(self, who):
return self.topoBuilder.getHost(who) return self.topoBuilder.getHost(who)