aboutsummaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen
diff options
context:
space:
mode:
authorPierrick Louin <pierrick.louin@orange.com>2020-11-08 21:49:49 +0100
committerPierrick Louin <pierrick.louin@orange.com>2020-11-09 22:58:15 +0100
commitbd0cf4ce9c30c8aae9b7a96cf9c8ea073cd9a548 (patch)
tree9959fedcecc8c5f2258fb8c84eead8ba8587ce9c /nfvbench/traffic_gen
parentd41631be9142a50284cfbfd252a53e97d7ebd8c7 (diff)
NFVBENCH-192: Complete/fix hdrh related processings to consider all cases
(multiple service chains, distribution n/a with intel VFs) Signed-off-by: Pierrick Louin <pierrick.louin@orange.com> Change-Id: I80e38601292a7777d37ed05959c8ef205505c2ac
Diffstat (limited to 'nfvbench/traffic_gen')
-rw-r--r--nfvbench/traffic_gen/traffic_base.py30
-rw-r--r--nfvbench/traffic_gen/trex_gen.py20
2 files changed, 30 insertions, 20 deletions
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py
index df28772..30aec6e 100644
--- a/nfvbench/traffic_gen/traffic_base.py
+++ b/nfvbench/traffic_gen/traffic_base.py
@@ -15,10 +15,10 @@
import abc
import sys
-import bitmath
-
from nfvbench.log import LOG
from . import traffic_utils
+from hdrh.histogram import HdrHistogram
+from functools import reduce
class Latency(object):
@@ -34,11 +34,23 @@ class Latency(object):
self.avg_usec = 0
self.hdrh = None
if latency_list:
+ hdrh_list = []
for lat in latency_list:
if lat.available():
self.min_usec = min(self.min_usec, lat.min_usec)
self.max_usec = max(self.max_usec, lat.max_usec)
self.avg_usec += lat.avg_usec
+ if lat.hdrh_available():
+ hdrh_list.append(HdrHistogram.decode(lat.hdrh))
+
+ # aggregate histograms if any
+ if hdrh_list:
+ def add_hdrh(x, y):
+ x.add(y)
+ return x
+ decoded_hdrh = reduce(add_hdrh, hdrh_list)
+ self.hdrh = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
+
# round to nearest usec
self.avg_usec = int(round(float(self.avg_usec) / len(latency_list)))
@@ -46,6 +58,9 @@ class Latency(object):
"""Return True if latency information is available."""
return self.min_usec != sys.maxsize
+ def hdrh_available(self):
+ """Return True if latency histogram information is available."""
+ return self.hdrh is not None
class TrafficGeneratorException(Exception):
"""Exception for traffic generator."""
@@ -133,15 +148,8 @@ class AbstractTrafficGenerator(object):
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
+ # actual interface speed? (may be a virtual override)
+ intf_speed = self.config.intf_speed_used
if hasattr(self.config, 'user_info') and self.config.user_info is not None:
if "extra_encapsulation_bytes" in self.config.user_info:
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index 4e20f73..d5625eb 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -168,6 +168,8 @@ class TRex(AbstractTrafficGenerator):
result["latency"] = in_stats["latency"]
# Merge HDRHistogram to have an overall value for all chains and ports
+ # (provided that the histogram exists in the stats returned by T-Rex)
+ # Of course, empty histograms will produce an empty (invalid) histogram.
try:
hdrh_list = []
if ifstats:
@@ -186,7 +188,7 @@ class TRex(AbstractTrafficGenerator):
x.add(y)
return x
decoded_hdrh = reduce(add_hdrh, hdrh_list)
- result["hdrh"] = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
+ result["overall_hdrh"] = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
except KeyError:
pass
@@ -589,8 +591,6 @@ class TRex(AbstractTrafficGenerator):
"""
streams = []
pg_id, lat_pg_id = self.get_pg_id(port, chain_id)
- if self.config.no_flow_stats:
- LOG.info("Traffic flow statistics are disabled.")
if l2frame == 'IMIX':
for ratio, l2_frame_size in zip(IMIX_RATIOS, IMIX_L2_SIZES):
pkt = self._create_pkt(stream_cfg, l2_frame_size)
@@ -602,12 +602,12 @@ class TRex(AbstractTrafficGenerator):
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowStats(pg_id=pg_id,
vxlan=True)
- if not self.config.no_flow_stats else None,
+ if not self.config.no_flow_stats else None,
mode=STLTXCont(pps=ratio)))
else:
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowStats(pg_id=pg_id)
- if not self.config.no_flow_stats else None,
+ if not self.config.no_flow_stats else None,
mode=STLTXCont(pps=ratio)))
if latency:
@@ -633,12 +633,12 @@ class TRex(AbstractTrafficGenerator):
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowStats(pg_id=pg_id,
vxlan=True)
- if not self.config.no_flow_stats else None,
+ if not self.config.no_flow_stats else None,
mode=STLTXCont()))
else:
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowStats(pg_id=pg_id)
- if not self.config.no_flow_stats else None,
+ if not self.config.no_flow_stats else None,
mode=STLTXCont()))
# for the latency stream, the minimum payload is 16 bytes even in case of vlan tagging
# without vlan, the min l2 frame size is 64
@@ -662,12 +662,12 @@ class TRex(AbstractTrafficGenerator):
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowLatencyStats(pg_id=lat_pg_id,
vxlan=True)
- if not self.config.no_latency_stats else None,
+ if not self.config.no_latency_stats else None,
mode=STLTXCont(pps=self.LATENCY_PPS)))
else:
streams.append(STLStream(packet=pkt,
flow_stats=STLFlowLatencyStats(pg_id=lat_pg_id)
- if not self.config.no_latency_stats else None,
+ if not self.config.no_latency_stats else None,
mode=STLTXCont(pps=self.LATENCY_PPS)))
return streams
@@ -1005,6 +1005,8 @@ class TRex(AbstractTrafficGenerator):
latency: True if latency measurement is needed
e2e: True if performing "end to end" connectivity check
"""
+ if self.config.no_flow_stats:
+ LOG.info("Traffic flow statistics are disabled.")
r = self.__is_rate_enough(l2frame_size, rates, bidirectional, latency)
if not r['result']:
raise TrafficGeneratorException(