Tutorials/a0Basic/Tutorial2: hello-world-wireless.rb

File hello-world-wireless.rb, 2.4 KB (added by nilanjan, 5 years ago)
Line 
1#
2# Copyright (c) 2006-2010 National ICT Australia (NICTA), Australia
3#
4# Permission is hereby granted, free of charge, to any person obtaining a copy
5# of this software and associated documentation files (the "Software"), to deal
6# in the Software without restriction, including without limitation the rights
7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8# copies of the Software, and to permit persons to whom the Software is
9# furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice shall be included in
12# all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20# THE SOFTWARE.
21#
22# Tutorial experiment
23#
24defProperty('res1', 'omf.nicta.node1', "ID of sender node")
25defProperty('res2', 'omf.nicta.node2', "ID of receiver node")
26defProperty('duration', 60, "Duration of the experiment")
27
28defGroup('Sender', property.res1) do |node|
29 node.addApplication("test:app:otg2") do |app|
30 app.setProperty('udp:local_host', '192.168.0.2')
31 app.setProperty('udp:dst_host', '192.168.0.3')
32 app.setProperty('udp:dst_port', 3000)
33 app.measure('udp_out', :samples => 1)
34 end
35 node.net.w0.mode = "adhoc"
36 node.net.w0.type = 'g'
37 node.net.w0.channel = "6"
38 node.net.w0.essid = "helloworld"
39 node.net.w0.ip = "192.168.0.2"
40end
41
42defGroup('Receiver', property.res2) do |node|
43 node.addApplication("test:app:otr2") do |app|
44 app.setProperty('udp:local_host', '192.168.0.3')
45 app.setProperty('udp:local_port', 3000)
46 app.measure('udp_in', :samples => 1)
47 end
48 node.net.w0.mode = "adhoc"
49 node.net.w0.type = 'g'
50 node.net.w0.channel = "6"
51 node.net.w0.essid = "helloworld"
52 node.net.w0.ip = "192.168.0.3"
53end
54
55onEvent(:ALL_UP_AND_INSTALLED) do |event|
56 info "This is my first OMF experiment"
57 wait 10
58 allGroups.startApplications
59 info "All my Applications are started now..."
60 wait property.duration
61 allGroups.stopApplications
62 info "All my Applications are stopped now."
63 Experiment.done
64end