add changePvAt to control application rate
During an experiment, you can change the application rate with the param changePvAt:when,-L XX(unit) Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
parent
d76f0c7f0c
commit
6576eb330f
@ -1,4 +1,10 @@
|
|||||||
xpType:ncpv
|
xpType:ncpv
|
||||||
ncClientPort_0:33400
|
ncClientPort_0:33400
|
||||||
clientPcap:yes
|
clientPcap:yes
|
||||||
|
ddCount:15000
|
||||||
|
pvRateLimit:100k
|
||||||
sched:roundrobin
|
sched:roundrobin
|
||||||
|
changePv:yes
|
||||||
|
changePvAt:5,-L 200k
|
||||||
|
changePvAt:10,-L 100k
|
||||||
|
changePvAt:15,-L 600k
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from mpExperience import MpExperience
|
from mpExperience import MpExperience
|
||||||
from mpParamXp import MpParamXp
|
from mpParamXp import MpParamXp
|
||||||
|
from mpPvAt import MpPvAt
|
||||||
|
|
||||||
class MpExperienceNCPV(MpExperience):
|
class MpExperienceNCPV(MpExperience):
|
||||||
"""
|
"""
|
||||||
@ -32,7 +33,47 @@ class MpExperienceNCPV(MpExperience):
|
|||||||
if len(self.ncClientPort) == 0:
|
if len(self.ncClientPort) == 0:
|
||||||
d = self.xpParam.getParam(MpParamXp.NCCLIENTPORT)
|
d = self.xpParam.getParam(MpParamXp.NCCLIENTPORT)
|
||||||
self.ncClientPort.append(d)
|
self.ncClientPort.append(d)
|
||||||
|
self.loadPvAt()
|
||||||
|
|
||||||
|
def loadPvAt(self):
|
||||||
|
self.changePvAt = []
|
||||||
|
self.changePv = self.xpParam.getParam(MpParamXp.CHANGEPV)
|
||||||
|
if self.changePv != "yes":
|
||||||
|
print("Don't change pv rate...")
|
||||||
|
return
|
||||||
|
changePvAt = self.xpParam.getParam(MpParamXp.CHANGEPVAT)
|
||||||
|
if not isinstance(changePvAt, list):
|
||||||
|
changePvAt = [changePvAt]
|
||||||
|
for p in changePvAt:
|
||||||
|
tab = p.split(",")
|
||||||
|
if len(tab)==2:
|
||||||
|
o = MpPvAt(float(tab[0]), tab[1])
|
||||||
|
self.addPvAt(o)
|
||||||
|
else:
|
||||||
|
print("pv wrong line : " + n)
|
||||||
|
|
||||||
|
def addPvAt(self, p):
|
||||||
|
if len(self.changePvAt) == 0 :
|
||||||
|
p.delta = p.at
|
||||||
|
else:
|
||||||
|
if p.at > self.changePvAt[-1].at:
|
||||||
|
p.delta = p.at - self.changePvAt[-1].at
|
||||||
|
else:
|
||||||
|
print("Do not take into account " + p.__str__() + \
|
||||||
|
"because ooo !")
|
||||||
|
return
|
||||||
|
|
||||||
|
self.changePvAt.append(p)
|
||||||
|
|
||||||
|
def getPvChangeCmd(self):
|
||||||
|
cmd = ""
|
||||||
|
for p in self.changePvAt:
|
||||||
|
cmd = cmd + "sleep " + str(p.delta)
|
||||||
|
cmd = cmd + " && "
|
||||||
|
cmd = cmd + MpExperienceNCPV.PV_BIN + " -R " + self.pvPid
|
||||||
|
cmd = cmd + " " + p.cmd + " && "
|
||||||
|
cmd = cmd + " true &"
|
||||||
|
return cmd
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
MpExperience.prepare(self)
|
MpExperience.prepare(self)
|
||||||
@ -64,6 +105,9 @@ class MpExperienceNCPV(MpExperience):
|
|||||||
"_" + str(id) + ".log"
|
"_" + str(id) + ".log"
|
||||||
print(s)
|
print(s)
|
||||||
return s
|
return s
|
||||||
|
def getPvPidCmd(self):
|
||||||
|
s = "pgrep -n pv"
|
||||||
|
return s
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
MpExperience.clean(self)
|
MpExperience.clean(self)
|
||||||
@ -77,6 +121,17 @@ class MpExperienceNCPV(MpExperience):
|
|||||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||||
|
|
||||||
cmd = self.getNCClientCmd(i)
|
cmd = self.getNCClientCmd(i)
|
||||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
self.mpConfig.client.sendCmd(cmd)
|
||||||
|
|
||||||
|
cmd = self.getPvPidCmd()
|
||||||
|
self.pvPid = self.mpTopo.commandTo(self.mpConfig.server, cmd)[:-1]
|
||||||
|
|
||||||
|
cmd = self.getPvChangeCmd()
|
||||||
|
print(cmd)
|
||||||
|
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||||
|
|
||||||
|
|
||||||
|
self.mpConfig.client.waitOutput()
|
||||||
|
|
||||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1")
|
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1")
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class MpMininetBuilder(Topo):
|
|||||||
self.net = None
|
self.net = None
|
||||||
|
|
||||||
def commandTo(self, who, cmd):
|
def commandTo(self, who, cmd):
|
||||||
who.cmd(cmd)
|
return who.cmd(cmd)
|
||||||
|
|
||||||
def notNSCommand(self, cmd):
|
def notNSCommand(self, cmd):
|
||||||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||||
|
@ -21,9 +21,8 @@ class MpParam:
|
|||||||
k = tab[0]
|
k = tab[0]
|
||||||
val = tab[1][:-1]
|
val = tab[1][:-1]
|
||||||
if k in self.paramDic:
|
if k in self.paramDic:
|
||||||
tmp = self.paramDic[k]
|
if not isinstance(self.paramDic[k], list):
|
||||||
self.paramDic[k] = []
|
self.paramDic[k] = [self.paramDic[k]]
|
||||||
self.paramDic[k].append(tmp)
|
|
||||||
self.paramDic[k].append(val)
|
self.paramDic[k].append(val)
|
||||||
else:
|
else:
|
||||||
self.paramDic[k] = val
|
self.paramDic[k] = val
|
||||||
|
@ -17,6 +17,8 @@ class MpParamXp(MpParam):
|
|||||||
PVZ = "pvZ"
|
PVZ = "pvZ"
|
||||||
NCSERVERPORT = "ncServerPort"
|
NCSERVERPORT = "ncServerPort"
|
||||||
NCCLIENTPORT = "ncClientPort"
|
NCCLIENTPORT = "ncClientPort"
|
||||||
|
CHANGEPV = "changePv"
|
||||||
|
CHANGEPVAT = "changePvAt"
|
||||||
|
|
||||||
# global sysctl
|
# global sysctl
|
||||||
sysctlKey = {}
|
sysctlKey = {}
|
||||||
@ -45,6 +47,7 @@ class MpParamXp(MpParam):
|
|||||||
defaultValue[PVG] = "10000"
|
defaultValue[PVG] = "10000"
|
||||||
defaultValue[NCSERVERPORT] = "33666"
|
defaultValue[NCSERVERPORT] = "33666"
|
||||||
defaultValue[NCCLIENTPORT] = "33555"
|
defaultValue[NCCLIENTPORT] = "33555"
|
||||||
|
defaultValue[CHANGEPV] = "no"
|
||||||
|
|
||||||
def __init__(self, paramFile):
|
def __init__(self, paramFile):
|
||||||
MpParam.__init__(self, paramFile)
|
MpParam.__init__(self, paramFile)
|
||||||
|
9
src/mpPvAt.py
Normal file
9
src/mpPvAt.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class MpPvAt:
|
||||||
|
def __init__(self, at, cmd):
|
||||||
|
self.at = at
|
||||||
|
self.cmd = cmd
|
||||||
|
self.delta = 0
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Pv... at " + str(self.at) + "(" + str(self.delta) + \
|
||||||
|
") will be " + self.cmd
|
@ -24,7 +24,7 @@ class MpTopo:
|
|||||||
|
|
||||||
def commandTo(self, who, cmd):
|
def commandTo(self, who, cmd):
|
||||||
self.logFile.write(who.__str__() + " : " + cmd + "\n")
|
self.logFile.write(who.__str__() + " : " + cmd + "\n")
|
||||||
self.topoBuilder.commandTo(who, cmd)
|
return self.topoBuilder.commandTo(who, cmd)
|
||||||
|
|
||||||
def notNSCommand(self, cmd):
|
def notNSCommand(self, cmd):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user