예제 #1
0
 def icmp_packet(self,
                 setup,
                 direction,
                 ptfadapter,
                 ip_version,
                 src_ip=None,
                 dst_ip=None,
                 icmp_type=8,
                 icmp_code=0):
     """Generate an ICMP packet for testing."""
     src_ip = src_ip or DEFAULT_SRC_IP[ip_version]
     dst_ip = dst_ip or self.get_dst_ip(direction, ip_version)
     if ip_version == "ipv4":
         return testutils.simple_icmp_packet(
             eth_dst=setup["destination_mac"][direction][self.src_port],
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ip_dst=dst_ip,
             ip_src=src_ip,
             icmp_type=icmp_type,
             icmp_code=icmp_code,
             ip_ttl=64,
         )
     else:
         return testutils.simple_icmpv6_packet(
             eth_dst=setup["destination_mac"][direction][self.src_port],
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ipv6_dst=dst_ip,
             ipv6_src=src_ip,
             icmp_type=icmp_type,
             icmp_code=icmp_code,
             ipv6_hlim=64,
         )
예제 #2
0
 def icmp_packet(self,
                 setup,
                 direction,
                 ptfadapter,
                 ip_version,
                 src_ip=None,
                 dst_ip=None):
     """Generate an ICMP packet for testing."""
     src_ip = src_ip or DEFAULT_SRC_IP[ip_version]
     dst_ip = dst_ip or self.get_dst_ip(direction, ip_version)
     dst_mac = setup[
         "router_mac"] if direction == "uplink->downlink" else setup[
             "vlan_mac"]
     if ip_version == "ipv4":
         return testutils.simple_icmp_packet(
             eth_dst=dst_mac,
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ip_dst=dst_ip,
             ip_src=src_ip,
             icmp_type=8,
             icmp_code=0,
             ip_ttl=64,
         )
     else:
         return testutils.simple_icmpv6_packet(
             eth_dst=dst_mac,
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ipv6_dst=dst_ip,
             ipv6_src=src_ip,
             icmp_type=8,
             icmp_code=0,
             ipv6_hlim=64,
         )
예제 #3
0
    def setUp(self):
        """
        Fetches all the parameters we need to run the tests.
        """

        self.dataplane = ptf.dataplane_instance

        self.test_params = testutils.test_params_get()
        self.hwsku = self.test_params['hwsku']
        self.asic_type = self.test_params['asic_type']
        self.router_mac = self.test_params['router_mac']
        self.src_port = int(self.test_params['src_port'])
        self.mirror_stage = self.test_params['mirror_stage']
        self.dst_mirror_ports = [
            int(p) for p in self.test_params['dst_mirror_ports'].split(",")
            if p
        ]
        self.dst_ports = [
            int(p) for p in self.test_params['dst_ports'].split(",")
        ]

        self.base_pkt = testutils.simple_arp_packet(
            eth_dst=self.router_mac, eth_src=self.dataplane.get_mac(0, 0))

        self.basev6_pkt = testutils.simple_icmpv6_packet(
            eth_dst=self.router_mac,
            eth_src=self.dataplane.get_mac(0, 0),
            icmp_type=135)

        testutils.add_filter(self.gre_filter)