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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 """Traffic keywords"""
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
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).
35 | | ... | *Arguments:*
37 | | ... | _NOTE:_ Arguments are based on topology:
38 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
40 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
41 | | ... | - src_ip - IP of source interface (TG-if1). Type: string
42 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: string
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
51 | | ... | - No value returned
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 \|
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 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_src_port}
63 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
64 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
65 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
66 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
67 | | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
68 | | Run Traffic Script On Node | send_icmp_check_headers.py | ${tg_node} |
71 | Send packet from Port to Port should failed
72 | | [Documentation] | Sends packet from ip (with specified mac) to ip
73 | | ... | (with dest mac). Using keyword : Send packet And Check
74 | | ... | Headers and subsequently checks the return value
76 | | ... | *Arguments:*
78 | | ... | _NOTE:_ Arguments are based on topology:
79 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
81 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
82 | | ... | - src_ip - IP of source interface (TG-if1). Type: string
83 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: string
84 | | ... | - tx_src_port - Interface of TG-if1. Type: string
85 | | ... | - tx_src_mac - MAC address of TG-if1. Type: string
86 | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string
87 | | ... | - rx_port - Interface of TG-if1. Type: string
88 | | ... | - rx_src_mac - MAC address of DUT1-if2. Type: string
89 | | ... | - rx_dst_mac - MAC address of TG-if2. Type: string
92 | | ... | - No value returned
96 | | ... | \| Send packet from Port to Port should failed \| ${nodes['TG']} \
97 | | ... | \| 10.0.0.1 \ \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \
98 | | ... | \| 08:00:27:a2:52:5b \| eth3 \| 08:00:27:4d:ca:7a \
99 | | ... | \| 08:00:27:7d:fd:10 \|
100 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} |
101 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} |
102 | | ... | ${rx_dst_mac}
103 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_src_port}
104 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
105 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
106 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
107 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
108 | | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
109 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
110 | | ... | Run Traffic Script On Node | send_icmp_check_headers.py
111 | | ... | ${tg_node} | ${args}
113 | Send Packet And Check ARP Request
114 | | [Documentation] | Send IP packet from tx_port and check if ARP Request\
115 | | ... | packet is received on rx_port.
117 | | ... | *Arguments:*
119 | | ... | _NOTE:_ Arguments are based on topology:
120 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
122 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
123 | | ... | - tx_src_ip - Source IP address of transferred packet (TG-if1).
124 | | ... | Type: string
125 | | ... | - tx_dst_ip - Destination IP address of transferred packet (TG-if2).
126 | | ... | Type: string
127 | | ... | - tx_port - Interface from which the IP packet is sent (TG-if1).
128 | | ... | Type: string
129 | | ... | - tx_dst_mac - Destination MAC address of IP packet (DUT-if1).
130 | | ... | Type: string
131 | | ... | - rx_port - Interface where the IP packet is received (TG-if2).
132 | | ... | Type: string
133 | | ... | - rx_src_mac - Source MAC address of ARP packet (DUT-if2).
134 | | ... | Type: string
135 | | ... | - rx_arp_src_ip - Source IP address of ARP packet (DUT-if2).
136 | | ... | Type: string
137 | | ... | - rx_arp_dst_ip - Destination IP address of ARP packet. Type: string
140 | | ... | - No value returned
144 | | ... | \| Send Packet And Check ARP Packet \| ${nodes['TG']} \| 16.0.0.1 \
145 | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
146 | | ... | \| eth4 \| 08:00:27:5b:49:dd \| 192.168.2.1 \| 192.168.2.2 \|
148 | | [Arguments] | ${tg_node} | ${tx_src_ip} | ${tx_dst_ip} | ${tx_port}
149 | | ... | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} | ${rx_arp_src_ip}
150 | | ... | ${rx_arp_dst_ip}
151 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
152 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
153 | | ${args}= | Catenate
154 | | ... | --tx_dst_mac | ${tx_dst_mac} | --rx_src_mac | ${rx_src_mac}
155 | | ... | --tx_src_ip | ${tx_src_ip} | --tx_dst_ip | ${tx_dst_ip}
156 | | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
157 | | ... | --rx_arp_src_ip ${rx_arp_src_ip} | --rx_arp_dst_ip ${rx_arp_dst_ip}
158 | | Run Traffic Script On Node | send_icmp_check_arp.py | ${tg_node} | ${args}
160 | Send TCP or UDP packet
161 | | [Documentation] | Sends TCP or UDP packet with specified source
162 | | ... | and destination port.
164 | | ... | *Arguments:*
166 | | ... | _NOTE:_ Arguments are based on topology:
167 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
169 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
170 | | ... | - src_ip - IP of source interface (TG-if1). Type: integer
171 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: integer
172 | | ... | - tx_port - Source interface (TG-if1). Type: string
173 | | ... | - tx_mac - MAC address of source interface (TG-if1). Type: string
174 | | ... | - rx_port - Destionation interface (TG-if1). Type: string
175 | | ... | - rx_mac - MAC address of destination interface (TG-if1). Type: string
176 | | ... | - protocol - Type of protocol. Type: string
177 | | ... | - source_port - Source TCP/UDP port. Type: string or integer
178 | | ... | - destination_port - Destination TCP/UDP port. Type: string or integer
181 | | ... | - No value returned
185 | | ... | \| Send TCP or UDP packet \| ${nodes['TG']} \
186 | | ... | \| 16.0.0.1 \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
187 | | ... | \| eth4 \| 08:00:27:c9:6a:d5 \| TCP \| 20 \| 80 \|
189 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
190 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
191 | | ... | ${destination_port}
192 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
193 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
194 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
195 | | ... | --rx_mac | ${rx_mac}
196 | | ... | --src_ip | ${src_ip}
197 | | ... | --dst_ip | ${dst_ip}
198 | | ... | --tx_if | ${tx_port_name}
199 | | ... | --rx_if | ${rx_port_name}
200 | | ... | --protocol | ${protocol}
201 | | ... | --source_port | ${source_port}
202 | | ... | --destination_port | ${destination_port}
203 | | Run Traffic Script On Node | send_tcp_udp.py
204 | | ... | ${tg_node} | ${args}
206 | Send TCP or UDP packet should failed
207 | | [Documentation] | Sends TCP or UDP packet with specified source
208 | | ... | and destination port.
210 | | ... | *Arguments:*
212 | | ... | _NOTE:_ Arguments are based on topology:
213 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
215 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
216 | | ... | - src_ip - IP of source interface (TG-if1). Type: integer
217 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: integer
218 | | ... | - tx_port - Source interface (TG-if1). Type: string
219 | | ... | - tx_mac - MAC address of source interface (TG-if1). Type: string
220 | | ... | - rx_port - Destionation interface (TG-if1). Type: string
221 | | ... | - rx_mac - MAC address of destination interface (TG-if1). Type: string
222 | | ... | - protocol - Type of protocol. Type: string
223 | | ... | - source_port - Source TCP/UDP port. Type: string or integer
224 | | ... | - destination_port - Destination TCP/UDP port. Type: string or integer
227 | | ... | - No value returned
231 | | ... | \| Send TCP or UDP packet should failed \| ${nodes['TG']} \
232 | | ... | \| 16.0.0.1 \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
233 | | ... | \| eth4 \| 08:00:27:c9:6a:d5 \| TCP \| 20 \| 80 \|
235 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
236 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
237 | | ... | ${destination_port}
238 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
239 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
240 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
241 | | ... | --rx_mac | ${rx_mac}
242 | | ... | --src_ip | ${src_ip}
243 | | ... | --dst_ip | ${dst_ip}
244 | | ... | --tx_if | ${tx_port_name}
245 | | ... | --rx_if | ${rx_port_name}
246 | | ... | --protocol | ${protocol}
247 | | ... | --source_port | ${source_port}
248 | | ... | --destination_port | ${destination_port}
249 | | Run Keyword And Expect Error | TCP/UDP Rx timeout
250 | | ... | Run Traffic Script On Node | send_tcp_udp.py
251 | | ... | ${tg_node} | ${args}
253 | Receive And Check Router Advertisement Packet
254 | | [Documentation] | Wait until RA packet is received and then verify\
255 | | ... | specific fields of received RA packet.
257 | | ... | *Arguments:*
259 | | ... | - node - Node where to check for RA packet. Type: dictionary
260 | | ... | - rx_port - Interface where the packet is received. Type: string
261 | | ... | - src_mac - MAC address of source interface from which the link-local\
262 | | ... | IPv6 address is constructed and checked. Type: string
263 | | ... | - interval - Configured retransmit interval. Optional. Type: integer
266 | | ... | - No value returned
270 | | ... | \| Receive And Check Router Advertisement Packet \
271 | | ... | \| ${nodes['DUT1']} \| eth2 \| 08:00:27:cc:4f:54 \|
273 | | [Arguments] | ${node} | ${rx_port} | ${src_mac} | ${interval}=${0}
274 | | ${rx_port_name}= | Get interface name | ${node} | ${rx_port}
275 | | ${args}= | Catenate
276 | | ... | --rx_if ${rx_port_name}
277 | | ... | --src_mac ${src_mac}
278 | | ... | --interval ${interval}
279 | | Run Traffic Script On Node | check_ra_packet.py | ${node} | ${args}
281 | Send Router Solicitation and check response
282 | | [Documentation] | Send RS packet, wait for response and then verify\
283 | | ... | specific fields of received RA packet.
285 | | ... | *Arguments:*
287 | | ... | - tg_node - TG node to send RS packet from. Type: dictionary
288 | | ... | - dut_node - DUT node to send RS packet to. Type: dictionary
289 | | ... | - rx_port - Interface where the packet is sent from. Type: string
290 | | ... | - tx_port - Interface where the packet is sent to. Type: string
291 | | ... | - src_ip - Source IP address of RS packet. Optional. If not provided,\
292 | | ... | link local address will be used. Type: string
295 | | ... | - No value returned
299 | | ... | \| Send Router Solicitation and check response \
300 | | ... | \| ${nodes['TG']} \| ${nodes['DUT1']} \| eth2 \
301 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \|
303 | | [Arguments] | ${tg_node} | ${dut_node} | ${tx_port} | ${rx_port}
304 | | ... | ${src_ip}=''
305 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${tx_port}
306 | | ${dst_mac}= | Get Interface Mac | ${dut_node} | ${rx_port}
307 | | ${src_int_name}= | Get interface name | ${tg_node} | ${tx_port}
308 | | ${dst_int_name}= | Get interface name | ${dut_node} | ${rx_port}
309 | | ${args}= | catenate
310 | | ... | --rx_if ${dst_int_name} --tx_if ${src_int_name}
311 | | ... | --src_mac ${src_mac} | --dst_mac ${dst_mac}
312 | | ... | --src_ip ${src_ip}
313 | | Run Traffic Script On Node | send_rs_check_ra.py
314 | | ... | ${tg_node} | ${args}
317 | | [Documentation] | Send ARP Request and check if the ARP Response is received.
319 | | ... | *Arguments:*
321 | | ... | _NOTE:_ Arguments are based on topology:
322 | | ... | TG(if1)<->(if1)DUT
324 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
325 | | ... | - tx_port - Interface from which the ARP packet is sent (TG-if1).
326 | | ... | Type: string
327 | | ... | - src_mac - Source MAC address of ARP packet (TG-if1).
328 | | ... | Type: string
329 | | ... | - tgt_mac - Target MAC address which is expected in the response
330 | | ... | (DUT-if1). Type: string
331 | | ... | - src_ip - Source IP address of ARP packet (TG-if1).
332 | | ... | Type: string
333 | | ... | - tgt_ip - Target IP address of ARP packet (DUT-if1).
334 | | ... | Type: string
337 | | ... | - No value returned
341 | | ... | \| Send ARP Request \| ${nodes['TG']} \| eth3 \
342 | | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \
343 | | ... | \| 10.0.0.100 \| 192.168.1.5 \|
345 | | [Arguments] | ${tg_node} | ${tx_port}
346 | | ... | ${src_mac} | ${tgt_mac}
347 | | ... | ${src_ip} | ${tgt_ip}
348 | | ${args}= | Catenate | --tx_if | ${tx_port}
349 | | ... | --src_mac | ${src_mac} | --dst_mac | ${tgt_mac}
350 | | ... | --src_ip | ${src_ip} | --dst_ip | ${tgt_ip}
351 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
353 | Send ARP Request should failed
354 | | [Documentation] | Send ARP Request and
355 | | ... | the ARP Response should not be received.
357 | | ... | *Arguments:*
359 | | ... | _NOTE:_ Arguments are based on topology:
360 | | ... | TG(if1)<->(if1)DUT
362 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
363 | | ... | - tx_port - Interface from which the ARP packet is sent (TG-if1).
364 | | ... | Type: string
365 | | ... | - src_mac - Source MAC address of ARP packet (TG-if1).
366 | | ... | Type: string
367 | | ... | - tgt_mac - Target MAC address which is expected in the response
368 | | ... | (DUT-if1). Type: string
369 | | ... | - src_ip - Source IP address of ARP packet (TG-if1).
370 | | ... | Type: string
371 | | ... | - tgt_ip - Target IP address of ARP packet (DUT-if1).
372 | | ... | Type: string
375 | | ... | - No value returned
379 | | ... | \| Send ARP Request should failed \| ${nodes['TG']} \| eth3 \
380 | | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \
381 | | ... | \| 10.0.0.100 \| 192.168.1.5 \|
383 | | [Arguments] | ${tg_node} | ${tx_port}
384 | | ... | ${src_mac} | ${tgt_mac}
385 | | ... | ${src_ip} | ${tgt_ip}
386 | | ${args}= | Catenate | --tx_if | ${tx_port}
387 | | ... | --src_mac | ${src_mac} | --dst_mac | ${tgt_mac}
388 | | ... | --src_ip | ${src_ip} | --dst_ip | ${tgt_ip}
389 | | Run Keyword And Expect Error | ARP reply timeout
390 | | ... | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
392 | Send Packets And Check Multipath Routing
393 | | [Documentation] | Send 100 IP ICMP packets traffic and check if it is\
394 | | ... | divided into two paths.
396 | | ... | *Arguments:*
398 | | ... | _NOTE:_ Arguments are based on topology:
399 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
401 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
402 | | ... | - src_port - Interface of TG-if1. Type: string
403 | | ... | - dst_port - Interface of TG-if2. Type: string
404 | | ... | - src_ip - IP of source interface (TG-if1). Type: string
405 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: string
406 | | ... | - tx_src_mac - MAC address of TG-if1. Type: string
407 | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string
408 | | ... | - rx_src_mac - MAC address of DUT-if2. Type: string
409 | | ... | - rx_dst_mac_1 - MAC address of interface for path 1. Type: string
410 | | ... | - rx_dst_mac_2 - MAC address of interface for path 2. Type: string
413 | | ... | - No value returned
417 | | ... | \| Send Packet And Check Multipath Routing \| ${nodes['TG']} \
418 | | ... | \| eth2 \| eth3 \| 16.0.0.1 \| 32.0.0.1 \
419 | | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \| 08:00:27:54:59:f9 \
420 | | ... | \| 02:00:00:00:00:02 \| 02:00:00:00:00:03 \|
422 | | [Arguments] | ${tg_node} | ${src_port} | ${dst_port} | ${src_ip} | ${dst_ip}
423 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_src_mac}
424 | | ... | ${rx_dst_mac_1} | ${rx_dst_mac_2}
425 | | ${src_port_name}= | Get interface name | ${tg_node} | ${src_port}
426 | | ${dst_port_name}= | Get interface name | ${tg_node} | ${dst_port}
427 | | ${args}= | Catenate | --tx_if | ${src_port_name}
428 | | ... | --rx_if | ${dst_port_name} | --src_ip | ${src_ip}
429 | | ... | --dst_ip | ${dst_ip} | --tg_if1_mac | ${tx_src_mac}
430 | | ... | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac | ${rx_src_mac}
431 | | ... | --path_1_mac | ${rx_dst_mac_1} | --path_2_mac | ${rx_dst_mac_2}
432 | | Run Traffic Script On Node | send_icmp_check_multipath.py | ${tg_node}