From 8b15550fd60efc464aa19589cc0ea638ded20f3d Mon Sep 17 00:00:00 2001 From: Deepak S Date: Fri, 30 Dec 2016 09:23:49 -0800 Subject: Adding ping based sample VNF appliance This patch defines - Generic VNF APIs to test Network service --> instantiate --> collect_kpi --> run_traffic --> listen_traffic --> terminate - vnf Descriptor to map the physical NFVi topology of the Test unit. JIRA: YARDSTICK-491 Change-Id: I6b7e09972fc536977b65d8a19d635a220815e5f3 Signed-off-by: Deepak S --- .../network_services/traffic_profile/fixed.py | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 yardstick/network_services/traffic_profile/fixed.py (limited to 'yardstick/network_services/traffic_profile/fixed.py') diff --git a/yardstick/network_services/traffic_profile/fixed.py b/yardstick/network_services/traffic_profile/fixed.py new file mode 100644 index 000000000..a456c2bd7 --- /dev/null +++ b/yardstick/network_services/traffic_profile/fixed.py @@ -0,0 +1,60 @@ +# Copyright (c) 2016-2017 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" Fixed traffic profile definitions """ + +from __future__ import absolute_import + +from yardstick.network_services.traffic_profile.base import TrafficProfile +from stl.trex_stl_lib.trex_stl_streams import STLTXCont +from stl.trex_stl_lib.trex_stl_client import STLStream +from stl.trex_stl_lib.trex_stl_packet_builder_scapy import STLPktBuilder +from stl.trex_stl_lib import api as Pkt + + +class FixedProfile(TrafficProfile): + """ + This profile adds a single stream at the beginning of the traffic session + """ + def __init__(self, tp_config): + super(FixedProfile, self).__init__(tp_config) + self.first_run = True + + def execute(self, traffic_generator): + if self.first_run: + for index, ports in enumerate(traffic_generator.my_ports): + ext_intf = \ + traffic_generator.vnfd["vdu"][0]["external-interface"] + virtual_interface = ext_intf[index]["virtual-interface"] + src_ip = virtual_interface["local_ip"] + dst_ip = virtual_interface["dst_ip"] + + traffic_generator.client.add_streams( + self._create_stream(src_ip, dst_ip), + ports=[ports]) + + traffic_generator.client.start(ports=traffic_generator.my_ports) + self.first_run = False + + def _create_stream(self, src_ip, dst_ip): + base_frame = \ + Pkt.Ether() / Pkt.IP(src=src_ip, dst=dst_ip) / Pkt.UDP(dport=12, + sport=1025) + + frame_size = self.params["traffic_profile"]["frame_size"] + pad_size = max(0, frame_size - len(base_frame)) + frame = base_frame / ("x" * max(0, pad_size)) + + frame_rate = self.params["traffic_profile"]["frame_rate"] + return STLStream(packet=STLPktBuilder(pkt=frame), + mode=STLTXCont(pps=frame_rate)) -- cgit 1.2.3-korg