Changes between Version 31 and Version 32 of Tutorials/a0Basic/Tutorial2


Ignore:
Timestamp:
Feb 12, 2013, 11:57:58 PM (12 years ago)
Author:
ssugrim
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials/a0Basic/Tutorial2

    v31 v32  
    2828{{{
    2929#
    30 # A)  Define the 'sender' group, which has the unique node [1,1]
    31 #     Nodes in this group will execute the application 'test:proto:sender'
    32 #
    33 defGroup('sender', [1,1]) {|node|
    34 
    35   node.prototype("test:proto:sender", {
    36     'destinationHost' => '192.168.1.2',
    37     'packetSize' => 1024,
    38     'rate' => 300,
    39     'protocol' => 'udp'   
    40   })
    41 
    42   node.net.w0.mode = "managed"
    43 }
    44 
    45 #
    46 # B)  Define the 'receiver' group, which has the unique node [1,2]
    47 #     Nodes in this group will execute the application 'test:proto:receiver'
    48 #
    49 defGroup('receiver', [1,2]) {|node|
    50 
    51   node.prototype("test:proto:receiver" , {
    52     'protocol' => 'udp'
    53   })
    54 
    55   node.net.w0.mode = "master"
    56 }
    57 
    58 #
    59 # C)  Configure the wireless interfaces of all the nodes involved in
    60 #     this experiment
    61 #
    62 allGroups.net.w0 { |w|
    63   w.type = 'b'
    64   w.channel = "6"
    65   w.essid = "helloworld"
    66   w.ip = "%192.168.%x.%y"
    67 }
    68 
    69 #
    70 # D)  When all the nodes are turned On and the all the applications
    71 #     are installed and ready, we can start to perform the experiment
    72 #
    73 whenAllInstalled() {|node|
    74 
    75   wait 30
    76 
     30# Tutorial experiment
     31#
     32defProperty('duration', 60, "Duration of the experiment")
     33defProperty('graph', false, "Display graph or not")
     34
     35baseTopo = Topology['system:topo:imaged']
     36
     37st = defTopology("sender") do |t|
     38  t.addNode(baseTopo.getNodeByIndex(0))
     39end
     40
     41rt = defTopology("receiver") do |t|
     42  t.addNode(baseTopo.getNodeByIndex(1))
     43end
     44 
     45defGroup('Sender', "sender") do |node|
     46  node.addApplication("test:app:otg2") do |app|
     47    app.setProperty('udp:local_host', '192.168.0.2')
     48    app.setProperty('udp:dst_host', '192.168.0.3')
     49    app.setProperty('udp:dst_port', 3000)
     50    app.measure('udp_out', :samples => 1)
     51  end
     52  node.net.w1.mode = "adhoc"
     53  node.net.w1.type = 'g'
     54  node.net.w1.channel = "6"
     55  node.net.w1.essid = "helloworld"
     56  node.net.w1.ip = "192.168.0.2"
     57end
     58
     59defGroup('Receiver', "receiver") do |node|
     60  node.addApplication("test:app:otr2") do |app|
     61    app.setProperty('udp:local_host', '192.168.0.3')
     62    app.setProperty('udp:local_port', 3000)
     63    app.measure('udp_in', :samples => 1)
     64  end
     65  node.net.w1.mode = "adhoc"
     66  node.net.w1.type = 'g'
     67  node.net.w1.channel = "6"
     68  node.net.w1.essid = "helloworld"
     69  node.net.w1.ip = "192.168.0.3"
     70end
     71
     72onEvent(:ALL_UP_AND_INSTALLED) do |event|
     73  info "This is my first OMF experiment"
     74  wait 15
    7775  allGroups.startApplications
    78   wait 40
    79 
     76  info "All my Applications are started now..."
     77  wait property.duration
     78  allGroups.stopApplications
     79  info "All my Applications are stopped now."
    8080  Experiment.done
    81 }
     81end
     82
     83if property.graph.value
     84  addTab(:defaults)
     85  addTab(:graph2) do |tab|
     86    opts = { :postfix => %{This graph shows the Sequence Number from the UDP traffic.}, :updateEvery => 1 }
     87    tab.addGraph("Sequence_Number", opts) do |g|
     88      dataOut = Array.new
     89      dataIn = Array.new
     90      mpOut = ms('udp_out')
     91      mpIn = ms('udp_in')
     92      mpOut.project(:oml_ts_server, :seq_no).each do |sample|
     93        dataOut << sample.tuple
     94      end
     95      mpIn.project(:oml_ts_server, :seq_no).each do |sample|
     96        dataIn << sample.tuple
     97      end
     98      g.addLine(dataOut, :label => "Sender (outgoing UDP)")
     99      g.addLine(dataIn, :label => "Receiver (incoming UDP)")
     100    end
     101  end
     102end
    82103}}}
    83104