Bugfixing for ns3::MatrixPropagationLossModel ...
[nepi.git] / examples / omf_vlc.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 #
5 # Experiment Topology:
6 #
7 #  n1 --- n2
8 #  0.1   0.2 
9 #    
10
11 from nepi.core.design import ExperimentDescription, FactoriesProvider
12 from nepi.core.execute import ExperimentController
13 import getpass
14 import tempfile
15 import time
16
17 root_dir = tempfile.mkdtemp()
18
19 exp_desc = ExperimentDescription()
20
21 testbed_id = "omf"
22 omf_provider = FactoriesProvider(testbed_id)
23 omf_desc = exp_desc.add_testbed_description(omf_provider)
24 omf_desc.set_attribute_value("homeDirectory", root_dir)
25 omf_desc.set_attribute_value("enableDebug", True)
26 omf_desc.set_attribute_value("xmppSlice", "default_slice")
27 omf_desc.set_attribute_value("xmppHost", "xmpp-omf.onelab.eu")
28 omf_desc.set_attribute_value("xmppPort", 5222)
29 omf_desc.set_attribute_value("xmppPassword", "1234")
30
31 node1 = omf_desc.create("Node")
32 node1.set_attribute_value("hostname", "omf.my.wlab18")
33 node2 = omf_desc.create("Node")
34 node2.set_attribute_value("hostname", "omf.my.wlab49")
35
36 iface12 = omf_desc.create("WifiInterface")
37 iface12.set_attribute_value("mode", "adhoc")
38 iface12.set_attribute_value("channel", "6")
39 iface12.set_attribute_value("type", "g")
40 iface12.set_attribute_value("essid", "cvlcmode")
41 iface12.set_attribute_value("ip", "192.168.0.18")
42 node1.connector("devs").connect(iface12.connector("node"))
43
44 iface21 = omf_desc.create("WifiInterface")
45 iface21.set_attribute_value("mode", "adhoc")
46 iface21.set_attribute_value("channel", "6")
47 iface21.set_attribute_value("type", "g")
48 iface21.set_attribute_value("essid", "cvlcmode")
49 iface21.set_attribute_value("ip", "192.168.0.49")
50 node2.connector("devs").connect(iface21.connector("node"))
51
52 channel = omf_desc.create("Channel")
53 channel.set_attribute_value("mode", "adhoc")
54 channel.set_attribute_value("channel", "6")
55 channel.set_attribute_value("type", "g")
56 channel.set_attribute_value("essid", "cvlcmode")
57 channel.connector("devs").connect(iface12.connector("chan"))
58 channel.connector("devs").connect(iface21.connector("chan"))
59
60 app2 = omf_desc.create("OmfApplication")
61 app2.set_attribute_value("appId", "Vlc#2")
62 app2.set_attribute_value("arguments", "rtp://239.255.0.1:1234")
63 app2.set_attribute_value("path", "/opt/vlc-1.1.13/vlc")
64 app2.connector("node").connect(node2.connector("apps"))
65
66 app1 = omf_desc.create("OmfApplication")
67 app1.set_attribute_value("appId", "Vlc#1")
68 app1.set_attribute_value("arguments", "/opt/10-by-p0d.avi --sout '#duplicate{dst=display,dst=rtp{mux=ts,dst=239.255.0.1,port=1234}}'")
69 app1.set_attribute_value("path", "/opt/vlc-1.1.13/vlc")
70 app1.connector("node").connect(node1.connector("apps"))
71
72 xml = exp_desc.to_xml()
73
74 controller = ExperimentController(xml, root_dir)
75 controller.start()
76 #while not (controller.is_finished(app1.guid) and \
77 #        controller.is_finished(app2.guid)):
78 #    time.sleep(0.5)
79
80 time.sleep(20)
81
82 controller.set(iface21.guid, "channel", "1")
83
84 time.sleep(15)
85
86 controller.stop()
87 controller.shutdown()
88