summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
index 29341674..4bd9fd4c 100644
--- a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
@@ -3,47 +3,49 @@ from trex_stl_lib.api import *
import time
-def simple_burst ():
+def simple_burst (port_a, port_b, pkt_size, burst_size, rate):
# 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')
+ pkt_base = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()
+ pad = max(0, pkt_size - len(pkt_base)) * 'x'
+ pkt = STLPktBuilder(pkt = pkt_base / pad)
# create two bursts and link them
s1 = STLStream(name = 'A',
packet = pkt,
- mode = STLTXSingleBurst(total_pkts = 5000),
+ mode = STLTXSingleBurst(total_pkts = burst_size),
next = 'B')
s2 = STLStream(name = 'B',
self_start = False,
packet = pkt,
- mode = STLTXSingleBurst(total_pkts = 3000))
+ mode = STLTXSingleBurst(total_pkts = burst_size))
# connect to server
c.connect()
# prepare our ports
- c.reset(ports = [0, 3])
+ c.reset(ports = [port_a, port_b])
# add both streams to ports
- stream_ids = c.add_streams([s1, s2], ports = [0, 3])
+ stream_ids = c.add_streams([s1, s2], ports = [port_a, port_b])
# run 5 times
for i in range(1, 6):
c.clear_stats()
- c.start(ports = [0, 3], mult = "1gbps")
- c.wait_on_traffic(ports = [0, 3])
+ c.start(ports = [port_a, port_b], mult = rate)
+ c.wait_on_traffic(ports = [port_a, port_b])
stats = c.get_stats()
ipackets = stats['total']['ipackets']
print("Test iteration {0} - Packets Received: {1} ".format(i, ipackets))
- # (5000 + 3000) * 2 ports = 16,000
- if (ipackets != (16000)):
+ # two streams X 2 ports
+ if (ipackets != (burst_size * 2 * 2)):
passed = False
except STLError as e:
@@ -53,12 +55,17 @@ def simple_burst ():
finally:
c.disconnect()
- if passed:
+ if c.get_warnings():
+ print("\n\n*** test had warnings ****\n\n")
+ for w in c.get_warnings():
+ print(w)
+
+ if passed and not c.get_warnings():
print("\nTest has passed :-)\n")
else:
print("\nTest has failed :-(\n")
# run the tests
-simple_burst()
+simple_burst(0, 3, 256, 50000, "80%")