|  | 1 | [wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/ScriptsRepository Scripts Repository] > otf.rb | 
          
            |  | 2 |  | 
          
            |  | 3 | {{{ | 
          
            |  | 4 |  | 
          
            |  | 5 | require 'handler/appDefinition' | 
          
            |  | 6 |  | 
          
            |  | 7 | a = AppDefinition.create('test:app:otf') | 
          
            |  | 8 | a.name = "otr" | 
          
            |  | 9 | a.version(0, 0, 2) | 
          
            |  | 10 | a.shortDescription = "Programmable traffic forwarder" | 
          
            |  | 11 | a.description = <<TEXT | 
          
            |  | 12 | otf is a configurable traffic forwarder. It re-route traffice from one | 
          
            |  | 13 | incoming interface to another one using raw sockets | 
          
            |  | 14 | TEXT | 
          
            |  | 15 |  | 
          
            |  | 16 | #addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil) | 
          
            |  | 17 | a.addProperty('protocol', 'Protocol to use [raw|raw_libmac]', nil, String, false) | 
          
            |  | 18 | a.addProperty('rxdev', 'incoming interface [eth0|eth2|eth3|ath0|ath1]', nil, String, false) | 
          
            |  | 19 | a.addProperty('txdev', 'outgoing interface [eth0|eth2|eth3|ath0|ath1]', nil, String, false) | 
          
            |  | 20 | a.addProperty('dstfilter', 'packet filter using destination IP address', nil, String, false) | 
          
            |  | 21 | a.addProperty('dstmacaddr', 'MAC address for next-hop', nil,String, false) | 
          
            |  | 22 |  | 
          
            |  | 23 | a.addMeasurement("senderport", nil, [ | 
          
            |  | 24 | ['stream_no', 'int'], | 
          
            |  | 25 | ['pkt_seqno', 'long'], | 
          
            |  | 26 | ['pkt_size', 'long'], | 
          
            |  | 27 | ['gen_timestamp', 'long'], | 
          
            |  | 28 | ['tx_timestamp', 'long'] | 
          
            |  | 29 | ]) | 
          
            |  | 30 |  | 
          
            |  | 31 | a.addMeasurement("otfreceiver", nil, [ | 
          
            |  | 32 | ['flow_no'],'int','id of receiving flow'], | 
          
            |  | 33 | ['pkt_num_rcvd','long',' Packet Sequence id of the flow'], | 
          
            |  | 34 | ['rcvd_pkt_size', 'long', 'Payload size'], | 
          
            |  | 35 | ['rx_timestamp', 'long', 'Time when packet has been received'], | 
          
            |  | 36 | ['rssi', 'int', 'rssi of received packet'] , | 
          
            |  | 37 | ['xmit_rate','int','channel rate of received packet'] | 
          
            |  | 38 | ]) | 
          
            |  | 39 |  | 
          
            |  | 40 | a.path = "/usr/local/bin/otf" | 
          
            |  | 41 |  | 
          
            |  | 42 | if $0 == __FILE__ | 
          
            |  | 43 | require 'stringio' | 
          
            |  | 44 | require 'rexml/document' | 
          
            |  | 45 | include REXML | 
          
            |  | 46 |  | 
          
            |  | 47 | sio = StringIO.new() | 
          
            |  | 48 | a.to_xml.write($stdout, 2) | 
          
            |  | 49 | end | 
          
            |  | 50 |  | 
          
            |  | 51 |  | 
          
            |  | 52 | }}} |