| 1 | {{{ |
| 2 | ################################################## |
| 3 | # AODV with OTG |
| 4 | # Every node has two prototypes: sender/receiver and AODV |
| 5 | # AODV rt table logs are reported every 4 secs on the nodes to |
| 6 | # /var/log/aodv.rtlog |
| 7 | # These will soon be OMLized to report to the database instead |
| 8 | ################################################## |
| 9 | |
| 10 | Experiment.name = "tutorial-aodv" |
| 11 | Experiment.project = "orbit:tutorial" |
| 12 | |
| 13 | # |
| 14 | # Define nodes used in experiment |
| 15 | # |
| 16 | defNodes('sender', [1,2]) {|node| |
| 17 | node.image = nil # assume the right image to be on disk |
| 18 | |
| 19 | node.prototype("test:proto:sender", { |
| 20 | 'destinationHost' => '192.168.1.1', |
| 21 | 'packetSize' => 1024, |
| 22 | 'rate' => 300, |
| 23 | 'protocol' => 'udp' |
| 24 | }) |
| 25 | node.net.w0.mode = "master" |
| 26 | } |
| 27 | |
| 28 | defNodes('receiver', [1,1]) {|node| |
| 29 | node.image = nil # assume the right image to be on disk |
| 30 | node.prototype("test:proto:receiver" , { |
| 31 | 'hostname' => '192.168.1.1', |
| 32 | 'protocol' => 'udp_libmac' |
| 33 | }) |
| 34 | node.net.w0.mode = "managed" |
| 35 | } |
| 36 | |
| 37 | defNodes('everyone',[[1,1],[1,2]]) {|node| |
| 38 | node.image = nil |
| 39 | node.prototype("test:proto:aodvrouter", { |
| 40 | 'interface' => 'ath0', #Run aodvd on interface ath0 |
| 41 | 'log' => nil, #Enable logging |
| 42 | 'routelog' => 4 #Enable routing table logging every 4 secs |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | |
| 47 | allNodes.net.w0 { |w| |
| 48 | w.type = 'b' |
| 49 | w.essid = "helloworld" |
| 50 | w.ip = "%192.168.%x.%y" |
| 51 | } |
| 52 | |
| 53 | # |
| 54 | # Now, start the application |
| 55 | # |
| 56 | whenAllInstalled() {|node| |
| 57 | #First start AODV daemon on all nodes |
| 58 | NodeSet['everyone'].startApplications |
| 59 | |
| 60 | wait 10 |
| 61 | |
| 62 | #Then start receiver and sender |
| 63 | NodeSet['receiver'].startApplications |
| 64 | wait 30 |
| 65 | NodeSet['sender'].startApplications |
| 66 | |
| 67 | wait 180 |
| 68 | |
| 69 | Experiment.done |
| 70 | } |
| 71 | |
| 72 | }}} |
| 73 | |
| 74 | |
| 75 | |
| 76 | == For Developers == |
| 77 | The application definition and prototype definitions corresponding to AODV router are as follows |
| 78 | |
| 79 | == Application definition == |
| 80 | {{{ |
| 81 | # |
| 82 | # Create an application representation from scratch |
| 83 | # |
| 84 | require 'handler/appDefinition' |
| 85 | |
| 86 | a = AppDefinition.create('test:app:aodvd') |
| 87 | a.name = "aodvd" |
| 88 | a.version(0, 0, 1) |
| 89 | a.shortDescription = "AODV routing protocol" |
| 90 | a.description = <<TEXT |
| 91 | AODV launch |
| 92 | TEXT |
| 93 | |
| 94 | # addProperty(name, description, mnemonic, type, isDynamic = false, constraints |
| 95 | = nil) |
| 96 | a.addProperty('interface', 'Interface to run on', ?i, String, false) |
| 97 | a.addProperty('log', 'Enable logging', ?l, String, false) |
| 98 | a.addProperty('rttable', 'Log rting table every N secs', ?r, String, false) |
| 99 | a.path = "/usr/sbin/aodvd" |
| 100 | |
| 101 | if $0 == __FILE__ |
| 102 | require 'stringio' |
| 103 | require 'rexml/document' |
| 104 | include REXML |
| 105 | |
| 106 | sio = StringIO.new() |
| 107 | a.to_xml.write(sio, 2) |
| 108 | sio.rewind |
| 109 | puts sio.read |
| 110 | |
| 111 | sio.rewind |
| 112 | doc = Document.new(sio) |
| 113 | t = AppDefinition.from_xml(doc.root) |
| 114 | |
| 115 | puts |
| 116 | puts "-------------------------" |
| 117 | puts |
| 118 | t.to_xml.write($stdout, 2) |
| 119 | |
| 120 | end |
| 121 | |
| 122 | }}} |
| 123 | |
| 124 | === Prototype definition === |
| 125 | {{{ |
| 126 | # |
| 127 | # Define a prototype |
| 128 | # |
| 129 | |
| 130 | require 'handler/prototype' |
| 131 | require 'handler/filter' |
| 132 | require 'handler/appDefinition' |
| 133 | |
| 134 | p = Prototype.create("test:proto:aodvrouter") |
| 135 | p.name = "AODV daemon" |
| 136 | p.description = "Nodes which receive packets" |
| 137 | p.defProperty('interface', 'Interface to listen on') |
| 138 | p.defProperty('log', 'Enable logging') |
| 139 | p.defProperty('routelog', 'Enable logging') |
| 140 | |
| 141 | aodvd = p.addApplication('aodvd', "test:app:aodvd") |
| 142 | aodvd.bindProperty('interface') |
| 143 | aodvd.bindProperty('log') |
| 144 | aodvd.bindProperty('rttable','routelog') |
| 145 | |
| 146 | |
| 147 | if $0 == __FILE__ |
| 148 | p.to_xml.write($stdout, 2) |
| 149 | puts |
| 150 | end |
| 151 | |
| 152 | |
| 153 | }}} |