From fe2f17272bf79345fa5c318e620c1538d975b2be Mon Sep 17 00:00:00 2001 From: Julien Tribino Date: Fri, 18 Jan 2013 17:58:07 +0100 Subject: [PATCH] add some vlc experiments examples --- examples/omf-iminds-vlc.py | 117 ++++++++++++++++++++++++++++ examples/omf-nitos-vlc.py | 117 ++++++++++++++++++++++++++++ examples/omf-plexuslab-vlc.py | 12 +-- src/nepi/testbeds/omf/omf_client.py | 2 +- 4 files changed, 242 insertions(+), 6 deletions(-) create mode 100644 examples/omf-iminds-vlc.py create mode 100644 examples/omf-nitos-vlc.py diff --git a/examples/omf-iminds-vlc.py b/examples/omf-iminds-vlc.py new file mode 100644 index 00000000..d3a8ec02 --- /dev/null +++ b/examples/omf-iminds-vlc.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# +# Experiment Topology: +# +# n1 --- n2 +# 0.1 0.2 +# + +from nepi.core.design import ExperimentDescription, FactoriesProvider +from nepi.core.execute import ExperimentController +import getpass +import logging +import tempfile +import time + +logging.basicConfig(level=logging.DEBUG) + +root_dir = tempfile.mkdtemp() + +exp_desc = ExperimentDescription() + +testbed_id = "omf" +omf_provider = FactoriesProvider(testbed_id) +omf_desc = exp_desc.add_testbed_description(omf_provider) +omf_desc.set_attribute_value("homeDirectory", root_dir) +omf_desc.set_attribute_value("enableDebug", True) +omf_desc.set_attribute_value("xmppSlice", "default_slice_iMinds") +omf_desc.set_attribute_value("xmppHost", "xmpp.ilabt.iminds.be") +omf_desc.set_attribute_value("xmppPort", 5222) +omf_desc.set_attribute_value("xmppPassword", "1234") + +# Add node1 +node1 = omf_desc.create("Node") +node1.set_attribute_value("hostname", "omf.ibbt.open.node3") + +# Add configuration for interface 1 +iface1 = omf_desc.create("WifiInterface") +iface1.set_attribute_value("alias", "w0") +iface1.set_attribute_value("mode", "adhoc") +iface1.set_attribute_value("channel", "6") +iface1.set_attribute_value("type", "g") +iface1.set_attribute_value("essid", "cvlcmode") +iface1.set_attribute_value("ip", "192.168.0.3") +node1.connector("devs").connect(iface1.connector("node")) + +# Add multicast route to node 1 +route1 = node1.add_route() +route1.set_attribute_value("Destination", "224.0.0.0") +route1.set_attribute_value("NetPrefix", 4) +route1.set_attribute_value("Device", "wlan0") + +# Add node2 +node2 = omf_desc.create("Node") +node2.set_attribute_value("hostname", "omf.ibbt.open.node4") + +# Add configuration for interface 2 +iface2 = omf_desc.create("WifiInterface") +iface2.set_attribute_value("alias", "w0") +iface2.set_attribute_value("mode", "adhoc") +iface2.set_attribute_value("channel", "6") +iface2.set_attribute_value("type", "g") +iface2.set_attribute_value("essid", "cvlcmode") +iface2.set_attribute_value("ip", "192.168.0.4") +node2.connector("devs").connect(iface2.connector("node")) + +# Add multicast route to node 2 +route2 = node2.add_route() +route2.set_attribute_value("Destination", "224.0.0.0") +route2.set_attribute_value("NetPrefix", 4) +route2.set_attribute_value("Device", "wlan0") + +# Add a channel +channel = omf_desc.create("Channel") +channel.set_attribute_value("mode", "adhoc") +channel.set_attribute_value("channel", "6") +channel.set_attribute_value("type", "g") +channel.set_attribute_value("essid", "cvlcmode") +channel.connector("devs").connect(iface1.connector("chan")) +channel.connector("devs").connect(iface2.connector("chan")) + +# Add a vlc server to stream a video using multicast +app1 = omf_desc.create("OmfApplication") +app1.set_attribute_value("appId", "Vlc#1") +app1.set_attribute_value("arguments", "/opt/bbb_240p_mpeg4_lq.ts --sout '#rtp{dst=239.255.0.1,port=1234,mux=ts}' vlc://quit") +app1.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") +app1.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority") +app1.connector("node").connect(node1.connector("apps")) + +# Add a vlc client to receive the video stream +app2 = omf_desc.create("OmfApplication") +app2.set_attribute_value("appId", "Vlc#2") +app2.set_attribute_value("arguments", "rtp://239.255.0.1:1234") +app2.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") +# To see the stream to a ssh -X connection, the DISPLAY variable must be set to the value of the node. +# Also don't forget to execute in 'xhost + localhost' in the node +app2.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority") +app2.connector("node").connect(node2.connector("apps")) + +xml = exp_desc.to_xml() + +controller = ExperimentController(xml, root_dir) +controller.start() +#while not (controller.is_finished(app1.guid) and \ +# controller.is_finished(app2.guid)): +# time.sleep(0.5) + +time.sleep(10) + +#controller.set(iface2.guid, "channel", "1") + +#time.sleep(5) + +controller.stop() +controller.shutdown() + diff --git a/examples/omf-nitos-vlc.py b/examples/omf-nitos-vlc.py new file mode 100644 index 00000000..3475703f --- /dev/null +++ b/examples/omf-nitos-vlc.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# +# Experiment Topology: +# +# n1 --- n2 +# 0.1 0.2 +# + +from nepi.core.design import ExperimentDescription, FactoriesProvider +from nepi.core.execute import ExperimentController +import getpass +import logging +import tempfile +import time + +logging.basicConfig(level=logging.DEBUG) + +root_dir = tempfile.mkdtemp() + +exp_desc = ExperimentDescription() + +testbed_id = "omf" +omf_provider = FactoriesProvider(testbed_id) +omf_desc = exp_desc.add_testbed_description(omf_provider) +omf_desc.set_attribute_value("homeDirectory", root_dir) +omf_desc.set_attribute_value("enableDebug", True) +omf_desc.set_attribute_value("xmppSlice", "tribino") +omf_desc.set_attribute_value("xmppHost", "nitlab.inf.uth.gr") +omf_desc.set_attribute_value("xmppPort", 5222) +omf_desc.set_attribute_value("xmppPassword", "1234") + +# Add node1 +node1 = omf_desc.create("Node") +node1.set_attribute_value("hostname", "omf.nitos.node019") + +# Add configuration for interface 1 +iface1 = omf_desc.create("WifiInterface") +iface1.set_attribute_value("alias", "w0") +iface1.set_attribute_value("mode", "adhoc") +iface1.set_attribute_value("channel", "6") +iface1.set_attribute_value("type", "g") +iface1.set_attribute_value("essid", "cvlcmode") +iface1.set_attribute_value("ip", "192.168.0.19") +node1.connector("devs").connect(iface1.connector("node")) + +# Add multicast route to node 1 +route1 = node1.add_route() +route1.set_attribute_value("Destination", "224.0.0.0") +route1.set_attribute_value("NetPrefix", 4) +route1.set_attribute_value("Device", "wlan0") + +# Add node2 +node2 = omf_desc.create("Node") +node2.set_attribute_value("hostname", "omf.nitos.node020") + +# Add configuration for interface 2 +iface2 = omf_desc.create("WifiInterface") +iface2.set_attribute_value("alias", "w0") +iface2.set_attribute_value("mode", "adhoc") +iface2.set_attribute_value("channel", "6") +iface2.set_attribute_value("type", "g") +iface2.set_attribute_value("essid", "cvlcmode") +iface2.set_attribute_value("ip", "192.168.0.20") +node2.connector("devs").connect(iface2.connector("node")) + +# Add multicast route to node 2 +route2 = node2.add_route() +route2.set_attribute_value("Destination", "224.0.0.0") +route2.set_attribute_value("NetPrefix", 4) +route2.set_attribute_value("Device", "wlan0") + +# Add a channel +channel = omf_desc.create("Channel") +channel.set_attribute_value("mode", "adhoc") +channel.set_attribute_value("channel", "6") +channel.set_attribute_value("type", "g") +channel.set_attribute_value("essid", "cvlcmode") +channel.connector("devs").connect(iface1.connector("chan")) +channel.connector("devs").connect(iface2.connector("chan")) + +# Add a vlc server to stream a video using multicast +app1 = omf_desc.create("OmfApplication") +app1.set_attribute_value("appId", "Vlc#1") +app1.set_attribute_value("arguments", "/opt/bbb_240p_mpeg4_lq.ts --sout '#rtp{dst=239.255.0.1,port=1234,mux=ts}' vlc://quit") +app1.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") +app1.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority") +app1.connector("node").connect(node1.connector("apps")) + +# Add a vlc client to receive the video stream +app2 = omf_desc.create("OmfApplication") +app2.set_attribute_value("appId", "Vlc#2") +app2.set_attribute_value("arguments", "rtp://239.255.0.1:1234") +app2.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") +# To see the stream to a ssh -X connection, the DISPLAY variable must be set to the value of the node. +# Also don't forget to execute in 'xhost + localhost' in the node +app2.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority") +app2.connector("node").connect(node2.connector("apps")) + +xml = exp_desc.to_xml() + +controller = ExperimentController(xml, root_dir) +controller.start() +#while not (controller.is_finished(app1.guid) and \ +# controller.is_finished(app2.guid)): +# time.sleep(0.5) + +time.sleep(10) + +#controller.set(iface2.guid, "channel", "1") + +#time.sleep(5) + +controller.stop() +controller.shutdown() + diff --git a/examples/omf-plexuslab-vlc.py b/examples/omf-plexuslab-vlc.py index ff20b5f2..0601cd03 100644 --- a/examples/omf-plexuslab-vlc.py +++ b/examples/omf-plexuslab-vlc.py @@ -42,7 +42,7 @@ iface1.set_attribute_value("mode", "adhoc") iface1.set_attribute_value("channel", "6") iface1.set_attribute_value("type", "g") iface1.set_attribute_value("essid", "cvlcmode") -iface1.set_attribute_value("ip", "192.168.0.17") +iface1.set_attribute_value("ip", "10.0.0.17") node1.connector("devs").connect(iface1.connector("node")) # Add multicast route to node 1 @@ -62,7 +62,7 @@ iface2.set_attribute_value("mode", "adhoc") iface2.set_attribute_value("channel", "6") iface2.set_attribute_value("type", "g") iface2.set_attribute_value("essid", "cvlcmode") -iface2.set_attribute_value("ip", "192.168.0.37") +iface2.set_attribute_value("ip", "10.0.0.37") node2.connector("devs").connect(iface2.connector("node")) # Add multicast route to node 2 @@ -83,7 +83,8 @@ channel.connector("devs").connect(iface2.connector("chan")) # Add a vlc server to stream a video using multicast app1 = omf_desc.create("OmfApplication") app1.set_attribute_value("appId", "Vlc#1") -app1.set_attribute_value("arguments", "/opt/bbb_240p_mpeg4_lq.ts --sout '#rtp{dst=239.255.0.1,port=1234,mux=ts}' vlc://quit") +#app1.set_attribute_value("arguments", "/opt/bbb_240p_mpeg4_lq.ts --sout '#rtp{dst=239.255.0.1,port=1234,mux=ts}' vlc://quit") +app1.set_attribute_value("arguments", "/opt/bbb_240p_mpeg4_lq.ts --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}' vlc://quit") app1.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") app1.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority") app1.connector("node").connect(node1.connector("apps")) @@ -91,7 +92,8 @@ app1.connector("node").connect(node1.connector("apps")) # Add a vlc client to receive the video stream app2 = omf_desc.create("OmfApplication") app2.set_attribute_value("appId", "Vlc#2") -app2.set_attribute_value("arguments", "rtp://239.255.0.1:1234") +#app2.set_attribute_value("arguments", "rtp://239.255.0.1:1234") +app2.set_attribute_value("arguments", "rtp://10.0.0.37:1234") app2.set_attribute_value("path", "/opt/vlc-1.1.13/cvlc") # To see the stream to a ssh -X connection, the DISPLAY variable must be set to the value of the node. # Also don't forget to execute in 'xhost + localhost' in the node @@ -106,7 +108,7 @@ controller.start() # controller.is_finished(app2.guid)): # time.sleep(0.5) -time.sleep(5) +time.sleep(30) #controller.set(iface2.guid, "channel", "1") diff --git a/src/nepi/testbeds/omf/omf_client.py b/src/nepi/testbeds/omf/omf_client.py index fd1b9306..eb3d2d84 100644 --- a/src/nepi/testbeds/omf/omf_client.py +++ b/src/nepi/testbeds/omf/omf_client.py @@ -21,7 +21,7 @@ class OMFClient(sleekxmpp.ClientXMPP): self.add_event_handler("pubsub_publish", self.handle_omf_message) self._logger = logging.getLogger("nepi.testbeds.omf") - + @property def ready(self): return self._ready -- 2.47.0