3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Julien Tribino <julien.tribino@inria.fr>
21 from nepi.execution.resource import ResourceFactory
22 from nepi.execution.ec import ExperimentController
24 from nepi.resources.omf.node import OMFNode
25 from nepi.resources.omf.application import OMFApplication
26 from nepi.resources.omf.interface import OMFWifiInterface
27 from nepi.resources.omf.channel import OMFChannel
35 ec = ExperimentController()
37 # Register the different RM that will be used
38 ResourceFactory.register_type(OMFNode)
39 ResourceFactory.register_type(OMFWifiInterface)
40 ResourceFactory.register_type(OMFChannel)
41 ResourceFactory.register_type(OMFApplication)
43 # Create and Configure the Nodes
44 guid = ec.register_resource("OMFNode")
45 node1 = ec.get_resource(guid)
46 node1.set('hostname', 'omf.plexus.wlab17')
47 node1.set('xmppSlice', "nepi")
48 node1.set('xmppHost', "xmpp-plexus.onelab.eu")
49 node1.set('xmppPort', "5222")
50 node1.set('xmppPassword', "1234")
52 guid = ec.register_resource("OMFNode")
53 node2 = ec.get_resource(guid)
54 node2.set('hostname', "omf.plexus.wlab37")
55 node2.set('xmppSlice', "nepi")
56 node2.set('xmppHost', "xmpp-plexus.onelab.eu")
57 node2.set('xmppPort', "5222")
58 node2.set('xmppPassword', "1234")
60 # Create and Configure the Interfaces
61 guid = ec.register_resource("OMFWifiInterface")
62 iface1 = ec.get_resource(guid)
63 iface1.set('alias', "w0")
64 iface1.set('mode', "adhoc")
65 iface1.set('type', "g")
66 iface1.set('essid', "helloworld")
67 iface1.set('ip', "10.0.0.17")
68 iface1.set('xmppSlice', "nepi")
69 iface1.set('xmppHost', "xmpp-plexus.onelab.eu")
70 iface1.set('xmppPort', "5222")
71 iface1.set('xmppPassword', "1234")
73 guid = ec.register_resource("OMFWifiInterface")
74 iface2 = ec.get_resource(guid)
75 iface2.set('alias', "w0")
76 iface2.set('mode', "adhoc")
77 iface2.set('type', 'g')
78 iface2.set('essid', "helloworld")
79 iface2.set('ip', "10.0.0.37")
80 iface2.set('xmppSlice', "nepi")
81 iface2.set('xmppHost', "xmpp-plexus.onelab.eu")
82 iface2.set('xmppPort', "5222")
83 iface2.set('xmppPassword', "1234")
85 # Create and Configure the Channel
86 guid = ec.register_resource("OMFChannel")
87 channel = ec.get_resource(guid)
88 channel.set('channel', "6")
89 channel.set('xmppSlice', "nepi")
90 channel.set('xmppHost', "xmpp-plexus.onelab.eu")
91 channel.set('xmppPort', "5222")
92 channel.set('xmppPassword', "1234")
94 # Create and Configure the Application
95 guid = ec.register_resource("OMFApplication")
96 app1 = ec.get_resource(guid)
97 app1.set('appid', 'Vlc#1')
98 app1.set('path', "/opt/vlc-1.1.13/cvlc")
99 app1.set('args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
100 app1.set('env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
101 app1.set('xmppSlice', "nepi")
102 app1.set('xmppHost', "xmpp-plexus.onelab.eu")
103 app1.set('xmppPort', "5222")
104 app1.set('xmppPassword', "1234")
106 guid = ec.register_resource("OMFApplication")
107 app2 = ec.get_resource(guid)
108 app2.set('appid', 'Vlc#2')
109 app2.set('path', "/opt/vlc-1.1.13/cvlc")
110 app2.set('args', "rtp://10.0.0.37:1234")
111 app2.set('env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
112 app2.set('xmppSlice', "nepi")
113 app2.set('xmppHost', "xmpp-plexus.onelab.eu")
114 app2.set('xmppPort', "5222")
115 app2.set('xmppPassword', "1234")
117 guid = ec.register_resource("OMFApplication")
118 app3 = ec.get_resource(guid)
119 app3.set('appid', 'Kill#2')
120 app3.set('path', "/usr/bin/killall")
121 app3.set('args', "vlc")
123 app3.set('xmppSlice', "nepi")
124 app3.set('xmppHost', "xmpp-plexus.onelab.eu")
125 app3.set('xmppPort', "5222")
126 app3.set('xmppPassword', "1234")
129 app3.connect(node1.guid)
130 node1.connect(app3.guid)
132 app1.connect(node1.guid)
133 node1.connect(app1.guid)
135 node1.connect(iface1.guid)
136 iface1.connect(node1.guid)
138 iface1.connect(channel.guid)
139 channel.connect(iface1.guid)
141 channel.connect(iface2.guid)
142 iface2.connect(channel.guid)
144 iface2.connect(node2.guid)
145 node2.connect(iface2.guid)
147 node2.connect(app2.guid)
148 app2.connect(node2.guid)
165 # Start the Interfaces
174 # Start the Application
181 # Stop the Application