From 5dec2220690155474c59ac9e9150dc5759e2ba0e Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Tue, 9 Apr 2024 16:03:26 -0600 Subject: [PATCH 1/3] Fix AsyncSniffer not storing packets during monitor period --- .../python/src/net_orc/network_orchestrator.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 233680d38..fbd3954ca 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -51,6 +51,7 @@ def __init__(self, session): self._session = session self._monitor_in_progress = False + self._monitor_packets = [] self._listener = None self._net_modules = [] @@ -239,6 +240,7 @@ def _start_device_monitor(self, device): """Start a timer until the steady state has been reached and callback the steady state method for this device.""" self.get_session().set_status('Monitoring') + self._monitor_packets = [] LOGGER.info(f'Monitoring device with mac addr {device.mac_addr} ' f'for {str(self._session.get_monitor_period())} seconds') @@ -246,23 +248,27 @@ def _start_device_monitor(self, device): device.mac_addr.replace(':', '')) sniffer = AsyncSniffer(iface=self._session.get_device_interface(), - timeout=self._session.get_monitor_period()) + timeout=self._session.get_monitor_period(), + prn=self._monitor_packet_callback) sniffer.start() while sniffer.running: if not self._ip_ctrl.check_interface_status( self._session.get_device_interface()): - self._session.set_status('Cancelled') sniffer.stop() + self._session.set_status('Cancelled') LOGGER.error('Device interface disconnected, cancelling Testrun') - packet_capture = sniffer.results - wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), packet_capture) + LOGGER.info(f'Monitor Captures: {self._monitor_packets}') + wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), self._monitor_packets) self._monitor_in_progress = False self.get_listener().call_callback(NetworkEvent.DEVICE_STABLE, device.mac_addr) + def _monitor_packet_callback(self, packet): + self._monitor_packets.append(packet) + def _check_network_services(self): LOGGER.debug('Checking network modules...') for net_module in self._net_modules: From 5942f63ecb5da809d236ea1143f7f7f54e7c52d5 Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Tue, 9 Apr 2024 16:06:26 -0600 Subject: [PATCH 2/3] cleanup --- framework/python/src/net_orc/network_orchestrator.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index fbd3954ca..4f8aa69f3 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -258,10 +258,7 @@ def _start_device_monitor(self, device): sniffer.stop() self._session.set_status('Cancelled') LOGGER.error('Device interface disconnected, cancelling Testrun') - packet_capture = sniffer.results - LOGGER.info(f'Monitor Captures: {self._monitor_packets}') wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), self._monitor_packets) - self._monitor_in_progress = False self.get_listener().call_callback(NetworkEvent.DEVICE_STABLE, device.mac_addr) From c5e9540466a2422b8d8a5d9ae64d4052c9385898 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Tue, 16 Apr 2024 09:22:57 +0100 Subject: [PATCH 3/3] Fix pylint issue --- framework/python/src/net_orc/network_orchestrator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 4f8aa69f3..aa23f1918 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -258,7 +258,8 @@ def _start_device_monitor(self, device): sniffer.stop() self._session.set_status('Cancelled') LOGGER.error('Device interface disconnected, cancelling Testrun') - wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), self._monitor_packets) + wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), + self._monitor_packets) self._monitor_in_progress = False self.get_listener().call_callback(NetworkEvent.DEVICE_STABLE, device.mac_addr)