[PATCH v2 7/7] dts: save received packets with artifacts

Luca Vizzarro luca.vizzarro at arm.com
Thu Sep 4 13:45:07 CEST 2025


The CapturingTrafficGenerator class manually creates pcaps to store the
received packets into. Change the behaviour to rely on Artifacts for
this operation.

Signed-off-by: Luca Vizzarro <luca.vizzarro at arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek at arm.com>
---
 .../traffic_generator/capturing_traffic_generator.py     | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/dts/framework/testbed_model/traffic_generator/capturing_traffic_generator.py b/dts/framework/testbed_model/traffic_generator/capturing_traffic_generator.py
index a85858ba07..ec0993e6b7 100644
--- a/dts/framework/testbed_model/traffic_generator/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/traffic_generator/capturing_traffic_generator.py
@@ -16,7 +16,7 @@
 import scapy.utils
 from scapy.packet import Packet
 
-from framework.settings import SETTINGS
+from framework.testbed_model.artifact import Artifact
 from framework.testbed_model.port import Port
 from framework.utils import get_packet_summaries
 
@@ -131,6 +131,7 @@ def _send_packets_and_capture(
         """
 
     def _write_capture_from_packets(self, capture_name: str, packets: list[Packet]) -> None:
-        file_name = f"{SETTINGS.output_dir}/{capture_name}.pcap"
-        self._logger.debug(f"Writing packets to {file_name}.")
-        scapy.utils.wrpcap(file_name, packets)
+        artifact = Artifact("local", f"{capture_name}.pcap")
+        self._logger.debug(f"Writing packets to {artifact.local_path}.")
+        with artifact.open("wb") as file:
+            scapy.utils.wrpcap(file, packets)
-- 
2.43.0



More information about the dev mailing list