# pack the profile
try:
- profile = STLProfile.load(opts.file[0])
+ for port in opts.ports:
+ profile = STLProfile.load(opts.file[0], direction = (port % 2), port = port)
+ self.add_streams(profile.get_streams(), ports = port)
+
except STLError as e:
self.logger.log(format_text("\nError while loading profile '{0}'\n".format(opts.file[0]), 'bold'))
self.logger.log(e.brief() + "\n")
return
- self.add_streams(profile.get_streams(), ports = opts.ports)
-
if opts.dry:
self.validate(opts.ports, opts.mult, opts.duration, opts.total)
else:
# handle YAMLs
for input_file in input_files:
try:
- profile = STLProfile.load(input_file)
+ profile = STLProfile.load(input_file, direction = (self.port_id % 2), port = self.port_id)
except STLError as e:
s = format_text("\nError while loading profile '{0}'\n".format(input_file), 'bold')
s += "\n" + e.brief()
default = None,
type = int)
+ parser.add_argument("-i", "--port",
+ help = "Simulate a specific port ID [default is 0]",
+ dest = "port_id",
+ default = 0,
+ type = int)
+
+
parser.add_argument("-r", "--release",
help = "runs on release image instead of debug [default is False]",
action = "store_true",
mode = 'none'
try:
- r = STLSim(bp_sim_path = options.bp_sim_path)
+ r = STLSim(bp_sim_path = options.bp_sim_path, port_id = options.port_id)
r.run(input_list = options.input_file,
outfile = options.output_file,
@staticmethod
- def load_py (python_file):
+ def load_py (python_file, direction = 0, **kwargs):
""" load from Python profile """
# check filename
module = __import__(file, globals(), locals(), [], -1)
reload(module) # reload the update
- streams = module.register().get_streams()
+ streams = module.register().get_streams(direction = direction, **kwargs)
return STLProfile(streams)
except Exception as e:
a, b, tb = sys.exc_info()
- x =''.join(traceback.format_list(traceback.extract_tb(tb)[1:])) + a.__name__ + ": " + str(b) + "\n"
+ x =''.join(traceback.format_list(traceback.extract_tb(tb)[0:])) + a.__name__ + ": " + str(b) + "\n"
summary = "\nPython Traceback follows:\n\n" + x
raise STLError(summary)
@staticmethod
- def load (filename):
+ def load (filename, direction = 0, **kwargs):
""" load a profile by its type supported type are
* py
* yaml
* pcap file that converted to profile automaticly
:parameters:
- filename : string as filename
+ filename : string as filename
+ direction : profile's direction (if supported by the profile)
+ kwargs : forward those key-value pairs to the profile
"""
suffix = x[1] if (len(x) == 2) else None
if suffix == 'py':
- profile = STLProfile.load_py(filename)
+ profile = STLProfile.load_py(filename, direction, **kwargs)
elif suffix == 'yaml':
profile = STLProfile.load_yaml(filename)
from trex_stl_lib.api import *
class STLS1(object):
- def get_streams(self):
+ def get_streams(self, direction = 0, **kwargs):
streams = []
'''
for stream in self.streams:
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
class STLS1(object):
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"), # path relative to pwd
mode = STLTXCont(pps=1000),
flow_stats = STLFlowStats(pg_id = 7)),
Missing values will be filled with defaults
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(frame_size = 100,
vlan_id = [1, 2, 3, 4], # can be either array or string separated by spaces
vlan_protocol_tag_id = '8100 0x8100', # hex with optional prefix '0x'
Creates 3 streams (imix) Eth/802.1Q/IP/TCP without VM
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
#'''
return STLHltStream(
#enable_auto_detect_instrumentation = '1', # not supported yet
Creates 3 streams (imix) Eth/802.1Q/IP/TCP without VM
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(
#enable_auto_detect_instrumentation = '1', # not supported yet
ip_dst_addr = '192.168.3.3',
Creates Eth/802.1Q/802.1Q/IP/TCP stream
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(
l3_protocol = 'ipv4',
ip_src_addr = '100.1.1.1',
MAC dst will have <mac_dst_count> number of incremental values
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
mac_dst_count = 10
mac_src_count = 10
pkts_per_burst = 10
Two Eth/IP/UDP streams with VM to get different size of packet by frame_size
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLHltStream(length_mode = 'increment',
frame_size_min = 100,
frame_size_max = 3000,
Each stream will get rate_pps * his ratio / sum of ratios
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(length_mode = 'imix', rate_pps = 2,
l3_imix1_size = 60, l3_imix1_ratio = 4,
l3_imix2_size = 400, l3_imix2_ratio = 3,
class STLS1(object):
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(length_mode = 'imix', rate_pps = 2,
l3_protocol = 'ipv4', l4_protocol = 'udp')
Eth/IP/TCP stream with VM to get different ip addresses
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(split_by_cores = 'duplicate',
l3_protocol = 'ipv4',
ip_src_addr = '192.168.1.1',
Eth/IPv6/UDP stream without VM, default values
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLHltStream(l3_protocol = 'ipv6',
l3_length = 150,
l4_protocol = 'udp',
Eth/IPv6/UDP stream with VM, to change the ipv6 addr (only 32 lsb)
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(l3_protocol = 'ipv6', l3_length = 150, l4_protocol = 'udp',
ipv6_src_addr = '1111:2222:3333:4444:5555:6666:7777:8888',
ipv6_dst_addr = '1111:1111:1111:1111:1111:1111:1111:1111',
Two Eth/IP/UDP streams with VM to get different size of packet by l3_length
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLHltStream(length_mode = 'increment',
l3_length_min = 100,
l3_length_max = 3000,
Eth/IP/UDP stream with VM, to change the MAC addr (only 32 lsb)
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(l3_protocol = 'ipv4', l4_protocol = 'udp',
mac_src = '10:00:00:00:00:01', mac_dst = '10:00:00:00:01:00',
mac_src2 = '11:11:00:00:00:01', mac_dst2 = '11:11:00:00:01:00',
Eth/IP/TCP stream with VM to get 10 different TCP ports
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(l3_protocol = 'ipv4',
l4_protocol = 'tcp',
tcp_src_port_mode = 'decrement',
Seconds stream will decrease the packet size in reverse way
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
max_size = 9*1024
return [STLHltStream(length_mode = 'increment',
frame_size_max = max_size,
The ports overlap the max and min at very first packets
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(l3_protocol = 'ipv4',
l4_protocol = 'udp',
udp_src_port_mode = 'decrement',
Using "consistent_random = True" to have same random ports each test
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLHltStream(l3_protocol = 'ipv4',
l4_protocol = 'udp',
udp_src_port_mode = 'random',
Default Eth/802.1Q/IP/TCP stream without VM
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(l2_encap = 'ethernet_ii_vlan',
l3_protocol = 'ipv4', l4_protocol = 'tcp',
direction = direction)
Missing values will be filled with defaults
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return STLHltStream(frame_size = 100,
vlan_id = '1 2 1000 4 5', # 5 vlans
vlan_id_mode = 'increment fixed decrement random', # 5th vlan will be default fixed
Creates Eth/802.1Q/IP/UDP stream with VM on src IP
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
ipv4_address_step = '0.0.1.0'
num_of_sessions_per_spoke = 1000
ip_tgen_hub = '190.1.0.1'
Creates Eth/802.1Q/IPv6/UDP stream without VM (if num_of_sessions_per_spoke is 1)
'''
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
ipv6_tgen_rtr = '2005:0:1::1'
num_of_sessions_per_spoke = 1 # in given example is not passed forward, taking default
ipv6_address_step = '0:0:0:1:0:0:0:0'
mode = STLTXCont(pps = pps))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
if direction == 0:
src = self.ip_range['src']
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
def __init__ (self, pcap_file):
self.pcap_file = pcap_file
- def get_streams (self,
- ipg_usec = 10.0,
- loop_count = 1):
+ def get_streams (self, direction = 0, **kwargs):
- profile = STLProfile.load_pcap(self.pcap_file, ipg_usec = ipg_usec, loop_count = loop_count)
+ profile = STLProfile.load_pcap(self.pcap_file, ipg_usec = kwargs.get('ipg_usec', 10.0), loop_count = kwargs.get('loop_count', 1))
return profile.get_streams()
return vm
- def get_streams (self,
- ipg_usec = 10.0,
- loop_count = 5,
- ip_src_range = None,
- ip_dst_range = {'start' : '10.0.0.1', 'end': '10.0.0.254'}):
+ def get_streams (self, direction = 0, **kwargs):
+
+ ip_src_range = kwargs.get('ip_src_range', None)
+ ip_dst_range = kwargs.get('up_dst_range', {'start' : '10.0.0.1', 'end': '10.0.0.254'})
vm = self.create_vm(ip_src_range, ip_dst_range)
- profile = STLProfile.load_pcap(self.pcap_file, ipg_usec = ipg_usec, loop_count = loop_count, vm = vm)
+
+ profile = STLProfile.load_pcap(self.pcap_file,
+ ipg_usec = kwargs.get('ipg_usec', 10.0),
+ loop_count = kwargs.get('loop_count', 5),
+ vm = vm)
return profile.get_streams()
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
mode = STLTXSingleBurst( pps = 1, total_pkts = 17) )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
mode = STLTXSingleBurst( pps = 1, total_pkts = 17) )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
mode = STLTXSingleBurst( pps = 1, total_pkts = 17) )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
mode = STLTXSingleBurst( pps = 1, total_pkts = 100) )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
class STLS1(object):
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"), # path relative to pwd
mode = STLTXCont(pps=10)) ] #rate continues, could be STLTXSingleBurst,STLTXMultiBurst
class STLS1(object):
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
return [STLStream(packet = STLPktBuilder(pkt ="yaml/udp_64B_no_crc.pcap",
path_relative_to_profile = True), # path relative to profile and not to loader path
mode = STLTXCont(pps=10)) ] #rate continues, could be STLTXSingleBurst,STLTXMultiBurst
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream(packet = STLPktBuilder(pkt = base_pkt,vm = vm),
mode = STLTXSingleBurst( pps=10, total_pkts = self.num_clients )) # single burst of G-ARP
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
),
mode = STLTXCont())
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
class STLS1(object):
- def create_stream (self):
- return STLStream(
- packet =
- STLPktBuilder(
- pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/
- UDP(dport=12,sport=1025)/(10*'x')
- ),
- mode = STLTXCont())
-
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
+
# create 1 stream
if direction==0:
src_ip="16.0.0.1"
#mac_dst_override_mode=STLStreamDstMAC_PKT # another way to explictly take it
)
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
#mac_dst_override_mode=STLStreamDstMAC_PKT # another way to explictly take it
)
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
#mac_src_override_by_pkt=True # another way to explictly take it
)
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream( packet = pkt_a ,
mode = STLTXCont() )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return STLStream( packet = pkt_a ,
mode = STLTXCont() )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
return stream
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
mode = STLTXSingleBurst( pps = 1, total_pkts = 17) )
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
]).get_streams()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return self.create_stream()
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
- def get_streams (self, direction = 0):
+ def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]