UHTutorial: step1-ping_all.rb

File step1-ping_all.rb, 5.7 KB (added by divyashri.bhat@gmail.com, 6 years ago)
Line 
1defProperty('source1', "nodeA-fivenodeping", "ID of a resource")
2defProperty('source2', "nodeB-fivenodeping", "ID of a resource")
3defProperty('source3', "nodeC-fivenodeping", "ID of a resource")
4defProperty('source4', "nodeD-fivenodeping", "ID of a resource")
5defProperty('source5', "nodeE-fivenodeping", "ID of a resource")
6#defProperty('graph', true, "Display graph or not")
7
8
9defProperty('sinkaddr11', '192.168.1.2', "Ping destination address")
10defProperty('sinkaddr12', '192.168.1.4', "Ping destination address")
11
12defProperty('sinkaddr11', '192.168.6.10', "Ping destination address")
13defProperty('sinkaddr12', '192.168.5.12', "Ping destination address")
14
15defProperty('sinkaddr21', '192.168.4.11', "Ping destination address")
16defProperty('sinkaddr22', '192.168.2.12', "Ping destination address")
17defProperty('sinkaddr23', '192.168.1.13', "Ping destination address")
18
19defProperty('sinkaddr31', '192.168.5.11', "Ping destination address")
20defProperty('sinkaddr32', '192.168.2.10', "Ping destination address")
21defProperty('sinkaddr33', '192.168.3.13', "Ping destination address")
22defProperty('sinkaddr34', '192.168.6.14', "Ping destination address")
23
24defProperty('sinkaddr41', '192.168.1.10', "Ping destination address")
25defProperty('sinkaddr42', '192.168.3.12', "Ping destination address")
26
27defProperty('sinkaddr51', '192.168.6.12', "Ping destination address")
28
29defApplication('ping') do |app|
30  app.description = 'Simple Definition for the ping-oml2 application'
31  # Define the path to the binary executable for this application
32  app.binary_path = '/usr/local/bin/ping-oml2'
33  # Define the configurable parameters for this application
34  # For example if target is set to foo.com and count is set to 2, then the
35  # application will be started with the command line:
36  # /usr/bin/ping-oml2 -a foo.com -c 2
37  app.defProperty('target', 'Address to ping', '-a', {:type => :string})
38  app.defProperty('count', 'Number of times to ping', '-c', {:type => :integer})
39  # Define the OML2 measurement point that this application provides.
40  # Here we have only one measurement point (MP) named 'ping'. Each measurement
41  # sample from this MP will be composed of a 4-tuples (addr,ttl,rtt,rtt_unit)
42  app.defMeasurement('ping') do |m|
43    m.defMetric('dest_addr',:string)
44    m.defMetric('ttl',:uint32)
45    m.defMetric('rtt',:double)
46    m.defMetric('rtt_unit',:string)
47  end
48end
49defGroup('Source1', property.source1) do |node|
50  node.addApplication("ping") do |app|
51    app.setProperty('target', property.sinkaddr12)
52    app.setProperty('count', 30)
53    #app.setProperty('interval', 1)
54    app.measure('ping', :samples => 1)
55  end
56end
57
58
59defGroup('Source2', property.source2) do |node|
60  node.addApplication("ping") do |app|
61    app.setProperty('target', property.sinkaddr11)
62    app.setProperty('count', 30)
63    #app.setProperty('interval', 1)
64    app.measure('ping', :samples => 1)
65  end
66  node.addApplication("ping") do |app|
67    app.setProperty('target', property.sinkaddr21)
68    app.setProperty('count', 30)
69    #app.setProperty('interval', 1)
70    app.measure('ping', :samples => 1)
71  end
72
73  node.addApplication("ping") do |app|
74    app.setProperty('target', property.sinkaddr22)
75    app.setProperty('count', 30)
76    #app.setProperty('interval', 1)
77    app.measure('ping', :samples => 1)
78  end
79
80  node.addApplication("ping") do |app|
81    app.setProperty('target', property.sinkaddr23)
82    app.setProperty('count', 30)
83    #app.setProperty('interval', 1)
84    app.measure('ping', :samples => 1)
85  end
86end
87
88defGroup('Source3', property.source3) do |node|
89  node.addApplication("ping") do |app|
90    app.setProperty('target', property.sinkaddr31)
91    app.setProperty('count', 30)
92    #app.setProperty('interval', 1)
93    app.measure('ping', :samples => 1)
94  end
95
96  node.addApplication("ping") do |app|
97    app.setProperty('target', property.sinkaddr32)
98    app.setProperty('count', 30)
99    #app.setProperty('interval', 1)
100    app.measure('ping', :samples => 1)
101  end
102
103  node.addApplication("ping") do |app|
104    app.setProperty('target', property.sinkaddr33)
105    app.setProperty('count', 30)
106    #app.setProperty('interval', 1)
107    app.measure('ping', :samples => 1)
108  end
109
110  node.addApplication("ping") do |app|
111    app.setProperty('target', property.sinkaddr34)
112    app.setProperty('count', 30)
113    #app.setProperty('interval', 1)
114    app.measure('ping', :samples => 1)
115  end
116end
117
118defGroup('Source4', property.source4) do |node|
119  node.addApplication("ping") do |app|
120    app.setProperty('target', property.sinkaddr41)
121    app.setProperty('count', 30)
122    #app.setProperty('interval', 1)
123    app.measure('ping', :samples => 1)
124  end
125
126  node.addApplication("ping") do |app|
127    app.setProperty('target', property.sinkaddr42)
128    app.setProperty('count', 30)
129    #app.setProperty('interval', 1)
130    app.measure('ping', :samples => 1)
131  end
132end
133
134defGroup('Source5', property.source5) do |node|
135  node.addApplication("ping") do |app|
136    app.setProperty('target', property.sinkaddr51)
137    app.setProperty('count', 30)
138    #app.setProperty('interval', 1)
139    app.measure('ping', :samples => 1)
140  end
141end
142
143
144
145
146#defGroup('Sink1', property.sink1) do |node|
147#end
148
149#defGroup('Sink2', property.sink2) do |node|
150#end
151
152#defGroup('Sink3', property.sink3) do |node|
153#end
154
155#defGroup('Sink4', property.sink4) do |node|
156#end
157
158#defGroup('Sink5', property.sink5) do |node|
159#end
160
161onEvent(:ALL_UP_AND_INSTALLED) do |event|
162  info "Starting the ping"
163  after 5 do
164    allGroups.startApplications
165  end
166  after 70 do
167    info "Stopping the ping"
168    allGroups.stopApplications
169    Experiment.done
170  end
171end
172
173defGraph 'RTT' do |g|
174  g.ms('ping').select(:oml_seq, :dest_addr, :rtt)
175  g.caption "RTT of received packets."
176  g.type 'line_chart3'
177  g.mapping :x_axis => :oml_seq, :y_axis => :rtt, :group_by => :dest_addr
178  g.xaxis :legend => 'oml_seq'
179  g.yaxis :legend => 'rtt', :ticks => {:format => 's'}
180end