wiki:HowTo/UsingAODV/Scripts
##################################################
# AODV with OTG
# Every node has two prototypes: sender/receiver and AODV
# AODV rt table logs are reported every 4 secs on the nodes to
# /var/log/aodv.rtlog
# These will soon be OMLized to report to the database instead
##################################################

Experiment.name = "tutorial-aodv"
Experiment.project = "orbit:tutorial"

#
# Define nodes used in experiment
#
defNodes('sender', [1,2]) {|node|
  node.image = nil  # assume the right image to be on disk

  node.prototype("test:proto:sender", {
    'destinationHost' => '192.168.1.1',
    'packetSize' => 1024,
    'rate' => 300,
    'protocol' => 'udp'
  })
  node.net.w0.mode = "master"
}

defNodes('receiver', [1,1]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:receiver" , {
    'hostname' => '192.168.1.1',
    'protocol' => 'udp_libmac'
  })
  node.net.w0.mode = "managed"
}

defNodes('everyone',[[1,1],[1,2]]) {|node|
  node.image = nil
  node.prototype("test:proto:aodvrouter", {
'interface' => 'ath0',   #Run aodvd on interface ath0
  'log' => nil,            #Enable logging
  'routelog' => 4          #Enable routing table logging every 4 secs
  })
}


allNodes.net.w0 { |w|
  w.type = 'b'
  w.essid = "helloworld"
  w.ip = "%192.168.%x.%y"
}

#
# Now, start the application
#
whenAllInstalled() {|node|
 #First start AODV daemon on all nodes
  NodeSet['everyone'].startApplications

  wait 10

  #Then start receiver and sender
  NodeSet['receiver'].startApplications
  wait 30
  NodeSet['sender'].startApplications

  wait 180

  Experiment.done
}

For Developers

The application definition and prototype definitions corresponding to AODV router are as follows

Application definition

#
# Create an application representation from scratch
#
require 'handler/appDefinition'

a = AppDefinition.create('test:app:aodvd')
a.name = "aodvd"
a.version(0, 0, 1)
a.shortDescription = "AODV routing protocol"
a.description = <<TEXT
AODV launch
TEXT

# addProperty(name, description, mnemonic, type, isDynamic = false, constraints
= nil)
a.addProperty('interface', 'Interface to run on', ?i, String, false)
a.addProperty('log', 'Enable logging', ?l, String, false)
a.addProperty('rttable', 'Log rting table every N secs', ?r, String, false)
a.path = "/usr/sbin/aodvd"

if $0 == __FILE__
  require 'stringio'
  require 'rexml/document'
  include REXML

  sio = StringIO.new()
  a.to_xml.write(sio, 2)
  sio.rewind
  puts sio.read

  sio.rewind
  doc = Document.new(sio)
  t = AppDefinition.from_xml(doc.root)

  puts
  puts "-------------------------"
  puts
  t.to_xml.write($stdout, 2)

end

Prototype definition

#
# Define a prototype
#

require 'handler/prototype'
require 'handler/filter'
require 'handler/appDefinition'

p = Prototype.create("test:proto:aodvrouter")
p.name = "AODV daemon"
p.description = "Nodes which receive packets"
p.defProperty('interface', 'Interface to listen on')
p.defProperty('log', 'Enable logging')
p.defProperty('routelog', 'Enable logging')

aodvd = p.addApplication('aodvd', "test:app:aodvd")
aodvd.bindProperty('interface')
aodvd.bindProperty('log')
aodvd.bindProperty('rttable','routelog')


if $0 == __FILE__
  p.to_xml.write($stdout, 2)
  puts
end


Last modified 11 years ago Last modified on 11/01/06 17:15:39