def generate_and_verify_traffic(duthost, ptfadapter, tbinfo, ip_dst, expected_ports, ipv6=False):
    if ipv6:
        pkt = testutils.simple_tcpv6_packet(eth_dst=duthost.facts['router_mac'], eth_src=ptfadapter.dataplane.get_mac(0, 0), ipv6_src='2001:db8:85a3::8a2e:370:7334', ipv6_dst=ip_dst, ipv6_hlim=64, tcp_sport=1234, tcp_dport=4321)
    else:
        pkt = testutils.simple_tcp_packet(eth_dst=duthost.facts['router_mac'], eth_src=ptfadapter.dataplane.get_mac(0, 0), ip_src='1.1.1.1', ip_dst=ip_dst, ip_ttl=64, tcp_sport=1234, tcp_dport=4321)
    exp_pkt = pkt.copy()
    exp_pkt = mask.Mask(exp_pkt)
    exp_pkt.set_do_not_care_scapy(packet.Ether, 'dst')
    exp_pkt.set_do_not_care_scapy(packet.Ether, 'src')
    if ipv6:
        exp_pkt.set_do_not_care_scapy(packet.IPv6, 'hlim')
        exp_pkt.set_do_not_care_scapy(packet.IPv6, 'chksum')
    else:
        exp_pkt.set_do_not_care_scapy(packet.IP, 'ttl')
        exp_pkt.set_do_not_care_scapy(packet.IP, 'chksum')
    ptf_t1_intf = random.choice(get_t1_ptf_ports(duthost, tbinfo))
    ptf_t1_intf_index = int(ptf_t1_intf.strip('eth'))
    ptfadapter.dataplane.flush()
    testutils.send(ptfadapter, ptf_t1_intf_index, pkt)
    testutils.verify_packet_any_port(ptfadapter, exp_pkt, ports=expected_ports)
def generate_and_verify_traffic(duthost, ptfadapter, tbinfo, ip_dst, expected_ports, ipv6=False):
    if ipv6:
        pkt = testutils.simple_tcpv6_packet(eth_dst=duthost.facts['router_mac'], eth_src=ptfadapter.dataplane.get_mac(0, 0), ipv6_src='2001:db8:85a3::8a2e:370:7334', ipv6_dst=ip_dst, ipv6_hlim=64, tcp_sport=1234, tcp_dport=4321)
    else:
        pkt = testutils.simple_tcp_packet(eth_dst=duthost.facts['router_mac'], eth_src=ptfadapter.dataplane.get_mac(0, 0), ip_src='1.1.1.1', ip_dst=ip_dst, ip_ttl=64, tcp_sport=1234, tcp_dport=4321)
    exp_pkt = pkt.copy()
    exp_pkt = mask.Mask(exp_pkt)
    exp_pkt.set_do_not_care_scapy(packet.Ether, 'dst')
    exp_pkt.set_do_not_care_scapy(packet.Ether, 'src')
    if ipv6:
        exp_pkt.set_do_not_care_scapy(packet.IPv6, 'hlim')
        exp_pkt.set_do_not_care_scapy(packet.IPv6, 'chksum')
    else:
        exp_pkt.set_do_not_care_scapy(packet.IP, 'ttl')
        exp_pkt.set_do_not_care_scapy(packet.IP, 'chksum')
    ptf_t1_intf = random.choice(get_t1_ptf_ports(duthost, tbinfo))
    ptf_t1_intf_index = int(ptf_t1_intf.strip('eth'))
    ptfadapter.dataplane.flush()
    testutils.send(ptfadapter, ptf_t1_intf_index, pkt)
    testutils.verify_packet_any_port(ptfadapter, exp_pkt, ports=expected_ports)