From ad043dbc66865d79d78e5d0954c4b2eea32edecd Mon Sep 17 00:00:00 2001 From: Kerim Gokarslan Date: Thu, 22 Mar 2018 17:21:11 -0700 Subject: NFVBENCH-56 Multi-chaining traffic starts may be too early for some runs Change-Id: I332a53e3dd3e14e9cba4ad9f57bdfd094ffa4d3a Signed-off-by: Kerim Gokarslan --- nfvbench/traffic_gen/trex.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'nfvbench/traffic_gen/trex.py') diff --git a/nfvbench/traffic_gen/trex.py b/nfvbench/traffic_gen/trex.py index 207fd52..4c9f492 100644 --- a/nfvbench/traffic_gen/trex.py +++ b/nfvbench/traffic_gen/trex.py @@ -66,6 +66,8 @@ class TRex(AbstractTrafficGenerator): self.streamblock = defaultdict(list) self.rates = [] self.arps = {} + self.capture_id = None + self.packet_list = [] def get_version(self): return self.client.get_server_version() @@ -455,6 +457,24 @@ class TRex(AbstractTrafficGenerator): def stop_traffic(self): self.client.stop(ports=self.port_handle) + def start_capture(self): + if self.capture_id: + self.stop_capture() + self.client.set_service_mode(ports=self.port_handle) + self.capture_id = self.client.start_capture(rx_ports=self.port_handle) + + def fetch_capture_packets(self): + if self.capture_id: + self.packet_list = [] + self.client.fetch_capture_packets(capture_id=self.capture_id['id'], + output=self.packet_list) + + def stop_capture(self): + if self.capture_id: + self.client.stop_capture(capture_id=self.capture_id['id']) + self.capture_id = None + self.client.set_service_mode(ports=self.port_handle, enabled=False) + def cleanup(self): if self.client: try: -- cgit 1.2.3-korg