diff options
author | Deepak S <deepak.s@linux.intel.com> | 2016-12-30 09:23:49 -0800 |
---|---|---|
committer | Deepak S <deepak.s@linux.intel.com> | 2017-01-19 08:28:49 +0530 |
commit | 8b15550fd60efc464aa19589cc0ea638ded20f3d (patch) | |
tree | b2254ab2de360c9c4bfeca09a01bea27f64a7771 /yardstick/network_services/traffic_profile | |
parent | c1d6fd53c49a2cc5c0a7eab82e15dcf1a08f4e32 (diff) |
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 <deepak.s@linux.intel.com>
Diffstat (limited to 'yardstick/network_services/traffic_profile')
-rw-r--r-- | yardstick/network_services/traffic_profile/fixed.py | 60 |
1 files changed, 60 insertions, 0 deletions
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)) |