DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicholas Pratte <npratte@iol.unh.edu>
To: Honnappa.Nagarahalli@arm.com, dmarx@iol.unh.edu,
	yoan.picchi@foss.arm.com, probb@iol.unh.edu,
	paul.szczepanek@arm.com, luca.vizzarro@arm.com
Cc: dev@dpdk.org, Nicholas Pratte <npratte@iol.unh.edu>
Subject: [PATCH v2] dts: add time delay to async sniffer callback function
Date: Wed, 13 Nov 2024 13:56:29 -0500	[thread overview]
Message-ID: <20241113185629.14327-1-npratte@iol.unh.edu> (raw)
In-Reply-To: <20241030170808.29452-1-npratte@iol.unh.edu>

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>
---
 .../testbed_model/traffic_generator/scapy.py          | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/dts/framework/testbed_model/traffic_generator/scapy.py b/dts/framework/testbed_model/traffic_generator/scapy.py
index be5ae3b895..434c0a231f 100644
--- a/dts/framework/testbed_model/traffic_generator/scapy.py
+++ b/dts/framework/testbed_model/traffic_generator/scapy.py
@@ -188,22 +188,24 @@ 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}')),"
             ),
             ")",
         ]
         if filter_config:
-            sniffer_commands.insert(-1, f"filter='{filter_config}'")
+            sniffer_commands.insert(-2, f"filter='{filter_config}'")
 
         self.send_command(f"\n{self._python_indentation}".join(sniffer_commands))
 
@@ -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


  parent reply	other threads:[~2024-11-13 18:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 17:08 [PATCH v1] " Nicholas Pratte
2024-11-06 20:17 ` Paul Szczepanek
2024-11-13  7:27   ` Patrick Robb
2024-11-13 18:56 ` Nicholas Pratte [this message]
2024-11-14  6:01 ` Patrick Robb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241113185629.14327-1-npratte@iol.unh.edu \
    --to=npratte@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@iol.unh.edu \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).