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