aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dpdk/perf/10ge2p1x710-eth-l2xcbase-testpmd-mrr.robot
blob: fa5144ee780e5dae40bc5cf0ef22c133b8114cee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright (c) 2018 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

*** Settings ***
| Resource | resources/libraries/robot/performance/performance_setup.robot
| Resource | resources/libraries/robot/dpdk/default.robot
| Library | resources.libraries.python.topology.Topology
| Library | resources.libraries.python.NodePath
| Library | resources.libraries.python.InterfaceUtil
| Library | resources.libraries.python.DPDK.DPDKTools
| ...
| Force Tags | 3_NODE_SINGLE_LINK_TOPO | HW_ENV | PERFTEST | MRR | 1NUMA
| ... | NIC_Intel-X710 | DPDK | ETH | L2XCFWD | BASE
| ...
| Suite Setup | Set up DPDK 3-node performance topology with DUT's NIC model
| ... | L2 | Intel-X710
| Suite Teardown | Tear down DPDK 3-node performance topology
| ...
| Test Template | Local Template
| ...
| Documentation | *Raw results L2 routing test cases*
| ... | *[Top] Network Topologies:* TG-DUT1-DUT2-TG 3-node circular topology\
| ... | with single links between nodes.
| ... | *[Enc] Packet Encapsulations:* Eth-IPv4 for L2 frame forwarding.
| ... | *[Cfg] DUT configuration:* DUT1 and DUT2 run the DPDK testpmd\
| ... | application and use the io forwarding mode. DUT1 and DUT2 tested with\
| ... | 2p10GE NIC X710 by Intel.
| ... | *[Ver] TG verification:* In MaxReceivedRate test TG sends traffic\
| ... | at line rate and reports total received/sent packets over trial period.\
| ... | Test packets are generated by TG on\
| ... | links to DUTs. TG traffic profile contains two L3 flow-groups\
| ... | (flow-group per direction, 254 flows per flow-group) with all packets\
| ... | containing Ethernet header, IPv4 header with IP protocol=61 and static\
| ... | payload. MAC addresses are matching MAC addresses of the TG node\
| ... | interfaces.

*** Variables ***
# X710 bandwidth limit
| ${s_limit}= | ${10000000000}
# Traffic profile:
| ${traffic_profile}= | trex-sl-3n-ethip4-ip4src254

*** Keywords ***
| Local Template
| | [Documentation]
| | ... | [Cfg] DUT runs L2 frame forwarding config.\
| | ... | Each DUT uses ${phy_cores} physical core(s) for worker threads.
| | ... | [Ver] Measure MaxReceivedRate for ${framesize} frames using single\
| | ... | trial throughput test.
| | ...
| | [Arguments] | ${framesize} | ${phy_cores} | ${rxq}=${None}
| | ...
| | ${max_rate} | ${jumbo} = | Get Max Rate And Jumbo
| | ... | ${s_limit} | ${framesize}
| | Given Start L2FWD on all DUTs | ${phy_cores} | ${rxq} | ${jumbo}
| | Then Traffic should pass with maximum rate
| | ... | ${max_rate}pps | ${framesize} | ${traffic_profile}

*** Test Cases ***
| tc01-64B-1c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 64B | 1C
| | framesize=${64} | phy_cores=${1}

| tc02-64B-2c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 64B | 2C
| | framesize=${64} | phy_cores=${2}

| tc03-64B-4c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 64B | 4C
| | framesize=${64} | phy_cores=${4}

| tc04-1518B-1c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 1518B | 1C
| | framesize=${1518} | phy_cores=${1}

| tc05-1518B-2c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 1518B | 2C
| | framesize=${1518} | phy_cores=${2}

| tc06-1518B-4c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 1518B | 4C
| | framesize=${1518} | phy_cores=${4}

| tc07-9000B-1c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 9000B | 1C
| | framesize=${9000} | phy_cores=${1}

| tc08-9000B-2c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 9000B | 2C
| | framesize=${9000} | phy_cores=${2}

| tc09-9000B-4c-eth-l2xcbase-testpmd-mrr
| | [Tags] | 9000B | 4C
| | framesize=${9000} | phy_cores=${4}

| tc10-IMIX-1c-eth-l2xcbase-testpmd-mrr
| | [Tags] | IMIX | 1C
| | framesize=IMIX_v4_1 | phy_cores=${1}

