| 1 | #
|
|---|
| 2 | # This is a script example, which illustrates the use of topologies in
|
|---|
| 3 | # an experiment scripts
|
|---|
| 4 | #
|
|---|
| 5 | # The scenario of this experiment involves two group of nodes: 'sender' and
|
|---|
| 6 | # 'receiver'. The 'sender' group will generate some broadcast traffic, which will
|
|---|
| 7 | # be received by the 'receiver' group.
|
|---|
| 8 | #
|
|---|
| 9 | # Each group contains nodes that are not explicitly defined within this script, but
|
|---|
| 10 | # rather randomly drawn from the set of active nodes on the tested where this script is
|
|---|
| 11 | # running. In other words, this script example does not specifically name which node belongs to
|
|---|
| 12 | # which group.
|
|---|
| 13 | #
|
|---|
| 14 | # More information on the available commands to define a topology are available on the
|
|---|
| 15 | # following page:
|
|---|
| 16 | # http://www.orbit-lab.org/wiki/Documentation/NodeHandler/Commands/defTopology
|
|---|
| 17 | #
|
|---|
| 18 | # In this example we:
|
|---|
| 19 | # 1) Define a 1st Topology, which will be used to build the 'sender' group of nodes
|
|---|
| 20 | # 2) Define a 2nd Topology, which will be used to build the 'receiver' group of nodes
|
|---|
| 21 | # 3) Define the 'sender' group of nodes
|
|---|
| 22 | # 4) Define the 'receiver' group of nodes
|
|---|
| 23 | # 5) Finally run the experiment
|
|---|
| 24 | #
|
|---|
| 25 |
|
|---|
| 26 | # 1)
|
|---|
| 27 | # Define a topology that will hold the sender node(s) of this experiment
|
|---|
| 28 | #
|
|---|
| 29 | defTopology('senderTopo') { |t|
|
|---|
| 30 | # Load the topology which contains all the active nodes for the
|
|---|
| 31 | # testbed on which this script is running
|
|---|
| 32 | baseTopo = Topology['system:topo:active']
|
|---|
| 33 | # Draw a random node from the pool of active ones
|
|---|
| 34 | aNode = baseTopo.getUniqueRandomNode
|
|---|
| 35 | # Add this random node to this 'senderTopo' topology
|
|---|
| 36 | t.addNode(aNode)
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | # 2)
|
|---|
| 40 | # Define a topology that will hold the receiver node(s) of this
|
|---|
| 41 | # experiment
|
|---|
| 42 | #
|
|---|
| 43 | defTopology('receiverTopo') { |t|
|
|---|
| 44 | # Load the topology which contains all the active nodes for the
|
|---|
| 45 | # testbed on which this script is running
|
|---|
| 46 | baseTopo = Topology['system:topo:active']
|
|---|
| 47 | # Repeat the following 'receiverNumber' of time
|
|---|
| 48 | for count in 1..4
|
|---|
| 49 | # Draw a random node from the pool of active ones
|
|---|
| 50 | aNode = baseTopo.getUniqueRandomNode
|
|---|
| 51 | # Add this random node to this 'receiverTopo' topology
|
|---|
| 52 | t.addNode(aNode)
|
|---|
| 53 | end
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | # 3)
|
|---|
| 57 | # Define the 'sender' group for this experiment
|
|---|
| 58 | # This group will include the node(s) from the 'senderTopo' topology
|
|---|
| 59 | # See "HelloWorld" tutorial pages for more info on the following commands
|
|---|
| 60 | #
|
|---|
| 61 | defGroup('sender', 'senderTopo') {|node|
|
|---|
| 62 | node.prototype("test:proto:sender", {
|
|---|
| 63 | 'broadcast' => 'on',
|
|---|
| 64 | 'destinationHost' => '192.168.255.255',
|
|---|
| 65 | 'packetSize' => 1024,
|
|---|
| 66 | 'rate' => 200,
|
|---|
| 67 | 'protocol' => 'udp'
|
|---|
| 68 | })
|
|---|
| 69 | node.net.w0.mode = "Master"
|
|---|
| 70 | node.net.w0.type = "g"
|
|---|
| 71 | node.net.w0.essid = "npc123"
|
|---|
| 72 | node.net.w0.ip = "192.168.0.1"
|
|---|
| 73 | wait 30
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | # 4)
|
|---|
| 77 | # Define the 'receiver' group for this experiment
|
|---|
| 78 | # This group will include the node(s) from the 'receiverTopo' topology
|
|---|
| 79 | # See "HelloWorld" tutorial pages for more info on the following commands
|
|---|
| 80 | #
|
|---|
| 81 | defGroup('receivers', 'receiverTopo') {|node|
|
|---|
| 82 | node.prototype("test:proto:receiver" , {
|
|---|
| 83 | 'protocol' => 'udp'
|
|---|
| 84 | })
|
|---|
| 85 | node.net.w0.mode = "Managed"
|
|---|
| 86 | node.net.w0.type = "g"
|
|---|
| 87 | node.net.w0.essid = "npc123"
|
|---|
| 88 | node.net.w0.ip = "%192.168.%x.%y"
|
|---|
| 89 | wait 30
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | # 5)
|
|---|
| 93 | # When all the applications are installed on the nodes in all the groups,
|
|---|
| 94 | # we can start running the applications used in this experiment
|
|---|
| 95 | # See "HelloWorld" tutorial pages for more info on the following commands
|
|---|
| 96 | #
|
|---|
| 97 | whenAllInstalled() {|node|
|
|---|
| 98 | wait 15
|
|---|
| 99 | allGroups.startApplications
|
|---|
| 100 | wait 15
|
|---|
| 101 | Experiment.done
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|