diff options
author | 2015-11-25 04:46:56 -0500 | |
---|---|---|
committer | 2015-11-25 04:46:56 -0500 | |
commit | 4a41c26a5cf23635a5b1332af6e806c915cf7e6c (patch) | |
tree | 35e77fb81f60e5b6537d865760ea1d8f6f485c99 | |
parent | b0446de90c05d0a129fc38e6aef981dff243ccb7 (diff) |
support for "total" flag for start
also fixed a bug in mpps (trex console)
3 files changed, 20 insertions, 11 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py index af166b7f..30550ca3 100755 --- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py +++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py @@ -880,6 +880,7 @@ class CTRexStatelessClient(object): "start", self.cmd_start_line.__doc__, parsing_opts.PORT_LIST_WITH_ALL, + parsing_opts.TOTAL, parsing_opts.FORCE, parsing_opts.STREAM_FROM_PATH_OR_FILE, parsing_opts.DURATION, @@ -906,6 +907,10 @@ class CTRexStatelessClient(object): return RC_ERR("Failed to load stream pack") + if opts.total: + # if total was set - divide it between the ports + opts.mult['max'] = opts.mult['max'] / len(opts.ports) + return self.cmd_start(opts.ports, stream_list, opts.mult, opts.force, opts.duration) def cmd_stop_line (self, line): diff --git a/scripts/automation/trex_control_plane/console/parsing_opts.py b/scripts/automation/trex_control_plane/console/parsing_opts.py index 14e8c563..d2484a83 100755 --- a/scripts/automation/trex_control_plane/console/parsing_opts.py +++ b/scripts/automation/trex_control_plane/console/parsing_opts.py @@ -19,6 +19,7 @@ SERVER_IP = 7 STREAM_FROM_PATH_OR_FILE = 8 DURATION = 9 FORCE = 10 +TOTAL = 11 # list of ArgumentGroup types MUTEX = 1 @@ -56,7 +57,7 @@ match_multiplier_help = """Multiplier should be passed in the following format: def match_multiplier(val): '''match some val against multiplier shortcut inputs ''' - match = re.match("^(\d+(\.\d+)?)(bps|kbps|mbps|gbps|pps|kpps|mbps|%?)$", val) + match = re.match("^(\d+(\.\d+)?)(bps|kbps|mbps|gbps|pps|kpps|mpps|%?)$", val) result = {} @@ -68,7 +69,7 @@ def match_multiplier(val): # raw type (factor) if not unit: result['type'] = 'raw' - result['factor'] = value + result['max'] = value elif unit == 'bps': result['type'] = 'max_bps' @@ -123,6 +124,13 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'], 'default': 1.0, 'type': match_multiplier}), + + TOTAL: ArgumentPack(['-t', '--total'], + {'help': "traffic will be divided between all ports specified", + 'dest': "total", + 'default': False, + 'action': "store_true"}), + PORT_LIST: ArgumentPack(['--port'], {"nargs": '+', 'dest':'ports', diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index d22fda7d..f148261c 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -475,25 +475,21 @@ TrexRpcCmdStartTraffic::_run(const Json::Value ¶ms, Json::Value &result) { const Json::Value &mul = parse_object(params, "mul", result); + std::string mul_type = parse_string(mul, "type", result); + double max_rate = parse_double(mul, "max", result); /* dispatch according to type of multiplier */ try { if (mul_type == "raw") { - - double m = parse_double(mul, "factor", result); - port->start_traffic(m, duration); + port->start_traffic(max_rate, duration); } else if (mul_type == "max_bps") { - - double max_bps = parse_double(mul, "max", result); - port->start_traffic_max_bps(max_bps, duration); + port->start_traffic_max_bps(max_rate, duration); } else if (mul_type == "max_pps") { - - double max_pps = parse_double(mul, "max", result); - port->start_traffic_max_pps(max_pps, duration); + port->start_traffic_max_pps(max_rate, duration); } } catch (const TrexRpcException &ex) { |