|   | 1 |  | 
          
          
            |   | 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:tcpsender") | 
          
          
            |   | 14 | p.name = "Sender" | 
          
          
            |   | 15 | p.description = "A node which transmit a stream of packets" | 
          
          
            |   | 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', 'cbr') | 
          
          
            |   | 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 |  | 
          
          
            |   | 24 | # Define applications to be installed on this type of node, | 
          
          
            |   | 25 | # bind the application properties to the prototype properties, | 
          
          
            |   | 26 | # and finally, define what measurements should be collected | 
          
          
            |   | 27 | # for each application. | 
          
          
            |   | 28 | # | 
          
          
            |   | 29 | otg = p.addApplication(:otg, "test:app:otg") | 
          
          
            |   | 30 | otg.bindProperty('protocol') | 
          
          
            |   | 31 | otg.bindProperty('port') | 
          
          
            |   | 32 | otg.bindProperty('generator') | 
          
          
            |   | 33 | otg.bindProperty('dsthostname', 'destinationHost') | 
          
          
            |   | 34 | otg.bindProperty('size', 'packetSize') | 
          
          
            |   | 35 | otg.bindProperty('rate') | 
          
          
            |   | 36 |  | 
          
          
            |   | 37 | otg.addMeasurement('senderport',  Filter::TIME,  | 
          
          
            |   | 38 |   {Filter::SAMPLE_SIZE => 1}, | 
          
          
            |   | 39 |   [   | 
          
          
            |   | 40 |     ['pkt_seqno'], | 
          
          
            |   | 41 |     ['pkt_size', Filter::SUM], | 
          
          
            |   | 42 |     ['gen_timestamp'], | 
          
          
            |   | 43 |     ['tx_timestamp'] | 
          
          
            |   | 44 |   ] | 
          
          
            |   | 45 | ) | 
          
          
            |   | 46 |  | 
          
          
            |   | 47 | if $0 == __FILE__ | 
          
          
            |   | 48 |   p.to_xml.write($stdout, 2) | 
          
          
            |   | 49 |   puts | 
          
          
            |   | 50 | end | 
          
          
            |   | 51 |  | 
          
          
            |   | 52 |  | 
          
          
            |   | 53 |  | 
          
          
            |   | 54 |  | 
          
          
            |   | 55 | }}} |