CSIT-683: Re-organize L2 libraries - func
[csit.git] / resources / libraries / robot / l2_traffic.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.topology.Topology
16 | Library | resources.libraries.python.TrafficScriptExecutor
17 | Documentation | Keywords to send and receive different types of traffic \
18 | ... | through L2 network.
19
20 *** Keywords ***
21 | Send ICMP packet and verify received packet
22 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to \
23 | | ... | destination interface. Packet can be set with Dot1q or
24 | | ... | Dot1ad tag(s) when required.
25 | | ...
26 | | ... | *Arguments:*
27 | | ...
28 | | ... | - tg_node - TG node. Type: dictionary
29 | | ... | - src_int - Source interface. Type: string
30 | | ... | - dst_int - Destination interface. Type: string
31 | | ... | - src_ip - Source IP address (Optional). Type: string
32 | | ... | - dst_ip - Destination IP address (Optional). Type: string
33 | | ... | - encaps - Encapsulation: Dot1q or Dot1ad (Optional). Type: string
34 | | ... | - vlan1 - VLAN (outer) tag (Optional). Type: integer
35 | | ... | - vlan2 - VLAN inner tag (Optional). Type: integer
36 | | ... | - encaps_rx - Expected encapsulation on RX side: Dot1q or Dot1ad
37 | | ... | (Optional). Type: string
38 | | ... | - vlan1_rx - VLAN (outer) tag on RX side (Optional). Type: integer
39 | | ... | - vlan2_rx - VLAN inner tag on RX side (Optional). Type: integer
40 | | ...
41 | | ... | *Return:*
42 | | ...
43 | | ... | - No value returned
44 | | ...
45 | | ... | *Example:*
46 | | ...
47 | | ... | _NOTE:_ Default IP is IPv4
48 | | ...
49 | | ... | \| Send ICMP packet and verify received packet \| ${nodes['TG']} \
50 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
51 | | ... | \| Send ICMP packet and verify received packet \| ${nodes['TG']} \
52 | | ... | \| ${tg_to_dut1} \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=100 \|
53 | | ... | \| Send ICMP packet and verify received packet \| ${nodes['TG']} \
54 | | ... | \| ${tg_to_dut1} \| ${tg_to_dut2} \| encaps=Dot1ad \| vlan1=110 \
55 | | ... | \| vlan2=220 \|
56 | | ... | \| Send ICMP packet and verify received packet \| ${nodes['TG']} \
57 | | ... | \| ${tg_to_dut1} \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \
58 | | ... | \| encaps_rx=Dot1q \|
59 | | ... | \| Send ICMP packet and verify received packet \| ${nodes['TG']} \
60 | | ... | \| ${tg_to_dut1} \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \
61 | | ... | \| encaps_rx=Dot1q \| vlan1_rx=120 \|
62 | | ...
63 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int}
64 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2 | ${encaps}=${EMPTY}
65 | | ... | ${vlan1}=${EMPTY} | ${vlan2}=${EMPTY} | ${encaps_rx}=${EMPTY}
66 | | ... | ${vlan1_rx}=${EMPTY} | ${vlan2_rx}=${EMPTY}
67 | | ...
68 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
69 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
70 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
71 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
72 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
73 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
74 | | ${args}= | Run Keyword If | '${encaps}' == '${EMPTY}'
75 | | | ... | Set Variable | ${args}
76 | | ... | ELSE | Catenate | ${args} | --encaps ${encaps} | --vlan1 ${vlan1}
77 | | ${args}= | Run Keyword If | '${vlan2}' == '${EMPTY}'
78 | | | ... | Set Variable | ${args}
79 | | ... | ELSE | Catenate | ${args} | --vlan2 ${vlan2}
80 | | ${args}= | Run Keyword If | '${encaps_rx}' == '${EMPTY}'
81 | | | ... | Set Variable | ${args}
82 | | ... | ELSE | Catenate | ${args} | --encaps_rx ${encaps_rx}
83 | | ${args}= | Run Keyword If | '${vlan1_rx}' == '${EMPTY}'
84 | | | ... | Set Variable | ${args}
85 | | ... | ELSE | Catenate | ${args} | --vlan1_rx ${vlan1_rx}
86 | | ${args}= | Run Keyword If | '${vlan2_rx}' == '${EMPTY}'
87 | | | ... | Set Variable | ${args}
88 | | ... | ELSE | Catenate | ${args} | --vlan2_rx ${vlan2_rx}
89 | | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
90
91 | ICMP packet transmission should fail
92 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to
93 | | ... | destination interface and expect failure with
94 | | ... | ICMP echo Rx timeout error message.
95 | | ...
96 | | ... | *Arguments:*
97 | | ...
98 | | ... | - tg_node - TG node. Type: dictionary
99 | | ... | - src_int - Source interface. Type: string
100 | | ... | - dst_int - Destination interface. Type: string
101 | | ... | - src_ip - Source IP address (Optional). Type: string
102 | | ... | - dst_ip - Destination IP address (Optional). Type: string
103 | | ...
104 | | ... | *Return:*
105 | | ...
106 | | ... | - No value returned
107 | | ...
108 | | ... | *Example:*
109 | | ...
110 | | ... | _NOTE:_ Default IP is IPv4
111 | | ...
112 | | ... | \| ICMP packet transmission should fail\| ${nodes['TG']} \
113 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
114 | | ...
115 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int} |
116 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2
117 | | ...
118 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
119 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
120 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
121 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
122 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
123 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
124 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
125 | | ... | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
126
127 | Send ICMPv4 bidirectionally and verify received packets
128 | | [Documentation] | Send ICMPv4 echo request from both directions,
129 | | ... | from interface1 to interface2 and from interface2 to interface1.
130 | | ...
131 | | ... | *Arguments:*
132 | | ...
133 | | ... | - tg_node - TG node. Type: dictionary
134 | | ... | - src_int - Source interface. Type: string
135 | | ... | - dst_int - Destination interface. Type: string
136 | | ... | - src_ip - Source IP address (Optional). Type: string
137 | | ... | - dst_ip - Destination IP address (Optional). Type: string
138 | | ...
139 | | ... | *Return:*
140 | | ...
141 | | ... | - No value returned
142 | | ...
143 | | ... | *Example:*
144 | | ...
145 | | ... | \| Send ICMPv4 bidirectionally and verify received packets \
146 | | ... | \| ${nodes['TG']} \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
147 | | ...
148 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=192.168.100.1 |
149 | | ... | ${dst_ip}=192.168.100.2
150 | | ...
151 | | Send ICMP packet and verify received packet
152 | | ... | ${tg_node} | ${int1} | ${int2} | ${src_ip} | ${dst_ip}
153 | | Send ICMP packet and verify received packet
154 | | ... | ${tg_node} | ${int2} | ${int1} | ${dst_ip} | ${src_ip}
155
156 | Send ICMPv6 bidirectionally and verify received packets
157 | | [Documentation] | Send ICMPv6 echo request from both directions,
158 | | ... | from interface1 to interface2 and from interface2 to interface1.
159 | | ...
160 | | ... | *Arguments:*
161 | | ...
162 | | ... | - tg_node - TG node. Type: dictionary
163 | | ... | - src_int - Source interface. Type: string
164 | | ... | - dst_int - Destination interface. Type: string
165 | | ... | - src_ip - Source IP address (Optional). Type: string
166 | | ... | - dst_ip - Destination IP address (Optional). Type: string
167 | | ...
168 | | ... | *Return:*
169 | | ...
170 | | ... | - No value returned
171 | | ...
172 | | ... | *Example:*
173 | | ...
174 | | ... | \| Send ICMPv6 bidirectionally and verify received packets \
175 | | ... | \| ${nodes['TG']} \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
176 | | ...
177 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=3ffe:63::1 |
178 | | ... | ${dst_ip}=3ffe:63::2
179 | | ...
180 | | Send ICMP packet and verify received packet
181 | | ... | ${tg_node} | ${int1} | ${int2} | ${src_ip} | ${dst_ip}
182 | | Send ICMP packet and verify received packet
183 | | ... | ${tg_node} | ${int2} | ${int1} | ${dst_ip} | ${src_ip}