From da33d374ef656da0648059439f2e28a0bfe2f13a Mon Sep 17 00:00:00 2001 From: Myron Sosyak Date: Thu, 2 Aug 2018 14:34:03 +0100 Subject: 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 Signed-off-by: Pshyk Serhiy Signed-off-by: Mytnyk, Volodymyr --- .../libs/ixia_libs/ixnet/ixnet_api.py | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py') 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) -- cgit 1.2.3-korg