| tc11-IMIX-2c-eth-l2xcbase-testpmd-mrr
| | [Tags] | IMIX | 2C
| | framesize=IMIX_v4_1 | phy_cores=${2}

| tc12-IMIX-4c-eth-l2xcbase-testpmd-mrr
| | [Tags] | IMIX | 4C
| | framesize=IMIX_v4_1 | phy_cores=${4}
with self.assertRaises(Exception): STLHltStream(mac_src2 = '00:00:00:00:00:0k') with self.assertRaises(Exception): STLHltStream(mac_dst2 = '100:00:00:00:00:00') # wrong encap with self.assertRaises(Exception): STLHltStream(l2_encap = 'ethernet_sdfgsdfg') # all default values test_stream = STLHltStream() self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGusUAAAAAwAAAAQQAAFAAAAABAAAAAVAAD+U1/QAAISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: [] split_by_var: '' ''' # Eth/IP/TCP, test MAC fields VM, wait for masking of variables for MAC @nottest def test_macs_vm(self): test_stream = STLHltStream(name = 'stream-0', ) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' TBD ''' # Eth/IP/TCP, ip src and dest is changed by VM def test_ip_ranges(self): # running on single core not implemented yet with self.assertRaises(Exception): test_stream = STLHltStream(split_by_cores = 'single', ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5,) # wrong type with self.assertRaises(Exception): test_stream = STLHltStream(split_by_cores = 12345, ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5,) test_stream = STLHltStream(split_by_cores = 'duplicate', ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5, ip_dst_addr = '5.5.5.5', ip_dst_count = 2, ip_dst_mode = 'random', name = 'test_ip_ranges', rate_pps = 1) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_ip_ranges stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: pps: 1.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGrxPAqAEBBQUFBQQAAFAAAAABAAAAAVAAD+UqSwAAISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 0 max_value: 4 min_value: 0 name: inc_4_4_1 op: inc size: 4 step: 1 type: flow_var - add_value: 3232235777 is_big_endian: true name: inc_4_4_1 pkt_offset: 26 type: write_flow_var - init_value: 0 max_value: 4294967295 min_value: 0 name: ip_dst_random op: random size: 4 step: 1 type: flow_var - add_value: 0 is_big_endian: true name: ip_dst_random pkt_offset: 30 type: write_flow_var - pkt_offset: 14 type: fix_checksum_ipv4 split_by_var: '' ''' # Eth / IP / TCP, tcp ports are changed by VM def test_tcp_ranges(self): test_stream = STLHltStream(tcp_src_port_mode = 'decrement', tcp_src_port_count = 10, tcp_dst_port_mode = 'random', tcp_dst_port_count = 10, tcp_dst_port = 1234, name = 'test_tcp_ranges', rate_pps = '2') self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_tcp_ranges stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: pps: 2.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGusUAAAAAwAAAAQQABNIAAAABAAAAAVAAD+UxewAAISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 9 max_value: 9 min_value: 0 name: dec_2_9_1 op: dec size: 2 step: 1 type: flow_var - add_value: 1015 is_big_endian: true name: dec_2_9_1 pkt_offset: 34 type: write_flow_var - init_value: 0 max_value: 65535 min_value: 0 name: tcp_dst_random op: random size: 2 step: 1 type: flow_var - add_value: 0 is_big_endian: true name: tcp_dst_random pkt_offset: 36 type: write_flow_var - pkt_offset: 14 type: fix_checksum_ipv4 split_by_var: dec_2_9_1 ''' # Eth / IP / UDP, udp ports are changed by VM def test_udp_ranges(self): # UDP is not set, expecting ignore of wrong UDP arguments STLHltStream(udp_src_port_mode = 'qwerqwer', udp_src_port_count = 'weqwer', udp_src_port = 'qwerqwer', udp_dst_port_mode = 'qwerqwe', udp_dst_port_count = 'sfgsdfg', udp_dst_port = 'sdfgsdfg') # UDP is set, expecting fail due to wrong UDP arguments with self.assertRaises(Exception): STLHltStream(l4_protocol = 'udp', udp_src_port_mode = 'qwerqwer', udp_src_port_count = 'weqwer', udp_src_port = 'qwerqwer', udp_dst_port_mode = 'qwerqwe', udp_dst_port_count = 'sfgsdfg', udp_dst_port = 'sdfgsdfg') # generate it already with correct arguments test_stream = STLHltStream(l4_protocol = 'udp', udp_src_port_mode = 'decrement', udp_src_port_count = 10, udp_src_port = 1234, udp_dst_port_mode = 'increment', udp_dst_port_count = 10, udp_dst_port = 1234, name = 'test_udp_ranges', rate_percent = 20,) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_udp_ranges stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 20.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEARuroAAAAAwAAAAQTSBNIAHsmgISEhISEhISEhISEhISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 9 max_value: 9 min_value: 0 name: dec_2_9_1 op: dec size: 2 step: 1 type: flow_var - add_value: 1225 is_big_endian: true name: dec_2_9_1 pkt_offset: 34 type: write_flow_var - init_value: 0 max_value: 9 min_value: 0 name: inc_2_9_1 op: inc size: 2 step: 1 type: flow_var - add_value: 1234 is_big_endian: true name: inc_2_9_1 pkt_offset: 36 type: write_flow_var - pkt_offset: 14 type: fix_checksum_ipv4 split_by_var: dec_2_9_1 ''' # Eth/IP/TCP, packet length is changed in VM by frame_size def test_pkt_len_by_framesize(self): # just check errors, no compare to golden STLHltStream(length_mode = 'increment', frame_size_min = 100, frame_size_max = 3000) test_stream = STLHltStream(length_mode = 'decrement', frame_size_min = 100, frame_size_max = 3000, name = 'test_pkt_len_by_framesize', rate_bps = 1000) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_pkt_len_by_framesize stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: bps_L2: 1000.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAuqAAAAAEAGr00AAAAAwAAAAQQAAFAAAAABAAAAAVAAD+UwiwAAISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEh meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 3000 max_value: 3000 min_value: 100 name: pkt_len op: dec size: 2 step: 1 type: flow_var - name: pkt_len type: trim_pkt_size - add_value: -14 is_big_endian: true name: pkt_len pkt_offset: 16 type: write_flow_var - pkt_offset: 14 type: fix_checksum_ipv4 split_by_var: pkt_len ''' # Eth/IP/UDP, packet length is changed in VM by l3_length def test_pkt_len_by_l3length(self): test_stream = STLHltStream(l4_protocol = 'udp', length_mode = 'random', l3_length_min = 100, l3_length_max = 400, name = 'test_pkt_len_by_l3length') self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_pkt_len_by_l3length stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABCABFAAGQAAAAAEARuVwAAAAAwAAAAQQAAFABfCaTISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEh meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 114 max_value: 414 min_value: 114 name: pkt_len op: random size: 2 step: 1 type: flow_var - name: pkt_len type: trim_pkt_size - add_value: -14 is_big_endian: true name: pkt_len pkt_offset: 16 type: write_flow_var - add_value: -34 is_big_endian: true name: pkt_len pkt_offset: 38 type: write_flow_var - pkt_offset: 14 type: fix_checksum_ipv4 split_by_var: '' ''' # Eth/IP/TCP, with vlan, no VM def test_vlan_basic(self): with self.assertRaises(Exception): STLHltStream(l2_encap = 'ethernet_ii', vlan_id = 'sdfgsdgf') test_stream = STLHltStream(l2_encap = 'ethernet_ii') assert ':802.1Q:' not in test_stream.get_pkt_type(), 'Default packet should not include dot1q' test_stream = STLHltStream(name = 'test_vlan_basic', l2_encap = 'ethernet_ii_vlan') assert ':802.1Q:' in test_stream.get_pkt_type(), 'No dot1q in packet with encap ethernet_ii_vlan' self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_vlan_basic stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABgQAwAAgARQAALgAAAABABrrJAAAAAMAAAAEEAABQAAAAAQAAAAFQAA/leEMAACEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: [] split_by_var: '' ''' # Eth/IP/TCP, with 4 vlan def test_vlan_multiple(self): # default frame size should be not enough with self.assertRaises(Exception): STLHltStream(vlan_id = [1, 2, 3, 4]) test_stream = STLHltStream(name = 'test_vlan_multiple', frame_size = 100, vlan_id = [1, 2, 3, 4], # can be either array or string separated by spaces vlan_protocol_tag_id = '8100 0x8100') pkt_layers = test_stream.get_pkt_type() assert '802.1Q:' * 4 in pkt_layers, 'No four dot1q layers in packet: %s' % pkt_layers self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_vlan_multiple stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABgQAwAYEAMAKBADADgQAwBAgARQAARgAAAABABrqxAAAAAMAAAAEEAABQAAAAAQAAAAFQAA/l6p0AACEhISEhISEhISEhISEhISEhISEhISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: [] split_by_var: '' ''' # Eth/IP/TCP, with 5 vlans and VMs on vlan_id def test_vlan_vm(self): test_stream = STLHltStream(name = 'test_vlan_vm', 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 ) pkt_layers = test_stream.get_pkt_type() self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) assert '802.1Q:' * 5 in pkt_layers, 'No five dot1q layers in packet: %s' % pkt_layers self.golden_yaml = ''' - name: test_vlan_vm stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABgQAwAYEAMAKBADPogQAwBIEAMAUIAEUAAEIAAAAAQAa6tQAAAADAAAABBAAAUAAAAAEAAAABUAAP5SzkAAAhISEhISEhISEhISEhISEhISEhISEhISEhIQ== meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 0 max_value: 6 min_value: 0 name: dec_2_3_2 op: inc size: 2 step: 2 type: flow_var - add_value: 1 is_big_endian: true mask: 4095 name: dec_2_3_2 pkt_cast_size: 2 pkt_offset: 14 shift: 0 type: write_mask_flow_var - init_value: 9 max_value: 9 min_value: 0 name: dec_2_9_1 op: dec size: 2 step: 1 type: flow_var - add_value: 991 is_big_endian: true mask: 4095 name: dec_2_9_1 pkt_cast_size: 2 pkt_offset: 22 shift: 0 type: write_mask_flow_var - init_value: 0 max_value: 65535 min_value: 0 name: vlan_id_random op: random size: 2 step: 1 type: flow_var - add_value: 0 is_big_endian: true mask: 4095 name: vlan_id_random pkt_cast_size: 2 pkt_offset: 26 shift: 0 type: write_mask_flow_var split_by_var: dec_2_9_1 ''' # Eth/IPv6/TCP, no VM def test_ipv6_basic(self): # default frame size should be not enough with self.assertRaises(Exception): STLHltStream(l3_protocol = 'ipv6') # error should not affect STLHltStream(ipv6_src_addr = 'asdfasdfasgasdf') # error should affect with self.assertRaises(Exception): STLHltStream(l3_protocol = 'ipv6', ipv6_src_addr = 'asdfasdfasgasdf') test_stream = STLHltStream(name = 'test_ipv6_basic', l3_protocol = 'ipv6', length_mode = 'fixed', l3_length = 150, ) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_ipv6_basic stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABht1gAAAAAG4GQP6AAAAAAAAAAAAAAAAAABL+gAAAAAAAAAAAAAAAAAAiBAAAUAAAAAEAAAABUAAP5ctLAAAhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISE= meta: '' flow_stats: enabled: false self_start: true vm: instructions: [] split_by_var: '' ''' # Eth/IPv6/UDP, VM on ipv6 fields def test_ipv6_src_dst_ranges(self): test_stream = STLHltStream(name = 'test_ipv6_src_dst_ranges', 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:1111:0000:0011', ipv6_dst_count = 150, ) self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = ''' - name: test_ipv6_src_dst_ranges stream: action_count: 0 enabled: true flags: 3 isg: 0.0 mode: percentage: 10.0 type: continuous packet: binary: AAAAAAAAAAABAAABht1gAAAAAG4RQBERIiIzM0REVVVmZnd3iIgRERERERERERERERERERERBAAAUABucjohISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISE= meta: '' flow_stats: enabled: false self_start: true vm: instructions: - init_value: 0 max_value: 45 min_value: 0 name: inc_4_9_5 op: inc size: 4 step: 5 type: flow_var - add_value: 2004322440 is_big_endian: true name: inc_4_9_5 pkt_offset: 34 type: write_flow_var - init_value: 2533 max_value: 2533 min_value: 0 name: dec_4_149_17 op: dec size: 4 step: 17 type: flow_var - add_value: 286328620 is_big_endian: true name: dec_4_149_17 pkt_offset: 50 type: write_flow_var split_by_var: dec_4_149_17 ''' def yaml_save_location(self): #return os.devnull # debug/deveopment, comment line above return '/tmp/%s.yaml' % self._testMethodName