| | 1 | {{{ |
| | 2 | |
| | 3 | # Create an application representation from scratch |
| | 4 | # |
| | 5 | require 'handler/appDefinition' |
| | 6 | |
| | 7 | a = AppDefinition.create('test:app:iperfs') |
| | 8 | a.name = "iperfs" |
| | 9 | a.version(0, 0, 1) |
| | 10 | a.shortDescription = "Iperf traffic generator" |
| | 11 | a.description = <<TEXT |
| | 12 | Iperf is a traffic generator for TCP and UDP traffic. 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('udp', 'Use UDP, otherwise TCP by default', nil, String, false) |
| | 19 | a.addProperty('client', 'Run as client', nil, String, false) |
| | 20 | a.addProperty('port', 'Sender port number', nil, Integer, false) |
| | 21 | a.addProperty('window', 'TCP Send Window Size', nil, Integer, false) |
| | 22 | a.addProperty('len', "Payload length (bytes)", nil, Integer, false) |
| | 23 | a.addProperty('bandwidth', "Offered load for UDP", nil, Integer, false) |
| | 24 | a.addProperty('time', "Duration of traffic generation(secs)", nil, Integer, false) |
| | 25 | a.addProperty('parallel', "Number of parallel flows", nil, Integer, false) |
| | 26 | |
| | 27 | a.path = "/usr/bin/iperf" |
| | 28 | |
| | 29 | if $0 == __FILE__ |
| | 30 | require 'stringio' |
| | 31 | require 'rexml/document' |
| | 32 | include REXML |
| | 33 | |
| | 34 | sio = StringIO.new() |
| | 35 | a.to_xml.write(sio, 2) |
| | 36 | sio.rewind |
| | 37 | puts sio.read |
| | 38 | |
| | 39 | sio.rewind |
| | 40 | doc = Document.new(sio) |
| | 41 | t = AppDefinition.from_xml(doc.root) |
| | 42 | |
| | 43 | |
| | 44 | }}} |