156497efaacbcfcf45700967cc7fab0961976a38
[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 | Documentation | Keywords to send and receive different types of traffic \
16 | ...           | through L2 network.
17 | Library | resources.libraries.python.topology.Topology
18 | Library | resources.libraries.python.TrafficScriptExecutor
19
20 *** Keywords ***
21 | Send and receive ICMP Packet
22 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to \
23 | | ...             | destination interface. Dot1q or Dot1ad tag(s) can be set.
24 | | ...
25 | | ... | *Arguments:*
26 | | ...
27 | | ... | - tg_node - TG node. Type: dictionary
28 | | ... | - src_int - Source interface. Type: string
29 | | ... | - dst_int - Destination interface. Type: string
30 | | ... | - src_ip - Source IP address (Optional). Type: string
31 | | ... | - dst_ip - Destination IP address (Optional). Type: string
32 | | ... | - encaps - Encapsulation: Dot1q or Dot1ad (Optional). Type: string
33 | | ... | - vlan1 - VLAN (outer) tag (Optional). Type: integer
34 | | ... | - vlan2 - VLAN inner tag (Optional). Type: integer
35 | | ...
36 | | ... | *Return:*
37 | | ...
38 | | ... | - No value returned
39 | | ...
40 | | ... | *Example:*
41 | | ...
42 | | ... | _NOTE:_ Default IP is IPv4
43 | | ...
44 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \
45 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
46 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
47 | | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=100 \|
48 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
49 | | ... | \| ${tg_to_dut2} \| encaps=Dot1ad \| vlan1=110 \| vlan2=220 \|
50 | | ...
51 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int}
52 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2 | ${encaps}=${EMPTY}
53 | | ... | ${vlan1}=${EMPTY} | ${vlan2}=${EMPTY}
54 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
55 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
56 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
57 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
58 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
59 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
60 | | ${args1}= | Run Keyword Unless | '${encaps}' == '${EMPTY}' | Catenate
61 | | ... | --encaps ${encaps} | --vlan1 ${vlan1}
62 | | ${args2}= | Run Keyword Unless | '${vlan2}' == '${EMPTY}' | Set Variable
63 | | ... | --vlan2 ${vlan2}
64 | | ${args}= | Run Keyword If | '${args1}' == 'None' | Set Variable | ${args}
65 | | ... | ELSE IF | '${args2}' == 'None' | Catenate | ${args} | ${args1}
66 | | ... | ELSE | Catenate | ${args} | ${args1} | ${args2}
67 | | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
68
69 | Send and receive ICMP Packet should failed
70 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to
71 | | ...             | destination interface and expect failure with
72 | | ...             | ICMP echo Rx timeout error message.
73 | | ...
74 | | ... | *Arguments:*
75 | | ...
76 | | ... | - tg_node - TG node. Type: dictionary
77 | | ... | - src_int - Source interface. Type: string
78 | | ... | - dst_int - Destination interface. Type: string
79 | | ... | - src_ip - Source IP address (Optional). Type: string
80 | | ... | - dst_ip - Destination IP address (Optional). Type: string
81 | | ...
82 | | ... | *Return:*
83 | | ...
84 | | ... | - No value returned
85 | | ...
86 | | ... | *Example:*
87 | | ...
88 | | ... | _NOTE:_ Default IP is IPv4
89 | | ...
90 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \
91 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
92 | | ...
93 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int} |
94 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2
95 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
96 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
97 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
98 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
99 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
100 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
101 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
102 | | ... | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
103
104 | Send and receive ICMPv4 bidirectionally
105 | | [Documentation] | Send ICMPv4 echo request from both directions,
106 | | ...             | from interface1 to interface2 and
107 | | ...             | from interface2 to interface1.
108 | | ...
109 | | ... | *Arguments:*
110 | | ...
111 | | ... | - tg_node - TG node. Type: dictionary
112 | | ... | - src_int - Source interface. Type: string
113 | | ... | - dst_int - Destination interface. Type: string
114 | | ... | - src_ip - Source IP address (Optional). Type: string
115 | | ... | - dst_ip - Destination IP address (Optional). Type: string
116 | | ...
117 | | ... | *Return:*
118 | | ...
119 | | ... | - No value returned
120 | | ...
121 | | ... | *Example:*
122 | | ...
123 | | ... | \| Send and receive ICMPv4 bidirectionally \| ${nodes['TG']} \
124 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
125 | | ...
126 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=192.168.100.1 |
127 | | ... | ${dst_ip}=192.168.100.2
128 | | Send and receive ICMP Packet | ${tg_node} | ${int1} | ${int2} |
129 | | ... | ${src_ip} | ${dst_ip}
130 | | Send and receive ICMP Packet | ${tg_node} | ${int2} | ${int1} |
131 | | ... | ${dst_ip} | ${src_ip}
132
133 | Send and receive ICMPv6 bidirectionally
134 | | [Documentation] | Send ICMPv6 echo request from both directions,
135 | | ...             | from interface1 to interface2 and
136 | | ...             | from interface2 to interface1.
137 | | ...
138 | | ... | *Arguments:*
139 | | ...
140 | | ... | - tg_node - TG node. Type: dictionary
141 | | ... | - src_int - Source interface. Type: string
142 | | ... | - dst_int - Destination interface. Type: string
143 | | ... | - src_ip - Source IP address (Optional). Type: string
144 | | ... | - dst_ip - Destination IP address (Optional). Type: string
145 | | ...
146 | | ... | *Return:*
147 | | ...
148 | | ... | - No value returned
149 | | ...
150 | | ... | *Example:*
151 | | ...
152 | | ... | \| Send and receive ICMPv6 bidirectionally \| ${nodes['TG']} \
153 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
154 | | ...
155 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=3ffe:63::1 |
156 | | ... | ${dst_ip}=3ffe:63::2
157 | | Send and receive ICMP Packet | ${tg_node} | ${int1} | ${int2} |
158 | | ... | ${src_ip} | ${dst_ip}
159 | | Send and receive ICMP Packet | ${tg_node} | ${int2} | ${int1} |
160 | | ... | ${dst_ip} | ${src_ip}