wiki:Old/Documentation/OTG/ScriptsRepository/ExpFWD

Orbit > OTG? > Scripts Repository > Forwarding Example

 

require 'net/http'
require 'uri'

Experiment.name = "hop-2"
Experiment.project = "orbit:mutli-hop"

#Experiment.defProperty('rate', 10, 'Kilo Bits per second sent from sender')
#Experiment.defProperty('packetSize', 512, 'Size of packets sent from sender')
#Experiment.defProperty('destinationIP','12.0.0.7','The sink of the flow')

#
# Define nodes used in experiment
#

defNodes('receiver', [7,6]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:raw_receiver" , {
      'dstfilter' => '12.0.0.7',
      'rxdev' => 'ath0',
      'protocol' => 'raw'
  })
  node.net.w0.mode = "master"
  node.net.w0.essid = "helloworld"
  node.net.w0.type = 'a'
  node.net.w0.channel = 36
  node.net.w0.ip = '12.0.0.7'
}


defNodes('sender', [4,3]) {|node|
  node.image = nil  # assume the right image to be on disk

  node.prototype("test:proto:sender", {
    'destinationHost' => '12.0.0.7',
    'packetSize' => 1024,  node.net.w0.ip = "11.0.0.4"
    'rate' => 300,
    'protocol' => 'udp'
  })
  node.net.w0.mode = "managed"
  node.net.w0.essid = "helloworld"
  node.net.w0.ip = "11.0.0.4"
#  node.net.w0.gateway = "11.0.0.1"  
}


defNodes('forwarder', [5,8]) {|node|
  node.image = nil  # assume the right image to be on disk
   node.prototype("test:proto:forwarder", {
   'protocol' => 'raw',
   'rxdev' =>'ath0',
   'txdev' =>'ath0',
   'ipFilter' =>  "12.0.0.7",
   'nextHopMAC' =>'00:0E:35:85:0F:59'
  })
   node.net.w0.ip="11.0.0.1"
   node.net.w0.mode = "managed"   
   node.net.w0.essid = "helloworld"
}
 
#
# Now, start the application
#
whenAllInstalled() {|node|
puts "run something..."
  wait 30
 allNodes.startApplications
  wait 30

  Experiment.done
}

route set-up for the sender to use forwarder

To make the "forwarder" experiment work, there needs an additional cautious procedure to update the routing table of the sender. Becuase both the sender and forwarder are associated with the receiver AP in the script, we need to let the sender to always use the forwarder to send packets to AP instead of sending directly to AP. This can be done by a perl script

#!/usr/bin/perl
system("ssh root\@node4-3 route add 12.0.0.7 gw 11.0.0.1");

The perl-script shall only run when node is up. So, I think the right moment to run the perl-script is when the node is up and before the application starts. Therefore, that is why the ruby script given in the Wiki page has something like:

.....
whenAllInstalled() {|node|
puts "run something..."
  wait 30
allNodes.startApplications
  wait 30
......

When you see the prompt of "run something....", it is the moment to run the perl script.

Last modified 13 years ago Last modified on 11/10/06 20:05:17