hello-world-graph.rb

Thierry Rakotoarivelo, 08/09/2010 02:49 pm

Download (1.7 kB)

 
1
defGroup('Sender', "omf.nicta.node28") do |node|
2
  node.addApplication("test:app:otg2") do |app|
3
    app.setProperty('udp:local_host', '192.168.0.2')
4
    app.setProperty('udp:dst_host', '192.168.0.3')
5
    app.setProperty('udp:dst_port', 3000)
6
    app.measure('udp_out', :samples => 1)
7
  end
8
  node.net.w0.mode = "adhoc"
9
  node.net.w0.type = 'g'
10
  node.net.w0.channel = "6"
11
  node.net.w0.essid = "helloworld"
12
  node.net.w0.ip = "192.168.0.2"
13
end
14

    
15
defGroup('Receiver', "omf.nicta.node29") do |node|
16
  node.addApplication("test:app:otr2") do |app|
17
    app.setProperty('udp:local_host', '192.168.0.3')
18
    app.setProperty('udp:local_port', 3000)
19
    app.measure('udp_in', :samples => 1)
20
  end
21
  node.net.w0.mode = "adhoc"
22
  node.net.w0.type = 'g'
23
  node.net.w0.channel = "6"
24
  node.net.w0.essid = "helloworld"
25
  node.net.w0.ip = "192.168.0.3"
26
end
27

    
28
onEvent(:ALL_UP_AND_INSTALLED) do |event|
29
  info "This is my first OMF experiment"
30
  wait 10
31
  allGroups.startApplications
32
  info "All my Applications are started now..."
33
  wait 60
34
  allGroups.stopApplications
35
  info "All my Applications are stopped now."
36
  Experiment.done
37
end
38

    
39

    
40
addTab(:defaults)
41
addTab(:graph2) do |tab|
42
  opts = { :postfix => %{This graph shows the Sequence Number from the UDP traffic.}, :updateEvery => 1 }
43
  tab.addGraph("Sequence_Number", opts) do |g|
44
    dataOut = Array.new
45
    dataIn = Array.new
46
    mpOut = ms('udp_out')
47
    mpIn = ms('udp_in')
48
    mpOut.project(:oml_ts_server, :seq_no).each do |sample|
49
      dataOut << sample.tuple
50
    end
51
    mpIn.project(:oml_ts_server, :seq_no).each do |sample|
52
      dataIn << sample.tuple
53
    end
54
    g.addLine(dataOut, :label => "Sender (outgoing UDP)")
55
    g.addLine(dataIn, :label => "Receiver (incoming UDP)")
56
  end
57
end
58