wiki:Old/Documentation/OTG/ScriptsRepository/ExpFWD

Version 10 (modified by (none), 17 years ago) ( diff )

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");
Note: See TracWiki for help on using the wiki.