2015-01-08 18:52:45 +00:00
|
|
|
from mpParamXp import MpParamXp
|
2016-05-13 08:00:29 +00:00
|
|
|
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
|
2015-01-08 18:52:45 +00:00
|
|
|
|
|
|
|
class MpExperience:
|
|
|
|
PING = "ping"
|
2015-01-12 15:34:41 +00:00
|
|
|
NCPV = "ncpv"
|
2015-02-27 10:16:01 +00:00
|
|
|
NC = "nc"
|
2015-03-05 10:32:11 +00:00
|
|
|
NONE = "none"
|
2015-08-14 22:34:27 +00:00
|
|
|
HTTPS = "https"
|
2015-12-01 16:48:32 +00:00
|
|
|
HTTP = "http"
|
2015-11-05 14:06:30 +00:00
|
|
|
EPLOAD = "epload"
|
2015-12-02 09:22:57 +00:00
|
|
|
NETPERF = "netperf"
|
2015-12-02 14:22:51 +00:00
|
|
|
AB = "ab"
|
2016-04-14 14:01:39 +00:00
|
|
|
SIRI = "siri"
|
2016-01-18 09:32:56 +00:00
|
|
|
SENDFILE = "sendfile"
|
2016-04-27 14:08:21 +00:00
|
|
|
VLC = "vlc"
|
2016-06-01 09:00:51 +00:00
|
|
|
IPERF = "iperf"
|
2016-06-01 12:52:25 +00:00
|
|
|
DITG = "ditg"
|
2017-01-09 15:03:05 +00:00
|
|
|
MSG = "msg"
|
2017-02-22 12:41:42 +00:00
|
|
|
SIRIHTTP = "sirihttp"
|
2017-02-23 10:36:08 +00:00
|
|
|
SIRIMSG = "sirimsg"
|
2017-05-05 11:19:03 +00:00
|
|
|
QUIC = "quic"
|
2017-05-31 12:51:01 +00:00
|
|
|
QUICSIRI = "quicsiri"
|
2015-03-05 10:32:11 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def __init__(self, xpParam, mpTopo, mpConfig):
|
|
|
|
self.xpParam = xpParam
|
|
|
|
self.mpTopo = mpTopo
|
|
|
|
self.mpConfig = mpConfig
|
|
|
|
print(self.xpParam)
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def classicRun(self):
|
|
|
|
self.prepare()
|
|
|
|
self.run()
|
|
|
|
self.clean()
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def prepare(self):
|
2015-01-14 14:19:39 +00:00
|
|
|
self.setupSysctl()
|
2015-02-23 11:26:32 +00:00
|
|
|
self.runUserspacePM()
|
2016-05-05 08:40:28 +00:00
|
|
|
self.mpConfig.configureNetwork()
|
2016-06-21 15:31:17 +00:00
|
|
|
self.changeMetric()
|
2016-05-13 08:00:29 +00:00
|
|
|
self.putPriorityOnPaths()
|
2017-05-09 08:36:01 +00:00
|
|
|
self.disableTSO()
|
2015-01-08 18:52:45 +00:00
|
|
|
self.runTcpDump()
|
2015-01-16 02:59:52 +00:00
|
|
|
self.runNetemAt()
|
2015-01-08 18:52:45 +00:00
|
|
|
pass
|
|
|
|
|
2016-06-21 15:31:17 +00:00
|
|
|
def changeMetric(self):
|
|
|
|
metric = self.xpParam.getParam(MpParamXp.METRIC)
|
|
|
|
if int(metric) >= 0:
|
|
|
|
self.mpTopo.notNSCommand("echo " + metric + " > /sys/module/mptcp_sched_metric/parameters/metric")
|
|
|
|
|
2016-05-13 08:00:29 +00:00
|
|
|
def putPriorityOnPaths(self):
|
|
|
|
# Only meaningful if mpTopo is instance of MpMultiInterfaceTopo
|
|
|
|
if isinstance(self.mpTopo, MpMultiInterfaceTopo):
|
|
|
|
prioPath0 = self.xpParam.getParam(MpParamXp.PRIOPATH0)
|
|
|
|
prioPath1 = self.xpParam.getParam(MpParamXp.PRIOPATH1)
|
2016-05-13 08:06:52 +00:00
|
|
|
if not prioPath0 == prioPath1:
|
2016-05-13 13:36:25 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, "/home/mininet/iproute/ip/ip link set dev " +
|
2016-05-18 06:59:25 +00:00
|
|
|
self.mpConfig.getClientInterface(0) + " priority " + str(prioPath0))
|
2016-05-13 13:36:25 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.router, "/home/mininet/iproute/ip/ip link set dev " +
|
2016-05-18 06:59:25 +00:00
|
|
|
self.mpConfig.getRouterInterfaceSwitch(0) + " priority " +
|
2016-05-13 08:06:52 +00:00
|
|
|
str(prioPath0))
|
2016-05-13 13:36:25 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, "/home/mininet/iproute/ip/ip link set dev " +
|
2016-05-18 06:59:25 +00:00
|
|
|
self.mpConfig.getClientInterface(1) + " priority " + str(prioPath1))
|
2016-05-13 13:36:25 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.router, "/home/mininet/iproute/ip/ip link set dev " +
|
2016-05-18 06:59:25 +00:00
|
|
|
self.mpConfig.getRouterInterfaceSwitch(1) + " priority " +
|
2016-05-13 08:06:52 +00:00
|
|
|
str(prioPath1))
|
2016-05-13 08:00:29 +00:00
|
|
|
|
2016-06-21 15:35:03 +00:00
|
|
|
backupPath0 = self.xpParam.getParam(MpParamXp.BACKUPPATH0)
|
|
|
|
if int(backupPath0) > 0:
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, self.mpConfig.interfaceBUPCommand(self.mpConfig.getClientInterface(0)))
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.router, self.mpConfig.interfaceBUPCommand(self.mpConfig.getRouterInterfaceSwitch(0)))
|
2016-06-21 15:32:19 +00:00
|
|
|
backupPath1 = self.xpParam.getParam(MpParamXp.BACKUPPATH1)
|
|
|
|
if int(backupPath1) > 0:
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, self.mpConfig.interfaceBUPCommand(self.mpConfig.getClientInterface(1)))
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.router, self.mpConfig.interfaceBUPCommand(self.mpConfig.getRouterInterfaceSwitch(1)))
|
|
|
|
|
2017-05-09 08:36:01 +00:00
|
|
|
def disableTSO(self):
|
|
|
|
links = self.mpTopo.getLinkCharacteristics()
|
|
|
|
i = 0
|
|
|
|
for l in links:
|
|
|
|
lname = self.mpConfig.getMidLeftName(i)
|
|
|
|
rname = self.mpConfig.getMidRightName(i)
|
|
|
|
lbox = self.mpTopo.getHost(lname)
|
|
|
|
lif = self.mpConfig.getMidL2RInterface(i)
|
|
|
|
rif = self.mpConfig.getMidR2LInterface(i)
|
|
|
|
rbox = self.mpTopo.getHost(rname)
|
|
|
|
print(str(lname) + " " + str(lif))
|
|
|
|
print(str(rname) + " " + str(rif))
|
|
|
|
print("boxes " + str(lbox) + " " + str(rbox))
|
|
|
|
cmd = "ethtool -K " + lif + " tso off"
|
|
|
|
print(cmd)
|
|
|
|
self.mpTopo.commandTo(lbox, cmd)
|
|
|
|
cmd = "ethtool -K " + rif + " tso off"
|
|
|
|
print(cmd)
|
|
|
|
self.mpTopo.commandTo(rbox, cmd)
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
# And for the server
|
|
|
|
cmd = "ethtool -K " + self.mpConfig.getServerInterface() + " tso off"
|
|
|
|
print(cmd)
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
|
|
|
|
|
|
|
cmd = "ethtool -K " + self.mpConfig.getRouterInterfaceSwitch(self.mpConfig.getClientInterfaceCount()) + " tso off"
|
|
|
|
print(cmd)
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.router, cmd)
|
|
|
|
|
2015-02-23 11:26:32 +00:00
|
|
|
def runUserspacePM(self):
|
|
|
|
if self.xpParam.getParam(MpParamXp.KERNELPMC) != "netlink":
|
|
|
|
print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !")
|
|
|
|
else:
|
|
|
|
upmc = self.xpParam.getParam(MpParamXp.USERPMC)
|
2015-02-23 11:42:14 +00:00
|
|
|
upmca = self.xpParam.getParam(MpParamXp.USERPMCARGS)
|
2015-02-23 11:30:32 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, upmc + \
|
2015-02-26 09:40:18 +00:00
|
|
|
" " + upmca + " &>upmc.log &")
|
2015-02-23 11:26:32 +00:00
|
|
|
if self.xpParam.getParam(MpParamXp.KERNELPMS) != "netlink":
|
|
|
|
print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !")
|
|
|
|
else:
|
|
|
|
upms = self.xpParam.getParam(MpParamXp.USERPMS)
|
2015-02-23 11:42:14 +00:00
|
|
|
upmsa = self.xpParam.getParam(MpParamXp.USERPMSARGS)
|
2015-02-23 11:30:32 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.server, upms + \
|
2015-02-26 09:40:18 +00:00
|
|
|
" " + upmsa + " &>upms.log &")
|
2015-02-23 11:26:32 +00:00
|
|
|
|
|
|
|
def cleanUserspacePM(self):
|
|
|
|
if self.xpParam.getParam(MpParamXp.KERNELPMC) != "netlink":
|
|
|
|
print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !")
|
|
|
|
else:
|
|
|
|
upmc = self.xpParam.getParam(MpParamXp.USERPMC)
|
2015-02-23 11:30:32 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, "killall " + upmc)
|
2015-02-23 11:26:32 +00:00
|
|
|
if self.xpParam.getParam(MpParamXp.KERNELPMS) != "netlink":
|
|
|
|
print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !")
|
|
|
|
else:
|
|
|
|
upms = self.xpParam.getParam(MpParamXp.USERPMS)
|
2015-02-23 11:30:32 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.server, "killall " + upms)
|
2015-02-23 11:26:32 +00:00
|
|
|
|
2015-01-20 10:04:36 +00:00
|
|
|
def runNetemAt(self):
|
|
|
|
if not self.mpTopo.changeNetem == "yes":
|
2015-01-16 02:59:52 +00:00
|
|
|
print("I don't need to change netem")
|
2015-01-20 10:04:36 +00:00
|
|
|
return
|
|
|
|
print("Will change netem config on the fly")
|
|
|
|
links = self.mpTopo.getLinkCharacteristics()
|
2015-01-20 11:23:57 +00:00
|
|
|
i = 0
|
2015-01-20 10:04:36 +00:00
|
|
|
for l in links:
|
2015-01-20 11:23:57 +00:00
|
|
|
lname = self.mpConfig.getMidLeftName(i)
|
|
|
|
rname = self.mpConfig.getMidRightName(i)
|
|
|
|
lbox = self.mpTopo.getHost(lname)
|
|
|
|
lif = self.mpConfig.getMidL2RInterface(i)
|
|
|
|
rif = self.mpConfig.getMidR2LInterface(i)
|
|
|
|
rbox = self.mpTopo.getHost(rname)
|
|
|
|
print(str(lname) + " " + str(lif))
|
|
|
|
print(str(rname) + " " + str(rif))
|
|
|
|
print("boxes " + str(lbox) + " " + str(rbox))
|
|
|
|
cmd = l.buildNetemCmd(lif)
|
2015-01-20 10:04:36 +00:00
|
|
|
print(cmd)
|
2015-01-20 11:23:57 +00:00
|
|
|
self.mpTopo.commandTo(lbox, cmd)
|
|
|
|
cmd = l.buildNetemCmd(rif)
|
|
|
|
print(cmd)
|
|
|
|
self.mpTopo.commandTo(rbox, cmd)
|
2019-11-28 08:32:49 +00:00
|
|
|
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)
|
|
|
|
|
2015-01-20 11:23:57 +00:00
|
|
|
i = i + 1
|
2015-01-20 10:04:36 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def run(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def clean(self):
|
2015-01-12 15:34:41 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client,
|
|
|
|
"killall tcpdump")
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.server,
|
|
|
|
"killall tcpdump")
|
2015-01-14 14:19:39 +00:00
|
|
|
self.backUpSysctl()
|
2015-02-23 11:26:32 +00:00
|
|
|
self.cleanUserspacePM()
|
2015-01-08 18:52:45 +00:00
|
|
|
pass
|
|
|
|
|
2015-01-14 14:19:39 +00:00
|
|
|
def setupSysctl(self):
|
|
|
|
self.saveSysctl()
|
|
|
|
self.writeSysctl()
|
|
|
|
|
|
|
|
def saveSysctl(self):
|
|
|
|
self.sysctlBUP = {}
|
2015-02-23 10:32:22 +00:00
|
|
|
self._saveSysctl(MpParamXp.sysctlKey, self.sysctlBUP)
|
|
|
|
self.sysctlBUPC = {}
|
|
|
|
self._saveSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC,
|
|
|
|
ns = True, who = self.mpConfig.client)
|
|
|
|
self.sysctlBUPS = {}
|
|
|
|
self._saveSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS,
|
|
|
|
ns = True, who = self.mpConfig.server)
|
|
|
|
|
|
|
|
def _saveSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
|
|
|
|
for k in sysctlDic:
|
|
|
|
sysctlKey = sysctlDic[k]
|
2015-01-14 14:19:39 +00:00
|
|
|
cmd = self.cmdReadSysctl(sysctlKey)
|
2015-02-23 10:32:22 +00:00
|
|
|
if not ns:
|
|
|
|
val = self.mpTopo.notNSCommand(cmd)
|
|
|
|
else:
|
|
|
|
val = self.mpTopo.commandTo(who, cmd)
|
2015-01-14 14:19:39 +00:00
|
|
|
if val == "Error":
|
|
|
|
print("oooops can't get sysctl " + sysctlKey)
|
|
|
|
else:
|
2015-02-23 10:32:22 +00:00
|
|
|
sysctlBUP[k] = val.split(" ",2)[2][:-1]
|
|
|
|
|
2015-01-14 14:19:39 +00:00
|
|
|
|
|
|
|
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):
|
2015-02-23 10:32:22 +00:00
|
|
|
self._writeSysctl(MpParamXp.sysctlKey, self.sysctlBUP)
|
|
|
|
self._writeSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC,
|
|
|
|
ns = True, who = self.mpConfig.client)
|
|
|
|
self._writeSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS,
|
|
|
|
ns = True, who = self.mpConfig.server)
|
|
|
|
|
|
|
|
def _writeSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
|
|
|
|
for k in sysctlBUP:
|
|
|
|
sysctlKey = sysctlDic[k]
|
2015-01-14 14:19:39 +00:00
|
|
|
sysctlValue = self.xpParam.getParam(k)
|
|
|
|
cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue)
|
2015-02-23 10:32:22 +00:00
|
|
|
if not ns:
|
|
|
|
val = self.mpTopo.notNSCommand(cmd)
|
|
|
|
else:
|
|
|
|
val = self.mpTopo.commandTo(who, cmd)
|
2015-01-14 14:19:39 +00:00
|
|
|
if val == "Error":
|
|
|
|
print("oooops can't set sysctl " + sysctlKey)
|
|
|
|
|
2015-02-23 10:32:22 +00:00
|
|
|
|
2015-01-14 14:19:39 +00:00
|
|
|
def backUpSysctl(self):
|
2015-02-23 10:32:22 +00:00
|
|
|
self._backUpSysctl(MpParamXp.sysctlKey, self.sysctlBUP)
|
|
|
|
self._backUpSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC,
|
|
|
|
ns = True, who = self.mpConfig.client)
|
|
|
|
self._backUpSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS,
|
|
|
|
ns = True, who = self.mpConfig.server)
|
|
|
|
|
|
|
|
|
|
|
|
def _backUpSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None):
|
|
|
|
for k in sysctlBUP:
|
2015-02-23 10:40:04 +00:00
|
|
|
sysctlKey = sysctlDic[k]
|
2015-02-23 10:32:22 +00:00
|
|
|
sysctlValue = sysctlBUP[k]
|
2015-01-14 14:19:39 +00:00
|
|
|
cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue)
|
2015-02-23 10:32:22 +00:00
|
|
|
if not ns:
|
|
|
|
val = self.mpTopo.notNSCommand(cmd)
|
|
|
|
else:
|
|
|
|
val = self.mpTopo.commandTo(who, cmd)
|
|
|
|
|
2015-01-14 14:19:39 +00:00
|
|
|
if val == "Error":
|
|
|
|
print("oooops can't set sysctl " + sysctlKey)
|
|
|
|
|
2015-02-23 10:32:22 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def runTcpDump(self):
|
2015-01-12 15:34:41 +00:00
|
|
|
#todo : replace filename by cst
|
2015-01-21 09:38:11 +00:00
|
|
|
cpcap = self.xpParam.getParam(MpParamXp.CLIENTPCAP)
|
|
|
|
spcap = self.xpParam.getParam(MpParamXp.SERVERPCAP)
|
2016-04-13 07:38:17 +00:00
|
|
|
snaplenpcap = self.xpParam.getParam(MpParamXp.SNAPLENPCAP)
|
2015-01-21 09:38:11 +00:00
|
|
|
if cpcap == "yes" :
|
2015-01-12 15:34:41 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.client,
|
2016-04-13 07:38:17 +00:00
|
|
|
"tcpdump -i any -s " + snaplenpcap + " -w client.pcap &")
|
2015-01-21 09:38:11 +00:00
|
|
|
if spcap == "yes" :
|
2015-04-27 10:00:03 +00:00
|
|
|
self.mpTopo.commandTo(self.mpConfig.server,
|
2016-04-13 07:38:17 +00:00
|
|
|
"tcpdump -i any -s " + snaplenpcap + " -w server.pcap &")
|
2015-01-21 09:38:11 +00:00
|
|
|
if spcap == "yes" or cpcap == "yes":
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client,"sleep 5")
|