summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-05-08 17:32:12 +0300
committerimarom <imarom@cisco.com>2016-05-09 16:48:16 +0300
commitdb9145d248720c633dd4da6c785e071198986326 (patch)
tree86e00a08895f65e2840b2bf8a921b9e9298f11a1 /scripts/automation/trex_control_plane/stl/trex_stl_lib
parent75ce59e5652f9094beab854d263a850cfc81a3de (diff)
added duration to remote push
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py112
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py11
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py5
3 files changed, 104 insertions, 24 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 0d95131f..9f96b237 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -722,13 +722,13 @@ class STLClient(object):
return rc
- def __push_remote (self, pcap_filename, port_id_list, ipg_usec, speedup, count):
+ def __push_remote (self, pcap_filename, port_id_list, ipg_usec, speedup, count, duration):
port_id_list = self.__ports(port_id_list)
rc = RC()
for port_id in port_id_list:
- rc.add(self.ports[port_id].push_remote(pcap_filename, ipg_usec, speedup, count))
+ rc.add(self.ports[port_id].push_remote(pcap_filename, ipg_usec, speedup, count, duration))
return rc
@@ -1874,9 +1874,15 @@ class STLClient(object):
@__api_check(True)
- def push_remote (self, pcap_filename, ports = None, ipg_usec = None, speedup = 1.0, count = 1):
+ def push_remote (self,
+ pcap_filename,
+ ports = None,
+ ipg_usec = None,
+ speedup = 1.0,
+ count = 1,
+ duration = -1):
"""
- Push a remote reachable PCAP file
+ Push a remote server-reachable PCAP file
the path must be fullpath accessible to the server
:parameters:
@@ -1895,7 +1901,8 @@ class STLClient(object):
count: int
How many times to transmit the cap
-
+ duration: float
+ Limit runtime by duration in seconds
:raises:
+ :exc:`STLError`
@@ -1905,11 +1912,12 @@ class STLClient(object):
validate_type('pcap_filename', pcap_filename, str)
validate_type('ipg_usec', ipg_usec, (float, int, type(None)))
- validate_type('speedup', speedup, float)
+ validate_type('speedup', speedup, (float, int))
validate_type('count', count, int)
+ validate_type('duration', duration, (float, int))
- self.logger.pre_cmd("Pushing remote pcap on port(s) {0}:".format(ports))
- rc = self.__push_remote(pcap_filename, ports, ipg_usec, speedup, count)
+ self.logger.pre_cmd("Pushing remote PCAP on port(s) {0}:".format(ports))
+ rc = self.__push_remote(pcap_filename, ports, ipg_usec, speedup, count, duration)
self.logger.post_cmd(rc)
if not rc:
@@ -1917,7 +1925,71 @@ class STLClient(object):
@__api_check(True)
- def validate (self, ports = None, mult = "1", duration = "-1", total = False):
+ def push_pcap (self,
+ pcap_filename,
+ ports = None,
+ ipg_usec = None,
+ speedup = 1.0,
+ count = 1,
+ duration = -1):
+ """
+ Push a local PCAP to the server
+ This is equivalent to loading a PCAP file to a profile
+ and attaching the profile to port(s)
+
+ file size is limited to 1MB
+
+ :parameters:
+ pcap_filename : str
+ PCAP filename (accessible locally)
+
+ ports : list
+ Ports on which to execute the command
+
+ ipg_usec : float
+ Inter-packet gap in microseconds
+
+ speedup : float
+ A factor to adjust IPG. effectively IPG = IPG / speedup
+
+ count: int
+ How many times to transmit the cap
+
+ duration: float
+ Limit runtime by duration in seconds
+
+ :raises:
+ + :exc:`STLError`
+
+ """
+ ports = ports if ports is not None else self.get_acquired_ports()
+ ports = self._validate_port_list(ports)
+
+ validate_type('pcap_filename', pcap_filename, str)
+ validate_type('ipg_usec', ipg_usec, (float, int, type(None)))
+ validate_type('speedup', speedup, (float, int))
+ validate_type('count', count, int)
+ validate_type('duration', duration, (float, int))
+
+ # no support for > 1MB PCAP - use push remote
+ if os.path.getsize(pcap_filename) > (1024 * 1024):
+ raise STLError("PCAP size of {:,} B is too big for local push - consider using remote push".format(os.path.getsize(pcap_filename)))
+
+ self.remove_all_streams(ports = ports)
+
+ profile = STLProfile.load_pcap(pcap_filename,
+ ipg_usec,
+ speedup,
+ count)
+
+
+ id_list = self.add_streams(profile.get_streams(), ports)
+
+ return self.start(ports = ports, duration = duration)
+
+
+ @__api_check(True)
+ def validate (self, ports = None, mult = "1", duration = -1, total = False):
"""
Validate port(s) configuration
@@ -1964,6 +2036,8 @@ class STLClient(object):
rc = self.__validate(ports)
self.logger.post_cmd(rc)
+ if not rc:
+ raise STLError(rc)
for port in ports:
self.ports[port].print_profile(mult_obj, duration)
@@ -2606,24 +2680,24 @@ class STLClient(object):
else:
self.stop(active_ports)
- # pcap injection removes all previous streams from the ports
+
if opts.remote:
self.push_remote(opts.file[0],
ports = opts.ports,
ipg_usec = opts.ipg_usec,
speedup = opts.speedup,
- count = opts.count)
+ count = opts.count,
+ duration = opts.duration)
else:
- self.remove_all_streams(ports = opts.ports)
-
- profile = STLProfile.load_pcap(opts.file[0],
- opts.ipg_usec,
- opts.speedup,
- opts.count)
+ self.push_pcap(opts.file[0],
+ ports = opts.ports,
+ ipg_usec = opts.ipg_usec,
+ speedup = opts.speedup,
+ count = opts.count,
+ duration = opts.duration)
- id_list = self.add_streams(profile.get_streams(), opts.ports)
- self.start(ports = opts.ports, duration = opts.duration, force = opts.force)
+
return True
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 43fc29e6..391b2076 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -476,6 +476,9 @@ class Port(object):
@owned
def pause (self):
+ if (self.state == self.STATE_PCAP_TX) :
+ return self.err("pause is not supported during PCAP TX")
+
if (self.state != self.STATE_TX) :
return self.err("port is not transmitting")
@@ -512,6 +515,9 @@ class Port(object):
@owned
def update (self, mul, force):
+ if (self.state == self.STATE_PCAP_TX) :
+ return self.err("update is not supported during PCAP TX")
+
if (self.state != self.STATE_TX) :
return self.err("port is not transmitting")
@@ -561,14 +567,15 @@ class Port(object):
return self.ok()
@writeable
- def push_remote (self, pcap_filename, ipg_usec, speedup, count):
+ def push_remote (self, pcap_filename, ipg_usec, speedup, count, duration):
params = {"handler": self.handler,
"port_id": self.port_id,
"pcap_filename": pcap_filename,
"ipg_usec": ipg_usec if ipg_usec is not None else -1,
"speedup": speedup,
- "count": count}
+ "count": count,
+ "duration": duration}
rc = self.transmit("push_remote", params)
if rc.bad():
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
index 66aeaef4..92598312 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
@@ -959,8 +959,8 @@ class STLProfile(object):
raise STLError("file '{0}' does not exists".format(pcap_file))
# make sure IPG is not less than 1 usec
- if ipg_usec is not None and ipg_usec < 1:
- raise STLError("ipg_usec cannot be less than 1 usec: '{0}'".format(ipg_usec))
+ if ipg_usec is not None and ipg_usec < 0.001:
+ raise STLError("ipg_usec cannot be less than 0.001 usec: '{0}'".format(ipg_usec))
if loop_count < 0:
raise STLError("'loop_count' cannot be negative")
@@ -989,7 +989,6 @@ class STLProfile(object):
next = i + 1
action_count = 0
-
streams.append(STLStream(name = i,
packet = STLPktBuilder(pkt_buffer = cap, vm = vm),
mode = STLTXSingleBurst(total_pkts = 1, percentage = 100),