From ed859c44fa0a55eaeb876a1a55674d6583061f92 Mon Sep 17 00:00:00 2001 From: Benjamin Hesmans Date: Wed, 27 Apr 2016 16:08:21 +0200 Subject: [PATCH] Added VLC experience Signed-off-by: Benjamin Hesmans Signed-off-by: Quentin De Coninck --- src/conf/vlc/topo | 11 +++++ src/conf/vlc/xp | 6 +++ src/mpExperience.py | 1 + src/mpExperienceVLC.py | 91 ++++++++++++++++++++++++++++++++++++++++++ src/mpParamXp.py | 4 ++ src/mpXpRunner.py | 4 ++ 6 files changed, 117 insertions(+) create mode 100644 src/conf/vlc/topo create mode 100644 src/conf/vlc/xp create mode 100644 src/mpExperienceVLC.py diff --git a/src/conf/vlc/topo b/src/conf/vlc/topo new file mode 100644 index 0000000..9897e71 --- /dev/null +++ b/src/conf/vlc/topo @@ -0,0 +1,11 @@ +desc:Simple configuration with two para link +leftSubnet:10.0. +rightSubnet:10.1. +#path_x:delay,queueSize(may be calc),bw +path_0:10,20,2 +path_1:40,5,1,True +topoType:MultiIf +changeNetem:yes +#netem_{path_id}:at,cmd +netemAt_0:10,delay 10ms limit 1 +#netemAt_0:5,delay 2ms limit 15 loss 10% diff --git a/src/conf/vlc/xp b/src/conf/vlc/xp new file mode 100644 index 0000000..c5d84b8 --- /dev/null +++ b/src/conf/vlc/xp @@ -0,0 +1,6 @@ +xpType:vlc +clientPcap:yes +kpms:fullmesh +kpmc:fullmesh +vlctime:20 +sched:metric diff --git a/src/mpExperience.py b/src/mpExperience.py index 69e2b66..425bb05 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -12,6 +12,7 @@ class MpExperience: AB = "ab" SIRI = "siri" SENDFILE = "sendfile" + VLC = "vlc" def __init__(self, xpParam, mpTopo, mpConfig): self.xpParam = xpParam diff --git a/src/mpExperienceVLC.py b/src/mpExperienceVLC.py new file mode 100644 index 0000000..e6e6dc8 --- /dev/null +++ b/src/mpExperienceVLC.py @@ -0,0 +1,91 @@ +from mpExperience import MpExperience +from mpParamXp import MpParamXp +from mpPvAt import MpPvAt +import os + +class MpExperienceVLC(MpExperience): + SERVER_LOG = "vlc_server.log" + CLIENT_LOG = "vlc_client.log" + VLC_BIN = "/home/mininet/git/vlc/vlc" + PING_OUTPUT = "ping.log" + + def __init__(self, xpParamFile, mpTopo, mpConfig): + MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig) + self.loadParam() + self.ping() + MpExperience.classicRun(self) + + def ping(self): + self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ + MpExperienceVLC.PING_OUTPUT ) + count = self.xpParam.getParam(MpParamXp.PINGCOUNT) + for i in range(0, self.mpConfig.getClientInterfaceCount()): + cmd = self.pingCommand(self.mpConfig.getClientIP(i), + self.mpConfig.getServerIP(), n = count) + self.mpTopo.commandTo(self.mpConfig.client, cmd) + + def pingCommand(self, fromIP, toIP, n=5): + s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ + " >> " + MpExperienceVLC.PING_OUTPUT + print(s) + return s + + def loadParam(self): + """ + todo : param LD_PRELOAD ?? + """ + self.file = self.xpParam.getParam(MpParamXp.VLCFILE) + self.time = self.xpParam.getParam(MpParamXp.VLCTIME) + # todo + # self.random_size = self.xpParam.getParam(MpParamXp.VLCRANDOMSIZE) + + def prepare(self): + MpExperience.prepare(self) + self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ + MpExperienceVLC.CLIENT_LOG ) + self.mpTopo.commandTo(self.mpConfig.client, "Xvfb :66 &") + self.mpTopo.commandTo(self.mpConfig.server, "rm " + \ + MpExperienceVLC.SERVER_LOG ) + if self.file == "random": + self.mpTopo.commandTo(self.mpConfig.client, + "dd if=/dev/urandom of=random bs=1K count=" + \ + self.random_size) + + def getVLCServerCmd(self): + s = "/etc/init.d/apache2 restart &>" + MpExperienceVLC.SERVER_LOG + " " + print(s) + return s + + def getVLCClientCmd(self): + s = MpExperienceVLC.VLC_BIN + " -I dummy --x11-display :66" + \ + " --adaptative-logic 3 --no-loop --play-and-exit " + \ + " http://" + self.mpConfig.getServerIP() + \ + "/" + self.file + " 2>&1 | grep -E '(Neb|halp|bandwidth)' > " + MpExperienceVLC.CLIENT_LOG + if self.time != "0" : + s = s + " &" + print(s) + return s + + def clean(self): + MpExperience.clean(self) + if self.file == "random": + self.mpTopo.commandTo(self.mpConfig.client, "rm random*") + self.mpTopo.commandTo(self.mpConfig.client, "pkill Xvfb") + #todo use cst + #self.mpTopo.commandTo(self.mpConfig.server, "killall netcat") + + + def run(self): + cmd = self.getVLCServerCmd() + self.mpTopo.commandTo(self.mpConfig.server, cmd) + + self.mpTopo.commandTo(self.mpConfig.client, "sleep 1") + cmd = self.getVLCClientCmd() + self.mpTopo.commandTo(self.mpConfig.client, cmd) + + if self.time != "0" : + self.mpTopo.commandTo(self.mpConfig.client, "sleep " + self.time) + self.mpTopo.commandTo(self.mpConfig.client, "pkill -9 vlc") + + self.mpTopo.getCLI() + self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") diff --git a/src/mpParamXp.py b/src/mpParamXp.py index 6bf2804..c68cbe8 100644 --- a/src/mpParamXp.py +++ b/src/mpParamXp.py @@ -47,6 +47,8 @@ class MpParamXp(MpParam): SIRIMAXPAYLOADSIZE = "siriMaxPayloadSize" SIRIINTERVALTIMEMS = "siriIntervalTimeMs" SIRIBUFFERSIZE = "siriBufferSize" + VLCFILE = "vlcFile" + VLCTIME = "vlcTime" # global sysctl @@ -109,6 +111,8 @@ class MpParamXp(MpParam): defaultValue[SIRIMAXPAYLOADSIZE] = "500" defaultValue[SIRIINTERVALTIMEMS] = "333" defaultValue[SIRIBUFFERSIZE] = "9" + defaultValue[VLCFILE] = "bunny_ibmff_360.mpd" + defaultValue[VLCTIME] = "0" def __init__(self, paramFile): MpParam.__init__(self, paramFile) diff --git a/src/mpXpRunner.py b/src/mpXpRunner.py index 04f6459..b32813e 100644 --- a/src/mpXpRunner.py +++ b/src/mpXpRunner.py @@ -15,6 +15,7 @@ from mpExperienceEpload import MpExperienceEpload from mpExperienceNetperf import MpExperienceNetperf from mpExperienceAb import MpExperienceAb from mpExperienceSiri import MpExperienceSiri +from mpExperienceVLC import MpExperienceVLC from mpExperienceNone import MpExperienceNone from mpExperience import MpExperience from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo @@ -103,6 +104,9 @@ class MpXpRunner: elif xp == MpExperience.SENDFILE: MpExperienceSendFile(self.xpParam, self.mpTopo, self.mpTopoConfig) + elif xp == MpExperience.VLC: + MpExperienceVLC(self.xpParam, self.mpTopo, + self.mpTopoConfig) else: print("Unfound xp type..." + xp)