diff options
Diffstat (limited to 'nfvbench/traffic_gen/dummy.py')
-rw-r--r-- | nfvbench/traffic_gen/dummy.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py index 9beea28..95147ab 100644 --- a/nfvbench/traffic_gen/dummy.py +++ b/nfvbench/traffic_gen/dummy.py @@ -13,8 +13,8 @@ # under the License. from nfvbench.log import LOG -from traffic_base import AbstractTrafficGenerator -import traffic_utils as utils +from .traffic_base import AbstractTrafficGenerator +from . import traffic_utils as utils class DummyTG(AbstractTrafficGenerator): @@ -95,14 +95,14 @@ class DummyTG(AbstractTrafficGenerator): ports = list(self.traffic_client.generator_config.ports) self.port_handle = ports - def create_traffic(self, l2frame_size, rates, bidirectional, latency=True): + def create_traffic(self, l2frame_size, rates, bidirectional, latency=True, e2e=False): self.rates = [utils.to_rate_str(rate) for rate in rates] self.l2_frame_size = l2frame_size def clear_streamblock(self): pass - def get_stats(self): + def get_stats(self, ifstats=None): """Get stats from current run. The binary search mainly looks at 2 results to make the decision: @@ -147,6 +147,12 @@ class DummyTG(AbstractTrafficGenerator): total_tx_pps += tx_pps # actual total tx rate in pps result['total_tx_rate'] = total_tx_pps + # actual offered tx rate in bps + avg_packet_size = utils.get_average_packet_size(self.l2_frame_size) + total_tx_bps = utils.pps_to_bps(total_tx_pps, avg_packet_size) + result['offered_tx_rate_bps'] = total_tx_bps + + result.update(self.get_theoretical_rates(avg_packet_size)) return result def get_stream_stats(self, tg_stats, if_stats, latencies, chain_idx): @@ -176,8 +182,8 @@ class DummyTG(AbstractTrafficGenerator): def fetch_capture_packets(self): def _get_packet_capture(mac): # convert text to binary - src_mac = mac.replace(':', '').decode('hex') - return {'binary': 'SSSSSS' + src_mac} + src_mac = bytearray.fromhex(mac.replace(':', '')).decode() + return {'binary': bytes('SSSSSS' + src_mac, 'ascii')} # for packet capture, generate 2*scc random packets # normally we should generate packets coming from the right dest macs @@ -201,6 +207,9 @@ class DummyTG(AbstractTrafficGenerator): def set_mode(self): pass + def set_service_mode(self, enabled=True): + pass + def resolve_arp(self): """Resolve ARP sucessfully.""" def get_macs(port, scc): |