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/dummy.py | 14 ++++++++++++++ nfvbench/traffic_gen/trex.py | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'nfvbench/traffic_gen') diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py index 6f57f4d..788a53f 100644 --- a/nfvbench/traffic_gen/dummy.py +++ b/nfvbench/traffic_gen/dummy.py @@ -31,6 +31,11 @@ class DummyTG(AbstractTrafficGenerator): self.duration_sec = self.config.duration_sec self.intf_speed = config.generator_config.intf_speed self.set_response_curve() + self.packet_list = [{ + "binary": "01234567890123456789" + }, { + "binary": "98765432109876543210" + }] def get_version(self): return "0.1" @@ -164,9 +169,18 @@ class DummyTG(AbstractTrafficGenerator): def start_traffic(self): pass + def fetch_capture_packets(self): + pass + def stop_traffic(self): pass + def start_capture(self): + pass + + def stop_capture(self): + pass + def cleanup(self): pass 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