summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py17
-rwxr-xr-xscripts/automation/trex_control_plane/console/parsing_opts.py18
2 files changed, 25 insertions, 10 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 7bcbf2c7..af166b7f 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -146,13 +146,14 @@ class Port(object):
STATE_TX = 3
STATE_PAUSE = 4
- def __init__ (self, port_id, user, transmit):
+ def __init__ (self, port_id, speed, driver, user, transmit):
self.port_id = port_id
self.state = self.STATE_IDLE
self.handler = None
self.transmit = transmit
self.user = user
-
+ self.driver = driver
+ self.speed = speed
self.streams = {}
def err(self, msg):
@@ -161,6 +162,9 @@ class Port(object):
def ok(self):
return RC_OK()
+ def get_speed_bps (self):
+ return (self.speed * 1000 * 1000)
+
# take the port
def acquire(self, force = False):
params = {"port_id": self.port_id,
@@ -299,6 +303,11 @@ class Port(object):
if self.state == self.STATE_TX:
return self.err("Unable to start traffic - port is already transmitting")
+ # if percentage - translate
+ if mul['type'] == 'percentage':
+ mul['type'] = 'max_bps'
+ mul['max'] = self.get_speed_bps() * (mul['max'] / 100)
+
params = {"handler": self.handler,
"port_id": self.port_id,
"mul": mul,
@@ -461,7 +470,9 @@ class CTRexStatelessClient(object):
# create ports
for port_id in xrange(self.get_port_count()):
- self.ports.append(Port(port_id, self.user, self.transmit))
+ speed = self.system_info['ports'][port_id]['speed']
+ driver = self.system_info['ports'][port_id]['driver']
+ self.ports.append(Port(port_id, speed, driver, self.user, self.transmit))
# acquire all ports
rc = self.acquire()
diff --git a/scripts/automation/trex_control_plane/console/parsing_opts.py b/scripts/automation/trex_control_plane/console/parsing_opts.py
index 732ba764..ab678586 100755
--- a/scripts/automation/trex_control_plane/console/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/console/parsing_opts.py
@@ -42,6 +42,12 @@ def match_time_unit(val):
"-d 10m : in min \n"
"-d 1h : in hours")
+match_multiplier_help = """Multiplier should be passed in the following format:
+ [number][<empty> | bps | kbps | mbps | gbps | pps | kpps | mpps | %% ].
+ no suffix will provide an absoulute factor and percentage
+ will provide a percentage of the line rate. examples
+ : '-m 10', '-m 10kbps', '-m 10mpps', '-m 23%%' """
+
def match_multiplier(val):
'''match some val against multiplier shortcut inputs '''
@@ -88,16 +94,14 @@ def match_multiplier(val):
result['max'] = value * 1000 * 1000
elif unit == "%":
- raise argparse.ArgumentTypeError("percetange is currently unsupported...")
+ # will be translated by the port object
+ result['type'] = 'percentage'
+ result['max'] = value
return result
else:
- raise argparse.ArgumentTypeError("\n\nMultiplier should be passed in the following format: \n\n"
- "-m 100 : multiply by factor \n"
- "-m 1bps / 1kbps / 1mbps / 1gbps : normalize to bps \n"
- "-m 1pps / 1kpps / 1mbps : normalize to pps \n"
- "-m 40% : normalize to % from port line rate\n")
+ raise argparse.ArgumentTypeError(match_multiplier_help)
@@ -109,7 +113,7 @@ def is_valid_file(filename):
OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
- {'help': "Set multiplier for stream",
+ {'help': match_multiplier_help,
'dest': "mult",
'default': 1.0,
'type': match_multiplier}),