| | 1 | [wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/ScriptsRepository Scripts Repository] > expoo_sender.rb |
| | 2 | |
| | 3 | {{{ |
| | 4 | # |
| | 5 | # Define a prototype containing a single |
| | 6 | # traffic generator (otg). |
| | 7 | # |
| | 8 | |
| | 9 | require 'handler/prototype' |
| | 10 | require 'handler/filter' |
| | 11 | require 'handler/appDefinition' |
| | 12 | |
| | 13 | p = Prototype.create("test:proto:expoo_sender") |
| | 14 | p.name = "Exponential on off Sender" |
| | 15 | p.description = "A node which transmit a stream of packets with expoo geneator" |
| | 16 | # List properties of prototype |
| | 17 | p.defProperty('protocol', 'Protocol to use', 'udp') |
| | 18 | p.defProperty('port', 'port to bind by sender', 3000) |
| | 19 | p.defProperty('generator', 'Generator to use', 'expoo') |
| | 20 | p.defProperty('destinationHost', 'Host to send packets to') |
| | 21 | p.defProperty('packetSize', 'Size of packets', 1000) |
| | 22 | p.defProperty('rate', 'Number of bits per second', 1000) |
| | 23 | p.defProperty('ontime', 'burst length') |
| | 24 | p.defProperty('offtime','average idle time duration') |
| | 25 | p.defProperty('broadcast','broadcast or not', 'off') |
| | 26 | |
| | 27 | # Define applications to be installed on this type of node, |
| | 28 | # bind the application properties to the prototype properties, |
| | 29 | # and finally, define what measurements should be collected |
| | 30 | # for each application |
| | 31 | # |
| | 32 | otg = p.addApplication(:otg, "test:app:otg") |
| | 33 | otg.bindProperty('protocol') |
| | 34 | otg.bindProperty('port') |
| | 35 | otg.bindProperty('generator') |
| | 36 | otg.bindProperty('dsthostname', 'destinationHost') |
| | 37 | otg.bindProperty('size', 'packetSize') |
| | 38 | otg.bindProperty('rate') |
| | 39 | otg.bindProperty('ontime') |
| | 40 | otg.bindProperty('offtime') |
| | 41 | otg.bindProperty('broadcast') |
| | 42 | |
| | 43 | otg.addMeasurement('senderport', Filter::TIME, |
| | 44 | {Filter::SAMPLE_SIZE => 1}, |
| | 45 | [ |
| | 46 | ['pkt_seqno'], |
| | 47 | ['pkt_size', Filter::SUM], |
| | 48 | ['gen_timestamp'], |
| | 49 | ['tx_timestamp'] |
| | 50 | ] |
| | 51 | ) |
| | 52 | |
| | 53 | if $0 == __FILE__ |
| | 54 | p.to_xml.write($stdout, 2) |
| | 55 | puts |
| | 56 | end |
| | 57 | |
| | 58 | }}} |