| | 1 | {{{ |
| | 2 | # |
| | 3 | # Create an application representation from scratch |
| | 4 | # |
| | 5 | require 'handler/appDefinition' |
| | 6 | |
| | 7 | a = AppDefinition.create('test:app:otg') |
| | 8 | a.name = "otg" |
| | 9 | a.version(1, 1, 2) |
| | 10 | a.shortDescription = "Programmable traffic generator" |
| | 11 | a.description = <<TEXT |
| | 12 | OTG is a configurable traffic generator. It contains generators |
| | 13 | producing various forms of packet streams and port for sending |
| | 14 | these packets via various transports, such as TCP and UDP. |
| | 15 | TEXT |
| | 16 | |
| | 17 | # addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil) |
| | 18 | a.addProperty('protocol', 'Protocol to use [udp|tcp]', nil, String, false) |
| | 19 | a.addProperty('generator', "Generator to use [cbr|expoo]'; nil, String, false) |
| | 20 | #UDP/TCP |
| | 21 | a.addProperty("port", "Local port to bind to [int]", nil, Integer, false) |
| | 22 | a.addProperty("dsthostname", "Name of destination host [string]", nil, String, false) |
| | 23 | a.addProperty("dstport", "Destination port to send to", nil, String, false) |
| | 24 | a.addProperty("broadcast", "broadcast on/off", nil, String, false) |
| | 25 | |
| | 26 | # RAW |
| | 27 | a.addProperty("txdev","the device to tranmsit packets", nil, String, false) |
| | 28 | a.addProperty("dstmacaddr", "MAC address of the destination", nil, String, false) |
| | 29 | |
| | 30 | # CBR Generator |
| | 31 | a.addProperty("size", "Size of packet [bytes]", nil, Integer, false) |
| | 32 | a.addProperty("interval", "Internval between consecutive packets [msec]", nil, Integer, false) |
| | 33 | a.addProperty("rate", "Data rate of the flow [kbps]", nil, Integer, false) |
| | 34 | |
| | 35 | # Exponential On/Off traffic generator |
| | 36 | a.addProperty("ontime", "average burst length in milliseconds", nil, Integer, false) |
| | 37 | a.addProperty("offtime", "average idle time in milliseconds", nil, Integer, false) |
| | 38 | |
| | 39 | a.addMeasurement("senderport", nil, [ |
| | 40 | ['pkt_seqno', 'long'], |
| | 41 | ['pkt_size', 'long'], |
| | 42 | ['gen_timestamp', Float], |
| | 43 | ['tx_timestamp', 'long'] |
| | 44 | ]) |
| | 45 | |
| | 46 | #a.aptName = 'orbit-otg' |
| | 47 | |
| | 48 | a.path = "/usr/bin/otg" |
| | 49 | |
| | 50 | |
| | 51 | if $0 == __FILE__ |
| | 52 | require 'stringio' |
| | 53 | require 'rexml/document' |
| | 54 | include REXML |
| | 55 | |
| | 56 | sio = StringIO.new() |
| | 57 | a.to_xml.write(sio, 2) |
| | 58 | sio.rewind |
| | 59 | puts sio.read |
| | 60 | |
| | 61 | sio.rewind |
| | 62 | doc = Document.new(sio) |
| | 63 | t = AppDefinition.from_xml(doc.root) |
| | 64 | |
| | 65 | puts |
| | 66 | puts "-------------------------" |
| | 67 | puts |
| | 68 | t.to_xml.write($stdout, 2) |
| | 69 | end |
| | 70 | |
| | 71 | }}} |