Exemplo n.º 1
0
def run_test_ipv6(ptfadapter, facts):
    logger.info("Running test with ipv6 packets")

    pkt = testutils.simple_udpv6_packet(eth_dst=facts['src_router_mac'],
                                        eth_src=facts['src_host_mac'],
                                        ipv6_src=facts['dst_host_ipv6'],
                                        ipv6_dst=facts['dst_host_ipv6'],
                                        ipv6_hlim=DEFAULT_HLIM_TTL)
    logger.info("\nSend Packet:\neth_dst: {}, eth_src: {}, ipv6 ip: {}".format(
        facts['src_router_mac'], facts['src_host_mac'],
        facts['dst_host_ipv6']))

    testutils.send(ptfadapter, facts['src_port_ids'][0], pkt)

    exp_pkt = testutils.simple_udpv6_packet(eth_dst=facts['dst_host_mac'],
                                            eth_src=facts['dst_router_mac'],
                                            ipv6_src=facts['dst_host_ipv6'],
                                            ipv6_dst=facts['dst_host_ipv6'],
                                            ipv6_hlim=DEFAULT_HLIM_TTL - 1)
    logger.info(
        "\nExpect Packet:\neth_dst: {}, eth_src: {}, ipv6 ip: {}".format(
            facts['dst_host_mac'], facts['dst_router_mac'],
            facts['dst_host_ipv6']))

    testutils.verify_packet_any_port(ptfadapter,
                                     exp_pkt,
                                     facts['dst_port_ids'],
                                     timeout=WAIT_EXPECTED_PACKET_TIMEOUT)
Exemplo n.º 2
0
def run_test_ipv6(ptfadapter, gather_facts):
    logger.info("Running test with ipv6 packets")
    dst_host_ipv6 = str(
        ip_address(unicode(gather_facts['dst_router_ipv6'])) + 1)

    pkt = testutils.simple_udpv6_packet(eth_dst=gather_facts['src_router_mac'],
                                        eth_src=gather_facts['src_host_mac'],
                                        ipv6_src=dst_host_ipv6,
                                        ipv6_dst=dst_host_ipv6,
                                        ipv6_hlim=DEFAULT_HLIM_TTL)
    logger.info("\nSend Packet:\neth_dst: {}, eth_src: {}, ipv6 ip: {}".format(
        gather_facts['src_router_mac'], gather_facts['src_host_mac'],
        dst_host_ipv6))

    testutils.send(ptfadapter, int(gather_facts['src_port_ids'][0]), pkt)

    pkt = testutils.simple_udpv6_packet(eth_dst=gather_facts['dst_host_mac'],
                                        eth_src=gather_facts['dst_router_mac'],
                                        ipv6_src=dst_host_ipv6,
                                        ipv6_dst=dst_host_ipv6,
                                        ipv6_hlim=DEFAULT_HLIM_TTL - 1)
    logger.info(
        "\nExpect Packet:\neth_dst: {}, eth_src: {}, ipv6 ip: {}".format(
            gather_facts['dst_host_mac'], gather_facts['dst_router_mac'],
            dst_host_ipv6))

    port_list = [int(port) for port in gather_facts['dst_port_ids']]
    testutils.verify_packet_any_port(ptfadapter,
                                     pkt,
                                     port_list,
                                     timeout=WAIT_EXPECTED_PACKET_TIMEOUT)
Exemplo n.º 3
0
 def udp_packet(self,
                setup,
                direction,
                ptfadapter,
                ip_version,
                src_ip=None,
                dst_ip=None,
                sport=1234,
                dport=80):
     """Generate a UDP 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_udp_packet(
             eth_dst=dst_mac,
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ip_dst=dst_ip,
             ip_src=src_ip,
             udp_sport=sport,
             udp_dport=dport,
             ip_ttl=64)
     else:
         return testutils.simple_udpv6_packet(
             eth_dst=dst_mac,
             eth_src=ptfadapter.dataplane.get_mac(0, 0),
             ipv6_dst=dst_ip,
             ipv6_src=src_ip,
             udp_sport=sport,
             udp_dport=dport,
             ipv6_hlim=64)
Exemplo n.º 4
0
    def runTestIpv6(self):
        self.test.log("Run IPv6 based test")

        pkt = simple_udpv6_packet(eth_dst=self.srcRouterMac,
                                  eth_src=self.srcHostMac,
                                  ipv6_src=self.dstHostIpv6,
                                  ipv6_dst=self.dstHostIpv6,
                                  ipv6_hlim=self.pktTtlHlim)
        send(self.test, int(self.srcPortIds[0]), pkt)

        pkt = simple_udpv6_packet(eth_dst=self.dstHostMac,
                                  eth_src=self.dstRouterMac,
                                  ipv6_src=self.dstHostIpv6,
                                  ipv6_dst=self.dstHostIpv6,
                                  ipv6_hlim=self.pktTtlHlim-1)

        verify_packet_any_port(self.test, pkt, [int(port) for port in self.dstPortIds])

        self.test.log("IPv6 based test: done")
Exemplo n.º 5
0
    def contruct_packet(self, port_number):
        src_mac = self.my_mac[port_number]

        packet = testutils.simple_udpv6_packet(
            pktlen=100,
            eth_dst='33:33:00:01:00:02',
            eth_src=src_mac,
            ipv6_src='::1',
            ipv6_dst='ff02::1:2',
            udp_sport=546,
            udp_dport=547
        )

        return packet
Exemplo n.º 6
0
    def _base_udpv6_packet(self,
                           ptfadapter,
                           setup,
                           src_ip=DEFAULT_SRC_IP,
                           dst_ip=DEFAULT_DST_IP,
                           next_header=None,
                           dscp=None,
                           sport=2020,
                           dport=8080):
        pkt = testutils.simple_udpv6_packet(
            eth_src=ptfadapter.dataplane.get_mac(0, 0),
            eth_dst=setup["router_mac"],
            ipv6_src=src_ip,
            ipv6_dst=dst_ip,
            ipv6_dscp=dscp,
            ipv6_hlim=64,
            udp_sport=sport,
            udp_dport=dport,
        )

        if next_header:
            pkt["IPv6"].nh = next_header

        return pkt