diff options
author | 2016-01-24 04:01:30 -0500 | |
---|---|---|
committer | 2016-01-24 06:02:46 -0500 | |
commit | 6f4a51c126b7a78ee8e37d396ed2b61b05fa506c (patch) | |
tree | e8b1c20e0d02cb40fa1539f2896f07345625b6f3 /api/stl/examples | |
parent | db5b9d6085b3e5cf71e1abf42c7a745cb723e00e (diff) |
added example
Diffstat (limited to 'api/stl/examples')
-rw-r--r-- | api/stl/examples/stl_simple_burst.py | 53 | ||||
-rw-r--r-- | api/stl/examples/udp_64B.pcap | bin | 0 -> 104 bytes |
2 files changed, 53 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 |