diff --git a/src/conf/xp/3_ncpv b/src/conf/xp/3_ncpv index e912247..7afe0ea 100644 --- a/src/conf/xp/3_ncpv +++ b/src/conf/xp/3_ncpv @@ -1,4 +1,10 @@ xpType:ncpv ncClientPort_0:33400 clientPcap:yes +ddCount:15000 +pvRateLimit:100k sched:roundrobin +changePv:yes +changePvAt:5,-L 200k +changePvAt:10,-L 100k +changePvAt:15,-L 600k diff --git a/src/mpExperienceNCPV.py b/src/mpExperienceNCPV.py index 23bf7f8..9c4c677 100644 --- a/src/mpExperienceNCPV.py +++ b/src/mpExperienceNCPV.py @@ -1,5 +1,6 @@ from mpExperience import MpExperience from mpParamXp import MpParamXp +from mpPvAt import MpPvAt class MpExperienceNCPV(MpExperience): """ @@ -32,7 +33,47 @@ class MpExperienceNCPV(MpExperience): if len(self.ncClientPort) == 0: d = self.xpParam.getParam(MpParamXp.NCCLIENTPORT) 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): MpExperience.prepare(self) @@ -64,6 +105,9 @@ class MpExperienceNCPV(MpExperience): "_" + str(id) + ".log" print(s) return s + def getPvPidCmd(self): + s = "pgrep -n pv" + return s def clean(self): MpExperience.clean(self) @@ -77,6 +121,17 @@ class MpExperienceNCPV(MpExperience): self.mpTopo.commandTo(self.mpConfig.server, cmd) 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") diff --git a/src/mpMininetBuilder.py b/src/mpMininetBuilder.py index 4a5e30b..764e254 100644 --- a/src/mpMininetBuilder.py +++ b/src/mpMininetBuilder.py @@ -10,7 +10,7 @@ class MpMininetBuilder(Topo): self.net = None def commandTo(self, who, cmd): - who.cmd(cmd) + return who.cmd(cmd) def notNSCommand(self, cmd): p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) diff --git a/src/mpParam.py b/src/mpParam.py index e761c01..c6a42ac 100644 --- a/src/mpParam.py +++ b/src/mpParam.py @@ -21,9 +21,8 @@ class MpParam: k = tab[0] val = tab[1][:-1] if k in self.paramDic: - tmp = self.paramDic[k] - self.paramDic[k] = [] - self.paramDic[k].append(tmp) + if not isinstance(self.paramDic[k], list): + self.paramDic[k] = [self.paramDic[k]] self.paramDic[k].append(val) else: self.paramDic[k] = val diff --git a/src/mpParamXp.py b/src/mpParamXp.py index 70ec9ed..2626f13 100644 --- a/src/mpParamXp.py +++ b/src/mpParamXp.py @@ -17,6 +17,8 @@ class MpParamXp(MpParam): PVZ = "pvZ" NCSERVERPORT = "ncServerPort" NCCLIENTPORT = "ncClientPort" + CHANGEPV = "changePv" + CHANGEPVAT = "changePvAt" # global sysctl sysctlKey = {} @@ -45,6 +47,7 @@ class MpParamXp(MpParam): defaultValue[PVG] = "10000" defaultValue[NCSERVERPORT] = "33666" defaultValue[NCCLIENTPORT] = "33555" + defaultValue[CHANGEPV] = "no" def __init__(self, paramFile): MpParam.__init__(self, paramFile) diff --git a/src/mpPvAt.py b/src/mpPvAt.py new file mode 100644 index 0000000..9e1af2b --- /dev/null +++ b/src/mpPvAt.py @@ -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 diff --git a/src/mpTopo.py b/src/mpTopo.py index c1c0b7b..2537f24 100644 --- a/src/mpTopo.py +++ b/src/mpTopo.py @@ -24,7 +24,7 @@ class MpTopo: def commandTo(self, who, cmd): self.logFile.write(who.__str__() + " : " + cmd + "\n") - self.topoBuilder.commandTo(who, cmd) + return self.topoBuilder.commandTo(who, cmd) def notNSCommand(self, cmd): """