Fix VPP sends ARP requests for unknown destinations TC destination MAC address
[csit.git] / resources / libraries / robot / 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 """Traffic keywords"""
15
16 *** Settings ***
17 | Library | resources.libraries.python.IPv6Util
18 | Library | resources.libraries.python.IPv6Setup
19 | Library | resources.libraries.python.TrafficScriptExecutor
20 | Library | resources.libraries.python.NodePath
21 | Library | resources.libraries.python.Routing
22 | Library | resources.libraries.python.InterfaceUtil
23 | Library | resources.libraries.python.topology.Topology
24 | Resource | resources/libraries/robot/default.robot
25 | Resource | resources/libraries/robot/counters.robot
26 | Documentation | Traffic keywords
27
28 *** Keywords ***
29 | Send Packet And Check Headers
30 | | [Documentation] | Sends packet from IP (with source mac) to IP
31 | | ...             | (with dest mac). There has to be 4 MAC addresses
32 | | ...             | when using 2 node +
33 | | ...             | xconnect (one for each eth).
34 | | ...
35 | | ... | *Arguments:*
36 | | ...
37 | | ... | _NOTE:_ Arguments are based on topology:
38 | | ...             | TG(if1)->(if1)DUT(if2)->TG(if2)
39 | | ...
40 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
41 | | ... | - src_ip - IP of source interface (TG-if1). Type: int
42 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: int
43 | | ... | - tx_src_port - Interface of TG-if1. Type: string
44 | | ... | - tx_src_mac - MAC address of TG-if1. Type: string
45 | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string
46 | | ... | - rx_port - Interface of TG-if1. Type: string
47 | | ... | - rx_src_mac - MAC address of DUT1-if2. Type: string
48 | | ... | - rx_dst_mac - MAC address of TG-if2. Type: string
49 | | ...
50 | | ... | *Return:*
51 | | ... | - No value returned
52 | | ...
53 | | ... | *Example:*
54 | | ...
55 | | ... | \| Send Packet And Check Headers \| ${nodes['TG']} \| 10.0.0.1 \
56 | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \
57 | | ... | \| eth3 \| 08:00:27:4d:ca:7a \| 08:00:27:7d:fd:10 \|
58 | | ...
59 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} |
60 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac}
61 | | ... | ${rx_dst_mac}
62 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
63 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
64 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
65 | | ... | --tx_if | ${tx_src_port} | --rx_if | ${rx_port}
66 | | Run Traffic Script On Node | send_icmp_check_headers.py | ${tg_node} |
67 | | ... | ${args}
68
69 | Send packet from Port to Port should failed
70 | | [Documentation] | Sends packet from ip (with specified mac) to ip
71 | | ...             | (with dest mac). Using keyword : Send packet And Check
72 | | ...             | Headers and subsequently checks the return value
73 | | ...
74 | | ... | *Arguments:*
75 | | ...
76 | | ... | _NOTE:_ Arguments are based on topology:
77 | | ...             | TG(if1)->(if1)DUT(if2)->TG(if2)
78 | | ...
79 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
80 | | ... | - src_ip - IP of source interface (TG-if1). Type: int
81 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: int
82 | | ... | - tx_src_port - Interface of TG-if1. Type: string
83 | | ... | - tx_src_mac - MAC address of TG-if1. Type: string
84 | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string
85 | | ... | - rx_port - Interface of TG-if1. Type: string
86 | | ... | - rx_src_mac - MAC address of DUT1-if2. Type: string
87 | | ... | - rx_dst_mac - MAC address of TG-if2. Type: string
88 | | ...
89 | | ... | *Return:*
90 | | ... | - No value returned
91 | | ...
92 | | ... | *Example:*
93 | | ...
94 | | ... | \| Send packet from Port to Port should failed \| ${nodes['TG']} \
95 | | ... | \| 10.0.0.1 \ \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \
96 | | ... | \| 08:00:27:a2:52:5b \| eth3 \| 08:00:27:4d:ca:7a \
97 | | ... | \| 08:00:27:7d:fd:10 \|
98 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} |
99 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} |
100 | | ... | ${rx_dst_mac}
101 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
102 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
103 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
104 | | ... | --tx_if | ${tx_src_port} | --rx_if | ${rx_port}
105 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
106 | | ... | Run Traffic Script On Node | send_icmp_check_headers.py
107 | | ... | ${tg_node} | ${args}
108
109 | Send Packet And Check ARP Request
110 | | [Documentation] | Send IP packet from tx_port and check if ARP Request\
111 | | ...             | packet is received on rx_port.
112 | | ...
113 | | ... | *Arguments:*
114 | | ...
115 | | ... | _NOTE:_ Arguments are based on topology:
116 | | ...             | TG(if1)->(if1)DUT(if2)->TG(if2)
117 | | ...
118 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
119 | | ... | - tx_src_ip - Source IP address of transferred packet (TG-if1).
120 | | ... |               Type: string
121 | | ... | - tx_dst_ip - Destination IP address of transferred packet (TG-if2).
122 | | ... |               Type: string
123 | | ... | - tx_port - Interface from which the IP packet is sent (TG-if1).
124 | | ... |             Type: string
125 | | ... | - tx_dst_mac - Destination MAC address of IP packet (DUT-if1).
126 | | ... |                Type: string
127 | | ... | - rx_port - Interface where the IP packet is received (TG-if2).
128 | | ... |             Type: string
129 | | ... | - rx_src_mac - Source MAC address of ARP packet (DUT-if2).
130 | | ... |                Type: string
131 | | ... | - rx_arp_src_ip - Source IP address of ARP packet (DUT-if2).
132 | | ... |                   Type: string
133 | | ... | - rx_arp_dst_ip - Destination IP address of ARP packet. Type: string
134 | | ...
135 | | ... | *Return:*
136 | | ... | - No value returned
137 | | ...
138 | | ... | *Example:*
139 | | ...
140 | | ... | \| Send Packet And Check ARP Packet \| ${nodes['TG']} \| 16.0.0.1 \
141 | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
142 | | ... | \| eth4 \| 08:00:27:5b:49:dd \| 192.168.2.1 \| 192.168.2.2 \|
143 | | ...
144 | | [Arguments] | ${tg_node} | ${tx_src_ip} | ${tx_dst_ip} | ${tx_port}
145 | | ... | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} | ${rx_arp_src_ip}
146 | | ... | ${rx_arp_dst_ip}
147 | | ${args}= | Catenate
148 | | ... | --tx_dst_mac | ${tx_dst_mac} | --rx_src_mac | ${rx_src_mac}
149 | | ... | --tx_src_ip | ${tx_src_ip} | --tx_dst_ip | ${tx_dst_ip}
150 | | ... | --tx_if | ${tx_port} | --rx_if | ${rx_port}
151 | | ... | --rx_arp_src_ip ${rx_arp_src_ip} | --rx_arp_dst_ip ${rx_arp_dst_ip}
152 | | Run Traffic Script On Node | send_icmp_check_arp.py | ${tg_node} | ${args}
153
154 | Send TCP or UDP packet
155 | | [Documentation] | Sends TCP or UDP packet with specified source
156 | | ...             | and destination port.
157 | | ...
158 | | ... | *Arguments:*
159 | | ...
160 | | ... | _NOTE:_ Arguments are based on topology:
161 | | ...             | TG(if1)->(if1)DUT(if2)->TG(if2)
162 | | ...
163 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
164 | | ... | - src_ip - IP of source interface (TG-if1). Type: integer
165 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: integer
166 | | ... | - tx_port - Source interface (TG-if1). Type: string
167 | | ... | - tx_mac - MAC address of source interface (TG-if1). Type: string
168 | | ... | - rx_port - Destionation interface (TG-if1). Type: string
169 | | ... | - rx_mac - MAC address of destination interface (TG-if1). Type: string
170 | | ... | - protocol - Type of protocol. Type: string
171 | | ... | - source_port - Source TCP/UDP port. Type: string or integer
172 | | ... | - destination_port - Destination TCP/UDP port. Type: string or integer
173 | | ...
174 | | ... | *Return:*
175 | | ... | - No value returned
176 | | ...
177 | | ... | *Example:*
178 | | ...
179 | | ... | \| Send TCP or UDP packet \| ${nodes['TG']} \
180 | | ... | \| 16.0.0.1 \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
181 | | ... | \| eth4 \| 08:00:27:c9:6a:d5 \| TCP \| 20 \| 80 \|
182 | | ...
183 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
184 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
185 | | ... | ${destination_port}
186 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
187 | | ...                 | --rx_mac | ${rx_mac}
188 | | ...                 | --src_ip | ${src_ip}
189 | | ...                 | --dst_ip | ${dst_ip}
190 | | ...                 | --tx_if | ${tx_port}
191 | | ...                 | --rx_if | ${rx_port}
192 | | ...                 | --protocol | ${protocol}
193 | | ...                 | --source_port | ${source_port}
194 | | ...                 | --destination_port | ${destination_port}
195 | | Run Traffic Script On Node | send_tcp_udp.py
196 | | ... | ${tg_node} | ${args}
197
198 | Send TCP or UDP packet should failed
199 | | [Documentation] | Sends TCP or UDP packet with specified source
200 | | ...             | and destination port.
201 | | ...
202 | | ... | *Arguments:*
203 | | ...
204 | | ... | _NOTE:_ Arguments are based on topology:
205 | | ...             | TG(if1)->(if1)DUT(if2)->TG(if2)
206 | | ...
207 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
208 | | ... | - src_ip - IP of source interface (TG-if1). Type: integer
209 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: integer
210 | | ... | - tx_port - Source interface (TG-if1). Type: string
211 | | ... | - tx_mac - MAC address of source interface (TG-if1). Type: string
212 | | ... | - rx_port - Destionation interface (TG-if1). Type: string
213 | | ... | - rx_mac - MAC address of destination interface (TG-if1). Type: string
214 | | ... | - protocol - Type of protocol. Type: string
215 | | ... | - source_port - Source TCP/UDP port. Type: string or integer
216 | | ... | - destination_port - Destination TCP/UDP port. Type: string or integer
217 | | ...
218 | | ... | *Return:*
219 | | ... | - No value returned
220 | | ...
221 | | ... | *Example:*
222 | | ...
223 | | ... | \| Send TCP or UDP packet should failed \| ${nodes['TG']} \
224 | | ... | \| 16.0.0.1 \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
225 | | ... | \| eth4 \| 08:00:27:c9:6a:d5 \| TCP \| 20 \| 80 \|
226 | | ...
227 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
228 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
229 | | ... | ${destination_port}
230 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
231 | | ...                 | --rx_mac | ${rx_mac}
232 | | ...                 | --src_ip | ${src_ip}
233 | | ...                 | --dst_ip | ${dst_ip}
234 | | ...                 | --tx_if | ${tx_port}
235 | | ...                 | --rx_if | ${rx_port}
236 | | ...                 | --protocol | ${protocol}
237 | | ...                 | --source_port | ${source_port}
238 | | ...                 | --destination_port | ${destination_port}
239 | | Run Keyword And Expect Error | TCP/UDP Rx timeout
240 | | ... | Run Traffic Script On Node | send_tcp_udp.py
241 | | ... | ${tg_node} | ${args}
242
243 | Receive And Check Router Advertisement Packet
244 | | [Documentation] | Wait until RA packet is received and then check
245 | | ...             | specific packet fields whether they are correct.
246 | | ...
247 | | ... | *Arguments:*
248 | | ...
249 | | ... | - node - Node where to check for RA packet. Type: dictionary
250 | | ... | - rx_port - Interface where the packet is received. Type: string
251 | | ... | - src_mac - MAC address of source interface from which the link-local
252 | | ... |             IPv6 address is constructed and checked. Type: string
253 | | ...
254 | | ... | *Return:*
255 | | ... | - No value returned
256 | | ...
257 | | ... | *Example:*
258 | | ...
259 | | ... | \| Receive And Check Router Advertisement Packet \
260 | | ... | \| ${nodes['DUT1']} \| eth2 \| 08:00:27:cc:4f:54 \|
261 | | ...
262 | | [Arguments] | ${node} | ${rx_port} | ${src_mac}
263 | | ${args}= | Catenate | --rx_if | ${rx_port} | --src_mac | ${src_mac}
264 | | Run Traffic Script On Node | check_ra_packet.py | ${node} | ${args}