aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/InterfaceUtil.py40
-rw-r--r--resources/libraries/python/Trace.py24
-rw-r--r--resources/libraries/python/topology.py24
-rw-r--r--resources/libraries/robot/interfaces.robot15
-rw-r--r--resources/libraries/robot/ipv4.robot14
-rw-r--r--resources/libraries/robot/ipv6.robot26
-rw-r--r--resources/templates/vat/show_trace.vat1
-rwxr-xr-xresources/traffic_scripts/ipv4_sweep_ping.py12
8 files changed, 126 insertions, 30 deletions
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index 14473ee4d4..aeb54be86a 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -53,7 +53,45 @@ class InterfaceUtil(object):
cmd = 'ip link set {} {}'.format(interface, state)
exec_cmd_no_error(node, cmd, sudo=True)
else:
- raise Exception('Unknown NodeType: "{}"'.format(node['type']))
+ raise Exception('Node {} has unknown NodeType: "{}"'.
+ format(node['host'], node['type']))
+
+ @staticmethod
+ def set_interface_ethernet_mtu(node, interface, mtu):
+ """Set Ethernet MTU for specified interface.
+
+ Function can be used only for TGs.
+
+ :param node: node where the interface is
+ :param interface: interface name
+ :param mtu: MTU to set
+ :type node: dict
+ :type interface: str
+ :type mtu: int
+ :return: nothing
+ """
+ if node['type'] == NodeType.DUT:
+ ValueError('Node {}: Setting Ethernet MTU for interface '
+ 'on DUT nodes not supported', node['host'])
+ elif node['type'] == NodeType.TG:
+ cmd = 'ip link set {} mtu {}'.format(interface, mtu)
+ exec_cmd_no_error(node, cmd, sudo=True)
+ else:
+ raise ValueError('Node {} has unknown NodeType: "{}"'.
+ format(node['host'], node['type']))
+
+ @staticmethod
+ def set_default_ethernet_mtu_on_all_interfaces_on_node(node):
+ """Set default Ethernet MTU on all interfaces on node.
+
+ Function can be used only for TGs.
+
+ :param node: node where to set default MTU
+ :type node: dict
+ :return: nothing
+ """
+ for ifc in node['interfaces'].values():
+ InterfaceUtil.set_interface_ethernet_mtu(node, ifc['name'], 1500)
@staticmethod
def vpp_node_interfaces_ready_wait(node, timeout=10):
diff --git a/resources/libraries/python/Trace.py b/resources/libraries/python/Trace.py
new file mode 100644
index 0000000000..8168b909ea
--- /dev/null
+++ b/resources/libraries/python/Trace.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from resources.libraries.python.VatExecutor import VatExecutor
+from resources.libraries.python.topology import NodeType
+
+class Trace(object):
+
+ @staticmethod
+ def show_packet_trace_on_all_duts(nodes):
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ vat = VatExecutor()
+ vat.execute_script("show_trace.vat", node, json_out=False)
diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py
index e2c069fc98..75542ad070 100644
--- a/resources/libraries/python/topology.py
+++ b/resources/libraries/python/topology.py
@@ -257,6 +257,7 @@ class Topology(object):
format(ifc, if_mac))
ifc['name'] = interface_dict["interface_name"]
ifc['vpp_sw_index'] = interface_dict["sw_if_index"]
+ ifc['mtu'] = interface_dict["mtu"]
def update_vpp_interface_data_on_node(self, node):
"""Update vpp generated interface data for a given node in DICT__nodes
@@ -347,14 +348,31 @@ class Topology(object):
"""
for port in node['interfaces'].values():
port_name = port.get('name')
- if port_name is None:
- continue
if port_name == interface:
return port.get('vpp_sw_index')
return None
@staticmethod
+ def get_interface_mtu(node, interface):
+ """Get interface MTU.
+
+ Returns physical layer MTU (max. size of Ethernet frame).
+ :param node: Node to get interface MTU on.
+ :param interface: Interface name.
+ :type node: dict
+ :type interface: str
+ :return: MTU or None if not found.
+ :rtype: int
+ """
+ for port in node['interfaces'].values():
+ port_name = port.get('name')
+ if port_name == interface:
+ return port.get('mtu')
+
+ return None
+
+ @staticmethod
def get_interface_mac_by_port_key(node, port_key):
"""Get MAC address for the interface based on port key.
@@ -382,8 +400,6 @@ class Topology(object):
"""
for port in node['interfaces'].values():
port_name = port.get('name')
- if port_name is None:
- continue
if port_name == interface:
return port.get('mac_address')
diff --git a/resources/libraries/robot/interfaces.robot b/resources/libraries/robot/interfaces.robot
index 18c9c0cc81..649ee63253 100644
--- a/resources/libraries/robot/interfaces.robot
+++ b/resources/libraries/robot/interfaces.robot
@@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
*** Settings ***
+| Library | resources.libraries.python.InterfaceUtil
+| Library | resources.libraries.python.NodePath
| Resource | resources/libraries/robot/vat/interfaces.robot
*** Keywords ***
@@ -18,3 +20,16 @@
| | VPP reports interfaces through VAT on | ${node}
#| | VPP reports interfaces through ODL on | ${node}
#| | VPP reports interfaces through DEBUGCLI on | ${node}
+
+| Setup MTU on TG based on MTU on DUT
+| | [Documentation] | Type of the tg_node must be TG and dut_node must be DUT
+| | [Arguments] | ${tg_node} | ${dut_node}
+| | Append Nodes | ${tg_node} | ${dut_node}
+| | Compute Path
+| | ${tg_port} | ${tg_node}= | First Interface
+| | ${dut_port} | ${dut_node}= | Last Interface
+| | # get physical layer MTU (max. size of Ethernet frame)
+| | ${mtu}= | Get Interface MTU | ${dut_node} | ${dut_port}
+| | # Ethernet MTU is physical layer MTU minus size of Ethernet header and FCS
+| | ${eth_mtu}= | Evaluate | ${mtu} - 14 - 4
+| | Set Interface Ethernet MTU | ${tg_node} | ${tg_port} | ${eth_mtu}
diff --git a/resources/libraries/robot/ipv4.robot b/resources/libraries/robot/ipv4.robot
index 4c76644c54..63a1188332 100644
--- a/resources/libraries/robot/ipv4.robot
+++ b/resources/libraries/robot/ipv4.robot
@@ -75,18 +75,20 @@
| Ipv4 icmp echo sweep
| | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
-| | [Arguments] | ${src_node} | ${dst_node} | ${src_port} | ${dst_port}
+| | [Arguments] | ${src_node} | ${dst_node} | ${start_size} | ${end_size} | ${step}
+| | Append Nodes | ${src_node} | ${dst_node}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Interface
| | ${src_ip}= | Get IPv4 address of node "${src_node}" interface "${src_port}" from "${nodes_ipv4_addr}"
| | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}" from "${nodes_ipv4_addr}"
| | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
| | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
| | | ... | ${dst_mac} | ${src_ip} | ${dst_ip}
-| # TODO: end_size is currently minimum MTU size for Ethernet minus IPv4 and
-| # ICMP echo header size (1500 - 20 - 8),
-| # MTU info is not in VAT sw_interface_dump output
-| | ${args}= | Set Variable | ${args} --start_size 1 --end_size 1472 --step 1
-| | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args}
+| | ${args}= | Set Variable
+| | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
+| | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args} | ${20}
| Send ARP request and validate response
| | [Arguments] | ${tg_node} | ${vpp_node}
diff --git a/resources/libraries/robot/ipv6.robot b/resources/libraries/robot/ipv6.robot
index 78a8eda45a..17ab14274f 100644
--- a/resources/libraries/robot/ipv6.robot
+++ b/resources/libraries/robot/ipv6.robot
@@ -14,12 +14,12 @@
"""IPv6 keywords"""
*** Settings ***
-| Library | resources/libraries/python/IPv6Util.py
-| Library | resources/libraries/python/IPv6Setup.py
-| Library | resources/libraries/python/TrafficScriptExecutor.py
-| Library | resources/libraries/python/NodePath.py
-| Library | resources/libraries/python/Routing.py
-| Library | resources/libraries/python/InterfaceUtil.py
+| Library | resources.libraries.python.IPv6Util
+| Library | resources.libraries.python.IPv6Setup
+| Library | resources.libraries.python.TrafficScriptExecutor
+| Library | resources.libraries.python.NodePath
+| Library | resources.libraries.python.Routing
+| Library | resources.libraries.python.InterfaceUtil
| Library | resources.libraries.python.topology.Topology
| Resource | resources/libraries/robot/default.robot
| Resource | resources/libraries/robot/counters.robot
@@ -42,12 +42,13 @@
| | Run Traffic Script On Node | icmpv6_echo.py | ${tg_node} | ${args}
| | Vpp dump stats | ${dst_node}
| | ${ipv6_counter}= | Vpp get interface ipv6 counter | ${dst_node} | ${dst_port}
-| | Should Be Equal | ${ipv6_counter} | ${2} | #ICMPv6 neighbor advertisment + ICMPv6 echo request
+| | Should Be Equal | ${ipv6_counter} | ${2} | #ICMPv6 neighbor advertisement + ICMPv6 echo request
| Ipv6 icmp echo sweep
| | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
-| | [Arguments] | ${tg_node} | ${dut_node} | ${nodes_addr}
-| | Append Nodes | ${tg_node} | ${dut_node}
+| | [Arguments] | ${src_node} | ${dst_node} | ${start_size} | ${end_size}
+| | ... | ${step} | ${nodes_addr}
+| | Append Nodes | ${src_node} | ${dst_node}
| | Compute Path
| | ${src_port} | ${src_node}= | First Interface
| | ${dst_port} | ${dst_node}= | Last Interface
@@ -57,10 +58,9 @@
| | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
| | | ... | ${dst_mac} | ${src_ip} | ${dst_ip}
-| # TODO: end_size is currently minimum MTU size for IPv6 minus IPv6 and ICMPv6
-| # echo header size, MTU info is not in VAT sw_interface_dump output
-| | ${args}= | Set Variable | ${args} --start_size 0 --end_size 1232 --step 1
-| | Run Traffic Script On Node | ipv6_sweep_ping.py | ${tg_node} | ${args} | ${20}
+| | ${args}= | Set Variable
+| | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
+| | Run Traffic Script On Node | ipv6_sweep_ping.py | ${src_node} | ${args} | ${20}
| Ipv6 tg to dut1 egress
| | [Documentation] | Send traffic from TG to first DUT egress interface
diff --git a/resources/templates/vat/show_trace.vat b/resources/templates/vat/show_trace.vat
new file mode 100644
index 0000000000..9146d3c89e
--- /dev/null
+++ b/resources/templates/vat/show_trace.vat
@@ -0,0 +1 @@
+exec show trace
diff --git a/resources/traffic_scripts/ipv4_sweep_ping.py b/resources/traffic_scripts/ipv4_sweep_ping.py
index cd332d0391..7f6759724c 100755
--- a/resources/traffic_scripts/ipv4_sweep_ping.py
+++ b/resources/traffic_scripts/ipv4_sweep_ping.py
@@ -20,7 +20,7 @@ import logging
import os
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from resources.libraries.python.PacketVerifier import RxQueue, TxQueue,\
- auto_pad, create_gratuitous_arp_request, checksum_equal
+ create_gratuitous_arp_request, checksum_equal
from resources.libraries.python.TrafficScriptArg import TrafficScriptArg
from scapy.layers.inet import IP, ICMP
from scapy.all import Ether, Raw
@@ -55,10 +55,10 @@ def main():
# send ICMP echo request with incremented data length and receive ICMP
# echo reply
for echo_seq in range(start_size, end_size+1, step):
- pkt_send = auto_pad(Ether(src=src_mac, dst=dst_mac) /
- IP(src=src_ip, dst=dst_ip) /
- ICMP(id=echo_id, seq=echo_seq) /
- Raw(load=data[0:echo_seq]))
+ pkt_send = (Ether(src=src_mac, dst=dst_mac) /
+ IP(src=src_ip, dst=dst_ip) /
+ ICMP(id=echo_id, seq=echo_seq) /
+ Raw(load=data[0:echo_seq]))
sent_packets.append(pkt_send)
txq.send(pkt_send)
@@ -97,7 +97,7 @@ def main():
if 'Raw' in icmpv4:
load = icmpv4['Raw'].load
else:
- load = []
+ load = ""
if load != data[0:echo_seq]:
raise RuntimeError(
'Received ICMP payload does not match sent payload')