| | 1 | {{{ |
| | 2 | # |
| | 3 | # Create an application representation from scratch |
| | 4 | # |
| | 5 | require 'handler/appDefinition' |
| | 6 | |
| | 7 | a = AppDefinition.create('test:app:itgs') |
| | 8 | a.name = "itgs" |
| | 9 | a.version(0, 0, 1) |
| | 10 | a.shortDescription = "D-ITG Sender" |
| | 11 | a.description = <<TEXT |
| | 12 | ITGSend 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 | #Flow options |
| | 19 | a.addProperty('m', 'MSR type: either onewaydelay or RTT', ?m, String, false) |
| | 20 | a.addProperty('a', 'Destination address', ?a, String, false) |
| | 21 | a.addProperty('r', 'Remote port', ?r, Integer, false) |
| | 22 | a.addProperty('T', 'Protocol type TCP/UDP/UDP_Libmac', ?T, Integer, false) |
| | 23 | a.addProperty('f', 'TTL',?f, Integer, false) |
| | 24 | a.addProperty('d', 'Gen_Delay',?d, Integer, false) |
| | 25 | a.addProperty('t', "Duration of traffic generation(millisecs)", ?t, Integer, false) |
| | 26 | |
| | 27 | #Interdeparture time options |
| | 28 | a.addProperty('C', 'Constant interdeparture time b/w packets (pkts_per_s)', ?C, Integer, false) |
| | 29 | a.addProperty('E', '(Exponential) Average packets per sec', ?E, Integer, false) |
| | 30 | a.addProperty('O', '(Poisson) Average pkts per sec', ?O, Integer, false) |
| | 31 | #Note that Pareto, Cauchy, UNiform, Normal and Gamma distributions will be added |
| | 32 | |
| | 33 | #Log file options |
| | 34 | a.addProperty('l', 'Log file', ?l, String, false) |
| | 35 | |
| | 36 | #Packet size options |
| | 37 | a.addProperty('c', 'Constant payload size', ?c, Integer, false) |
| | 38 | a.addProperty('e', "Average pkt size (exponential)", ?e, Integer, false) |
| | 39 | a.addProperty('o', "Poisson distributed avg. pkt size", ?o, Integer, false) |
| | 40 | #Note that Pareto, Cauchy, UNiform, Normal and Gamma distributions will be added |
| | 41 | |
| | 42 | # Applications (note that no other interdeparture or packet size can be chosen |
| | 43 | # if an application is chosen |
| | 44 | a.addProperty('App', 'VoIP traffic', ?Z, Integer, false) |
| | 45 | a.addProperty('codec', 'VoIP codec: G.711.1, G.711.2, G.723.1, G.729.2, G.729.3', ?i, String, false) |
| | 46 | a.addProperty('voip_control', 'protocol_type RTP or CRTP',?h, String, false) |
| | 47 | |
| | 48 | a.addProperty('Telnet', 'Telnet traffic', nil, Integer, false) |
| | 49 | a.addProperty('DNS', 'DNS traffic', nil, Integer, false) |
| | 50 | |
| | 51 | |
| | 52 | a.path = "/usr/bin/ITGSend" |
| | 53 | |
| | 54 | if $0 == __FILE__ |
| | 55 | require 'stringio' |
| | 56 | require 'rexml/document' |
| | 57 | include REXML |
| | 58 | |
| | 59 | sio = StringIO.new() |
| | 60 | a.to_xml.write(sio, 2) |
| | 61 | sio.rewind |
| | 62 | puts sio.read |
| | 63 | |
| | 64 | sio.rewind |
| | 65 | doc = Document.new(sio) |
| | 66 | t = AppDefinition.from_xml(doc.root) |
| | 67 | |
| | 68 | puts |
| | 69 | puts "-------------------------" |
| | 70 | puts |
| | 71 | t.to_xml.write($stdout, 2) |
| | 72 | |
| | 73 | end |
| | 74 | |
| | 75 | |
| | 76 | }}} |