* [PATCH v1] dts: add time delay to async sniffer callback function
@ 2024-10-30 17:08 Nicholas Pratte
0 siblings, 0 replies; only message in thread
From: Nicholas Pratte @ 2024-10-30 17:08 UTC (permalink / raw)
To: yoan.picchi, dmarx, paul.szczepanek, Honnappa.Nagarahalli,
luca.vizzarro, probb
Cc: dev, Nicholas Pratte
There exists a bug within i40e NICs in which the async sniffer does not
catch send packets as a result of the callback function sending packets
too quickly before the NICs are ready to start capturing.
There could be a multitude of reasons why this happens on these NICs, but
for the time being, inserting a one second delay in the callback function
will suffice.
Bugzilla ID: 1573
Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
---
dts/framework/testbed_model/traffic_generator/scapy.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dts/framework/testbed_model/traffic_generator/scapy.py b/dts/framework/testbed_model/traffic_generator/scapy.py
index be5ae3b895..9fa9feaf47 100644
--- a/dts/framework/testbed_model/traffic_generator/scapy.py
+++ b/dts/framework/testbed_model/traffic_generator/scapy.py
@@ -188,17 +188,19 @@ def _shell_create_sniffer(
when set to an empty string.
"""
self._shell_set_packet_list(packets_to_send)
+ # We need to introduce a short delay in the sniffer sendp() for i40e NICs.
+ self.send_command("import time")
sniffer_commands = [
f"{self._sniffer_name} = AsyncSniffer(",
f"iface='{recv_port.logical_name}',",
"store=True,",
# *args is used in the arguments of the lambda since Scapy sends parameters to the
# callback function which we do not need for our purposes.
- "started_callback=lambda *args: sendp(",
+ "started_callback=lambda *args: (time.sleep(1), sendp(",
(
# Additional indentation is added to this line only for readability of the logs.
f"{self._python_indentation}{self._send_packet_list_name},"
- f" iface='{send_port.logical_name}'),"
+ f" iface='{send_port.logical_name}')),"
),
")",
]
@@ -223,7 +225,8 @@ def _shell_start_and_stop_sniffing(self, duration: float) -> list[Packet]:
"""
sniffed_packets_name = "gathered_packets"
self.send_command(f"{self._sniffer_name}.start()")
- time.sleep(duration)
+ # Insert a one second delay to prevent timeout errors from occurring
+ time.sleep(duration + 1)
self.send_command(f"{sniffed_packets_name} = {self._sniffer_name}.stop(join=True)")
# An extra newline is required here due to the nature of interactive Python shells
packet_strs = self.send_command(
--
2.44.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-10-30 17:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-30 17:08 [PATCH v1] dts: add time delay to async sniffer callback function Nicholas Pratte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).