[PATCH v4] dts: add retry loop to trex traffic generation
Andrew Bailey
abailey at iol.unh.edu
Tue Jun 9 15:33:49 CEST 2026
There was an issue where the single core forward test would report zero
MPPS intermittently. This was due to TREX reporting that the link was
down when the client was called to start generating traffic. The links
were being reported down by TREX on the tg even when testpmd was
reporting them up on the SUT. Adding a retry loop to the generate
traffic method of TREX gives the tg enough time to set up and send
traffic.
Bugzilla ID: 1946
Fixes: d77d7f04f24c ("dts: add single-core performance test suite")
Signed-off-by: Andrew Bailey <abailey at iol.unh.edu>
---
.../testbed_model/traffic_generator/trex.py | 35 ++++++++++++++-----
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/dts/framework/testbed_model/traffic_generator/trex.py b/dts/framework/testbed_model/traffic_generator/trex.py
index 22cd20dea9..f21892e396 100644
--- a/dts/framework/testbed_model/traffic_generator/trex.py
+++ b/dts/framework/testbed_model/traffic_generator/trex.py
@@ -220,7 +220,9 @@ def _create_packet_stream(self, packet: Packet) -> None:
]
self._shell.send_command("\n".join(packet_stream))
- def _send_traffic_and_get_stats(self, duration: float, send_mpps: float | None = None) -> str:
+ def _send_traffic_and_get_stats(
+ self, duration: float, send_mpps: float | None = None, retry_attempts: int = 5
+ ) -> str:
"""Send traffic and get TG Rx stats.
Sends traffic from the TRex client's ports for the given duration.
@@ -230,15 +232,30 @@ def _send_traffic_and_get_stats(self, duration: float, send_mpps: float | None =
Args:
duration: The traffic generation duration.
send_mpps: The millions of packets per second for TRex to send from each port.
+ retry_attempts: The number of times to retry this command on failure.
+
+ Raises:
+ SSHTimeoutError: If TRex fails to send traffic in the allotted attempts.
"""
- if send_mpps:
- self._shell.send_command(f"""{self.stl_client_name}.start(ports=[0, 1],
- mult = '{send_mpps}mpps',
- duration = {duration})""")
- else:
- self._shell.send_command(f"""{self.stl_client_name}.start(ports=[0, 1],
- mult = '100%',
- duration = {duration})""")
+ link_up = False
+ attempt = 0
+
+ while not link_up and attempt < retry_attempts:
+ if send_mpps:
+ result = self._shell.send_command(f"""{self.stl_client_name}.start(ports=[0, 1],
+ mult = '{send_mpps}mpps',
+ duration = {duration})""")
+ else:
+ result = self._shell.send_command(f"""{self.stl_client_name}.start(ports=[0, 1],
+ mult = '100%',
+ duration = {duration})""")
+ link_up = "link is DOWN" not in result
+ if not link_up:
+ self._logger.info(
+ f"Generate traffic command failed (attempt {attempt + 1} of {retry_attempts})"
+ )
+ time.sleep(0.25)
+ attempt += 1
time.sleep(duration)
--
2.54.0
More information about the dev
mailing list