summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-03-31 16:20:20 +0300
committerHanoh Haim <hhaim@cisco.com>2016-03-31 16:20:20 +0300
commita6f72a194d47e5df1e822cbcec22f1f4df1da482 (patch)
treec6fe8e0c65925707c5cb107ef5ee9b877a014fa1 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
parent300ca9bcaa3309665421efd5ed51c49f9b81006d (diff)
parenta627a1d4a35f27e0da4599fbeddae97bc5470010 (diff)
Merge David4 branch
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py')
-rwxr-xr-x[-rw-r--r--]scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py110
1 files changed, 55 insertions, 55 deletions
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 2bd98d4a..78f51ec6 100644..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
@@ -21,22 +21,22 @@ class STLTXMode(object):
def __init__ (self, pps = None, bps_L1 = None, bps_L2 = None, percentage = None):
"""
- Speed could be in packet per second (pps) or L2/L1 bps or port precent
- only one of them is valid.
+ Speed can be given in packets per second (pps), L2/L1 bps, or port percent
+ Use only one unit.
you can enter pps =10000 oe bps_L1=10
:parameters:
pps : float
- packet per second
+ Packets per second
bps_L1 : float
- bit per second L1 (with IPG)
+ Bits per second L1 (with IPG)
bps_L2 : float
- bit per second L2 (Ethernet-FCS)
+ Bits per second L2 (Ethernet-FCS)
percentage : float
- link interface precent 0-100 e.g. 10 is 10%% of the port link setup
+ Link interface percent (0-100). Example: 10 is 10% of the port link setup
.. code-block:: python
:caption: STLTXMode Example
@@ -95,11 +95,11 @@ class STLTXMode(object):
# continuous mode
class STLTXCont(STLTXMode):
- """ continuous mode """
+ """ Continuous mode """
def __init__ (self, **kwargs):
"""
- continuous mode
+ Continuous mode
see :class:`trex_stl_lib.trex_stl_streams.STLTXMode` for rate
@@ -112,7 +112,7 @@ class STLTXCont(STLTXMode):
super(STLTXCont, self).__init__(**kwargs)
- self.fields['type'] = 'continuous'
+ self.fields['type'] = 'Continuous'
@staticmethod
def __str__ ():
@@ -124,11 +124,11 @@ class STLTXSingleBurst(STLTXMode):
def __init__ (self, total_pkts = 1, **kwargs):
"""
- single burst mode
+ Single burst mode
:parameters:
total_pkts : int
- how many packets for this burst
+ Number of packets for this burst
see :class:`trex_stl_lib.trex_stl_streams.STLTXMode` for rate
@@ -154,7 +154,7 @@ class STLTXSingleBurst(STLTXMode):
# multi burst mode
class STLTXMultiBurst(STLTXMode):
- """ Multi burst mode """
+ """ Multi-burst mode """
def __init__ (self,
pkts_per_burst = 1,
@@ -162,18 +162,18 @@ class STLTXMultiBurst(STLTXMode):
count = 1,
**kwargs):
"""
- Multi burst mode
+ Multi-burst mode
:parameters:
pkts_per_burst: int
- how many packets per burst
+ Number of packets per burst
ibg : float
- inter burst gap in usec 1000,000.0 is 1 sec
+ Inter-burst gap in usec 1,000,000.0 is 1 sec
count : int
- how many bursts
+ Number of bursts
see :class:`trex_stl_lib.trex_stl_streams.STLTXMode` for rate
@@ -230,7 +230,7 @@ class STLFlowStats(object):
def to_json (self):
- """ dump as json"""
+ """ Dump as json"""
return dict(self.fields)
@staticmethod
@@ -238,7 +238,7 @@ class STLFlowStats(object):
return {'enabled' : False}
class STLStream(object):
- """ One stream object, include mode, Field Engine mode packet template and Rx stats
+ """ One stream object. Includes mode, Field Engine mode packet template and Rx stats
.. code-block:: python
:caption: STLStream Example
@@ -277,42 +277,42 @@ class STLStream(object):
:parameters:
name : string
- The name of the stream. Needed if this stream is dependent on another stream and another stream need to refer to this stream by its name.
+ Name of the stream. Required if this stream is dependent on another stream, and another stream needs to refer to this stream by name.
packet : STLPktBuilder see :class:`trex_stl_lib.trex_stl_packet_builder_scapy.STLPktBuilder`
- The template packet and field engine program e.g. packet = STLPktBuilder(pkt = base_pkt/pad)
+ Template packet and field engine program. Example: packet = STLPktBuilder(pkt = base_pkt/pad)
mode : :class:`trex_stl_lib.trex_stl_streams.STLTXCont` or :class:`trex_stl_lib.trex_stl_streams.STLTXSingleBurst` or :class:`trex_stl_lib.trex_stl_streams.STLTXMultiBurst`
enabled : bool
- if the stream is enabled.
+ Indicates whether the stream is enabled.
self_start : bool
- In case it is False another stream will activate it
+ If False, another stream activates it.
isg : float
- Inter stream gap in usec. time to wait until stream will send the first packet
+ Inter-stream gap in usec. Time to wait until the stream sends the first packet.
flow_stats : :class:`trex_stl_lib.trex_stl_streams.STLFlowStats`
- Per stream statistic object see STLFlowStats
+ Per stream statistic object. See: STLFlowStats
next : string
- The name of the stream to activate
+ Name of the stream to activate.
stream_id :
- for HLTAPI usage
+ For use by HLTAPI.
action_count : uint16_t
- In case there is a next stream how many loops until stopping. Default is zero, which mean unlimited
+ If there is a next stream, number of loops before stopping. Default: 0 (unlimited).
random_seed: uint16_t
- If given the seed for this stream will be this value. Good in case you need a deterministic random value
+ If given, the seed for this stream will be this value. Useful if you need a deterministic random value.
mac_src_override_by_pkt : bool
- Template packet will set src MAC
+ Template packet sets src MAC.
mac_dst_override_mode=None : STLStreamDstMAC_xx
- Template packet will set dst MAC
+ Template packet sets dst MAC.
"""
@@ -326,7 +326,7 @@ class STLStream(object):
validate_type('random_seed',random_seed,int);
if (type(mode) == STLTXCont) and (next != None):
- raise STLError("continuous stream cannot have a next stream ID")
+ raise STLError("Continuous stream cannot have a next stream ID")
# tag for the stream and next - can be anything
self.name = name
@@ -412,7 +412,7 @@ class STLStream(object):
def to_json (self):
"""
- return json format
+ Return json format
"""
return dict(self.fields)
@@ -448,7 +448,7 @@ class STLStream(object):
def get_pkt_type (self):
- """ Get packet description for example IP:UDP """
+ """ Get packet description. Example: IP:UDP """
if self.packet_desc == None:
self.packet_desc = STLPktBuilder.pkt_layers_desc_from_buffer(self.get_pkt())
@@ -476,7 +476,7 @@ class STLStream(object):
return self.get_rate_from_field(self.fields['mode']['rate'])
def to_pkt_dump (self):
- """ print packet description from scapy """
+ """ Print packet description from Scapy """
if self.name:
print("Stream Name: ",self.name)
scapy_b = self.scapy_pkt_builder;
@@ -488,7 +488,7 @@ class STLStream(object):
def to_yaml (self):
- """ convert to YAML """
+ """ Convert to YAML """
y = {}
if self.name:
@@ -510,7 +510,7 @@ class STLStream(object):
# returns the Python code (text) to build this stream, inside the code it will be in variable "stream"
def to_code (self):
- """ convert to Python code as profile """
+ """ Convert to Python code as profile """
packet = Ether(self.pkt)
layer = packet
while layer: # remove checksums
@@ -625,7 +625,7 @@ class STLStream(object):
return r'\x{0:02x}'.format(ord(match.group()))
def dump_to_yaml (self, yaml_file = None):
- """ print as yaml """
+ """ Print as yaml """
yaml_dump = yaml.dump([self.to_yaml()], default_flow_style = False)
# write to file if provided
@@ -646,7 +646,7 @@ class YAMLLoader(object):
packet_type = set(packet_dict).intersection(['binary', 'pcap'])
if len(packet_type) != 1:
- raise STLError("packet section must contain either 'binary' or 'pcap'")
+ raise STLError("Packet section must contain either 'binary' or 'pcap'")
if 'binary' in packet_type:
try:
@@ -711,7 +711,7 @@ class YAMLLoader(object):
pg_id = flow_stats_obj.get('stream_id')
if pg_id == None:
- raise STLError("enabled RX stats section must contain 'stream_id' field")
+ raise STLError("Enabled RX stats section must contain 'stream_id' field")
return STLFlowStats(pg_id = pg_id)
@@ -826,7 +826,7 @@ class STLProfile(object):
def get_streams (self):
- """ Get the list of stream"""
+ """ Get the list of streams"""
return self.streams
def __str__ (self):
@@ -840,7 +840,7 @@ class STLProfile(object):
@staticmethod
def load_yaml (yaml_file):
- """ load from YAML file a profile with number of streams"""
+ """ Load (from YAML file) a profile with a number of streams"""
# check filename
if not os.path.isfile(yaml_file):
@@ -875,11 +875,11 @@ class STLProfile(object):
@staticmethod
def load_py (python_file, direction = 0, port_id = 0, **kwargs):
- """ load from Python profile """
+ """ Load from Python profile """
# check filename
if not os.path.isfile(python_file):
- raise STLError("file '{0}' does not exists".format(python_file))
+ raise STLError("File '{0}' does not exist".format(python_file))
basedir = os.path.dirname(python_file)
sys.path.append(basedir)
@@ -892,7 +892,7 @@ class STLProfile(object):
t = STLProfile.get_module_tunables(module)
for arg in kwargs:
if not arg in t:
- raise STLError("profile {0} does not support tunable '{1}' - supported tunables are: '{2}'".format(python_file, arg, t))
+ raise STLError("Profile {0} does not support tunable '{1}' - supported tunables are: '{2}'".format(python_file, arg, t))
streams = module.register().get_streams(direction = direction,
port_id = port_id,
@@ -919,26 +919,26 @@ class STLProfile(object):
# loop_count = 0 means loop forever
@staticmethod
def load_pcap (pcap_file, ipg_usec = None, speedup = 1.0, loop_count = 1, vm = None):
- """ Convert a pcap file with a number of packets to a list of connected streams
+ """ Convert a pcap file with a number of packets to a list of connected streams.
packet1->packet2->packet3 etc
:parameters:
pcap_file : string
- The name of the pcap file
+ Name of the pcap file
ipg_usec : float
- The inter packet gap in usec. in case of None IPG is taken from pcap file
+ Inter packet gap in usec. If IPG=0, IPG is taken from pcap file
speedup : float
- By which factor to get IPG smaller so we will send pcap file in speedup
+ When reading the pcap file, divide IPG by this "speedup" factor. Resulting IPG is sped up by this factor.
loop_count : uint16_t
- how many loops to repeat the pcap file
+ Number of loops to repeat the pcap file
vm : list
- A list of Field engine instructions
+ List of Field engine instructions
:return: STLProfile
@@ -996,12 +996,12 @@ class STLProfile(object):
@staticmethod
def load (filename, direction = 0, port_id = 0, **kwargs):
- """ load a profile by its type supported type are
+ """ Load a profile by its type. Supported types are:
* py
* yaml
* pcap file that converted to profile automaticly
- :parameters:
+ :Parameters:
filename : string as filename
direction : profile's direction (if supported by the profile)
port_id : which port ID this profile is being loaded to
@@ -1033,7 +1033,7 @@ class STLProfile(object):
return profile.meta
def dump_as_pkt (self):
- """ dump the profile as scapy packet. in case it is raw convert to scapy and dump it"""
+ """ Dump the profile as Scapy packet. If the packet is raw, convert it to Scapy before dumping it."""
cnt=0;
for stream in self.streams:
print("=======================")
@@ -1043,7 +1043,7 @@ class STLProfile(object):
stream.to_pkt_dump()
def dump_to_yaml (self, yaml_file = None):
- """ convert it to yaml """
+ """ Convert the profile to yaml """
yaml_list = [stream.to_yaml() for stream in self.streams]
yaml_str = yaml.dump(yaml_list, default_flow_style = False)
@@ -1055,7 +1055,7 @@ class STLProfile(object):
return yaml_str
def dump_to_code (self, profile_file = None):
- """ convert it to Python native profile. yeah this is cool """
+ """ Convert the profile to Python native profile. """
profile_dump = '''# !!! Auto-generated code !!!
from trex_stl_lib.api import *