summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/examples
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-03 16:34:20 +0200
committerimarom <imarom@cisco.com>2016-03-03 18:11:08 +0200
commit13cfb2c4ea55b7e0dab40155d8d51e7955ae4681 (patch)
tree7887702e364d3aa1917e3f9ca073602b88cae8c5 /scripts/automation/trex_control_plane/stl/examples
parent0a10805acc189a36eecb4d49b858bd911bc45f4e (diff)
RX stats API
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/examples')
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_run_udp_simple.py1
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py57
2 files changed, 57 insertions, 1 deletions
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_run_udp_simple.py b/scripts/automation/trex_control_plane/stl/examples/stl_run_udp_simple.py
index db005608..465b3dde 100644
--- a/scripts/automation/trex_control_plane/stl/examples/stl_run_udp_simple.py
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_run_udp_simple.py
@@ -19,7 +19,6 @@ class t_global(object):
args=None;
-import dpkt
import time
import json
import string
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py b/scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py
new file mode 100644
index 00000000..daff6105
--- /dev/null
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py
@@ -0,0 +1,57 @@
+import stl_path
+from trex_stl_lib.api import *
+
+import time
+import pprint
+
+def rx_example (tx_port, rx_port):
+
+ # create client
+ c = STLClient()
+ passed = True
+
+ try:
+ pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example')
+ total_pkts = 500000
+ s1 = STLStream(name = 'rx',
+ packet = pkt,
+ rx_stats = STLRxStats(user_id = 5),
+ mode = STLTXSingleBurst(total_pkts = total_pkts, bps_L2 = 250000000))
+
+ # connect to server
+ c.connect()
+
+ # prepare our ports
+ c.reset(ports = [tx_port, rx_port])
+
+ # add both streams to ports
+ c.add_streams([s1], ports = [tx_port])
+
+ print "injecting {0} packets on port {1}".format(total_pkts, tx_port)
+ c.clear_stats()
+ c.start(ports = [tx_port])
+ c.wait_on_traffic(ports = [tx_port])
+
+ time.sleep(1)
+ stats = c.get_stats()
+ pprint.pprint(stats['rx_stats'])
+ print "port 3: ipackets {0}, ibytes {1}".format(stats[3]['ipackets'], stats[3]['ibytes'])
+ #rx_stas = stats['rx_stats']
+
+
+ except STLError as e:
+ passed = False
+ print e
+
+ finally:
+ c.disconnect()
+
+ if passed:
+ print "\nTest has passed :-)\n"
+ else:
+ print "\nTest has failed :-(\n"
+
+
+# run the tests
+rx_example(tx_port = 0, rx_port = 3)
+