UHTutorial: step3-pinge2e_new.rb

File step3-pinge2e_new.rb, 4.8 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
7
8defProperty('sinkaddr11', '192.168.1.13', "Ping destination address")
9defProperty('sinkaddr12', '192.168.3.13', "Ping destination address")
10defProperty('sinkaddr13', '192.168.6.14', "Ping destination address")
11
12defProperty('sinkaddr21', '192.168.6.14', "Ping destination address")
13
14defProperty('sinkaddr41', '192.168.4.11', "Ping destination address")
15defProperty('sinkaddr42', '192.168.5.11', "Ping destination address")
16defProperty('sinkaddr43', '192.168.6.14', "Ping destination address")
17
18defProperty('sinkaddr51', '192.168.5.11', "Ping destination address")
19defProperty('sinkaddr52', '192.168.2.10', "Ping destination address")
20defProperty('sinkaddr53', '192.168.3.13', "Ping destination address")
21
22defApplication('ping') do |app|
23  app.description = 'Simple Definition for the ping-oml2 application'
24  # Define the path to the binary executable for this application
25  app.binary_path = '/usr/local/bin/ping-oml2'
26  # Define the configurable parameters for this application
27  # For example if target is set to foo.com and count is set to 2, then the
28  # application will be started with the command line:
29  # /usr/bin/ping-oml2 -a foo.com -c 2
30  app.defProperty('target', 'Address to ping', '-a', {:type => :string})
31  app.defProperty('count', 'Number of times to ping', '-c', {:type => :integer})
32  # Define the OML2 measurement point that this application provides.
33  # Here we have only one measurement point (MP) named 'ping'. Each measurement
34  # sample from this MP will be composed of a 4-tuples (addr,ttl,rtt,rtt_unit)
35  app.defMeasurement('ping') do |m|
36    m.defMetric('dest_addr',:string)
37    m.defMetric('ttl',:uint32)
38    m.defMetric('rtt',:double)
39    m.defMetric('rtt_unit',:string)
40  end
41end
42
43defGroup('Source1', property.source1) do |node|
44  node.addApplication("ping") do |app|
45        app.setProperty('target', property.sinkaddr11)
46        app.setProperty('count', 30)
47        #app.setProperty('interval', 1)
48        app.measure('ping', :samples => 1)
49      end
50     
51  node.addApplication("ping") do |app|
52    app.setProperty('target', property.sinkaddr12)
53    app.setProperty('count', 30)
54    #app.setProperty('interval', 1)
55    app.measure('ping', :samples => 1)
56  end
57
58  node.addApplication("ping") do |app|
59    app.setProperty('target', property.sinkaddr13)
60    app.setProperty('count', 30)
61    #app.setProperty('interval', 1)
62    app.measure('ping', :samples => 1)
63  end
64end
65
66defGroup('Source2', property.source1) do |node|
67  node.addApplication("ping") do |app|
68    app.setProperty('target', property.sinkaddr21)
69    app.setProperty('count', 30)
70    #app.setProperty('interval', 1)
71    app.measure('ping', :samples => 1)
72  end               
73end
74
75defGroup('Source4', property.source3) do |node|
76  node.addApplication("ping") do |app|
77    app.setProperty('target', property.sinkaddr41)
78    app.setProperty('count', 30)
79    #app.setProperty('interval', 1)
80    app.measure('ping', :samples => 1)
81  end
82
83  node.addApplication("ping") do |app|
84    app.setProperty('target', property.sinkaddr42)
85    app.setProperty('count', 30)
86    #app.setProperty('interval', 1)
87    app.measure('ping', :samples => 1)
88  end
89
90  node.addApplication("ping") do |app|
91    app.setProperty('target', property.sinkaddr43)
92    app.setProperty('count', 30)
93    #app.setProperty('interval', 1)
94    app.measure('ping', :samples => 1)
95  end
96end
97
98defGroup('Source5', property.source3) do |node|
99  node.addApplication("ping") do |app|
100    app.setProperty('target', property.sinkaddr51)
101    app.setProperty('count', 30)
102    #app.setProperty('interval', 1)
103    app.measure('ping', :samples => 1)
104  end
105
106  node.addApplication("ping") do |app|
107    app.setProperty('target', property.sinkaddr52)
108    app.setProperty('count', 30)
109    #app.setProperty('interval', 1)
110    app.measure('ping', :samples => 1)
111  end
112
113   node.addApplication("ping") do |app|
114    app.setProperty('target', property.sinkaddr53)
115    app.setProperty('count', 30)
116    #app.setProperty('interval', 1)
117    app.measure('ping', :samples => 1)
118  end
119end
120
121onEvent(:ALL_UP_AND_INSTALLED) do |event|
122   info "Starting the ping"
123  after 5 do
124    allGroups.startApplications
125  end
126  after 70 do
127    info "Stopping the ping"
128    allGroups.stopApplications
129    Experiment.done
130  end
131end
132
133
134defGraph 'RTT' do |g|
135  g.ms('ping').select(:oml_seq, :dest_addr, :rtt)
136  g.caption "RTT of received packets."
137  g.type 'line_chart3'
138  g.mapping :x_axis => :oml_seq, :y_axis => :rtt, :group_by => :dest_addr
139  g.xaxis :legend => 'oml_seq'
140  g.yaxis :legend => 'rtt', :ticks => {:format => 's'}
141end
142
143