['hlt/hlt_tcp_ranges.py', '-m 1 -l 20', True],
['hlt/hlt_udp_ports.py', '-m 1 -l 20', True],
['hlt/hlt_udp_random_ports.py', '-m 1 -l 20', True],
+ #['hlt/hlt_ip_ranges.py', '-m 1 -l 20', True], # can't run now, random on full range issue
+ ['hlt/hlt_framesize_vm.py', '-m 1 -l 20', True],
+ ['hlt/hlt_l3_length_vm.py', '-m 1 -l 20', True],
+ ['hlt/hlt_vlan_default.py', '-m 1 -l 20', True],
+ ['hlt/hlt_4vlans.py', '-m 1 -l 20', True],
+ ['hlt/hlt_vlans_vm.py', '-m 1 -l 20', True],
+ ['hlt/hlt_ipv6_default.py', '-m 1 -l 20', True],
+ ['hlt/hlt_ipv6_ranges.py', '-m 1 -l 20', True],
)
for obj in p:
'vlan_cfi': 1,
'vlan_protocol_tag_id': None,
#L3, general
- 'l3_protocol': 'ipv4', # ( ipv4 | ipv6 )
+ 'l3_protocol': None, # ( ipv4 | ipv6 )
'l3_length_min': 110,
'l3_length_max': 238,
'l3_length_step': 1,
'ipv6_dst_step': 1, # we are changing only 32 lowest bits; can be ipv6 or number
'ipv6_dst_count': 1,
#L4, TCP
- 'l4_protocol': 'tcp', # ( tcp | udp )
+ 'l4_protocol': None, # ( tcp | udp )
'tcp_src_port': 1024,
'tcp_dst_port': 80,
'tcp_seq_num': 1,
rate_key = intersect_rate_args[0]
except IndexError:
rate_key = 'rate_percent'
+ if rate_key is 'rate_percent' and float(kwargs['rate_percent']) > 100:
+ raise STLError('rate_percent should not exceed 100%')
if kwargs['length_mode'] == 'imix': # several streams with given length
streams_arr = []
# stream generation
try:
stream = STLStream(packet = packet,
- random_seed = 1 if kwargs['consistent_random'] else 0,
+ random_seed = 1 if is_true(kwargs['consistent_random']) else 0,
#enabled = True,
#self_start = True,
mode = transmit_mode_class,
base_pkt = l2_layer
### L3 ###
- if kwargs['l3_protocol'] == 'ipv4':
+ if kwargs['l3_protocol'] is None:
+ l3_layer = None
+ elif kwargs['l3_protocol'] == 'ipv4':
#fields_desc = [ BitField("version" , 4 , 4),
# BitField("ihl", None, 4),
# XByteField("tos", 0),
raise STLError('ipv6_dst_mode %s is not supported' % kwargs['ipv6_dst_mode'])
vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'IPv6.dst', offset_fixup = 12, add_val = add_val))
- else:
+ elif kwargs['l3_protocol'] is not None:
raise NotImplementedError("l3_protocol '%s' is not supported by TRex yet." % kwargs['l3_protocol'])
- base_pkt /= l3_layer
+ if l3_layer is not None:
+ base_pkt /= l3_layer
### L4 ###
+ l4_layer = None
if kwargs['l4_protocol'] == 'tcp':
+ assert kwargs['l3_protocol'] in ('ipv4', 'ipv6'), 'TCP must be over ipv4/ipv6'
#fields_desc = [ ShortEnumField("sport", 20, TCP_SERVICES),
# ShortEnumField("dport", 80, TCP_SERVICES),
# IntField("seq", 0),
# XShortField("chksum", None),
# ShortField("urgptr", 0),
# TCPOptionsField("options", {}) ]
+
tcp_flags = ('F' if kwargs['tcp_fin_flag'] else '' +
'S' if kwargs['tcp_syn_flag'] else '' +
'R' if kwargs['tcp_rst_flag'] else '' +
vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'TCP.dport', add_val = add_val))
elif kwargs['l4_protocol'] == 'udp':
+ assert kwargs['l3_protocol'] in ('ipv4', 'ipv6'), 'UDP must be over ipv4/ipv6'
#fields_desc = [ ShortEnumField("sport", 53, UDP_SERVICES),
# ShortEnumField("dport", 53, UDP_SERVICES),
# ShortField("len", None),
else:
raise STLError('udp_dst_port_mode %s is not supported' % kwargs['udp_dst_port_mode'])
vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'UDP.dport', add_val = add_val))
- else:
- raise NotImplementedError("l4_protocol '%s' is not supported by TRex yet." % kwargs['l3_protocol'])
- base_pkt /= l4_layer
+ elif kwargs['l4_protocol'] is not None:
+ raise NotImplementedError("l4_protocol '%s' is not supported by TRex yet." % kwargs['l4_protocol'])
+ if l4_layer is not None:
+ base_pkt /= l4_layer
trim_dict = {'increment': 'inc', 'decrement': 'dec', 'random': 'random'}
length_mode = kwargs['length_mode']
payload_len = kwargs['l3_length_max'] + len(l2_layer) - len(base_pkt)
vm_cmds.append(CTRexVmDescTrimPktSize('pkt_len'))
- if l3_layer.name == 'IP' or l4_layer.name == 'UDP': # add here other things need to fix due to size change
- if l3_layer.name == 'IP':
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'IP.len', add_val = -len(l2_layer)))
- if l4_layer.name == 'UDP':
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'UDP.len', add_val = -len(l2_layer) - len(l3_layer)))
+ if (l3_layer and l3_layer.name == 'IP'):
+ vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'IP.len', add_val = -len(l2_layer)))
+ if (l4_layer and l4_layer.name == 'UDP'):
+ vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'UDP.len', add_val = -len(l2_layer) - len(l3_layer)))
else:
raise STLError('length_mode should be one of the following: %s' % ['auto', 'fixed'] + trim_dict.keys())
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Eth/802.1Q/802.1Q/802.1Q/802.1Q/IPv6/TCP stream without VM
+ Missing values will be filled with defaults
+ '''
+
+ def create_streams (self, direction = 0):
+
+ 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'
+ vlan_user_priority = '4 3 2', # forth will be default
+ l3_protocol = 'ipv6',
+ l4_protocol = 'tcp',
+ direction = direction)
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction = direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Two Eth/IP/UDP streams with VM to get different size of packet by frame_size
+ '''
+
+ def create_streams (self, direction = 0):
+ return [STLHltStream(length_mode = 'increment',
+ frame_size_min = 100,
+ frame_size_max = 3000,
+ l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
+ rate_bps = 1000000,
+ direction = direction,
+ ),
+ STLHltStream(length_mode = 'decrement',
+ frame_size_min = 100,
+ frame_size_max = 3000,
+ l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
+ rate_bps = 100000,
+ direction = direction,
+ )
+ ]
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
l3_imix2_size = 400, l3_imix2_ratio = 3,
l3_imix3_size = 2000, l3_imix3_ratio = 2,
l3_imix4_size = 8000, l3_imix4_ratio = 1,
+ l3_protocol = 'ipv4',
l4_protocol = 'udp', direction = direction,
)
class STLS1(object):
def create_streams (self):
- return STLHltStream(length_mode = 'imix', rate_pps = 2)
+ return STLHltStream(length_mode = 'imix', rate_pps = 2,
+ l3_protocol = 'ipv4', l4_protocol = 'tcp')
def get_streams (self, direction = 0):
return self.create_streams()
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Eth/IP/TCP stream with VM to get different ip addresses
+ '''
+
+ def create_streams (self, direction = 0):
+ return [STLHltStream(split_by_cores = 'duplicate',
+ l3_protocol = 'ipv4',
+ ip_src_addr = '192.168.1.1',
+ ip_src_mode = 'increment',
+ ip_src_count = 5,
+ ip_dst_addr = '5.5.5.5',
+ ip_dst_mode = 'random',
+ consistent_random = True,
+ rate_pps = 1),
+ ]
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Eth/IPv6/UDP stream without VM, default values
+ '''
+
+ def create_streams (self, direction = 0):
+ return [STLHltStream(l3_protocol = 'ipv6',
+ l3_length = 150,
+ l4_protocol = 'udp',
+ direction = direction,
+ ),
+ ]
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Eth/IPv6/UDP stream with VM, to change the ipv6 addr (only 32 lsb)
+ '''
+
+ def create_streams (self, direction = 0):
+ 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',
+ ipv6_src_mode = 'increment', ipv6_src_step = 5, ipv6_src_count = 10,
+ ipv6_dst_mode = 'decrement', ipv6_dst_step = '1111:1111:1111:1111:1111:0000:0000:0011', ipv6_dst_count = 150,
+ )
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Two Eth/IP/UDP streams with VM to get different size of packet by l3_length
+ '''
+
+ def create_streams (self, direction = 0):
+ return [STLHltStream(length_mode = 'increment',
+ l3_length_min = 100,
+ l3_length_max = 3000,
+ l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
+ rate_bps = 1000000,
+ direction = direction,
+ ),
+ STLHltStream(length_mode = 'decrement',
+ l3_length_min = 100,
+ l3_length_max = 3000,
+ l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
+ rate_bps = 1000000,
+ direction = direction,
+ )
+ ]
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
'''
def create_streams (self, direction = 0):
- return [STLHltStream(tcp_src_port_mode = 'decrement',
+ return [STLHltStream(l3_protocol = 'ipv4',
+ l4_protocol = 'tcp',
+ tcp_src_port_mode = 'decrement',
tcp_src_port_count = 10,
tcp_src_port = 1234,
tcp_dst_port_mode = 'increment',
max_size = 9*1024
return [STLHltStream(length_mode = 'increment',
frame_size_max = max_size,
+ l3_protocol = 'ipv4',
ip_src_addr = '16.0.0.1',
ip_dst_addr = '48.0.0.1',
l4_protocol = 'udp',
),
STLHltStream(length_mode = 'decrement',
frame_size_max = max_size,
+ l3_protocol = 'ipv4',
ip_src_addr = '16.0.0.1',
ip_dst_addr = '48.0.0.1',
l4_protocol = 'udp',
'''
def create_streams (self, direction = 0):
- return [STLHltStream(l4_protocol = 'udp',
+ return [STLHltStream(l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
udp_src_port_mode = 'decrement',
udp_src_port_count = 45,
udp_src_port_step = 20,
'''
def create_streams (self, direction = 0):
- return [STLHltStream(l4_protocol = 'udp',
+ return [STLHltStream(l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
udp_src_port_mode = 'random',
udp_dst_port_mode = 'random',
direction = direction,
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Default Eth/802.1Q/IP/TCP stream without VM
+ '''
+
+ def create_streams (self, direction = 0):
+
+ return STLHltStream(l2_encap = 'ethernet_ii_vlan',
+ l3_protocol = 'ipv4', l4_protocol = 'tcp',
+ direction = direction)
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction = direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.trex_stl_hltapi import STLHltStream
+
+
+class STLS1(object):
+ '''
+ Eth/802.1Q/802.1Q/802.1Q/802.1Q/802.1Q/IPv4/UDP stream with complex VM on vlan_id's
+ Missing values will be filled with defaults
+ '''
+
+ def create_streams (self, direction = 0):
+
+ 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
+ vlan_id_step = 2, # 1st vlan step will be 2, others - default 1
+ vlan_id_count = [4, 1, 10], # 4th independent on count, 5th will be fixed
+ l3_protocol = 'ipv4',
+ l4_protocol = 'udp',
+ direction = direction,
+ )
+
+ def get_streams (self, direction = 0):
+ return self.create_streams(direction = direction)
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+