diff options
author | fmenguy <francoisregis.menguy@orange.com> | 2020-09-22 17:10:10 +0200 |
---|---|---|
committer | fmenguy <francoisregis.menguy@orange.com> | 2020-10-05 11:34:07 +0200 |
commit | 94845d2bf7416d8b59e2eaf017244832cf3277f4 (patch) | |
tree | 945df71df19229ee5aa4ab227811bedece9442ff /nfvbench/traffic_gen/traffic_base.py | |
parent | 64579b717d47ab7f654c574794831be984bf32e1 (diff) |
NFVBENCH-177: Add a config item 'user_info' and theoretical max rate value
Change-Id: If96ccbffab67cfc0a08279d94cf7a5e81d958044
Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
Diffstat (limited to 'nfvbench/traffic_gen/traffic_base.py')
-rw-r--r-- | nfvbench/traffic_gen/traffic_base.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py index abf5a22..df28772 100644 --- a/nfvbench/traffic_gen/traffic_base.py +++ b/nfvbench/traffic_gen/traffic_base.py @@ -15,6 +15,8 @@ import abc import sys +import bitmath + from nfvbench.log import LOG from . import traffic_utils @@ -126,3 +128,32 @@ class AbstractTrafficGenerator(object): return: a list of speed in Gbps indexed by the port# """ + + def get_theoretical_rates(self, avg_packet_size): + + result = {} + + intf_speeds = self.get_port_speed_gbps() + tg_if_speed = bitmath.parse_string(str(intf_speeds[0]) + 'Gb').bits + intf_speed = tg_if_speed + + if hasattr(self.config, 'intf_speed') and self.config.intf_speed is not None: + # in case of limitation due to config, TG speed is not accurate + # value is overridden by conf + if self.config.intf_speed != tg_if_speed: + intf_speed = bitmath.parse_string(self.config.intf_speed.replace('ps', '')).bits + + if hasattr(self.config, 'user_info') and self.config.user_info is not None: + if "extra_encapsulation_bytes" in self.config.user_info: + frame_size_full_encapsulation = avg_packet_size + self.config.user_info[ + "extra_encapsulation_bytes"] + result['theoretical_tx_rate_pps'] = traffic_utils.bps_to_pps( + intf_speed, frame_size_full_encapsulation) * 2 + result['theoretical_tx_rate_bps'] = traffic_utils.pps_to_bps( + result['theoretical_tx_rate_pps'], avg_packet_size) + else: + result['theoretical_tx_rate_pps'] = traffic_utils.bps_to_pps(intf_speed, + avg_packet_size) * 2 + result['theoretical_tx_rate_bps'] = traffic_utils.pps_to_bps( + result['theoretical_tx_rate_pps'], avg_packet_size) + return result |