From ac8b7ce3b05805a978b8186440e62dcd0d9023c3 Mon Sep 17 00:00:00 2001 From: selias Date: Wed, 21 Sep 2016 10:52:31 +0200 Subject: CSIT-235: Switched Port Analyzer mirroring (SPAN) - IPv4 - add library for SPAN setup - add telemetry traffic script and a keyword to run it - add "telemetry" folders for python and robot libraries - move IPFIX libraries to these new folders - add first SPAN test case, mirroring IPv4 ICMP packets Change-Id: Ibca35f724c13662bf80dce2d7e2649d1a0b8676a Signed-off-by: selias --- resources/libraries/python/IPFIXSetup.py | 129 --------------------- resources/libraries/python/IPFIXUtil.py | 107 ----------------- resources/libraries/python/telemetry/IPFIXSetup.py | 129 +++++++++++++++++++++ resources/libraries/python/telemetry/IPFIXUtil.py | 107 +++++++++++++++++ resources/libraries/python/telemetry/SPAN.py | 48 ++++++++ resources/libraries/python/telemetry/__init__.py | 12 ++ resources/libraries/robot/ipfix.robot | 111 ------------------ resources/libraries/robot/telemetry/ipfix.robot | 111 ++++++++++++++++++ resources/libraries/robot/telemetry/span.robot | 56 +++++++++ 9 files changed, 463 insertions(+), 347 deletions(-) delete mode 100644 resources/libraries/python/IPFIXSetup.py delete mode 100644 resources/libraries/python/IPFIXUtil.py create mode 100644 resources/libraries/python/telemetry/IPFIXSetup.py create mode 100644 resources/libraries/python/telemetry/IPFIXUtil.py create mode 100644 resources/libraries/python/telemetry/SPAN.py create mode 100644 resources/libraries/python/telemetry/__init__.py delete mode 100644 resources/libraries/robot/ipfix.robot create mode 100644 resources/libraries/robot/telemetry/ipfix.robot create mode 100644 resources/libraries/robot/telemetry/span.robot (limited to 'resources/libraries') diff --git a/resources/libraries/python/IPFIXSetup.py b/resources/libraries/python/IPFIXSetup.py deleted file mode 100644 index f0f35f3bc6..0000000000 --- a/resources/libraries/python/IPFIXSetup.py +++ /dev/null @@ -1,129 +0,0 @@ -# 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. - -"""IPFIX setup library""" - -from resources.libraries.python.topology import Topology -from resources.libraries.python.VatExecutor import VatTerminal - - -class IPFIXSetup(object): - """Class contains methods for seting up IPFIX reporting on DUTs.""" - - def __init__(self): - """Initializer.""" - pass - - @staticmethod - def setup_ipfix_exporter(node, collector, source, fib=None, mtu=None, - interval=None): - """Setup an IPFIX exporter on node to export collected flow data. - - :param node: DUT node. - :param collector: IP address of flow data collector. - :param source: IP address of local interface to send flow data from. - :param fib: fib table ID. - :param mtu: Maximum transfer unit of path to collector. - :param interval: Frequency of sending template packets, in seconds. - :type node: dict - :type collector: str - :type source: str - :type fib: int - :type mtu: int - :type interval: int - """ - - fib = "vrf_id {0}".format(fib) if fib else '' - mtu = "path_mtu {0}".format(mtu) if mtu else '' - interval = "template_interval {0}".format(interval) if interval else '' - - with VatTerminal(node, json_param=False) as vat: - vat.vat_terminal_exec_cmd_from_template('ipfix_exporter_set.vat', - collector=collector, - source=source, - fib=fib, - mtu=mtu, - interval=interval) - - @staticmethod - def assign_interface_to_flow_table(node, interface, table_id, - ip_version='ip4'): - """Assigns a VPP interface to the specified classify table for IPFIX - flow data collection. - - :param node: DUT node. - :param interface: An interface on the DUT node. - :param table_id: ID of a classify table. - :param ip_version: Version of IP protocol. Valid options are ip4, ip6. - :type node: dict - :type interface: str or int - :type table_id: int - :type ip_version: str - """ - - if isinstance(interface, basestring): - sw_if_index = Topology.get_interface_sw_index(node, interface) - elif isinstance(interface, int): - sw_if_index = interface - else: - raise TypeError - - table = "{0}-table {1}".format(ip_version, table_id) - - with VatTerminal(node, json_param=False) as vat: - vat.vat_terminal_exec_cmd_from_template( - "ipfix_interface_enable.vat", - interface=sw_if_index, - table=table, - delete='') - - @staticmethod - def set_ipfix_stream(node, domain=None, src_port=None): - """Set an IPFIX export stream. Can be used to break up IPFIX reports - into separate reporting domains. - - :param node: DUT node. - :param domain: Desired index number of exporting domain. - :param src_port: Source port to use when sending IPFIX packets. Default - is the standard IPFIX port 4739. - :type node: dict - :type domain: int - :type src_port: int - """ - - domain = "domain {0}".format(domain) if domain else '' - src_port = "src_port {0}".format(src_port) if src_port else '' - - with VatTerminal(node, json_param=False) as vat: - vat.vat_terminal_exec_cmd_from_template("ipfix_stream_set.vat", - domain=domain, - src_port=src_port) - - @staticmethod - def assign_classify_table_to_exporter(node, table_id, ip_version='ip4'): - """Assign a classify table to an IPFIX exporter. Classified packets will - be included in the IPFIX flow report. - - :param node: DUT node. - :param table_id: ID of a classify table. - :param ip_version: Version of IP protocol. Valid options are ip4, ip6. - :type node: dict - :type table_id: int - :type ip_version: str - """ - - with VatTerminal(node, json_param=False) as vat: - vat.vat_terminal_exec_cmd_from_template("ipfix_table_add.vat", - table=table_id, - ip_version=ip_version, - add_del='add') diff --git a/resources/libraries/python/IPFIXUtil.py b/resources/libraries/python/IPFIXUtil.py deleted file mode 100644 index 1b193f8325..0000000000 --- a/resources/libraries/python/IPFIXUtil.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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. - -"""IPFIX utilities library. Provides classes that allow scapy to work -with IPFIX packets. - - Note: - Template and data sets in one packet are not supported. - Option template sets (Set_ID = 3) are not supported. - """ - - -from scapy.all import Packet, bind_layers -from scapy.fields import ByteField, ShortField, IntField, LongField, IPField,\ - StrFixedLenField, FieldListField -from scapy.layers.inet import UDP -from scapy.layers.inet6 import IP6Field -from scapy.contrib.ppi_geotag import UTCTimeField - - -class IPFIXHandler(object): - """Class for handling IPFIX packets. To use, create instance of class before - dissecting IPFIX packets with scapy, then run update_template every time - an IPFIX template packet is received.""" - - template_elements = { - 4: ByteField("Protocol_ID", 0x00), - 7: ShortField("src_port", 0), - 8: IPField("IPv4_src", ""), - 11: ShortField("dst_port", 0), - 12: IPField("IPv4_dst", ""), - 27: IP6Field("IPv6_src", "::"), - 28: IP6Field("IPv6_dst", "::"), - 86: LongField("packetTotalCount", 0), - 180: ShortField("udp_src_port", 0), - 181: ShortField("udp_dst_port", 0), - 182: ShortField("tcp_src_port", 0), - 183: ShortField("tcp_dst_port", 0), - 193: ByteField("Next_header", 0x00) - } - - def __init__(self): - """Initializer, registers IPFIX header and template layers with scapy. - """ - bind_layers(UDP, IPFIXHeader, dport=4739) - bind_layers(IPFIXHeader, IPFIXTemplate, Set_ID=2) - - def update_template(self, packet): - """Updates IPFIXData class with new data template. Registers IPFIX data - layer with scapy using the new template. - - :param packet: Packet containing an IPFIX template. - :type packet: scapy.Ether - """ - template_list = packet['IPFIX template'].Template - template_id = packet['IPFIX template'].Template_ID - - IPFIXData.fields_desc = [] - for item in template_list[::2]: - try: - IPFIXData.fields_desc.append(self.template_elements[item]) - except KeyError: - raise KeyError( - "Unknown IPFIX template element with ID {0}".format(item)) - bind_layers(IPFIXHeader, IPFIXData, Set_ID=template_id) - # if the packet doesn't end here, assume it contains more data sets - bind_layers(IPFIXData, IPFIXData) - - -class IPFIXHeader(Packet): - """Class for IPFIX header.""" - name = "IPFIX header" - fields_desc = [StrFixedLenField("Version", 0x000a, length=2), - ShortField("Message Length", 0), - UTCTimeField("Timestamp(UTC)", ""), - IntField("Sequence Number", 0), - IntField("Observation Domain ID", 0), - ShortField("Set_ID", 0), - ShortField("Set_Length", 0) - ] - - -class IPFIXTemplate(Packet): - """Class for IPFIX template layer.""" - name = "IPFIX template" - fields_desc = [ShortField("Template_ID", 256), - ShortField("nFields", 2), - FieldListField("Template", [], ShortField("type_len", ""), - count_from=lambda p: p.nFields*2) - ] - - -class IPFIXData(Packet): - """Class for IPFIX data layer. Needs to be updated with - a template before use.""" - name = "IPFIX flow data" - fields_desc = [] diff --git a/resources/libraries/python/telemetry/IPFIXSetup.py b/resources/libraries/python/telemetry/IPFIXSetup.py new file mode 100644 index 0000000000..f0f35f3bc6 --- /dev/null +++ b/resources/libraries/python/telemetry/IPFIXSetup.py @@ -0,0 +1,129 @@ +# 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. + +"""IPFIX setup library""" + +from resources.libraries.python.topology import Topology +from resources.libraries.python.VatExecutor import VatTerminal + + +class IPFIXSetup(object): + """Class contains methods for seting up IPFIX reporting on DUTs.""" + + def __init__(self): + """Initializer.""" + pass + + @staticmethod + def setup_ipfix_exporter(node, collector, source, fib=None, mtu=None, + interval=None): + """Setup an IPFIX exporter on node to export collected flow data. + + :param node: DUT node. + :param collector: IP address of flow data collector. + :param source: IP address of local interface to send flow data from. + :param fib: fib table ID. + :param mtu: Maximum transfer unit of path to collector. + :param interval: Frequency of sending template packets, in seconds. + :type node: dict + :type collector: str + :type source: str + :type fib: int + :type mtu: int + :type interval: int + """ + + fib = "vrf_id {0}".format(fib) if fib else '' + mtu = "path_mtu {0}".format(mtu) if mtu else '' + interval = "template_interval {0}".format(interval) if interval else '' + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template('ipfix_exporter_set.vat', + collector=collector, + source=source, + fib=fib, + mtu=mtu, + interval=interval) + + @staticmethod + def assign_interface_to_flow_table(node, interface, table_id, + ip_version='ip4'): + """Assigns a VPP interface to the specified classify table for IPFIX + flow data collection. + + :param node: DUT node. + :param interface: An interface on the DUT node. + :param table_id: ID of a classify table. + :param ip_version: Version of IP protocol. Valid options are ip4, ip6. + :type node: dict + :type interface: str or int + :type table_id: int + :type ip_version: str + """ + + if isinstance(interface, basestring): + sw_if_index = Topology.get_interface_sw_index(node, interface) + elif isinstance(interface, int): + sw_if_index = interface + else: + raise TypeError + + table = "{0}-table {1}".format(ip_version, table_id) + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template( + "ipfix_interface_enable.vat", + interface=sw_if_index, + table=table, + delete='') + + @staticmethod + def set_ipfix_stream(node, domain=None, src_port=None): + """Set an IPFIX export stream. Can be used to break up IPFIX reports + into separate reporting domains. + + :param node: DUT node. + :param domain: Desired index number of exporting domain. + :param src_port: Source port to use when sending IPFIX packets. Default + is the standard IPFIX port 4739. + :type node: dict + :type domain: int + :type src_port: int + """ + + domain = "domain {0}".format(domain) if domain else '' + src_port = "src_port {0}".format(src_port) if src_port else '' + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template("ipfix_stream_set.vat", + domain=domain, + src_port=src_port) + + @staticmethod + def assign_classify_table_to_exporter(node, table_id, ip_version='ip4'): + """Assign a classify table to an IPFIX exporter. Classified packets will + be included in the IPFIX flow report. + + :param node: DUT node. + :param table_id: ID of a classify table. + :param ip_version: Version of IP protocol. Valid options are ip4, ip6. + :type node: dict + :type table_id: int + :type ip_version: str + """ + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template("ipfix_table_add.vat", + table=table_id, + ip_version=ip_version, + add_del='add') diff --git a/resources/libraries/python/telemetry/IPFIXUtil.py b/resources/libraries/python/telemetry/IPFIXUtil.py new file mode 100644 index 0000000000..1b193f8325 --- /dev/null +++ b/resources/libraries/python/telemetry/IPFIXUtil.py @@ -0,0 +1,107 @@ +# 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. + +"""IPFIX utilities library. Provides classes that allow scapy to work +with IPFIX packets. + + Note: + Template and data sets in one packet are not supported. + Option template sets (Set_ID = 3) are not supported. + """ + + +from scapy.all import Packet, bind_layers +from scapy.fields import ByteField, ShortField, IntField, LongField, IPField,\ + StrFixedLenField, FieldListField +from scapy.layers.inet import UDP +from scapy.layers.inet6 import IP6Field +from scapy.contrib.ppi_geotag import UTCTimeField + + +class IPFIXHandler(object): + """Class for handling IPFIX packets. To use, create instance of class before + dissecting IPFIX packets with scapy, then run update_template every time + an IPFIX template packet is received.""" + + template_elements = { + 4: ByteField("Protocol_ID", 0x00), + 7: ShortField("src_port", 0), + 8: IPField("IPv4_src", ""), + 11: ShortField("dst_port", 0), + 12: IPField("IPv4_dst", ""), + 27: IP6Field("IPv6_src", "::"), + 28: IP6Field("IPv6_dst", "::"), + 86: LongField("packetTotalCount", 0), + 180: ShortField("udp_src_port", 0), + 181: ShortField("udp_dst_port", 0), + 182: ShortField("tcp_src_port", 0), + 183: ShortField("tcp_dst_port", 0), + 193: ByteField("Next_header", 0x00) + } + + def __init__(self): + """Initializer, registers IPFIX header and template layers with scapy. + """ + bind_layers(UDP, IPFIXHeader, dport=4739) + bind_layers(IPFIXHeader, IPFIXTemplate, Set_ID=2) + + def update_template(self, packet): + """Updates IPFIXData class with new data template. Registers IPFIX data + layer with scapy using the new template. + + :param packet: Packet containing an IPFIX template. + :type packet: scapy.Ether + """ + template_list = packet['IPFIX template'].Template + template_id = packet['IPFIX template'].Template_ID + + IPFIXData.fields_desc = [] + for item in template_list[::2]: + try: + IPFIXData.fields_desc.append(self.template_elements[item]) + except KeyError: + raise KeyError( + "Unknown IPFIX template element with ID {0}".format(item)) + bind_layers(IPFIXHeader, IPFIXData, Set_ID=template_id) + # if the packet doesn't end here, assume it contains more data sets + bind_layers(IPFIXData, IPFIXData) + + +class IPFIXHeader(Packet): + """Class for IPFIX header.""" + name = "IPFIX header" + fields_desc = [StrFixedLenField("Version", 0x000a, length=2), + ShortField("Message Length", 0), + UTCTimeField("Timestamp(UTC)", ""), + IntField("Sequence Number", 0), + IntField("Observation Domain ID", 0), + ShortField("Set_ID", 0), + ShortField("Set_Length", 0) + ] + + +class IPFIXTemplate(Packet): + """Class for IPFIX template layer.""" + name = "IPFIX template" + fields_desc = [ShortField("Template_ID", 256), + ShortField("nFields", 2), + FieldListField("Template", [], ShortField("type_len", ""), + count_from=lambda p: p.nFields*2) + ] + + +class IPFIXData(Packet): + """Class for IPFIX data layer. Needs to be updated with + a template before use.""" + name = "IPFIX flow data" + fields_desc = [] diff --git a/resources/libraries/python/telemetry/SPAN.py b/resources/libraries/python/telemetry/SPAN.py new file mode 100644 index 0000000000..7933898c02 --- /dev/null +++ b/resources/libraries/python/telemetry/SPAN.py @@ -0,0 +1,48 @@ +# 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. + +"""SPAN setup library""" + +from resources.libraries.python.topology import Topology +from resources.libraries.python.VatExecutor import VatTerminal + + +# pylint: disable=too-few-public-methods +class SPAN(object): + """Class contains methods for setting up SPAN mirroring on DUTs.""" + + def __init__(self): + """Initializer.""" + pass + + @staticmethod + def set_span_mirroring(node, src_if, dst_if): + """Set Span mirroring on the specified node. + + :param node: DUT node. + :param src_if: Interface to mirror traffic from. + :param dst_if: Interface to mirror traffic to. + :type node: dict + :type src_if: str + :type dst_if: str + """ + + src_if = Topology.get_interface_name(node, src_if) + dst_if = Topology.get_interface_name(node, dst_if) + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template('span_create.vat', + src_if=src_if, + dst_if=dst_if, + ) + # TODO: Update "span_create.vat" to use VAT command, once available diff --git a/resources/libraries/python/telemetry/__init__.py b/resources/libraries/python/telemetry/__init__.py new file mode 100644 index 0000000000..5a0e0e1c5e --- /dev/null +++ b/resources/libraries/python/telemetry/__init__.py @@ -0,0 +1,12 @@ +# 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. diff --git a/resources/libraries/robot/ipfix.robot b/resources/libraries/robot/ipfix.robot deleted file mode 100644 index d8840a5261..0000000000 --- a/resources/libraries/robot/ipfix.robot +++ /dev/null @@ -1,111 +0,0 @@ -# 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. - -"""Traffic keywords""" - -*** Settings *** -| Library | resources.libraries.python.TrafficScriptExecutor -| Library | resources.libraries.python.InterfaceUtil -| Resource | resources/libraries/robot/default.robot -| Documentation | Traffic keywords - -*** Keywords *** -| Send packets and verify IPFIX -| | [Documentation] | Send simple TCP or UDP packets from source interface\ -| | ... | to destination interface. Listen for IPFIX flow report on source\ -| | ... | interface and verify received report against number of packets sent. -| | ... -| | ... | *Arguments:* -| | ... -| | ... | - tg_node - TG node. Type: dictionary -| | ... | - dst_node - Destination node. Type: dictionary -| | ... | - src_int - Source interface. Type: string -| | ... | - dst_int - Destination interface. Type: string -| | ... | - src_ip - Source IP address. Type: string -| | ... | - dst_ip - Destination IP address. Type: string -| | ... | - protocol - TCP or UDP (Optional, default is TCP). Type: string -| | ... | - port - Source and destination ports to use -| | ... | (Optional, default is port 20). Type: integer -| | ... | - count - Number of packets to send -| | ... | (Optional, default is one packet). Type: integer -| | ... | - timeout - Timeout value in seconds (Optional, default is 10 sec). -| | ... | Should be at least twice the configured IPFIX flow report interval. -| | ... | Type: integer -| | ... -| | ... | *Return:* -| | ... -| | ... | - No value returned -| | ... -| | ... | *Example:* -| | ... -| | ... | \| Send packets and verify IPFIX \| ${nodes['TG']} | ${nodes['DUT1']}\ -| | ... | \| eth1 \| GigabitEthernet0/8/0 \| 16.0.0.1 \| 192.168.0.2 \| UDP \ -| | ... | \| ${20} \| ${5} \| ${10} \| -| | ... | -| | [Arguments] | ${tg_node} | ${dst_node} | ${src_int} | ${dst_int} | -| | ... | ${src_ip} | ${dst_ip} | ${protocol}=tcp | ${port}=20 | ${count}=1 -| | ... | ${timeout}=${10} -| | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int} -| | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_int} -| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int} -| | ${dst_int_name}= | Get interface name | ${dst_node} | ${dst_int} -| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} -| | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip} -| | ${args}= | Set Variable -| | ... | ${args} --protocol ${protocol} --port ${port} --count ${count} -| | Run Traffic Script On Node | ipfix_check.py | ${tg_node} | ${args} -| | ... | ${timeout} - -| Send session sweep and verify IPFIX -| | [Documentation] | Send simple TCP or UDP packets from source interface\ -| | ... | to destination interface using a range of source addresses. Listen\ -| | ... | for IPFIX flow report on source interface and verify received report\ -| | ... | against number of packets sent from each source address. -| | ... -| | ... | *Arguments:* -| | ... -| | ... | - tg_node - TG node. Type: dictionary -| | ... | - dst_node - Destination node. Type: dictionary -| | ... | - src_int - Source interface. Type: string -| | ... | - dst_int - Destination interface. Type: string -| | ... | - src_ip - Source IP address. Type: string -| | ... | - dst_ip - Destination IP address. Type: string -| | ... | - ip_range - Number of sequential source addresses. Type:integer -| | ... | - protocol - TCP or UDP (Optional, defaults to TCP). Type: string -| | ... | - port - Source and destination ports to use (Optional). Type: integer -| | ... | - count - Number of packets to send (Optional). Type: integer -| | ... | - timeout - Timeout value in seconds (optional). Type:integer -| | ... -| | ... | *Return:* -| | ... -| | ... | - No value returned -| | ... -| | ... | *Example:* -| | ... -| | ... | \| Send packets and verify IPFIX \| ${nodes['TG']} | ${nodes['DUT1']}\ -| | ... | \| eth1 \| GigabitEthernet0/8/0 \| 16.0.0.1 \| 192.168.0.2 \| 20 \| -| | ... | UDP \| ${20} \| ${5} \| ${10} \| -| | ... | -| | [Arguments] | ${tg_node} | ${dst_node} | ${src_int} | ${dst_int} | -| | ... | ${src_ip} | ${dst_ip} | ${ip_range} | ${protocol}=tcp | ${port}=20 -| | ... | ${count}=${1} | ${timeout}=${10} -| | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int} -| | ${dst_mac}= | Set Variable | ${dut1_to_tg_mac} -| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int} -| | ${dst_int_name}= | Get interface name | ${dst_node} | ${dst_int} -| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} -| | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip} -| | ${args}= | Set Variable | ${args} --protocol ${protocol} --port ${port} -| | ${args}= | Set Variable | ${args} --count ${count} --sessions ${ip_range} -| | Run Traffic Script On Node | ipfix_sessions.py | ${tg_node} | ${args} -| | ... | ${timeout} \ No newline at end of file diff --git a/resources/libraries/robot/telemetry/ipfix.robot b/resources/libraries/robot/telemetry/ipfix.robot new file mode 100644 index 0000000000..5248964f29 --- /dev/null +++ b/resources/libraries/robot/telemetry/ipfix.robot @@ -0,0 +1,111 @@ +# 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. + +"""IPFIX keywords""" + +*** Settings *** +| Library | resources.libraries.python.TrafficScriptExecutor +| Library | resources.libraries.python.InterfaceUtil +| Resource | resources/libraries/robot/default.robot +| Documentation | Traffic keywords + +*** Keywords *** +| Send packets and verify IPFIX +| | [Documentation] | Send simple TCP or UDP packets from source interface\ +| | ... | to destination interface. Listen for IPFIX flow report on source\ +| | ... | interface and verify received report against number of packets sent. +| | ... +| | ... | *Arguments:* +| | ... +| | ... | - tg_node - TG node. Type: dictionary +| | ... | - dst_node - Destination node. Type: dictionary +| | ... | - src_int - Source interface. Type: string +| | ... | - dst_int - Destination interface. Type: string +| | ... | - src_ip - Source IP address. Type: string +| | ... | - dst_ip - Destination IP address. Type: string +| | ... | - protocol - TCP or UDP (Optional, default is TCP). Type: string +| | ... | - port - Source and destination ports to use +| | ... | (Optional, default is port 20). Type: integer +| | ... | - count - Number of packets to send +| | ... | (Optional, default is one packet). Type: integer +| | ... | - timeout - Timeout value in seconds (Optional, default is 10 sec). +| | ... | Should be at least twice the configured IPFIX flow report interval. +| | ... | Type: integer +| | ... +| | ... | *Return:* +| | ... +| | ... | - No value returned +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Send packets and verify IPFIX \| ${nodes['TG']} | ${nodes['DUT1']}\ +| | ... | \| eth1 \| GigabitEthernet0/8/0 \| 16.0.0.1 \| 192.168.0.2 \| UDP \ +| | ... | \| ${20} \| ${5} \| ${10} \| +| | ... | +| | [Arguments] | ${tg_node} | ${dst_node} | ${src_int} | ${dst_int} | +| | ... | ${src_ip} | ${dst_ip} | ${protocol}=tcp | ${port}=20 | ${count}=1 +| | ... | ${timeout}=${10} +| | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int} +| | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_int} +| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int} +| | ${dst_int_name}= | Get interface name | ${dst_node} | ${dst_int} +| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} +| | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip} +| | ${args}= | Set Variable +| | ... | ${args} --protocol ${protocol} --port ${port} --count ${count} +| | Run Traffic Script On Node | ipfix_check.py | ${tg_node} | ${args} +| | ... | ${timeout} + +| Send session sweep and verify IPFIX +| | [Documentation] | Send simple TCP or UDP packets from source interface\ +| | ... | to destination interface using a range of source addresses. Listen\ +| | ... | for IPFIX flow report on source interface and verify received report\ +| | ... | against number of packets sent from each source address. +| | ... +| | ... | *Arguments:* +| | ... +| | ... | - tg_node - TG node. Type: dictionary +| | ... | - dst_node - Destination node. Type: dictionary +| | ... | - src_int - Source interface. Type: string +| | ... | - dst_int - Destination interface. Type: string +| | ... | - src_ip - Source IP address. Type: string +| | ... | - dst_ip - Destination IP address. Type: string +| | ... | - ip_range - Number of sequential source addresses. Type:integer +| | ... | - protocol - TCP or UDP (Optional, defaults to TCP). Type: string +| | ... | - port - Source and destination ports to use (Optional). Type: integer +| | ... | - count - Number of packets to send (Optional). Type: integer +| | ... | - timeout - Timeout value in seconds (optional). Type:integer +| | ... +| | ... | *Return:* +| | ... +| | ... | - No value returned +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Send packets and verify IPFIX \| ${nodes['TG']} | ${nodes['DUT1']}\ +| | ... | \| eth1 \| GigabitEthernet0/8/0 \| 16.0.0.1 \| 192.168.0.2 \| 20 \| +| | ... | UDP \| ${20} \| ${5} \| ${10} \| +| | ... | +| | [Arguments] | ${tg_node} | ${dst_node} | ${src_int} | ${dst_int} | +| | ... | ${src_ip} | ${dst_ip} | ${ip_range} | ${protocol}=tcp | ${port}=20 +| | ... | ${count}=${1} | ${timeout}=${10} +| | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int} +| | ${dst_mac}= | Set Variable | ${dut1_to_tg_mac} +| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int} +| | ${dst_int_name}= | Get interface name | ${dst_node} | ${dst_int} +| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} +| | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip} +| | ${args}= | Set Variable | ${args} --protocol ${protocol} --port ${port} +| | ${args}= | Set Variable | ${args} --count ${count} --sessions ${ip_range} +| | Run Traffic Script On Node | ipfix_sessions.py | ${tg_node} | ${args} +| | ... | ${timeout} \ No newline at end of file diff --git a/resources/libraries/robot/telemetry/span.robot b/resources/libraries/robot/telemetry/span.robot new file mode 100644 index 0000000000..d994e95e3e --- /dev/null +++ b/resources/libraries/robot/telemetry/span.robot @@ -0,0 +1,56 @@ +# 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. + +*** Settings *** +| Library | resources.libraries.python.TrafficScriptExecutor +| Library | resources.libraries.python.topology.Topology +| Documentation | SPAN traffic keywords + +*** Keywords *** +| Send Packet And Check Received Copies +| | [Documentation] | Sends an ARP or ICMP packet from TG to DUT using one\ +| | ... | link, then receive a copy of both the sent packet and the DUT's reply\ +| | ... | on the second link. +| | ... +| | ... | *Arguments:* +| | ... +| | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary +| | ... | - tx_src_port - First interface on TG. Type: string +| | ... | - tx_src_mac - MAC address of the first interface on TG. Type: string +| | ... | - tx_dst_mac - MAC address of the first interface on DUT. Type: string +| | ... | - rx_port - Second interface on TG. Type: string +| | ... | - src_ip - Packet source IP address. Type: string +| | ... | - dst_ip - Packet destination IP address. Type: string +| | ... | - ptype - Type of payload, ARP or ICMP. Type: string +| | ... +| | ... | *Return:* +| | ... | - No value returned +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Send Packet And Check Received Copies \| ${nodes['TG']} \| eth1 \ +| | ... | \| 8:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \ +| | ... | \| eth3 \| 192.168.0.2 \| 192.168.0.3 \| ARP \| +| | ... +| | [Arguments] | ${tg_node} | ${tx_src_port} +| | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} +| | ... | ${src_ip} | ${dst_ip} | ${ptype} +| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_src_port} +| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port} +| | ${args}= | Catenate +| | ... | --tg_src_mac ${tx_src_mac} --dut_if1_mac ${tx_dst_mac} +| | ... | --src_ip ${src_ip} --dst_ip ${dst_ip} +| | ... | --tx_if ${tx_port_name} --rx_if | ${rx_port_name} +| | ... | --ptype ${ptype} +| | Run Traffic Script On Node | span_check.py | ${tg_node} | +| | ... | ${args} \ No newline at end of file -- cgit 1.2.3-korg