diff options
author | 2016-01-24 04:01:30 -0500 | |
---|---|---|
committer | 2016-01-24 06:02:46 -0500 | |
commit | 6f4a51c126b7a78ee8e37d396ed2b61b05fa506c (patch) | |
tree | e8b1c20e0d02cb40fa1539f2896f07345625b6f3 /api | |
parent | db5b9d6085b3e5cf71e1abf42c7a745cb723e00e (diff) |
added example
Diffstat (limited to 'api')
-rw-r--r-- | api/stl/examples/stl_simple_burst.py | 53 | ||||
-rw-r--r-- | api/stl/examples/udp_64B.pcap | bin | 0 -> 104 bytes | |||
-rw-r--r-- | api/stl/profiles/burst.yaml | 39 | ||||
-rw-r--r-- | api/stl/trex_stl_api.py | 17 |
4 files changed, 109 insertions, 0 deletions
diff --git a/api/stl/examples/stl_simple_burst.py b/api/stl/examples/stl_simple_burst.py new file mode 100644 index 00000000..7efb574a --- /dev/null +++ b/api/stl/examples/stl_simple_burst.py @@ -0,0 +1,53 @@ +import sys +sys.path.insert(0, "../") + +import trex_stl_api + +from trex_stl_api import STLClient, STLError + +import time + +# define a simple burst test +def simple_burst (): + + passed = True + + try: + with STLClient() as c: + + # activate this for some logging information + #c.logger.set_verbose(c.logger.VERBOSE_REGULAR) + + # repeat for 5 times + for i in xrange(1, 6): + + # read the stats before + before_ipackets = c.get_stats()['total']['ipackets'] + + # inject burst profile on two ports and block until done + c.start(profiles = '../profiles/burst.yaml', ports = [0, 1], mult = "1gbps") + c.wait_on_traffic(ports = [0, 1]) + + after_ipackets = c.get_stats()['total']['ipackets'] + + print "Test iteration {0} - Packets Received: {1} ".format(i, (after_ipackets - before_ipackets)) + + # we have 600 packets in the burst and two ports + if (after_ipackets - before_ipackets) != (600 * 2): + passed = False + + # error handling + except STLError as e: + passed = False + print e + + + + if passed: + print "\nTest has passed :-)\n" + else: + print "\nTest has failed :-(\n" + + +simple_burst() + diff --git a/api/stl/examples/udp_64B.pcap b/api/stl/examples/udp_64B.pcap Binary files differnew file mode 100644 index 00000000..699b9c80 --- /dev/null +++ b/api/stl/examples/udp_64B.pcap diff --git a/api/stl/profiles/burst.yaml b/api/stl/profiles/burst.yaml new file mode 100644 index 00000000..dbd348c7 --- /dev/null +++ b/api/stl/profiles/burst.yaml @@ -0,0 +1,39 @@ +### Single stream UDP packet, 64B ### +##################################### +- name: stream0 + stream: + self_start: True + next_stream_id: stream1 + packet: + binary: udp_64B.pcap + mode: + type: single_burst + pps: 100 + total_pkts : 100 + rx_stats: [] + vm: [] + +- name: stream1 + stream: + self_start: False + next_stream_id: stream2 + packet: + binary: udp_64B.pcap + mode: + type: single_burst + pps: 100 + total_pkts : 200 + rx_stats: [] + vm: [] + +- name: stream2 + stream: + self_start: False + packet: + binary: udp_64B.pcap + mode: + type: single_burst + pps: 100 + total_pkts : 300 + rx_stats: [] + vm: [] diff --git a/api/stl/trex_stl_api.py b/api/stl/trex_stl_api.py new file mode 100644 index 00000000..aad39916 --- /dev/null +++ b/api/stl/trex_stl_api.py @@ -0,0 +1,17 @@ +import os +import sys +import time + + +# update the import path to include the stateless client +root_path = os.path.dirname(os.path.abspath(__file__)) + +sys.path.insert(0, os.path.join(root_path, '../../scripts/automation/trex_control_plane/client/')) +sys.path.insert(0, os.path.join(root_path, '../../scripts/automation/trex_control_plane/client_utils/')) +sys.path.insert(0, os.path.join(root_path, '../../scripts/automation/trex_control_plane/client_utils/')) + +# aliasing +import trex_stateless_client +STLClient = trex_stateless_client.STLClient +STLError = trex_stateless_client.STLError + |