| | 1 | [wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/ScriptsRepository Scripts Repository] > forwarder.rb |
| | 2 | |
| | 3 | |
| | 4 | {{{ |
| | 5 | require 'handler/prototype' |
| | 6 | require 'handler/filter' |
| | 7 | require 'handler/appDefinition' |
| | 8 | |
| | 9 | p = Prototype.create("test:proto:forwarder") |
| | 10 | p.name = "Forwarder" |
| | 11 | p.description = "Nodes which forward packets" |
| | 12 | p.defProperty('protocol', 'Protocol to use', 'raw') |
| | 13 | p.defProperty('rxdev', 'hw interface to listen on', 'eth0') |
| | 14 | p.defProperty('txdev', 'hw interaface to send', 'eth0') |
| | 15 | p.defProperty('ipFilter', 'IP address of the destination', '12.0.0.6') |
| | 16 | p.defProperty('nextHopMAC', 'HW (MAC) address of next-hop receiver', 'FF:FF:FF:FF:FF:FF') |
| | 17 | |
| | 18 | otf = p.addApplication('otf', "test:app:otf") |
| | 19 | |
| | 20 | otf.bindProperty('protocol') |
| | 21 | otf.bindProperty('rxdev') |
| | 22 | otf.bindProperty('txdev') |
| | 23 | otf.bindProperty('dstfilter','ipFilter') |
| | 24 | otf.bindProperty('dstmacaddr','nextHopMAC') |
| | 25 | |
| | 26 | otf.addMeasurement('senderport', Filter::TIME, |
| | 27 | {Filter::SAMPLE_SIZE => 1}, |
| | 28 | [ |
| | 29 | ['stream_no'], |
| | 30 | ['pkt_seqno'], |
| | 31 | ['pkt_size', Filter::SUM], |
| | 32 | ['gen_timestamp'], |
| | 33 | ['tx_timestamp'] |
| | 34 | ] |
| | 35 | |
| | 36 | otf.addMeasurement('receiverport', Filter::TIME, |
| | 37 | {Filter::SAMPLE_SIZE => 1}, |
| | 38 | [ |
| | 39 | ['stream_no'], |
| | 40 | ['pkt_seqno'], |
| | 41 | ['sender_port'], ['flow_no'], |
| | 42 | ['pkt_num_rcvd'], |
| | 43 | ['rcvd_pkt_size', Filter::SUM], |
| | 44 | ['rx_timestamp', Filter::MEAN], |
| | 45 | ['rssi', Filter::MEAN], |
| | 46 | ['xmitrate'] |
| | 47 | ] |
| | 48 | ) |
| | 49 | |
| | 50 | if $0 == __FILE__ |
| | 51 | p.to_xml.write($stdout, 2) |
| | 52 | puts |
| | 53 | end |
| | 54 | |
| | 55 | }}} |