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 check
255 | | ... | specific packet fields whether they are correct.
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
265 | | ... | - No value returned
269 | | ... | \| Receive And Check Router Advertisement Packet \
270 | | ... | \| ${nodes['DUT1']} \| eth2 \| 08:00:27:cc:4f:54 \|
272 | | [Arguments] | ${node} | ${rx_port} | ${src_mac}
273 | | ${rx_port_name}= | Get interface name | ${node} | ${rx_port}
274 | | ${args}= | Catenate | --rx_if | ${rx_port_name} | --src_mac | ${src_mac}
275 | | Run Traffic Script On Node | check_ra_packet.py | ${node} | ${args}
278 | | [Documentation] | Send ARP Request and check if the ARP Response is received.
280 | | ... | *Arguments:*
282 | | ... | _NOTE:_ Arguments are based on topology:
283 | | ... | TG(if1)<->(if1)DUT
285 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
286 | | ... | - tx_port - Interface from which the ARP packet is sent (TG-if1).
287 | | ... | Type: string
288 | | ... | - src_mac - Source MAC address of ARP packet (TG-if1).
289 | | ... | Type: string
290 | | ... | - tgt_mac - Target MAC address which is expected in the response
291 | | ... | (DUT-if1). Type: string
292 | | ... | - src_ip - Source IP address of ARP packet (TG-if1).
293 | | ... | Type: string
294 | | ... | - tgt_ip - Target IP address of ARP packet (DUT-if1).
295 | | ... | Type: string
298 | | ... | - No value returned
302 | | ... | \| Send ARP Request \| ${nodes['TG']} \| eth3 \
303 | | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \
304 | | ... | \| 10.0.0.100 \| 192.168.1.5 \|
306 | | [Arguments] | ${tg_node} | ${tx_port}
307 | | ... | ${src_mac} | ${tgt_mac}
308 | | ... | ${src_ip} | ${tgt_ip}
309 | | ${args}= | Catenate | --tx_if | ${tx_port}
310 | | ... | --src_mac | ${src_mac} | --dst_mac | ${tgt_mac}
311 | | ... | --src_ip | ${src_ip} | --dst_ip | ${tgt_ip}
312 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
314 | Send ARP Request should failed
315 | | [Documentation] | Send ARP Request and
316 | | ... | the ARP Response should not be received.
318 | | ... | *Arguments:*
320 | | ... | _NOTE:_ Arguments are based on topology:
321 | | ... | TG(if1)<->(if1)DUT
323 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
324 | | ... | - tx_port - Interface from which the ARP packet is sent (TG-if1).
325 | | ... | Type: string
326 | | ... | - src_mac - Source MAC address of ARP packet (TG-if1).
327 | | ... | Type: string
328 | | ... | - tgt_mac - Target MAC address which is expected in the response
329 | | ... | (DUT-if1). Type: string
330 | | ... | - src_ip - Source IP address of ARP packet (TG-if1).
331 | | ... | Type: string
332 | | ... | - tgt_ip - Target IP address of ARP packet (DUT-if1).
333 | | ... | Type: string
336 | | ... | - No value returned
340 | | ... | \| Send ARP Request should failed \| ${nodes['TG']} \| eth3 \
341 | | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \
342 | | ... | \| 10.0.0.100 \| 192.168.1.5 \|
344 | | [Arguments] | ${tg_node} | ${tx_port}
345 | | ... | ${src_mac} | ${tgt_mac}
346 | | ... | ${src_ip} | ${tgt_ip}
347 | | ${args}= | Catenate | --tx_if | ${tx_port}
348 | | ... | --src_mac | ${src_mac} | --dst_mac | ${tgt_mac}
349 | | ... | --src_ip | ${src_ip} | --dst_ip | ${tgt_ip}
350 | | Run Keyword And Expect Error | ARP reply timeout
351 | | ... | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}