| 1 | [wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/ScriptsRepository Scripts Repository] > otr.rb |
| 2 | |
| 3 | {{{ |
| 4 | require 'handler/appDefinition' |
| 5 | |
| 6 | a = AppDefinition.create('test:app:otr') |
| 7 | a.name = "otr" |
| 8 | a.version(1, 1, 2) |
| 9 | a.shortDescription = "Programmable traffic generator" |
| 10 | a.description = <<TEXT |
| 11 | otr is a configurable traffic sink. It contains port to receive |
| 12 | packet streams via various transport options, such as TCP and UDP. |
| 13 | TEXT |
| 14 | |
| 15 | #addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil) |
| 16 | a.addProperty('protocol', 'Protocol to use [udp|tcp]', nil, String, false) |
| 17 | a.addProperty('hostname', 'My own ID', nil, String, false) |
| 18 | a.addProperty('port', 'transport port number of listen on', nil, "xsd:int", false) |
| 19 | a.addProperty('rxdev', 'Device Name of local host to receive',nil, String, false) |
| 20 | a.addProperty('dstfilter','filter packets with IP destination address',nil, String, false) |
| 21 | |
| 22 | |
| 23 | a.addMeasurement("receiverport", nil, [ |
| 24 | ['pkt_seqno', 'long', 'Packet sequence id of the stream'], |
| 25 | ['flow_no', 'int','id of receiving flow'], |
| 26 | ['rcvd_pkt_size', 'long', 'Payload size'], |
| 27 | ['rx_timestamp', 'long', 'Time when packet has been received'], |
| 28 | ['rssi', 'int', 'rssi of received packet'] , |
| 29 | ['xmitrate','int','channel rate of received packet'] |
| 30 | ]) |
| 31 | |
| 32 | a.addMeasurement("flow", nil, [ |
| 33 | ['flow_no', 'int', 'id of the flow'], |
| 34 | ['sender_port', 'int', 'port number of sender socket'] |
| 35 | ]) |
| 36 | |
| 37 | #a.aptName = 'orbit-otr' |
| 38 | |
| 39 | a.path = "/usr/local/bin/otr" |
| 40 | |
| 41 | if $0 == __FILE__ |
| 42 | require 'stringio' |
| 43 | require 'rexml/document' |
| 44 | include REXML |
| 45 | |
| 46 | sio = StringIO.new() |
| 47 | a.to_xml.write($stdout, 2) |
| 48 | end |
| 49 | }}} |