aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-08-23 15:09:08 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-08-23 17:16:08 +0100
commit26b4f32e75113fff93b3904428e23228963eca43 (patch)
treedeacb203054fcee56e402905b7960a69688db155
parentc6175b5bc59706c3a423fe2781f99e32930bb570 (diff)
Make TRex IMIX traffic mode configurable
Enable TRex IMIX generation using two modes: - Distribution in packages. - Distribution in byes. The default one will be distribution in packages, like the default one in IxNetwork. JIRA: YARDSTICK-1397 Change-Id: I86b2527968496218b0515349fc0a2680a84261e5 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
-rw-r--r--yardstick/common/constants.py4
-rw-r--r--yardstick/network_services/traffic_profile/rfc2544.py30
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py35
3 files changed, 60 insertions, 9 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index 3d775d48e..03733b6da 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -176,3 +176,7 @@ SCOPE_CLUSTER = 'Cluster'
# VNF definition
SSH_PORT = 22
LUA_PORT = 22022
+
+# IMIX mode
+DISTRIBUTION_IN_PACKETS = 'mode_DIP'
+DISTRIBUTION_IN_BYTES = 'mode_DIB'
diff --git a/yardstick/network_services/traffic_profile/rfc2544.py b/yardstick/network_services/traffic_profile/rfc2544.py
index 987029373..4b339c2ed 100644
--- a/yardstick/network_services/traffic_profile/rfc2544.py
+++ b/yardstick/network_services/traffic_profile/rfc2544.py
@@ -19,6 +19,7 @@ from trex_stl_lib import trex_stl_client
from trex_stl_lib import trex_stl_packet_builder_scapy
from trex_stl_lib import trex_stl_streams
+from yardstick.common import constants
from yardstick.network_services.traffic_profile import trex_traffic_profile
@@ -140,7 +141,8 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile):
streams.extend(_streams)
return trex_stl_streams.STLProfile(streams)
- def _create_imix_data(self, imix):
+ def _create_imix_data(self, imix,
+ weight_mode=constants.DISTRIBUTION_IN_PACKETS):
"""Generate the IMIX distribution for a STL profile
The input information is the framesize dictionary in a test case
@@ -159,6 +161,20 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile):
E.g.:
imix_count = {64: 25, 128: 75}
+ The weight mode is described in [1]. There are two ways to describe the
+ weight of the packets:
+ - Distribution in packets: the weight defines the percentage of
+ packets sent per packet size. IXIA uses this definition.
+ - Distribution in bytes: the weight defines the percentage of bytes
+ sent per packet size.
+
+ Packet size # packets D. in packets Bytes D. in bytes
+ 40 7 58.33% 280 7%
+ 576 4 33.33% 2304 56%
+ 1500 1 8.33% 1500 37%
+
+ [1] https://en.wikipedia.org/wiki/Internet_Mix
+
:param imix: (dict) IMIX size and weight
"""
imix_count = {}
@@ -173,8 +189,16 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile):
imix_sum = 100
weight_normalize = float(imix_sum) / 100
- return {size: float(weight) / weight_normalize
- for size, weight in imix_count.items()}
+ imix_dip = {size: float(weight) / weight_normalize
+ for size, weight in imix_count.items()}
+
+ if weight_mode == constants.DISTRIBUTION_IN_BYTES:
+ return imix_dip
+
+ byte_total = sum([int(size) * weight
+ for size, weight in imix_dip.items()])
+ return {size: (int(size) * weight) / byte_total
+ for size, weight in imix_dip.items()}
def _create_vm(self, packet_definition):
"""Create the STL Raw instructions"""
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
index cfeebaa3a..4c546d7ef 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
@@ -20,6 +20,7 @@ from trex_stl_lib import trex_stl_client
from trex_stl_lib import trex_stl_packet_builder_scapy
from trex_stl_lib import trex_stl_streams
+from yardstick.common import constants
from yardstick.network_services.traffic_profile import rfc2544
from yardstick.tests.unit import base
@@ -140,16 +141,38 @@ class TestRFC2544Profile(base.BaseUnitTestCase):
port_pg_id, True)
mock_stl_profile.assert_called_once_with(['stream1'])
- def test__create_imix_data(self):
+ def test__create_imix_data_mode_DIB(self):
rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE)
data = {'64B': 50, '128B': 50}
- self.assertEqual({'64': 50.0, '128': 50.0},
- rfc2544_profile._create_imix_data(data))
+ self.assertEqual(
+ {'64': 50.0, '128': 50.0},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
data = {'64B': 1, '128b': 3}
- self.assertEqual({'64': 25.0, '128': 75.0},
- rfc2544_profile._create_imix_data(data))
+ self.assertEqual(
+ {'64': 25.0, '128': 75.0},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
data = {}
- self.assertEqual({}, rfc2544_profile._create_imix_data(data))
+ self.assertEqual(
+ {},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
+
+ def test__create_imix_data_mode_DIP(self):
+ rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE)
+ data = {'64B': 25, '128B': 25, '512B': 25, '1518B': 25}
+ byte_total = 64 * 25 + 128 * 25 + 512 * 25 + 1518 * 25
+ self.assertEqual(
+ {'64': 64 * 25.0 / byte_total, '128': 128 * 25.0 / byte_total,
+ '512': 512 * 25.0 / byte_total, '1518': 1518 * 25.0 / byte_total},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_PACKETS))
+ data = {}
+ self.assertEqual(
+ {},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_PACKETS))
def test__create_vm(self):
packet = {'outer_l2': 'l2_definition'}