wiki:Old/Documentation/OTG/ScriptsRepository/ExpFWD

Version 2 (modified by zhibinwu, 19 years ago) ( diff )

Orbit > OTG > Scripts Repository > Forwarding Example

require 'net/http'
require 'uri'

Experiment.name = "hop-4"
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
#
nodes([3,3], 'sender') {|node|
  node.image = nil  # assume the right image to be on disk
  # experiment property space
  node.prototype("test:proto:sender", {
    'destinationHost' => "12.0.0.7",
  })
  node.net.e0.ip = "11.0.0.4"
  node.net.e0.gateway="11.0.0.1"
}

nodes([8,8], 'receiver') {|node|
  node.image = nil
  node.prototype("test:proto:receiver" , {
   'hostname' => '12.0.0.7',
    'protocol' => 'udp_libmac'
  })
    node.net.w0.mode = "ad-hoc"
    node.net.w0.type = 'a'
  #  node.net.w0.essid = "mhop"
    node.net.w0.ip = "12.0.0.7"
    node.net.w0.gateway="12.0.0.1"
}


nodes([4,4], 'forwarder1') {|node|
  node.image = nil  # assume the right image to be on disk
   node.prototype("test:proto:forwarder", {
   'protocol' => 'raw',
   'rxdev' =>'eth0',
   'txdev' =>'eth2',
   'ipFilter' =>  "12.0.0.7",
   'nextHopMAC' =>'00:0E:35:85:0F:59'
  })
  node.net.e0.ip="11.0.0.1"
   node.net.w0.mode = "ad-hoc"
   node.net.w0.type = 'a'
 #  node.net.w0.essid = "mhop"
   node.net.w0.ip = "11.0.0.2"
}

nodes([5,5], 'forwarder2') {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:forwarder", {
   'protocol' => 'raw',
   'rxdev' =>'eth2',
   'txdev' =>'eth2',
   'ipFilter' => '12.0.0.7',
   'nextHopMAC' =>'00:0E:35:9E:4D:82'
   })
   node.net.w0.mode = "ad-hoc"
   node.net.w0.type = 'a'
#   node.net.w0.essid = "mhop"
   node.net.w0.ip = "14.0.0.1"
   }
nodes([6,6], 'forwarder3') {|node|
node.image = nil  # assume the right image to be on disk
node.prototype("test:proto:forwarder", {
    'protocol' => 'raw',
    'rxdev' =>'eth2',
    'txdev' =>'eth2',
    'ipFilter' => '12.0.0.7',
    'nextHopMAC' =>'00:0E:35:9E:55:7F'
    })
    node.net.w0.mode = "ad-hoc"
    node.net.w0.type = 'a'
    # node.net.w0.essid = "mhop"
     node.net.w0.ip = "15.0.0.1"
  }

nodes([7,7], 'forwarder4') {|node|
node.image = nil  # assume the right image to be on disk
node.prototype("test:proto:forwarder", {
    'protocol' => 'raw',
    'rxdev' =>'eth2',
    'txdev' =>'eth2',
    'ipFilter' => '12.0.0.7',
    'nextHopMAC' => '00:0E:35:9E:4D:B8'
    })
    node.net.w0.mode = "ad-hoc"
    node.net.w0.type = 'a'
    # node.net.w0.essid = "mhop"
    node.net.w0.ip = "12.0.0.1"
    }
whenAll("/*/*", "procs/proc/status[text()='INSTALLED.OK']") {|node|
#
# Start the OML Collection Server
#
filename = "http://console.grid.orbit-lab.org:4000/omls"
url = "http://idb1.grid.orbit-lab.org:5001/startCollectionServer?config_file=#{filename}"
response = Net::HTTP.get_response(URI.parse(url))
if (! response.kind_of? Net::HTTPSuccess)
        raise "Can't start OML Collection Server : #{response.to_s}"
end

#
# Now, start the application
#
  Experiment.props.packetSize = 256
  Experiment.props.rate = 2000

  print "\t\n Enter ESSID now\n"
  Kernel.sleep 20


  NodeSet['receiver'].startApplication('otr')
  NodeSet['forwarder1'].startApplication('otf')
  NodeSet['forwarder2'].startApplication('otf')
  NodeSet['forwarder3'].startApplication('otf')
  NodeSet['forwarder4'].startApplication('otf')
  NodeSet['sender'].startApplication('otg')

 # Kernel.sleep 5
  NodeSet['sender'].send(:STDIN, 'proc/otg', 'size 1024')
  NodeSet['sender'].send(:STDIN, 'proc/otg', 'rate 5000')

  Kernel.sleep 60
  NodeSet['sender'].send(:STDIN, 'proc/otg', 'exit')
  NodeSet['receiver'].send(:STDIN, 'proc/otr', 'exit')
 NodeSet['forwarder1'].send(:STDIN, 'proc/otf', 'exit')
  NodeSet['forwarder2'].send(:STDIN, 'proc/otf', 'exit')
  NodeSet['forwarder3'].send(:STDIN, 'proc/otf', 'exit')
  NodeSet['forwarder4'].send(:STDIN, 'proc/otf', 'exit')
  Kernel.sleep 10

#
# Stop the OML Collection Server
#
filename = "http://console.grid.orbit-lab.org:4000/omls"
url = "http://idb1.grid.orbit-lab.org:5001/stopCollectionServer?config_file=#{filename}"
response = Net::HTTP.get_response(URI.parse(url))
if (! response.kind_of? Net::HTTPSuccess)
        raise "Can't stop OML Collection Server : #{response.to_s}"
end


 NodeHandler.exit

}





Note: See TracWiki for help on using the wiki.