diff options
-rw-r--r-- | scripts/automation/trex_control_plane/stl/examples/stl_imix.py | 3 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py | 27 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py | 9 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 8 | ||||
-rw-r--r-- | scripts/yaml/burst_1000_pkt.yaml | 16 | ||||
-rw-r--r-- | scripts/yaml/burst_1pkt_1burst.yaml | 5 | ||||
-rw-r--r-- | scripts/yaml/burst_1pkt_vm.yaml | 3 | ||||
-rw-r--r-- | scripts/yaml/imix_1pkt_tuple_gen.yaml | 69 | ||||
-rw-r--r-- | scripts/yaml/imix_3pkt.yaml | 12 | ||||
-rw-r--r-- | scripts/yaml/udp_rand_size.yaml | 3 | ||||
-rw-r--r-- | scripts/yaml/udp_rand_size_9k.yaml | 3 | ||||
-rw-r--r-- | src/gtest/trex_stateless_gtest.cpp | 12 |
12 files changed, 59 insertions, 111 deletions
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py index ad329e16..b9fbbbb6 100644 --- a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py +++ b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py @@ -35,7 +35,8 @@ def imix_test (): dir_1 = table['dir'][1] # load IMIX profile - streams = c.load_profile('../../../../stl/profiles/imix.py') + profile = STLProfile.load_py('../../../../stl/profiles/imix.py') + streams = profile.get_streams() # add both streams to ports c.add_streams(streams, ports = dir_0) diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py index fd3bd0d1..ed0cb93a 100644 --- a/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py +++ b/scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py @@ -59,31 +59,6 @@ def simple_burst (): print "\nTest has failed :-(\n" -# -def sheker (): - pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example') - - # create two bursts and link them - s1 = STLStream(name = 'A', - packet = pkt, - mode = STLTXSingleBurst(total_pkts = 5000), - next = 'B') - - s2 = STLStream(name = 'B', - self_start = False, - packet = pkt, - mode = STLTXSingleBurst(total_pkts = 3000)) - - profile = STLProfile([s1, s2]) - print "**** BEFORE ****\n" - print profile - profile.to_yaml('1.yaml') - loaded_profile = STLProfile.load_yaml('1.yaml') - print "**** AFTER ****\n" - print loaded_profile - exit(0) - -sheker() # run the tests -#simple_burst() +simple_burst() diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py index 1252b752..9cea3ea8 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py @@ -140,7 +140,14 @@ class STLSim(object): # handle YAMLs for input_file in input_files: - stream_list += STLClient.load_profile(input_file) + try: + profile = STLProfile.load(input_file) + except STLError as e: + print format_text("\nError while loading profile '{0}'\n".format(input_file), 'bold') + print e.brief() + "\n" + return + + stream_list += profile.get_streams() # load streams 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 8ad15a52..9c190dad 100644 --- 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 @@ -271,7 +271,7 @@ class YAMLLoader(object): # hack the VM fields for now if 'vm' in s_obj: - stream.fields['vm'] = s_obj['vm'] + stream.fields['vm'].update(s_obj['vm']) return stream @@ -281,7 +281,11 @@ class YAMLLoader(object): # read YAML and pass it down to stream object yaml_str = f.read() - objects = yaml.load(yaml_str) + try: + objects = yaml.load(yaml_str) + except yaml.parser.ParserError as e: + raise STLError(str(e)) + streams = [self.__parse_stream(object) for object in objects] return streams diff --git a/scripts/yaml/burst_1000_pkt.yaml b/scripts/yaml/burst_1000_pkt.yaml index f982fa4f..99a121e2 100644 --- a/scripts/yaml/burst_1000_pkt.yaml +++ b/scripts/yaml/burst_1000_pkt.yaml @@ -1,39 +1,33 @@ ### Single stream UDP packet, 64B ### ##################################### - name: stream0 + next: stream1 stream: self_start: True - next_stream_id: stream1 packet: - binary: cap2/udp_64B.pcap + pcap: udp_64B_no_crc.pcap mode: type: single_burst pps: 100 total_pkts : 10000 - rx_stats: [] - vm: [] - name: stream1 + next: stream2 stream: self_start: False - next_stream_id: stream2 packet: - binary: cap2/udp_64B.pcap + pcap: udp_64B_no_crc.pcap mode: type: single_burst pps: 100 total_pkts : 10000 - rx_stats: [] - vm: [] - name: stream2 stream: self_start: False packet: - binary: cap2/udp_64B.pcap + pcap: udp_64B_no_crc.pcap mode: type: single_burst pps: 100 total_pkts : 10000 - rx_stats: [] - vm: []
\ No newline at end of file diff --git a/scripts/yaml/burst_1pkt_1burst.yaml b/scripts/yaml/burst_1pkt_1burst.yaml index defa776f..76c411a8 100644 --- a/scripts/yaml/burst_1pkt_1burst.yaml +++ b/scripts/yaml/burst_1pkt_1burst.yaml @@ -4,11 +4,8 @@ stream: self_start: True packet: - binary: cap2/udp_64B.pcap + pcap: udp_64B_no_crc.pcap mode: type: single_burst pps: 100 total_pkts : 100 - rx_stats: [] - vm: [] - diff --git a/scripts/yaml/burst_1pkt_vm.yaml b/scripts/yaml/burst_1pkt_vm.yaml index e202b42d..246b8813 100644 --- a/scripts/yaml/burst_1pkt_vm.yaml +++ b/scripts/yaml/burst_1pkt_vm.yaml @@ -4,12 +4,11 @@ stream: self_start: True packet: - binary: stl/udp_64B_no_crc.pcap # pcap should not include CRC + pcap: udp_64B_no_crc.pcap # pcap should not include CRC mode: type: single_burst total_pkts: 100 pps: 100 - rx_stats: [] vm: instructions: [ diff --git a/scripts/yaml/imix_1pkt_tuple_gen.yaml b/scripts/yaml/imix_1pkt_tuple_gen.yaml index 78156e5c..5ca232c4 100644 --- a/scripts/yaml/imix_1pkt_tuple_gen.yaml +++ b/scripts/yaml/imix_1pkt_tuple_gen.yaml @@ -4,60 +4,39 @@ stream: self_start: True packet: - binary: stl/udp_64B_no_crc.pcap # pcap should not include CRC + pcap: udp_64B_no_crc.pcap # pcap should not include CRC mode: type: continuous pps: 100 - rx_stats: [] # program that define 1M flows with IP range 16.0.0.1-16.0.0.254 # we will create a script that do that for you # this is the low level instructions - vm: [ - { - "type" : "tuple_flow_var", # name of the command + vm: + instructions: + - type : "tuple_flow_var" # name of the command + name : "tuple_gen" # tuple_gen.ip tuple_gen.port can be used - "name" : "tuple_gen", # tuple_gen.ip tuple_gen.port can be used - - "ip_min" : 0x10000001, # min ip 16.0.0.1 - "ip_max" : 0x100000fe, # max ip 16.0.0.254 + ip_min : 0x10000001 # min ip 16.0.0.1 + ip_max : 0x100000fe # max ip 16.0.0.254 - "port_min" : 1025, # min port 1025 - "port_max" : 65500, # max port 65500 + port_min : 1025 # min port 1025 + port_max : 65500 # max port 65500 - "limit_flows" : 1000000, # number of flows - "flags" : 0, # 1 - for unlimited - }, - - { - "type" : "write_flow_var", # command name + limit_flows : 1000000 # number of flows + flags : 0 # 1 - for unlimited - "name" : "tuple_gen.ip", # varible to write - - "add_value" : 0, # no need to add value - - "is_big_endian" : true, # write as big edian - - "pkt_offset" : 26, # write tuple_gen.ip into ipv4.src_ip - }, + - type : "write_flow_var" # command name + name : "tuple_gen.ip" # varible to write + add_value : 0 # no need to add value + is_big_endian : true # write as big edian + pkt_offset : 26 # write tuple_gen.ip into ipv4.src_ip - { - "type" : "fix_checksum_ipv4", # fix ipv4 header checksum - - "pkt_offset" : 14, # offset of ipv4 header - - }, - - { - "type" : "write_flow_var", # command name - - "name" : "tuple_gen.port", # varible to write - - "add_value" : 0, # no need to add value - - "is_big_endian" : true, # write as big edian - - "pkt_offset" : 34, # write tuple_gen.port into udp.src_port - } - - ] + - type : "fix_checksum_ipv4" # fix ipv4 header checksum + pkt_offset : 14 # offset of ipv4 header + + - type : "write_flow_var" # command name + name : "tuple_gen.port" # varible to write + add_value : 0 # no need to add value + is_big_endian : true # write as big edian + pkt_offset : 34 # write tuple_gen.port into udp.src_port diff --git a/scripts/yaml/imix_3pkt.yaml b/scripts/yaml/imix_3pkt.yaml index bc28549d..82d91935 100644 --- a/scripts/yaml/imix_3pkt.yaml +++ b/scripts/yaml/imix_3pkt.yaml @@ -4,29 +4,23 @@ stream: self_start: True packet: - binary: stl/udp_64B_no_crc.pcap # pcap should not include CRC + pcap: udp_64B_no_crc.pcap # pcap should not include CRC mode: type: continuous pps: 28 - rx_stats: [] - vm: [] - name: udp_594B stream: self_start: True packet: - binary: stl/udp_594B_no_crc.pcap # pcap should not include CRC + pcap: udp_594B_no_crc.pcap # pcap should not include CRC mode: type: continuous pps: 20 - rx_stats: [] - vm: [] - name: udp_1518B stream: self_start: True packet: - binary: stl/udp_1518B_no_crc.pcap # pcap should not include CRC + pcap: udp_1518B_no_crc.pcap # pcap should not include CRC mode: type: continuous pps: 4 - rx_stats: [] - vm: []
\ No newline at end of file diff --git a/scripts/yaml/udp_rand_size.yaml b/scripts/yaml/udp_rand_size.yaml index 2bbad4a0..ab1d21b9 100644 --- a/scripts/yaml/udp_rand_size.yaml +++ b/scripts/yaml/udp_rand_size.yaml @@ -4,11 +4,10 @@ stream: self_start: True packet: - binary: stl/udp_1518B_no_crc.pcap + pcap: udp_1518B_no_crc.pcap mode: type: continuous pps: 100 - rx_stats: [] # random packet size 60-1500 update ip.len/checksum/udp.len vm: diff --git a/scripts/yaml/udp_rand_size_9k.yaml b/scripts/yaml/udp_rand_size_9k.yaml index ecdd7ae0..0d7d1ec7 100644 --- a/scripts/yaml/udp_rand_size_9k.yaml +++ b/scripts/yaml/udp_rand_size_9k.yaml @@ -4,11 +4,10 @@ stream: self_start: True packet: - binary: stl/ipv4_udp_9k.pcap # should not include CRC 9K ip+14 = 9230 +FCS(by NIC)=9234 + pcap: ipv4_udp_9k.pcap # should not include CRC 9K ip+14 = 9230 +FCS(by NIC)=9234 mode: type: continuous pps: 100 - rx_stats: [] # random packet size 60-max packet size update ip.len/checksum/udp.len vm: diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index f01346b0..90f0606d 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -994,7 +994,7 @@ TEST_F(basic_vm, vm_syn_attack) { vm.Dump(stdout); CPcapLoader pcap; - pcap.load_pcap_file("stl/syn_packet.pcap",0); + pcap.load_pcap_file("yaml/syn_packet.pcap",0); @@ -1120,7 +1120,7 @@ TEST_F(basic_vm, vm_inc_size_64_128) { vm.add_instruction( new StreamVmInstructionWriteToPkt( "rand_pkt_size_var",32+6, -(14+20),true) ); - run_vm_program(vm,"stl/udp_1518B_no_crc.pcap","stl_vm_inc_size_64_128",20); + run_vm_program(vm,"yaml/udp_1518B_no_crc.pcap","stl_vm_inc_size_64_128",20); } TEST_F(basic_vm, vm_random_size_64_128) { @@ -1150,7 +1150,7 @@ TEST_F(basic_vm, vm_random_size_64_128) { ); - run_vm_program(vm,"stl/udp_1518B_no_crc.pcap","stl_vm_rand_size_64_128",20); + run_vm_program(vm,"yaml/udp_1518B_no_crc.pcap","stl_vm_rand_size_64_128",20); } @@ -1186,7 +1186,7 @@ TEST_F(basic_vm, vm_random_size_64_127_128) { bool fail=false; try { - run_vm_program(vm,"stl/udp_64B_no_crc.pcap","stl_vm_rand_size_64B_127_128",20); + run_vm_program(vm,"yaml/udp_64B_no_crc.pcap","stl_vm_rand_size_64B_127_128",20); } catch (const TrexException &ex) { fail=true; } @@ -1222,7 +1222,7 @@ TEST_F(basic_vm, vm_random_size_500b_0_9k) { vm.add_instruction( new StreamVmInstructionWriteToPkt( "rand_pkt_size_var",32+6, -(14+20),true) ); - run_vm_program(vm,"stl/udp_594B_no_crc.pcap","stl_vm_rand_size_512B_64_128",10); + run_vm_program(vm,"yaml/udp_594B_no_crc.pcap","stl_vm_rand_size_512B_64_128",10); } @@ -2404,7 +2404,7 @@ TEST_F(basic_stl, vm_enable1) { CEnableVm vm_test; vm_test.m_out_file = "exp/stl_vm_enable1"; - vm_test.m_input_packet = "stl/udp_594B_no_crc.pcap"; + vm_test.m_input_packet = "yaml/udp_594B_no_crc.pcap"; vm_test.run(false); } |