aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/SNATUtil.py171
-rw-r--r--resources/libraries/python/TrafficGenerator.py155
-rw-r--r--resources/libraries/python/VppConfigGenerator.py122
-rw-r--r--resources/libraries/python/ssh.py2
-rw-r--r--resources/libraries/robot/default.robot8
-rw-r--r--resources/libraries/robot/performance.robot37
-rw-r--r--resources/libraries/robot/snat.robot150
-rw-r--r--resources/templates/vat/snat/snat_deterministic_forward.vat1
-rw-r--r--resources/templates/vat/snat/snat_deterministic_reverse.vat1
-rw-r--r--resources/templates/vat/snat/snat_set_deterministic.vat1
-rw-r--r--resources/templates/vat/snat/snat_set_interfaces.vat1
-rw-r--r--resources/templates/vat/snat/snat_set_workers.vat1
-rw-r--r--resources/templates/vat/snat/snat_show_snat.vat1
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless.py118
14 files changed, 722 insertions, 47 deletions
diff --git a/resources/libraries/python/SNATUtil.py b/resources/libraries/python/SNATUtil.py
new file mode 100644
index 0000000000..02cf493a93
--- /dev/null
+++ b/resources/libraries/python/SNATUtil.py
@@ -0,0 +1,171 @@
+# Copyright (c) 2017 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.
+
+"""SNAT utilities library."""
+
+from resources.libraries.python.VatExecutor import VatTerminal
+
+
+class SNATUtil(object):
+ """This class defines the methods to set SNAT."""
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def set_snat_interfaces(node, int_in, int_out):
+ """Set inside and outside interfaces for SNAT.
+
+ :param node: DUT node.
+ :param int_in: Inside interface.
+ :param int_out: Outside interface.
+ :type node: dict
+ :type int_in: str
+ :type int_out: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of inside and outside interfaces for
+ SNAT fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_interfaces.vat',
+ int_in=int_in, int_out=int_out)
+ return response
+ except:
+ raise RuntimeError("Setting of inside and outside interfaces for "
+ "SNAT failed!")
+
+ @staticmethod
+ def set_snat_deterministic(node, ip_in, subnet_in, ip_out, subnet_out):
+ """Set deterministic behaviour of SNAT.
+
+ :param node: DUT node.
+ :param ip_in: Inside IP.
+ :param subnet_in: Inside IP subnet.
+ :param ip_out: Outside IP.
+ :param subnet_out: Outside IP subnet.
+ :type node: dict
+ :type ip_in: str
+ :type subnet_in: str or int
+ :type ip_out: str
+ :type subnet_out: str or int
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of deterministic behaviour of SNAT
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_deterministic.vat',
+ ip_in=ip_in, subnet_in=subnet_in,
+ ip_out=ip_out, subnet_out=subnet_out)
+ return response
+ except:
+ raise RuntimeError("Setting of deterministic behaviour of SNAT "
+ "failed!")
+
+ @staticmethod
+ def set_snat_workers(node, lcores):
+ """Set SNAT workers.
+
+ :param node: DUT node.
+ :param lcores: list of cores, format: range e.g. 1-5 or list of ranges
+ e.g.: 1-5,18-22.
+ :type node: dict
+ :type lcores: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of SNAT workers fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_workers.vat', lcores=lcores)
+ return response
+ except:
+ raise RuntimeError("Setting of SNAT workers failed!")
+
+ @staticmethod
+ def show_snat(node):
+ """Show the SNAT settings.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If getting of SNAT settings fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_show_snat.vat')
+ return response
+ except:
+ raise RuntimeError("Getting of SNAT settings failed!")
+
+ @staticmethod
+ def show_snat_deterministic_forward(node, ip_addr):
+ """Show forward IP address and port(s).
+
+ :param node: DUT node.
+ :param ip_addr: IP address.
+ :type node: dict
+ :type ip_addr: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If command 'exec snat deterministic forward'
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_deterministic_forward.vat', ip=ip_addr)
+ return response
+ except:
+ raise RuntimeError("Command 'exec snat deterministic forward {ip}'"
+ " failed!".format(ip=ip_addr))
+
+ @staticmethod
+ def show_snat_deterministic_reverse(node, ip_addr, port):
+ """Show reverse IP address.
+
+ :param node: DUT node.
+ :param ip_addr: IP address.
+ :param port: Port.
+ :type node: dict
+ :type ip_addr: str
+ :type port: str or int
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If command 'exec snat deterministic reverse'
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_deterministic_reverse.vat',
+ ip=ip_addr, port=port)
+ return response
+ except:
+ raise RuntimeError(
+ "Command 'exec snat deterministic reverse {ip}:{port}'"
+ " failed!".format(ip=ip_addr, port=port))
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 2313ec856b..8387ce2b3c 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -438,6 +438,161 @@ class TrafficGenerator(object):
_p0, _p1, _async, _latency,
warmup_time),
timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1u-1p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.0 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1024 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1028 "
+ "--p{5}_dst_end_udp_port 1028 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.0 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 1038 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-10u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.9 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 1173 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-100u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.99 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 2523 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration) + 60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.3.231 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 16023 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-2000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.7.207 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 31022 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-4000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.15.159 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 61022 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
elif traffic_type in ["3-node-IPv4-dst-10000"]:
(ret, stdout, stderr) = ssh.exec_command(
"sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py
index 267c47845f..e109d768fa 100644
--- a/resources/libraries/python/VppConfigGenerator.py
+++ b/resources/libraries/python/VppConfigGenerator.py
@@ -67,7 +67,7 @@ ip6 {{
hash-buckets 2000000
heap-size 3G
}}
-
+{snatconfig}
"""
# End VPP configuration template.
@@ -83,22 +83,21 @@ class VppConfigGenerator(object):
:param node: DUT node
:type node: dict
- :return: nothing
+ :returns: nothing
"""
for port in node['interfaces'].keys():
pci_addr = Topology.get_interface_pci_addr(node, port)
if pci_addr:
self.add_pci_device(node, pci_addr)
-
def add_pci_device(self, node, *pci_devices):
"""Add PCI device configuration for node.
:param node: DUT node.
- :param pci_device: PCI devices (format 0000:00:00.0 or 00:00.0)
+ :param pci_devices: PCI devices (format 0000:00:00.0 or 00:00.0)
:type node: dict
:type pci_devices: tuple
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -129,7 +128,7 @@ class VppConfigGenerator(object):
:param cpu_config: CPU configuration option, as a string.
:type node: dict
:type cpu_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -150,7 +149,7 @@ class VppConfigGenerator(object):
as a string.
:type node: dict
:type socketmem_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -168,7 +167,7 @@ class VppConfigGenerator(object):
:param heapsize_config: Heap Size configuration, as a string.
:type node: dict
:type heapsize_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -186,56 +185,73 @@ class VppConfigGenerator(object):
:param rxqueues_config: Rxqueues configuration, as a string.
:type node: dict
:type rxqueues_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
- if not hostname in self._nodeconfig:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'rxqueues_config' in self._nodeconfig[hostname]:
+ if 'rxqueues_config' not in self._nodeconfig[hostname]:
self._nodeconfig[hostname]['rxqueues_config'] = []
self._nodeconfig[hostname]['rxqueues_config'].append(rxqueues_config)
- logger.debug('Setting hostname {} rxqueues config to {}'.\
- format(hostname, rxqueues_config))
+ logger.debug('Setting hostname {} rxqueues config to {}'.
+ format(hostname, rxqueues_config))
def add_no_multi_seg_config(self, node):
"""Add No Multi Seg configuration for node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
- if not hostname in self._nodeconfig:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'no_multi_seg_config' in self._nodeconfig[hostname]:
+ if 'no_multi_seg_config' not in self._nodeconfig[hostname]:
self._nodeconfig[hostname]['no_multi_seg_config'] = []
- self._nodeconfig[hostname]['no_multi_seg_config'].append(
- "no-multi-seg")
- logger.debug('Setting hostname {} config with {}'.\
- format(hostname, "no-multi-seg"))
+ self._nodeconfig[hostname]['no_multi_seg_config'].append("no-multi-seg")
+ logger.debug('Setting hostname {} config with {}'.
+ format(hostname, "no-multi-seg"))
def add_enable_vhost_user_config(self, node):
"""Add enable-vhost-user configuration for node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
- if not hostname in self._nodeconfig:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'enable_vhost_user' in self._nodeconfig[hostname]:
+ if 'enable_vhost_user' not in self._nodeconfig[hostname]:
self._nodeconfig[hostname]['enable_vhost_user'] = []
- self._nodeconfig[hostname]['enable_vhost_user'].append(
- "enable-vhost-user")
- logger.debug('Setting hostname {} config with {}'.\
- format(hostname, "enable-vhost-user"))
+ self._nodeconfig[hostname]['enable_vhost_user'].\
+ append("enable-vhost-user")
+ logger.debug('Setting hostname {} config with {}'.
+ format(hostname, "enable-vhost-user"))
+
+ def add_snat_config(self, node):
+ """Add SNAT configuration for the node.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: nothing
+ """
+ if node['type'] != NodeType.DUT:
+ raise ValueError('Node type is not a DUT')
+ hostname = Topology.get_node_hostname(node)
+ if hostname not in self._nodeconfig:
+ self._nodeconfig[hostname] = {}
+ if 'snat_config' not in self._nodeconfig[hostname]:
+ self._nodeconfig[hostname]['snat_config'] = []
+ self._nodeconfig[hostname]['snat_config'].append("deterministic")
+ logger.debug('Setting hostname {} config with {}'.
+ format(hostname, "SNAT"))
def add_cryptodev_config(self, node, count):
"""Add cryptodev configuration for node.
@@ -276,7 +292,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -291,7 +307,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -306,7 +322,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -337,7 +353,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -352,45 +368,59 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
if hostname in self._nodeconfig:
self._nodeconfig[hostname]['rxqueues_config'] = []
- logger.debug('Clearing rxqueues config for hostname {}.'.\
- format(hostname))
+ logger.debug('Clearing rxqueues config for hostname {}.'.
+ format(hostname))
def remove_no_multi_seg_config(self, node):
"""Remove No Multi Seg configuration from node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
if hostname in self._nodeconfig:
self._nodeconfig[hostname]['no_multi_seg_config'] = []
- logger.debug('Clearing No Multi Seg config for hostname {}.'.\
- format(hostname))
+ logger.debug('Clearing No Multi Seg config for hostname {}.'.
+ format(hostname))
def remove_enable_vhost_user_config(self, node):
"""Remove enable-vhost-user configuration from node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
hostname = Topology.get_node_hostname(node)
if hostname in self._nodeconfig:
self._nodeconfig[hostname]['enable_vhost_user'] = []
- logger.debug('Clearing enable-vhost-user config for hostname {}.'.\
- format(hostname))
+ logger.debug('Clearing enable-vhost-user config for hostname {}.'.
+ format(hostname))
+
+ def remove_snat_config(self, node):
+ """Remove SNAT configuration for the node.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: nothing
+ """
+ if node['type'] != NodeType.DUT:
+ raise ValueError('Node type is not a DUT')
+ hostname = Topology.get_node_hostname(node)
+ if hostname in self._nodeconfig:
+ self._nodeconfig[hostname]['snat_config'] = []
+ logger.debug('Clearing SNAT config for hostname {}.'.format(hostname))
def apply_config(self, node, waittime=5, retries=12):
"""Generate and apply VPP configuration for node.
@@ -404,6 +434,8 @@ class VppConfigGenerator(object):
:type node: dict
:type waittime: int
:type retries: int
+ :raises RuntimeError: If writing config file failed, or restarting of
+ VPP failed.
"""
if node['type'] != NodeType.DUT:
@@ -420,6 +452,7 @@ class VppConfigGenerator(object):
enablevhostuser = ""
cryptodevconfig = ""
uiodriverconfig = ""
+ snatconfig = ""
if hostname in self._nodeconfig:
cfg = self._nodeconfig[hostname]
@@ -451,6 +484,11 @@ class VppConfigGenerator(object):
if 'enable_vhost_user' in cfg:
enablevhostuser = " " + "\n ".join(cfg['enable_vhost_user'])
+ if 'snat_config' in cfg:
+ snatconfig = "snat {\n"
+ snatconfig += " " + "\n ".join(cfg['snat_config'])
+ snatconfig += "\n}"
+
vppconfig = VPP_CONFIG_TEMPLATE.format(cpuconfig=cpuconfig,
pciconfig=pciconfig,
cryptodevconfig=cryptodevconfig,
@@ -460,7 +498,8 @@ class VppConfigGenerator(object):
rxqueuesconfig=rxqueuesconfig,
txqueuesconfig=txqueuesconfig,
nomultiseg=nomultiseg,
- enablevhostuser=enablevhostuser)
+ enablevhostuser=enablevhostuser,
+ snatconfig=snatconfig)
logger.debug('Writing VPP config to host {}: "{}"'.format(hostname,
vppconfig))
@@ -517,7 +556,6 @@ class VppConfigGenerator(object):
(ret, stdout, stderr) = \
ssh.exec_command('echo show hardware-interfaces | '
'nc 0 5002')
-
if ret == 0:
vpp_is_running = True
else:
diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py
index 7b15998be0..961f7e2ee8 100644
--- a/resources/libraries/python/ssh.py
+++ b/resources/libraries/python/ssh.py
@@ -285,7 +285,7 @@ class SSH(object):
logger.trace('SCP {0} to {1}:{2}'.format(
local_path, self._ssh.get_transport().getpeername(), remote_path))
# SCPCLient takes a paramiko transport as its only argument
- scp = SCPClient(self._ssh.get_transport())
+ scp = SCPClient(self._ssh.get_transport(), socket_timeout=10)
start = time()
scp.put(local_path, remote_path)
scp.close()
diff --git a/resources/libraries/robot/default.robot b/resources/libraries/robot/default.robot
index 08315c32ef..05314d6a15 100644
--- a/resources/libraries/robot/default.robot
+++ b/resources/libraries/robot/default.robot
@@ -281,6 +281,13 @@
| | :FOR | ${dut} | IN | @{duts}
| | | Add Enable Vhost User Config | ${nodes['${dut}']}
+| Add SNAT to all DUTs
+| | [Documentation] | Add SNAT configuration to all DUTs.
+| | ...
+| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | :FOR | ${dut} | IN | @{duts}
+| | | Add SNAT Config | ${nodes['${dut}']}
+
| Add Cryptodev to all DUTs
| | [Documentation] | AddCryptodev to VPP startup configuration to all
| | ... | DUTs
@@ -310,6 +317,7 @@
| | | Remove Rxqueues Config | ${nodes['${dut}']}
| | | Remove No Multi Seg Config | ${nodes['${dut}']}
| | | Remove Enable Vhost User Config | ${nodes['${dut}']}
+| | | Remove SNAT Config | ${nodes['${dut}']}
| Setup default startup configuration of VPP on all DUTs
| | [Documentation] | Setup default startup configuration of VPP to all DUTs.
diff --git a/resources/libraries/robot/performance.robot b/resources/libraries/robot/performance.robot
index ccfc526b03..7c1589392b 100644
--- a/resources/libraries/robot/performance.robot
+++ b/resources/libraries/robot/performance.robot
@@ -2334,6 +2334,43 @@
| | Add arp on dut | ${dut2} | ${dut2_if1} | ${dut1_dut2_ip4_address}
| | ... | ${dut1_if2_mac}
+| SNAT is initialized in a 3-node circular topology
+| | [Documentation] | Initialization of 3-node topology with SNAT between DUTs:
+| | ... | - set interfaces up
+| | ... | - set IP addresses
+| | ... | - set ARP
+| | ... | - create routes
+| | ... | - set SNAT - only on DUT1
+| | ...
+| | Set Interface State | ${dut1} | ${dut1_if1} | up
+| | Set Interface State | ${dut1} | ${dut1_if2} | up
+| | Set Interface State | ${dut2} | ${dut2_if1} | up
+| | Set Interface State | ${dut2} | ${dut2_if2} | up
+| | All Vpp Interfaces Ready Wait | ${nodes}
+| | ...
+| | IP addresses are set on interfaces | ${dut1} | ${dut1_if1} | 10.0.0.1 | 20
+| | IP addresses are set on interfaces | ${dut1} | ${dut1_if2} | 11.0.0.1 | 20
+| | IP addresses are set on interfaces | ${dut2} | ${dut2_if1} | 11.0.0.2 | 20
+| | IP addresses are set on interfaces | ${dut2} | ${dut2_if2} | 12.0.0.1 | 20
+| | ...
+| | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
+| | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
+| | ${dut1_if2_mac}= | Get Interface MAC | ${dut1} | ${dut1_if2}
+| | ${dut2_if1_mac}= | Get Interface MAC | ${dut2} | ${dut2_if1}
+| | ...
+| | Add arp on dut | ${dut1} | ${dut1_if1} | 10.0.0.2 | ${tg_if1_mac}
+| | Add arp on dut | ${dut1} | ${dut1_if2} | 11.0.0.2 | ${dut2_if1_mac}
+| | Add arp on dut | ${dut2} | ${dut2_if1} | 11.0.0.1 | ${dut1_if2_mac}
+| | Add arp on dut | ${dut2} | ${dut2_if2} | 12.0.0.2 | ${tg_if2_mac}
+| | ...
+| | Vpp Route Add | ${dut1} | 12.0.0.2 | 32 | 11.0.0.2 | ${dut1_if2}
+| | Vpp Route Add | ${dut1} | 20.0.0.0 | 18 | 10.0.0.2 | ${dut1_if1}
+| | Vpp Route Add | ${dut2} | 12.0.0.0 | 24 | 12.0.0.2 | ${dut2_if2}
+| | Vpp Route Add | ${dut2} | 200.0.0.0 | 30 | 11.0.0.1 | ${dut2_if1}
+| | ...
+| | Set inside and outside interfaces | ${dut1} | ${dut1_if1} | ${dut1_if2}
+| | Set deterministic mode for SNAT | ${dut1} | 20.0.0.0 | 18 | 200.0.0.0 | 30
+
| DPDK 2-node Performance Suite Setup with DUT's NIC model
| | [Documentation]
| | ... | Updates interfaces on all nodes and setup global
diff --git a/resources/libraries/robot/snat.robot b/resources/libraries/robot/snat.robot
new file mode 100644
index 0000000000..12c7a71369
--- /dev/null
+++ b/resources/libraries/robot/snat.robot
@@ -0,0 +1,150 @@
+# Copyright (c) 2017 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.
+
+*** Settings ***
+| Library | resources.libraries.python.SNATUtil
+| Library | resources.libraries.python.NAT.NATUtil
+| Documentation | Keywords for SNAT feature in VPP.
+
+*** Keywords ***
+| Set inside and outside interfaces
+| | [Documentation] | Set inside and outside interfaces for SNAT.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to set SNAT interfaces on. Type: dictionary
+| | ... | - int_in - Inside interface. Type: string
+| | ... | - int_out - Outside interface. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set inside and outside interfaces \| ${nodes['DUT1']} \
+| | ... | \| FortyGigabitEtherneta/0/0 \| FortyGigabitEtherneta/0/1 \|
+| | ...
+| | [Arguments] | ${node} | ${int_in} | ${int_out}
+| | ...
+| | ${int_in_name}= | Set variable | ${node['interfaces']['${int_in}']['name']}
+| | ${int_out_name}= | Set variable | ${node['interfaces']['${int_out}']['name']}
+| | Set SNAT Interfaces | ${node} | ${int_in_name} | ${int_out_name}
+
+| Set deterministic mode for SNAT
+| | [Documentation] | Set deterministic behaviour of SNAT.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to set deterministic mode for SNAT on.
+| | ... | Type: dictionary
+| | ... | - ip_in - Inside IP. Type: string
+| | ... | - subnet_in - Inside IP subnet. Type: string
+| | ... | - ip_out - Outside IP. Type: string
+| | ... | - subnet_out - Outside IP subnet. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set deterministic mode for SNAT \| ${nodes['DUT1']} \
+| | ... | \| 100.0.0.0 \| 12 \| 12.1.1.0 \| 24 \|
+| | ...
+| | [Arguments] | ${node} | ${ip_in} | ${subnet_in} | ${ip_out} | ${subnet_out}
+| | ...
+| | Set SNAT deterministic | ${node} | ${ip_in} | ${subnet_in} | ${ip_out}
+| | ... | ${subnet_out}
+
+| Set workers for SNAT
+| | [Documentation] | Set workers for SNAT.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to set SNAT workers on. Type: dictionary
+| | ... | - lcores - list of cores, format: range e.g. 1-5 or list of ranges \
+| | ... | e.g.: 1-5,18-22. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set workers for SNAT \| ${nodes['DUT1']} \| 12-23,36-47 \|
+| | ...
+| | [Arguments] | ${node} | ${lcores}
+| | ...
+| | Set SNAT workers | ${node} | ${lcores}
+
+| Show SNAT verbose
+| | [Documentation] | Get the SNAT settings on the node.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to show SNAT. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Show SNAT verbose \| ${nodes['DUT1']} \|
+| | ...
+| | [Arguments] | ${node}
+| | ...
+| | Show SNAT | ${node}
+
+| Get SNAT deterministic forward
+| | [Documentation] | Show forward IP address and port(s).
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to get SNAT deterministic forward on.
+| | ... | Type: dictionary
+| | ... | - ip - IP address. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Get SNAT deterministic forward \| ${nodes['DUT1']} \| 10.0.0.2 \|
+| | ...
+| | [Arguments] | ${node} | ${ip}
+| | ...
+| | Show SNAT deterministic forward | ${node} | ${ip}
+
+| Get SNAT deterministic reverse
+| | [Documentation] | Show reverse IP address.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to get SNAT deterministic reverse on.
+| | ... | Type: dictionary
+| | ... | - ip - IP address. Type: string
+| | ... | - port - Port. Type: string or integer
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Get SNAT deterministic reverse \| ${nodes['DUT1']} \| 10.0.0.2 \
+| | ... | \| 1025 \|
+| | ...
+| | [Arguments] | ${node} | ${ip} | ${port}
+| | ...
+| | Show SNAT deterministic reverse | ${node} | ${ip} | ${port}
+
+| Get NAT interfaces
+| | [Documentation] | Get list of interfaces configured with NAT from VPP node.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to get SNAT interfaces on. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Get NAT interfaces \| ${nodes['DUT1']} \|
+| | ...
+| | [Arguments] | ${node}
+| | ...
+| | VPP get NAT interfaces | ${node}
+
+| Get NAT static mappings
+| | [Documentation] | Get NAT static mappings from VPP node.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - DUT node to get SNAT static mappings on. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Get NAT static mappings \| ${nodes['DUT1']} \|
+| | ...
+| | [Arguments] | ${node}
+| | ...
+| | VPP get NAT static mappings | ${node}
diff --git a/resources/templates/vat/snat/snat_deterministic_forward.vat b/resources/templates/vat/snat/snat_deterministic_forward.vat
new file mode 100644
index 0000000000..3bb7b2b1f9
--- /dev/null
+++ b/resources/templates/vat/snat/snat_deterministic_forward.vat
@@ -0,0 +1 @@
+exec snat deterministic forward {ip} \ No newline at end of file
diff --git a/resources/templates/vat/snat/snat_deterministic_reverse.vat b/resources/templates/vat/snat/snat_deterministic_reverse.vat
new file mode 100644
index 0000000000..1b9ac5bac5
--- /dev/null
+++ b/resources/templates/vat/snat/snat_deterministic_reverse.vat
@@ -0,0 +1 @@
+exec snat deterministic reverse {ip}:{port} \ No newline at end of file
diff --git a/resources/templates/vat/snat/snat_set_deterministic.vat b/resources/templates/vat/snat/snat_set_deterministic.vat
new file mode 100644
index 0000000000..200ae69008
--- /dev/null
+++ b/resources/templates/vat/snat/snat_set_deterministic.vat
@@ -0,0 +1 @@
+exec snat deterministic add in {ip_in}/{subnet_in} out {ip_out}/{subnet_out} \ No newline at end of file
diff --git a/resources/templates/vat/snat/snat_set_interfaces.vat b/resources/templates/vat/snat/snat_set_interfaces.vat
new file mode 100644
index 0000000000..905c219ca3
--- /dev/null
+++ b/resources/templates/vat/snat/snat_set_interfaces.vat
@@ -0,0 +1 @@
+exec set interface snat in {int_in} out {int_out} \ No newline at end of file
diff --git a/resources/templates/vat/snat/snat_set_workers.vat b/resources/templates/vat/snat/snat_set_workers.vat
new file mode 100644
index 0000000000..23e8bac3eb
--- /dev/null
+++ b/resources/templates/vat/snat/snat_set_workers.vat
@@ -0,0 +1 @@
+exec set snat workers {lcores} \ No newline at end of file
diff --git a/resources/templates/vat/snat/snat_show_snat.vat b/resources/templates/vat/snat/snat_show_snat.vat
new file mode 100644
index 0000000000..0ce9f1e914
--- /dev/null
+++ b/resources/templates/vat/snat/snat_show_snat.vat
@@ -0,0 +1 @@
+exec show snat verbose \ No newline at end of file
diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py
index 504ef50eef..ae8d187670 100755
--- a/resources/tools/t-rex/t-rex-stateless.py
+++ b/resources/tools/t-rex/t-rex-stateless.py
@@ -172,12 +172,13 @@ def create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size):
return (stream1, stream2, lat_stream1, lat_stream2)
+
def create_streams(traffic_options, frame_size=64):
"""Create two IP packets to be used in stream.
:param traffic_options: Parameters for packets.
:param frame_size: Size of L2 frame.
- :type traffic_options: list
+ :type traffic_options: dict
:type frame_size: int
:return: Packet instances.
:rtype: Tuple of STLPktBuilder
@@ -197,13 +198,91 @@ def create_streams(traffic_options, frame_size=64):
p1_dst_end_ip = traffic_options['p1_dst_end_ip']
p2_dst_end_ip = traffic_options['p2_dst_end_ip']
- base_pkt_a = Ether()/IP(src=p1_src_start_ip, dst=p1_dst_start_ip, proto=61)
- base_pkt_b = Ether()/IP(src=p2_src_start_ip, dst=p2_dst_start_ip, proto=61)
+ try:
+ p1_src_start_udp_port = traffic_options['p1_src_start_udp_port']
+ p1_src_end_udp_port = traffic_options['p1_src_end_udp_port']
+ p1_dst_start_udp_port = traffic_options['p1_dst_start_udp_port']
+ p2_src_start_udp_port = traffic_options['p2_src_start_udp_port']
+ p2_dst_start_udp_port = traffic_options['p2_dst_start_udp_port']
+ p2_dst_end_udp_port = traffic_options['p2_dst_end_udp_port']
+ ports_defined = True
+ except KeyError:
+ ports_defined = False
+
+ if ports_defined:
+ base_pkt_a = (Ether() /
+ IP(src=p1_src_start_ip, dst=p1_dst_start_ip, proto=17) /
+ UDP(sport=int(p1_src_start_udp_port),
+ dport=int(p1_dst_start_udp_port)))
+ base_pkt_b = (Ether() /
+ IP(src=p2_src_start_ip, dst=p2_dst_start_ip, proto=17) /
+ UDP(sport=int(p2_src_start_udp_port),
+ dport=int(p2_dst_start_udp_port)))
+ else:
+ base_pkt_a = Ether() / IP(src=p1_src_start_ip, dst=p1_dst_start_ip,
+ proto=61)
+ base_pkt_b = Ether() / IP(src=p2_src_start_ip, dst=p2_dst_start_ip,
+ proto=61)
# The following code applies raw instructions to packet (IP src/dst
# increment). It splits the generated traffic by "ip_src"/"ip_dst" variable
# to cores and fix IPv4 header checksum.
- if p1_dst_end_ip and p2_dst_end_ip:
+ if ports_defined:
+ if p1_src_start_udp_port != p1_src_end_udp_port and \
+ p1_src_start_ip != p1_src_end_ip:
+ vm1 = STLScVmRaw([
+ STLVmTupleGen(ip_min=p1_src_start_ip,
+ ip_max=p1_src_end_ip,
+ port_min=int(p1_src_start_udp_port),
+ port_max=int(p1_src_end_udp_port),
+ name="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ vm2 = STLScVmRaw([
+ STLVmTupleGen(ip_min=p2_dst_start_ip,
+ ip_max=p2_dst_start_ip,
+ port_min=int(p2_dst_start_udp_port),
+ port_max=int(p2_dst_end_udp_port),
+ name="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.dport")
+ ])
+ elif p1_src_start_udp_port != p1_src_end_udp_port:
+ vm1 = STLScVmRaw([
+ STLVmFlowVar(name="sport",
+ min_value=int(p1_src_start_udp_port),
+ max_value=int(p1_src_end_udp_port),
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="sport", pkt_offset="UDP.sport")
+ ])
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=int(p2_dst_start_udp_port),
+ max_value=int(p2_dst_end_udp_port),
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="UDP.dport")
+ ])
+ elif p1_src_start_udp_port == p1_src_end_udp_port:
+ vm1 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=p1_src_start_ip,
+ max_value=p1_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src",
+ pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ ], split_by_field="src")
+ vm2 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=p2_src_start_ip,
+ max_value=p2_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src",
+ pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ ], split_by_field="src")
+ elif p1_dst_end_ip and p2_dst_end_ip:
vm1 = STLScVmRaw([STLVmFlowVar(name="dst",
min_value=p1_dst_start_ip,
max_value=p1_dst_end_ip,
@@ -524,6 +603,7 @@ def parse_args():
# help="Port 1 source MAC address")
# parser.add_argument("--p1_dst_mac",
# help="Port 1 destination MAC address")
+
parser.add_argument("--p1_src_start_ip", required=True,
help="Port 1 source start IP address")
parser.add_argument("--p1_src_end_ip",
@@ -534,10 +614,26 @@ def parse_args():
parser.add_argument("--p1_dst_end_ip",
default=False,
help="Port 1 destination end IP address")
+
+ parser.add_argument("--p1_src_start_udp_port",
+ default=None,
+ help="Port 1 source start UDP port.")
+ parser.add_argument("--p1_src_end_udp_port",
+ default=None,
+ help="Port 1 source end UDP port.")
+
+ parser.add_argument("--p1_dst_start_udp_port",
+ default=None,
+ help="Port 1 destination start UDP port.")
+ parser.add_argument("--p1_dst_end_udp_port",
+ default=None,
+ help="Port 1 destination end UDP port.")
+
# parser.add_argument("--p2_src_mac",
# help="Port 2 source MAC address")
# parser.add_argument("--p2_dst_mac",
# help="Port 2 destination MAC address")
+
parser.add_argument("--p2_src_start_ip", required=True,
help="Port 2 source start IP address")
parser.add_argument("--p2_src_end_ip",
@@ -549,6 +645,20 @@ def parse_args():
default=False,
help="Port 2 destination end IP address")
+ parser.add_argument("--p2_src_start_udp_port",
+ default=None,
+ help="Port 2 source start UDP port.")
+ parser.add_argument("--p2_src_end_udp_port",
+ default=None,
+ help="Port 2 source end UDP port.")
+
+ parser.add_argument("--p2_dst_start_udp_port",
+ default=None,
+ help="Port 2 destination start UDP port.")
+ parser.add_argument("--p2_dst_end_udp_port",
+ default=None,
+ help="Port 2 destination end UDP port.")
+
return parser.parse_args()