From d09df99769f67819c64a7a025dbdcd39811c7b44 Mon Sep 17 00:00:00 2001 From: Dan Klein Date: Tue, 20 Oct 2015 03:17:08 +0300 Subject: Major progress in console, yaml utils, and trex_streams basically done, minor changes remianing BIG ISSUE LEFT: rewire console to work with trexstateless client module --- scripts/stl/imix_1pkt.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/stl/imix_1pkt.yaml (limited to 'scripts/stl') diff --git a/scripts/stl/imix_1pkt.yaml b/scripts/stl/imix_1pkt.yaml new file mode 100755 index 00000000..128bd559 --- /dev/null +++ b/scripts/stl/imix_1pkt.yaml @@ -0,0 +1,11 @@ +### Single stream UDP packet, 64B ### +##################################### +- name: udp_64B + stream: + self_start: True + packet: + binary: cap2/udp_64B_1pkt.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] \ No newline at end of file -- cgit 1.2.3-korg From 5abe21ffb26a15c2a63e90b5628d704e8211b599 Mon Sep 17 00:00:00 2001 From: Dan Klein Date: Tue, 20 Oct 2015 09:12:33 +0300 Subject: + Added traffic options at stl directory + updated console to support multiplier on loading + fixed minor issues at yaml_utils and trex_streams objects + console not stable, YET --- .../trex_control_plane/client_utils/yaml_utils.py | 8 ++++-- .../trex_control_plane/common/trex_streams.py | 6 ++--- .../trex_control_plane/console/trex_console.py | 28 ++++++++++++++++++--- scripts/stl/imix_1pkt.yaml | 2 +- scripts/stl/imix_2pkt.yaml | 20 +++++++++++++++ scripts/stl/imix_3pkt.yaml | 29 ++++++++++++++++++++++ 6 files changed, 84 insertions(+), 9 deletions(-) create mode 100755 scripts/stl/imix_2pkt.yaml create mode 100755 scripts/stl/imix_3pkt.yaml (limited to 'scripts/stl') diff --git a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py index 414744fc..60630a04 100755 --- a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py +++ b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py @@ -108,7 +108,6 @@ class CTRexYAMLLoader(object): # validation on terminal type # print "Validating terminal type %s" % k res_ok, data = self.check_term_param_type(evaluated_obj.get(k), k, v, multiplier) - # print "Validating: ", res_ok if res_ok: # data field contains the value to save result_obj[k] = data @@ -138,8 +137,13 @@ class CTRexYAMLLoader(object): @staticmethod def _calc_final_value(val, multiplier, multiply): + def to_num(s): + try: + return int(s) + except ValueError: + return float(s) if multiply: - return (val * multiplier) + return val * to_num(multiplier) else: return val diff --git a/scripts/automation/trex_control_plane/common/trex_streams.py b/scripts/automation/trex_control_plane/common/trex_streams.py index 1aeb46b0..783f2769 100755 --- a/scripts/automation/trex_control_plane/common/trex_streams.py +++ b/scripts/automation/trex_control_plane/common/trex_streams.py @@ -43,7 +43,7 @@ class CStreamList(object): def export_to_yaml(self, file_path): raise NotImplementedError("export_to_yaml method is not implemented, yet") - def load_yaml(self, file_path, multiplier_dict={}): + def load_yaml(self, file_path, multiplier=1): # clear all existing streams linked to this object self.streams_list.clear() streams_data = load_yaml_to_obj(file_path) @@ -57,11 +57,11 @@ class CStreamList(object): "Provided item was:\n {stream}".format(stream)) new_stream_data = self.yaml_loader.validate_yaml(raw_stream, "stream", - multiplier= multiplier_dict.get(stream_name, 1)) + multiplier= multiplier) new_stream_obj = CStream() new_stream_obj.load_data(**new_stream_data) self.append_stream(stream_name, new_stream_obj) - return streams_data + return new_stream_data def compile_streams(self): # first, assign an id to each stream diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 688f80f3..27a5eeab 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -1,5 +1,22 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- + +""" +Dan Klein, Itay Marom +Cisco Systems, Inc. + +Copyright (c) 2015-2015 Cisco Systems, Inc. +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. +""" + import cmd import json import ast @@ -416,8 +433,12 @@ class TrexConsole(cmd.Cmd): if args >= 2: name = args[0] yaml_path = args[1] + try: + multiplier = args[2] + except IndexError: + multiplier = 1 stream_list = CStreamList() - loaded_obj = stream_list.load_yaml(yaml_path) + loaded_obj = stream_list.load_yaml(yaml_path, multiplier) # print self.rpc_client.pretty_json(json.dumps(loaded_obj)) if name in self.user_streams: print "Picked name already exist. Please pick another name." @@ -433,7 +454,8 @@ class TrexConsole(cmd.Cmd): raise return else: - print "please provide load name and YAML path, separated by space." + print "please provide load name and YAML path, separated by space.\n" \ + "Optionally, you may provide a third argument to specify multiplier." def do_show_stream_list(self, line): '''Shows the loaded stream list named [name] \n''' diff --git a/scripts/stl/imix_1pkt.yaml b/scripts/stl/imix_1pkt.yaml index 128bd559..511f8695 100755 --- a/scripts/stl/imix_1pkt.yaml +++ b/scripts/stl/imix_1pkt.yaml @@ -4,7 +4,7 @@ stream: self_start: True packet: - binary: cap2/udp_64B_1pkt.pcap + binary: cap2/udp_64B.pcap mode: type: continuous pps: 100 diff --git a/scripts/stl/imix_2pkt.yaml b/scripts/stl/imix_2pkt.yaml new file mode 100755 index 00000000..17a7bdc1 --- /dev/null +++ b/scripts/stl/imix_2pkt.yaml @@ -0,0 +1,20 @@ +### Two-stream UDP packets, 64B and 594B ### +############################################ +- name: udp_64B + stream: + self_start: True + packet: + binary: cap2/udp_64B.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] +- name: udp_594B + stream: + self_start: True + packet: + binary: cap2/udp_594B.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] \ No newline at end of file diff --git a/scripts/stl/imix_3pkt.yaml b/scripts/stl/imix_3pkt.yaml new file mode 100755 index 00000000..d3923fb8 --- /dev/null +++ b/scripts/stl/imix_3pkt.yaml @@ -0,0 +1,29 @@ +### Three-stream UDP packets, 64B, 594B and 1518B ### +##################################################### +- name: udp_64B + stream: + self_start: True + packet: + binary: cap2/udp_64B.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] +- name: udp_594B + stream: + self_start: True + packet: + binary: cap2/udp_594B.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] +- name: udp_1518B + stream: + self_start: True + packet: + binary: cap2/udp_1518B.pcap + mode: + type: continuous + pps: 100 + rx_stats: [] \ No newline at end of file -- cgit 1.2.3-korg