| 1 | = One Day GIMI Tutorial = |
| 2 | |
| 3 | == 1. Beginner's GIMI Tutorial == |
| 4 | |
| 5 | '''RSpec to be used''' |
| 6 | |
| 7 | UHGIMIimage (Available on Portal) |
| 8 | |
| 9 | Download Link: |
| 10 | [http://emmy9.casa.umass.edu/GEC-17/exogeni_omf6.rspec GIMI Rspec for OMF6] |
| 11 | |
| 12 | For more information: |
| 13 | |
| 14 | [http://groups.geni.net/geni/wiki/GEC18Agenda/GettingStartedWithGENI_III_GIMI/Procedure GEC 18 GIMI Tutorial] |
| 15 | |
| 16 | |
| 17 | == 2. OpenFlow and GIMI Tutorial == |
| 18 | |
| 19 | |
| 20 | == 3. Writing an OML Application E.g Layer 2 Ping (aka pingPlus)== |
| 21 | |
| 22 | === 3.1 Execute experiment manually on terminal === |
| 23 | |
| 24 | http://www.gpolab.bbn.com/experiment-support/gec17/pingPlus/pingPlus_v3.tar.gz |
| 25 | |
| 26 | [http://groups.geni.net/geni/wiki/GEC17Agenda/GettingStartedWithGENI_I/Procedure/Execute How to run pingPlus] |
| 27 | |
| 28 | {{{ |
| 29 | root@client:/bin# ./pingPlus fe:16:3e:00:74:38 eth1 10002 5 |
| 30 | RQ:'2114+4074' to fe:16:3e:0:74:38. |
| 31 | RL:2114+4074=6188 from fe:16:3e:0:74:38. |
| 32 | RTT = 4.629883 |
| 33 | |
| 34 | RQ:'6683+0' to fe:16:3e:0:74:38. |
| 35 | RL:6683+0=6683 from fe:16:3e:0:74:38. |
| 36 | RTT = 2.137939 |
| 37 | |
| 38 | RQ:'8044+1260' to fe:16:3e:0:74:38. |
| 39 | RL:8044+1260=9304 from fe:16:3e:0:74:38. |
| 40 | RTT = 0.438965 |
| 41 | |
| 42 | RQ:'5016+7303' to fe:16:3e:0:74:38. |
| 43 | RL:5016+7303=12319 from fe:16:3e:0:74:38. |
| 44 | RTT = 0.324951 |
| 45 | |
| 46 | RQ:'4986+2140' to fe:16:3e:0:74:38. |
| 47 | RL:4986+2140=7126 from fe:16:3e:0:74:38. |
| 48 | RTT = 0.461182 |
| 49 | |
| 50 | }}} |
| 51 | |
| 52 | === 3.2 Parse output to get Measurement points === |
| 53 | |
| 54 | {{{ |
| 55 | def process_output(row) |
| 56 | if not (parse= /RQ:'(?<pktsnt1>\d*)\+(?<pktsnt2>\d*)' to (?<host>[a-f0-9:]*)/.match(row)).nil? |
| 57 | puts "ReturnQual #{parse[:pktsnt1]}\n" |
| 58 | MPrt.inject(parse[:pktsnt1], parse[:pktsnt2],parse[:host]) |
| 59 | |
| 60 | elsif not (parse= /RL:(?<numofpkt1>\d*)\+(?<numofpkt2>\d*)=(?<totpktrec>\d*) from (?<dest_hw_addr>[a-f0-9:]*)/.match(row)).nil? |
| 61 | puts "ReturnLength\n" |
| 62 | p parse |
| 63 | p MPrl.inject(parse[:numofpkt1],parse[:numofpkt2],parse[:totpktrec],parse[:dest_hw_addr]) |
| 64 | |
| 65 | elsif not (parse = /RTT = (?<rtt>[0-9.]*)/.match(row)).nil? |
| 66 | puts "RoundTripTime #{parse[:rtt]}\n" |
| 67 | p parse |
| 68 | p MPrtt.inject(parse[:rtt]) |
| 69 | end |
| 70 | end |
| 71 | }}} |
| 72 | |
| 73 | === 3.3 Write Application Script === |
| 74 | {{{ |
| 75 | |
| 76 | #!/usr/bin/ruby1.9.1 |
| 77 | require 'rubygems' |
| 78 | require 'oml4r' |
| 79 | |
| 80 | class MPrt < OML4R::MPBase |
| 81 | name :pingrt |
| 82 | param :pktsnt1, :type => :integer |
| 83 | param :pktsnt2, :type => :integer |
| 84 | param :host, :type => :string |
| 85 | end |
| 86 | |
| 87 | class MPrl < OML4R::MPBase |
| 88 | name :pingrl |
| 89 | param :totpktrec, :type => :integer |
| 90 | param :numofpkt1, :type => :integer |
| 91 | param :numofpkt2, :type => :integer |
| 92 | param :dest_hw_addr, :type => :string |
| 93 | end |
| 94 | |
| 95 | class MPrtt < OML4R::MPBase |
| 96 | name :pingrtt |
| 97 | param :rtt, :type => :double |
| 98 | end |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | class Pingl2Wrapper |
| 104 | |
| 105 | def initialize(args) |
| 106 | @addr = nil |
| 107 | @if_num = '' |
| 108 | @eth = nil |
| 109 | @verbose = true |
| 110 | @numeric = '' |
| 111 | |
| 112 | leftover = OML4R::init(args, :appName => 'pingl2') do |argParser| |
| 113 | argParser.banner = "Runs layer 2 ping and reports measurements via OML\n\n" |
| 114 | argParser.on("-a" , "--dest_hw_addr ADDRESS", "Hardware address to ping (the -a switch is optional)"){ |address| @addr = address.to_s() } |
| 115 | argParser.on("-i","--interface IFNUM","Interface number"){ |if_num| @if_num ="#{if_num.to_i()}" } |
| 116 | argParser.on("-e", "--eth ETHTYPE","Ethernet Type") { |ethtype| @eth = ethtype.to_s() } |
| 117 | argParser.on("-c","--count NUMBER","Number of pings (default: infinite)"){ |count| @count = "#{count.to_i()}"} |
| 118 | argParser.on("-q", "--no-quiet ","Don't show layer 2 ping output on console"){ @verbose = false } |
| 119 | argParser.on("-n", "--[no]-numeric ", "No attempt twill be made to look up symbolic names for host addresses"){ @numeric ='-n' } |
| 120 | end |
| 121 | |
| 122 | if @addr.nil? |
| 123 | if leftover.length > 0 |
| 124 | @addr = leftover [0] |
| 125 | else |
| 126 | raise "You did not specify an address to ping!" |
| 127 | end |
| 128 | end |
| 129 | |
| 130 | end |
| 131 | |
| 132 | def process_output(row) |
| 133 | if not (parse= /RQ:'(?<pktsnt1>\d*)\+(?<pktsnt2>\d*)' to (?<host>[a-f0-9:]*)/.match(row)).nil? |
| 134 | puts "ReturnQual #{parse[:pktsnt1]}\n" |
| 135 | MPrt.inject(parse[:pktsnt1], parse[:pktsnt2],parse[:host]) |
| 136 | |
| 137 | elsif not (parse= /RL:(?<numofpkt1>\d*)\+(?<numofpkt2>\d*)=(?<totpktrec>\d*) from (?<dest_hw_addr>[a-f0-9:]*)/.match(row)).nil? |
| 138 | puts "ReturnLength\n" |
| 139 | p parse |
| 140 | p MPrl.inject(parse[:numofpkt1],parse[:numofpkt2],parse[:totpktrec],parse[:dest_hw_addr]) |
| 141 | |
| 142 | elsif not (parse = /RTT = (?<rtt>[0-9.]*)/.match(row)).nil? |
| 143 | puts "RoundTripTime #{parse[:rtt]}\n" |
| 144 | p parse |
| 145 | p MPrtt.inject(parse[:rtt]) |
| 146 | end |
| 147 | end |
| 148 | |
| 149 | def pingl2() |
| 150 | @pingio = IO.popen("/bin/pingPlus #{@addr} #{@eth} #{@if_num} #{@count}") |
| 151 | while true |
| 152 | row = @pingio.readline |
| 153 | puts row if @verbose |
| 154 | process_output(row) |
| 155 | end |
| 156 | end |
| 157 | |
| 158 | def start() |
| 159 | return if not @pingio.nil? |
| 160 | |
| 161 | # handle for OMF's exit command |
| 162 | a = Thread.new do |
| 163 | $stdin.each do |line| |
| 164 | if /^exit/ =~ line |
| 165 | Process.kill("INT",0) |
| 166 | end |
| 167 | end |
| 168 | end |
| 169 | |
| 170 | # Handle Ctrl+C and OMF's SIGTERM |
| 171 | Signal.trap("INT", stop) |
| 172 | Signal.trap("TERM", stop) |
| 173 | |
| 174 | begin |
| 175 | pingl2 |
| 176 | rescue EOFError |
| 177 | |
| 178 | end |
| 179 | end |
| 180 | |
| 181 | def stop() |
| 182 | return if @pingio.nil? |
| 183 | # Kill the ping process, which will result in EOFError from ping() |
| 184 | Process.kill("INT", @pingio.pid) |
| 185 | end |
| 186 | |
| 187 | end |
| 188 | begin |
| 189 | $stderr.puts "INFO\tpingl2 2.11.0\n" |
| 190 | app = Pingl2Wrapper.new(ARGV) |
| 191 | app.start() |
| 192 | sleep 1 |
| 193 | rescue Interrupt |
| 194 | rescue Exception => ex |
| 195 | $stderr.puts "Error\t#{ex}\n" |
| 196 | end |
| 197 | |
| 198 | |
| 199 | |
| 200 | # Local Variables: |
| 201 | # mode:ruby |
| 202 | # End: |
| 203 | # vim: ft=ruby:sw=2 |
| 204 | |
| 205 | }}} |
| 206 | |
| 207 | === 3.4 Write OEDL Script to test application === |
| 208 | {{{ |
| 209 | defProperty('source1', "client-testpingplus", "ID of a resource") |
| 210 | #defProperty('source2', "ig-utah-testBBN", "ID of a resource") |
| 211 | #defProperty('source3', "nodeC-createexoimage", "ID of a resource") |
| 212 | #defProperty('source4', "nodeD-createexoimage", "ID of a resource") |
| 213 | #defProperty('source5', "nodeE-createexoimage", "ID of a resource") |
| 214 | defProperty('graph', true, "Display graph or not") |
| 215 | |
| 216 | |
| 217 | defProperty('sinkaddr11', 'fe:16:3e:00:74:38', "Ping destination address") |
| 218 | defProperty('eth11','eth1',"Output Eth interface") |
| 219 | defProperty('sinkaddr12', 'fe:16:3e:00:74:38', "Ping destination address") |
| 220 | |
| 221 | #defProperty('sinkaddr11', '192.168.6.10', "Ping destination address") |
| 222 | #defProperty('sinkaddr12', '192.168.5.12', "Ping destination address") |
| 223 | |
| 224 | #defProperty('sinkaddr21', '192.168.4.11', "Ping destination address") |
| 225 | #defProperty('sinkaddr22', '192.168.2.12', "Ping destination address") |
| 226 | #defProperty('sinkaddr23', '192.168.1.13', "Ping destination address") |
| 227 | |
| 228 | #defProperty('sinkaddr31', '192.168.5.11', "Ping destination address") |
| 229 | #defProperty('sinkaddr32', '192.168.2.10', "Ping destination address") |
| 230 | #defProperty('sinkaddr33', '192.168.3.13', "Ping destination address") |
| 231 | #defProperty('sinkaddr34', '192.168.6.14', "Ping destination address") |
| 232 | |
| 233 | #defProperty('sinkaddr41', '192.168.1.10', "Ping destination address") |
| 234 | #defProperty('sinkaddr42', '192.168.3.12', "Ping destination address") |
| 235 | |
| 236 | #defProperty('sinkaddr51', '192.168.6.12', "Ping destination address") |
| 237 | |
| 238 | defApplication('ping') do |app| |
| 239 | app.description = 'Simple Definition for the pingl2 application' |
| 240 | # Define the path to the binary executable for this application |
| 241 | app.binary_path = '/usr/local/bin/pingl2' |
| 242 | # Define the configurable parameters for this application |
| 243 | # For example if target is set to foo.com and count is set to 2, then the |
| 244 | # application will be started with the command line: |
| 245 | # /usr/bin/ping-oml2 -a foo.com -c 2 |
| 246 | app.defProperty('target', 'Address to ping', '-a', {:type => :string}) |
| 247 | app.defProperty('count', 'Number of times to ping', '-c', {:type => :integer}) |
| 248 | app.defProperty('if_num', 'interface number', '-i', {:type => :integer}) |
| 249 | app.defProperty('eth', 'Ethernet Type', '-e', {:type => :string}) |
| 250 | # Define the OML2 measurement point that this application provides. |
| 251 | # Here we have only one measurement point (MP) named 'ping'. Each measurement |
| 252 | # sample from this MP will be composed of a 4-tuples (addr,ttl,rtt,rtt_unit) |
| 253 | app.defMeasurement('ping') do |m| |
| 254 | m.defMetric('hw_dest_addr',:string) |
| 255 | m.defMetric('rtt',:double) |
| 256 | end |
| 257 | end |
| 258 | defGroup('Source1', property.source1) do |node| |
| 259 | node.addApplication("ping") do |app| |
| 260 | app.setProperty('target', property.sinkaddr11) |
| 261 | app.setProperty('count', 30) |
| 262 | app.setProperty('if_num', 10002) |
| 263 | app.setProperty('eth',property.eth11) |
| 264 | app.measure('ping', :samples => 1) |
| 265 | end |
| 266 | end |
| 267 | |
| 268 | |
| 269 | #defGroup('Source2', property.source2) do |node| |
| 270 | # node.addApplication("ping") do |app| |
| 271 | # app.setProperty('target', property.sinkaddr11) |
| 272 | # app.setProperty('count', 30) |
| 273 | #app.setProperty('interval', 1) |
| 274 | # app.measure('ping', :samples => 1) |
| 275 | #end |
| 276 | #end |
| 277 | |
| 278 | |
| 279 | onEvent(:ALL_UP_AND_INSTALLED) do |event| |
| 280 | info "Starting the ping" |
| 281 | after 5 do |
| 282 | allGroups.startApplications |
| 283 | end |
| 284 | after 70 do |
| 285 | info "Stopping the ping" |
| 286 | allGroups.stopApplications |
| 287 | Experiment.done |
| 288 | end |
| 289 | end |
| 290 | |
| 291 | defGraph 'RTT' do |g| |
| 292 | g.ms('ping').select(:oml_seq, :hw_dest_addr, :rtt) |
| 293 | g.caption "RTT of received packets." |
| 294 | g.type 'line_chart3' |
| 295 | g.mapping :x_axis => :oml_seq, :y_axis => :rtt, :group_by => :hw_dest_addr |
| 296 | g.xaxis :legend => 'oml_seq' |
| 297 | g.yaxis :legend => 'rtt', :ticks => {:format => 's'} |
| 298 | end |
| 299 | |
| 300 | |
| 301 | |
| 302 | }}} |
| 303 | |
| 304 | |
| 305 | |
| 306 | |