Code for the Otr.rb Application

The code for the Orbit Traffic Receiver application is given below.

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