|   | 1 | [wiki:WikiStart Orbit] > [wiki:Documentation/Athstats Athstats] > [wiki:Documentation/Athstats/ScriptsRepository Scripts Repository] > UDP/TCP Unicast | 
          
          
            |   | 2 |  | 
          
          
            |   | 3 | {{{ | 
          
          
            |   | 4 |  | 
          
          
            |   | 5 | require 'net/http' | 
          
          
            |   | 6 | require 'uri' | 
          
          
            |   | 7 |  | 
          
          
            |   | 8 | Experiment.name = "tutorial-1a" | 
          
          
            |   | 9 | Experiment.project = "orbit:tutorial" | 
          
          
            |   | 10 |  | 
          
          
            |   | 11 | defProperty('rate', 300, 'Bits per second sent from sender') | 
          
          
            |   | 12 | defProperty('packetSize', 256, 'Size of packets sent from sender') | 
          
          
            |   | 13 | defProperty('startExp', 0, 'Start experiment flag - set to true only when all nodes have associated') | 
          
          
            |   | 14 |  | 
          
          
            |   | 15 | defNodes('receiver', [1,2]) {|node| | 
          
          
            |   | 16 |    node.image = nil  # assume the right image to be on disk | 
          
          
            |   | 17 |    node.prototype("test:proto:receiver" , { | 
          
          
            |   | 18 |         'hostname' => '192.168.1.2', | 
          
          
            |   | 19 |         'protocol' => 'udp' | 
          
          
            |   | 20 |    }) | 
          
          
            |   | 21 |    node.net.w0.type = 'a' | 
          
          
            |   | 22 |    node.net.w0.essid = "neo" | 
          
          
            |   | 23 |    node.net.w0.mode = "master" | 
          
          
            |   | 24 |    node.net.w0.ip = "%192.168.%x.%y" | 
          
          
            |   | 25 | } | 
          
          
            |   | 26 |  | 
          
          
            |   | 27 | defNodes('sender', [1,1]) {|node| | 
          
          
            |   | 28 |    node.image = nil  # assume the right image to be on disk | 
          
          
            |   | 29 |    node.prototype("test:proto:sender", { | 
          
          
            |   | 30 |         'destinationHost' => '192.168.1.2', | 
          
          
            |   | 31 |         'packetSize' => Experiment.property("packetSize"), | 
          
          
            |   | 32 |         'rate' => Experiment.property("rate"), | 
          
          
            |   | 33 |         'protocol' => 'udp', | 
          
          
            |   | 34 |    }) | 
          
          
            |   | 35 |    node.net.w0.type = 'a' | 
          
          
            |   | 36 |    node.net.w0.essid = "neo" | 
          
          
            |   | 37 |    node.net.w0.mode = "managed" | 
          
          
            |   | 38 |    node.net.w0.ip = "%192.168.%x.%y" | 
          
          
            |   | 39 | } | 
          
          
            |   | 40 |  | 
          
          
            |   | 41 | defNodes('allnodes', [[1,1],[1,2]]) {|node| | 
          
          
            |   | 42 |    node.image = nil  # assume the right image to be on disk | 
          
          
            |   | 43 |    node.prototype("test:proto:driverqueryapp", { | 
          
          
            |   | 44 |         'interface' => 'ath0', | 
          
          
            |   | 45 |         'interval' => '1000', | 
          
          
            |   | 46 |    }) | 
          
          
            |   | 47 | } | 
          
          
            |   | 48 |  | 
          
          
            |   | 49 | whenAllInstalled() {|node| | 
          
          
            |   | 50 |   Experiment.props.packetSize = 1350 | 
          
          
            |   | 51 |   Experiment.props.rate = 35000 | 
          
          
            |   | 52 |   Experiment.props.startExp = 0 | 
          
          
            |   | 53 |  | 
          
          
            |   | 54 |   puts "Starting applications" | 
          
          
            |   | 55 |  | 
          
          
            |   | 56 |   nodes('allnodes').startApplications | 
          
          
            |   | 57 |   nodes('receiver').startApplications | 
          
          
            |   | 58 |   nodes('sender').startApplications | 
          
          
            |   | 59 |  | 
          
          
            |   | 60 |   wait 60 | 
          
          
            |   | 61 |  | 
          
          
            |   | 62 |   puts "Stopping applications" | 
          
          
            |   | 63 |  | 
          
          
            |   | 64 |   nodes('sender').stopApplications | 
          
          
            |   | 65 |   nodes('receiver').stopApplications | 
          
          
            |   | 66 |   nodes('allnodes').stopApplications | 
          
          
            |   | 67 |  | 
          
          
            |   | 68 |   wait 10 | 
          
          
            |   | 69 |   Experiment.done | 
          
          
            |   | 70 | } | 
          
          
            |   | 71 |  | 
          
          
            |   | 72 | }}} |