aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKerim Gokarslan <kgokarsl@cisco.com>2018-04-02 16:38:24 -0700
committerKerim Gokarslan <kgokarsl@cisco.com>2018-04-03 11:44:03 -0700
commit5d582aada32e1c5f43601015660b7936013f5b30 (patch)
treec5f5a7d0365b165284c6caa73d394a91b9286128
parent34c00544f7f7dbfa49bbdcd83eca2936b60826c7 (diff)
NFVBENCH-79 TRex latency stats requires at least 18B payload size
Change-Id: I4add34e853d5b5a37efc877eb183a1fdc622d78a Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
-rw-r--r--nfvbench/nfvbench.py14
-rw-r--r--nfvbench/traffic_gen/traffic_base.py23
-rw-r--r--nfvbench/traffic_gen/trex.py7
3 files changed, 29 insertions, 15 deletions
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index 5899652..5e2de76 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -91,7 +91,19 @@ class NFVBench(object):
try:
self.update_config(opts)
self.setup()
-
+ new_frame_sizes = []
+ min_packet_size = "68" if self.config.vlan_tagging else "64"
+ for frame_size in self.config.frame_sizes:
+ try:
+ if int(frame_size) < int(min_packet_size):
+ new_frame_sizes.append(min_packet_size)
+ LOG.info("Adjusting frame size %s Bytes to minimum size %s Bytes due to "
+ + "traffic generator restriction", frame_size, min_packet_size)
+ else:
+ new_frame_sizes.append(frame_size)
+ except ValueError:
+ new_frame_sizes.append(frame_size)
+ self.config.frame_sizes = tuple(new_frame_sizes)
result = {
"date": datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
"nfvbench_version": __version__,
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py
index c2ac8d0..81537b3 100644
--- a/nfvbench/traffic_gen/traffic_base.py
+++ b/nfvbench/traffic_gen/traffic_base.py
@@ -23,19 +23,12 @@ class TrafficGeneratorException(Exception):
class AbstractTrafficGenerator(object):
- # src_mac (6) + dst_mac (6) + mac_type (2) + frame_check (4) = 18
- l2_header_size = 18
-
- imix_l2_sizes = [64, 594, 1518]
- imix_l3_sizes = [size - l2_header_size for size in imix_l2_sizes]
- imix_ratios = [7, 4, 1]
- imix_avg_l2_size = sum(
- [1.0 * imix[0] * imix[1] for imix in zip(imix_l2_sizes, imix_ratios)]) / sum(imix_ratios)
-
- traffic_utils.imix_avg_l2_size = imix_avg_l2_size
-
def __init__(self, config):
self.config = config
+ self.imix_l2_sizes = [64, 594, 1518]
+ self.imix_ratios = [7, 4, 1]
+ self.imix_avg_l2_size = 0
+ self.adjust_imix_min_size(64)
@abc.abstractmethod
def get_version(self):
@@ -96,3 +89,11 @@ class AbstractTrafficGenerator(object):
def cleanup(self):
# Must be implemented by sub classes
return None
+
+ def adjust_imix_min_size(self, min_size):
+ # assume the min size is always the first entry
+ self.imix_l2_sizes[0] = min_size
+ self.imix_avg_l2_size = sum(
+ [1.0 * imix[0] * imix[1] for imix in zip(self.imix_l2_sizes, self.imix_ratios)]) / sum(
+ self.imix_ratios)
+ traffic_utils.imix_avg_l2_size = self.imix_avg_l2_size
diff --git a/nfvbench/traffic_gen/trex.py b/nfvbench/traffic_gen/trex.py
index 4c9f492..7d64f0f 100644
--- a/nfvbench/traffic_gen/trex.py
+++ b/nfvbench/traffic_gen/trex.py
@@ -142,14 +142,13 @@ class TRex(AbstractTrafficGenerator):
def create_pkt(self, stream_cfg, l2frame_size):
pkt_base = Ether(src=stream_cfg['mac_src'], dst=stream_cfg['mac_dst'])
- # TRex requires minimum payload size 16B
if stream_cfg['vlan_tag'] is not None:
# 50 = 14 (Ethernet II) + 4 (Vlan tag) + 4 (CRC Checksum) + 20 (IPv4) + 8 (UDP)
pkt_base /= Dot1Q(vlan=stream_cfg['vlan_tag'])
- l2payload_size = max(max(64, int(l2frame_size)) - 50, 16)
+ l2payload_size = int(l2frame_size) - 50
else:
# 46 = 14 (Ethernet II) + 4 (CRC Checksum) + 20 (IPv4) + 8 (UDP)
- l2payload_size = max(max(64, int(l2frame_size)) - 46, 16)
+ l2payload_size = int(l2frame_size) - 46
payload = 'x' * l2payload_size
udp_args = {}
if stream_cfg['udp_src_port']:
@@ -205,6 +204,8 @@ class TRex(AbstractTrafficGenerator):
idx_lat = None
streams = []
if l2frame == 'IMIX':
+ min_size = 64 if stream_cfg['vlan_tag'] is None else 68
+ self.adjust_imix_min_size(min_size)
for t, (ratio, l2_frame_size) in enumerate(zip(self.imix_ratios, self.imix_l2_sizes)):
pkt = self.create_pkt(stream_cfg, l2_frame_size)
streams.append(STLStream(packet=pkt,