aboutsummaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen
diff options
context:
space:
mode:
authorfmenguy <francoisregis.menguy@orange.com>2020-05-06 17:35:35 +0200
committerfmenguy <francoisregis.menguy@orange.com>2020-05-27 11:07:32 +0200
commit143c4ff68068fd704e7eb4df1c82af29f087c871 (patch)
tree969713b19beae3944d5d25beb9a3dae8ed6fcf63 /nfvbench/traffic_gen
parentcaac5c7f6e80d33d5031f26e5e0f0ea6f1d3789b (diff)
[NFVBENCH-168] Improve config properties managed after a REST call
Change-Id: I20973c1c405dec8cce58f984e1fb84e345013b25 Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
Diffstat (limited to 'nfvbench/traffic_gen')
-rw-r--r--nfvbench/traffic_gen/dummy.py4
-rw-r--r--nfvbench/traffic_gen/traffic_utils.py6
-rw-r--r--nfvbench/traffic_gen/trex_gen.py6
3 files changed, 15 insertions, 1 deletions
diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py
index 7fd3fdb..272990a 100644
--- a/nfvbench/traffic_gen/dummy.py
+++ b/nfvbench/traffic_gen/dummy.py
@@ -147,6 +147,10 @@ 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
return result
def get_stream_stats(self, tg_stats, if_stats, latencies, chain_idx):
diff --git a/nfvbench/traffic_gen/traffic_utils.py b/nfvbench/traffic_gen/traffic_utils.py
index c875a5d..4366a6c 100644
--- a/nfvbench/traffic_gen/traffic_utils.py
+++ b/nfvbench/traffic_gen/traffic_utils.py
@@ -14,7 +14,6 @@
import bitmath
-from nfvbench.utils import multiplier_map
# IMIX frame size including the 4-byte FCS field
IMIX_L2_SIZES = [64, 594, 1518]
@@ -23,6 +22,11 @@ IMIX_RATIOS = [7, 4, 1]
IMIX_AVG_L2_FRAME_SIZE = sum(
[1.0 * imix[0] * imix[1] for imix in zip(IMIX_L2_SIZES, IMIX_RATIOS)]) / sum(IMIX_RATIOS)
+multiplier_map = {
+ 'K': 1000,
+ 'M': 1000000,
+ 'G': 1000000000
+}
def convert_rates(l2frame_size, rate, intf_speed):
"""Convert a given rate unit into the other rate units.
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index de9500a..a4f992d 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -95,6 +95,7 @@ class TRex(AbstractTrafficGenerator):
self.rates = []
self.capture_id = None
self.packet_list = []
+ self.l2_frame_size = 0
def get_version(self):
"""Get the Trex version."""
@@ -151,6 +152,10 @@ class TRex(AbstractTrafficGenerator):
total_tx_pkts = result[0]['tx']['total_pkts'] + result[1]['tx']['total_pkts']
result["total_tx_rate"] = cast_integer(total_tx_pkts / self.config.duration_sec)
+ # 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(result["total_tx_rate"], avg_packet_size)
+ result['offered_tx_rate_bps'] = total_tx_bps
result["flow_stats"] = in_stats["flow_stats"]
result["latency"] = in_stats["latency"]
return result
@@ -812,6 +817,7 @@ class TRex(AbstractTrafficGenerator):
.format(pps=r['rate_pps'],
bps=r['rate_bps'],
load=r['rate_percent']))
+ self.l2_frame_size = l2frame_size
# a dict of list of streams indexed by port#
# in case of fixed size, has self.chain_count * 2 * 2 streams
# (1 normal + 1 latency stream per direction per chain)