aboutsummaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen
diff options
context:
space:
mode:
authorfmenguy <francoisregis.menguy@orange.com>2020-09-22 17:10:10 +0200
committerfmenguy <francoisregis.menguy@orange.com>2020-10-05 11:34:07 +0200
commit94845d2bf7416d8b59e2eaf017244832cf3277f4 (patch)
tree945df71df19229ee5aa4ab227811bedece9442ff /nfvbench/traffic_gen
parent64579b717d47ab7f654c574794831be984bf32e1 (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')
-rw-r--r--nfvbench/traffic_gen/dummy.py2
-rw-r--r--nfvbench/traffic_gen/traffic_base.py31
-rw-r--r--nfvbench/traffic_gen/trex_gen.py3
3 files changed, 36 insertions, 0 deletions
diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py
index 25664e5..8a6d11a 100644
--- a/nfvbench/traffic_gen/dummy.py
+++ b/nfvbench/traffic_gen/dummy.py
@@ -151,6 +151,8 @@ class DummyTG(AbstractTrafficGenerator):
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):
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
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index 0bf6d93..f7250da 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -159,6 +159,9 @@ class TRex(AbstractTrafficGenerator):
avg_packet_size = utils.get_average_packet_size(self.l2_frame_size)
total_tx_bps = utils.pps_to_bps(result["total_tx_rate"], avg_packet_size)
result['offered_tx_rate_bps'] = total_tx_bps
+
+ result.update(self.get_theoretical_rates(avg_packet_size))
+
result["flow_stats"] = in_stats["flow_stats"]
result["latency"] = in_stats["latency"]