2020-06-24 15:18:40 +00:00
|
|
|
from core.experience import Experience, ExperienceParameter
|
|
|
|
import os
|
|
|
|
|
|
|
|
class VLC(Experience):
|
|
|
|
NAME = "vlc"
|
|
|
|
|
|
|
|
SERVER_LOG = "vlc_server.log"
|
|
|
|
CLIENT_LOG = "vlc_client.log"
|
|
|
|
VLC_BIN = "/home/mininet/vlc/vlc"
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def __init__(self, experience_parameter_filename, topo, topo_config):
|
|
|
|
super(VLC, self).__init__(experience_parameter_filename, topo, topo_config)
|
|
|
|
self.load_parameters()
|
2020-06-24 15:18:40 +00:00
|
|
|
self.ping()
|
|
|
|
|
|
|
|
def ping(self):
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
VLC.PING_OUTPUT )
|
2020-06-25 08:53:56 +00:00
|
|
|
count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
|
|
|
|
for i in range(0, self.topo_config.getClientInterfaceCount()):
|
|
|
|
cmd = self.pingCommand(self.topo_config.getClientIP(i),
|
|
|
|
self.topo_config.getServerIP(), n = count)
|
|
|
|
self.topo.command_to(self.topo_config.client, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def pingCommand(self, fromIP, toIP, n=5):
|
|
|
|
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
|
|
|
" >> " + VLC.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def load_parameters(self):
|
2020-06-25 08:53:56 +00:00
|
|
|
self.file = self.experience_parameter.get(ExperienceParameter.VLCFILE)
|
|
|
|
self.time = self.experience_parameter.get(ExperienceParameter.VLCTIME)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(VLC, self).prepare()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
VLC.CLIENT_LOG )
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "Xvfb :66 &")
|
|
|
|
self.topo.command_to(self.topo_config.server, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
VLC.SERVER_LOG )
|
|
|
|
if self.file == "random":
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client,
|
2020-06-24 15:18:40 +00:00
|
|
|
"dd if=/dev/urandom of=random bs=1K count=" + \
|
|
|
|
self.random_size)
|
|
|
|
|
|
|
|
def getVLCServerCmd(self):
|
|
|
|
s = "/etc/init.d/apache2 restart &>" + VLC.SERVER_LOG + " "
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def getVLCClientCmd(self):
|
|
|
|
s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && " \
|
|
|
|
+ VLC.VLC_BIN + " -I dummy --x11-display :66" + \
|
|
|
|
" --adaptive-logic 3 --no-loop --play-and-exit " + \
|
2020-06-25 08:53:56 +00:00
|
|
|
" http://" + self.topo_config.getServerIP() + \
|
2020-06-24 15:18:40 +00:00
|
|
|
"/" + self.file + " 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > " + VLC.CLIENT_LOG
|
|
|
|
if self.time != "0" :
|
|
|
|
s = s + " &"
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
super(VLC, self).clean(self)
|
|
|
|
if self.file == "random":
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm random*")
|
|
|
|
self.topo.command_to(self.topo_config.client, "pkill Xvfb")
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
cmd = self.getVLCServerCmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.server, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 1")
|
2020-06-24 15:18:40 +00:00
|
|
|
cmd = self.getVLCClientCmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
if self.time != "0" :
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "sleep " + self.time)
|
|
|
|
self.topo.command_to(self.topo_config.client, "pkill -9 -f vlc")
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|