summaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen/traffic_utils.py
diff options
context:
space:
mode:
authorahothan <ahothan@cisco.com>2018-11-13 15:34:29 -0800
committerahothan <ahothan@cisco.com>2018-11-13 15:34:29 -0800
commit9527113c350f92b2293f596b6153f9c9d626f2af (patch)
tree192c3687ff689fc961b5874298b3d940675e781d /nfvbench/traffic_gen/traffic_utils.py
parent7a90e74a1390794b72fc5c3629e141f2def908d7 (diff)
NFVBENCH-108 Adjust exact frame size to take into account FCS field2.0.5
Minimum L2 frame size is now set to 64 bytes. If VLAN tagging, min frame size for the latency stream is 68 bytes. Also fix issue with interface baseline. Change-Id: If6ff7515c0112ab419070c86f7094ff88930d33b Signed-off-by: ahothan <ahothan@cisco.com>
Diffstat (limited to 'nfvbench/traffic_gen/traffic_utils.py')
-rw-r--r--nfvbench/traffic_gen/traffic_utils.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/nfvbench/traffic_gen/traffic_utils.py b/nfvbench/traffic_gen/traffic_utils.py
index c3428a4..f856267 100644
--- a/nfvbench/traffic_gen/traffic_utils.py
+++ b/nfvbench/traffic_gen/traffic_utils.py
@@ -16,13 +16,18 @@
import bitmath
from nfvbench.utils import multiplier_map
-imix_avg_l2_size = None
+# IMIX frame size including the 4-byte FCS field
+IMIX_L2_SIZES = [64, 594, 1518]
+IMIX_RATIOS = [7, 4, 1]
+# weighted average l2 frame size includng the 4-byte FCS
+IMIX_AVG_L2_FRAME_SIZE = sum(
+ [1.0 * imix[0] * imix[1] for imix in zip(IMIX_L2_SIZES, IMIX_RATIOS)]) / sum(IMIX_RATIOS)
def convert_rates(l2frame_size, rate, intf_speed):
"""Convert a given rate unit into the other rate units.
- l2frame_size: size of the L2 frame in bytes or 'IMIX'
+ l2frame_size: size of the L2 frame in bytes (includes 32-bit FCS) or 'IMIX'
rate: a dict that has at least one of the following key:
'rate_pps', 'rate_bps', 'rate_percent'
with the corresponding input value
@@ -59,8 +64,13 @@ def convert_rates(l2frame_size, rate, intf_speed):
def get_average_packet_size(l2frame_size):
+ """Retrieve the average L2 frame size
+
+ l2frame_size: an L2 frame size in bytes (including FCS) or 'IMIX'
+ return: average l2 frame size inlcuding the 32-bit FCS
+ """
if l2frame_size.upper() == 'IMIX':
- return imix_avg_l2_size
+ return IMIX_AVG_L2_FRAME_SIZE
return float(l2frame_size)