aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services
diff options
context:
space:
mode:
authorMyron Sosyak <myronx.sosyak@intel.com>2018-08-02 14:34:03 +0100
committerMyron Sosyak <myronx.sosyak@intel.com>2018-08-02 14:34:53 +0100
commitda33d374ef656da0648059439f2e28a0bfe2f13a (patch)
treec96e3af6721822c5a3a232d1abeec92d31bdc53f /yardstick/network_services
parent0b7647a5a6c85a8a1762ec4482004107989c8550 (diff)
Add UDP ports configuration to IXIA traffic profile
- Implemented handling of UDP source and destination ports from IXIA traffic profile. - UDP ports can be defined as a single value or as a random range. Ports range is configured with two parameters 'fixed_bits' and 'mask_bits'. - For example '8-48' range definition will create a repeatable pattern of four values that fall within the range of 8 and 56. JIRA: YARDSTICK-1363 Change-Id: I0ace722f6be843ea79c3d3f4de22cb8fa5669d4f Signed-off-by: Myron Sosyak <myronx.sosyak@intel.com> Signed-off-by: Pshyk Serhiy <serhiyx.pshyk@intel.com> Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
Diffstat (limited to 'yardstick/network_services')
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py61
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py21
2 files changed, 81 insertions, 1 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
index ba27d4d05..2729cf6ea 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -40,6 +40,8 @@ IP_VERSION_6_MASK = 64
TRAFFIC_STATUS_STARTED = 'started'
TRAFFIC_STATUS_STOPPED = 'stopped'
+SUPPORTED_PROTO = [PROTO_UDP]
+
# NOTE(ralonsoh): this pragma will be removed in the last patch of this series
class IxNextgen(object): # pragma: no cover
@@ -440,6 +442,65 @@ class IxNextgen(object): # pragma: no cover
self._get_stack_item(fg_id, PROTO_IPV4)[0],
'dstIp', dstip, 1, dstmask, count)
+ def update_l4(self, traffic):
+ """Update the L4 headers
+
+ NOTE: Only UDP is currently supported
+ :param traffic: list of traffic elements; each traffic element contains
+ the injection parameter for each flow group
+ """
+ for traffic_param in traffic.values():
+ fg_id = str(traffic_param['id'])
+ if not self._get_config_element_by_flow_group_name(fg_id):
+ raise exceptions.IxNetworkFlowNotPresent(flow_group=fg_id)
+
+ proto = traffic_param['outer_l3']['proto']
+ if proto not in SUPPORTED_PROTO:
+ raise exceptions.IXIAUnsupportedProtocol(protocol=proto)
+
+ count = traffic_param['outer_l4']['count']
+ seed = traffic_param['outer_l4']['seed']
+
+ srcport = traffic_param['outer_l4']['srcport']
+ srcmask = traffic_param['outer_l4']['srcportmask']
+
+ dstport = traffic_param['outer_l4']['dstport']
+ dstmask = traffic_param['outer_l4']['dstportmask']
+
+ if proto in SUPPORTED_PROTO:
+ self._update_udp_port(self._get_stack_item(fg_id, proto)[0],
+ 'srcPort', srcport, seed, srcmask, count)
+
+ self._update_udp_port(self._get_stack_item(fg_id, proto)[0],
+ 'dstPort', dstport, seed, dstmask, count)
+
+ def _update_udp_port(self, descriptor, field, value,
+ seed=1, mask=0, count=1):
+ """Set the UDP port in a config element stack UDP field
+
+ :param udp_descriptor: (str) UDP descriptor, e.g.:
+ /traffic/trafficItem:1/configElement:1/stack:"udp-3"
+ :param field: (str) field name, e.g.: scrPort, dstPort
+ :param value: (int) UDP port fixed bits
+ :param seed: (int) seed length
+ :param mask: (int) UDP port mask
+ :param count: (int) number of random ports to generate
+ """
+ field_descriptor = self._get_field_in_stack_item(descriptor, field)
+
+ if mask == 0:
+ seed = count = 1
+
+ self.ixnet.setMultiAttribute(field_descriptor,
+ '-auto', 'false',
+ '-seed', seed,
+ '-fixedBits', value,
+ '-randomMask', mask,
+ '-valueType', 'random',
+ '-countValue', count)
+
+ self.ixnet.commit()
+
def _build_stats_map(self, view_obj, name_map):
return {data_yardstick: self.ixnet.execute(
'getColumnValues', view_obj, data_ixia)
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index 43455330f..056f32a57 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -42,6 +42,13 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
mask = utils.get_mask_from_ip_range(_ip_range[0], _ip_range[1])
return _ip_range[0], mask
+ def _get_fixed_and_mask(self, port_range):
+ _port_range = str(port_range).split('-')
+ if len(_port_range) == 1:
+ return int(_port_range[0]), 0
+
+ return int(_port_range[0]), int(_port_range[1])
+
def _get_ixia_traffic_profile(self, profile_data, mac=None):
mac = {} if mac is None else mac
result = {}
@@ -70,6 +77,9 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
srcip, srcmask = self._get_ip_and_mask(ip[src_key])
dstip, dstmask = self._get_ip_and_mask(ip[dst_key])
+ outer_l4 = value.get('outer_l4')
+ src_port, src_port_mask = self._get_fixed_and_mask(outer_l4['srcport'])
+ dst_port, dst_port_mask = self._get_fixed_and_mask(outer_l4['dstport'])
result[traffickey] = {
'bidir': False,
'id': port_id,
@@ -92,7 +102,15 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
'type': key,
'proto': ip['proto'],
},
- 'outer_l4': value['outer_l4'],
+ 'outer_l4': {
+ 'srcport': src_port,
+ 'dstport': dst_port,
+ 'srcportmask': src_port_mask,
+ 'dstportmask': dst_port_mask,
+ 'count': outer_l4['count'],
+ 'seed': outer_l4['seed'],
+ }
+
}
except KeyError:
continue
@@ -102,6 +120,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
def _ixia_traffic_generate(self, traffic, ixia_obj):
ixia_obj.update_frame(traffic, self.config.duration)
ixia_obj.update_ip_packet(traffic)
+ ixia_obj.update_l4(traffic)
ixia_obj.start_traffic()
def update_traffic_profile(self, traffic_generator):