def l3IPv6EcmpPacketTest()

in ptf/saihash.py [0:0]


    def l3IPv6EcmpPacketTest(self, hash_dict):
        """
        Function that performs the IPv6 ECMP test with L3 hashed traffic
        Args:
            hash_dict (dict): dictionary with variables that defines the list
            of hash test fields and traffic header hashed fields
        Returns:
            list: list of numbers of packet egressed on specific test port
        """
        ecmp_count = [0, 0, 0]
        src_mac_start = '00:22:22:22:{0}:{1}'
        src_mac = '00:22:22:22:22:22'
        dst_mac = ROUTER_MAC
        udp_sport = 7
        udp_dport = 7
        dst_ip = socket.inet_pton(socket.AF_INET6, '1000:1:1:0:0:0:0:1')
        dst_ip_arr = list(dst_ip)
        src_ip = socket.inet_pton(socket.AF_INET6, '6000:1:1:0:0:0:0:100')
        src_ip_arr = list(src_ip)
        for i in range(0, MAX_ITRS):
            if ('hash_src_mac' in hash_dict) and (hash_dict['hash_src_mac']):
                src_mac = src_mac_start.format(
                    str(0xFF & (i * 117)).zfill(4)[:2],
                    str(0xFF & (i * 13)).zfill(4)[2:])
            if ('hash_dst_ip' in hash_dict) and (hash_dict['hash_dst_ip']):
                dst_ip_arr[15] = 0xFF & (dst_ip_arr[15] + 17)
                dst_ip = binascii.unhexlify(''.join(
                    '%02x' % x for x in dst_ip_arr))
            if ('hash_src_ip' in hash_dict) and (hash_dict['hash_src_ip']):
                src_ip_arr[15] = 0xFF & (src_ip_arr[15] + 13)
                src_ip = binascii.unhexlify(''.join(
                    '%02x' % x for x in src_ip_arr))
            dst_ip_addr = socket.inet_ntop(socket.AF_INET6, dst_ip)
            src_ip_addr = socket.inet_ntop(socket.AF_INET6, src_ip)
            if ('hash_udp_sport' in hash_dict) and \
                    (hash_dict['hash_udp_sport']):
                udp_sport += 13
            if ('hash_udp_dport' in hash_dict) and \
                    (hash_dict['hash_udp_dport']):
                udp_dport += 13

            pkt = simple_udpv6_packet(eth_dst=ROUTER_MAC,
                                      eth_src=src_mac,
                                      ipv6_dst=dst_ip_addr,
                                      ipv6_src=src_ip_addr,
                                      udp_sport=udp_sport,
                                      udp_dport=udp_dport,
                                      ipv6_hlim=64)

            exp_pkt1 = simple_udpv6_packet(eth_dst='00:55:55:55:55:55',
                                           eth_src=ROUTER_MAC,
                                           ipv6_dst=dst_ip_addr,
                                           ipv6_src=src_ip_addr,
                                           udp_sport=udp_sport,
                                           udp_dport=udp_dport,
                                           ipv6_hlim=63)
            exp_pkt2 = simple_udpv6_packet(eth_dst='00:66:66:66:66:66',
                                           eth_src=ROUTER_MAC,
                                           ipv6_dst=dst_ip_addr,
                                           ipv6_src=src_ip_addr,
                                           udp_sport=udp_sport,
                                           udp_dport=udp_dport,
                                           ipv6_hlim=63)
            exp_pkt3 = simple_udpv6_packet(eth_dst='00:77:77:77:77:77',
                                           eth_src=ROUTER_MAC,
                                           ipv6_dst=dst_ip_addr,
                                           ipv6_src=src_ip_addr,
                                           udp_sport=udp_sport,
                                           udp_dport=udp_dport,
                                           ipv6_hlim=63)

            send_packet(self, self.dev_port11, pkt)
            ports_to_verify = [
                self.dev_port25,
                self.dev_port26,
                self.dev_port27]

            rcv_idx = verify_any_packet_any_port(
                self, [exp_pkt1, exp_pkt2, exp_pkt3], ports_to_verify)
            if DEBUG:
                print("idx:", rcv_idx, "dst_ip:", dst_ip_addr, " src_ip:",
                      src_ip_addr, " smac:", src_mac, " dmac: ", dst_mac)
            ecmp_count[rcv_idx] += 1

        return ecmp_count