def verify_unicast_packets(ptfadapter, send_pkt, exp_pkt, src_port, dst_ports): testutils.send(ptfadapter, src_port, send_pkt) try: testutils.verify_packets_any(ptfadapter, exp_pkt, ports=dst_ports) except AssertionError as detail: if "Did not receive expected packet on any of ports" in str(detail): logger.error("Expected packet was not received") raise
def verify_dhcp_relay_pkt_on_other_client_port_with_no_padding( self, dst_mac=BROADCAST_MAC, src_port=DHCP_CLIENT_PORT): # Form and send DHCP Relay packet dhcp_request = self.create_dhcp_request_packet(dst_mac, src_port) testutils.send_packet(self, self.client_port_index, dhcp_request) # Mask off fields we don't care about matching masked_request = Mask(dhcp_request) masked_request.set_do_not_care_scapy(scapy.Ether, "src") masked_request.set_do_not_care_scapy(scapy.IP, "version") masked_request.set_do_not_care_scapy(scapy.IP, "ihl") masked_request.set_do_not_care_scapy(scapy.IP, "tos") masked_request.set_do_not_care_scapy(scapy.IP, "len") masked_request.set_do_not_care_scapy(scapy.IP, "id") masked_request.set_do_not_care_scapy(scapy.IP, "flags") masked_request.set_do_not_care_scapy(scapy.IP, "frag") masked_request.set_do_not_care_scapy(scapy.IP, "ttl") masked_request.set_do_not_care_scapy(scapy.IP, "proto") masked_request.set_do_not_care_scapy(scapy.IP, "chksum") masked_request.set_do_not_care_scapy(scapy.IP, "src") masked_request.set_do_not_care_scapy(scapy.IP, "dst") masked_request.set_do_not_care_scapy(scapy.IP, "options") masked_request.set_do_not_care_scapy(scapy.UDP, "chksum") masked_request.set_do_not_care_scapy(scapy.UDP, "len") masked_request.set_do_not_care_scapy(scapy.DHCP, "options") masked_request.set_do_not_care_scapy(scapy.BOOTP, "sname") masked_request.set_do_not_care_scapy(scapy.BOOTP, "file") masked_request.set_do_not_care_scapy(scapy.BOOTP, "yiaddr") masked_request.set_do_not_care_scapy(scapy.BOOTP, "ciaddr") masked_request.set_do_not_care_scapy(scapy.BOOTP, "siaddr") masked_request.set_do_not_care_scapy(scapy.BOOTP, "giaddr") masked_request.set_do_not_care_scapy(scapy.BOOTP, "chaddr") try: testutils.verify_packets_any(self, masked_request, self.other_client_port) except Exception: self.assertTrue( False, "DHCP Relay packet not matched or Padded extra on client side" )
def test_vlan_tc5_untagged_non_broadcast( ptfadapter, vlan_ports_list, toggle_all_simulator_ports_to_rand_selected_tor): """ Test case #5 Send packets w/ src and dst specified over untagged ports in vlan Verify that bidirectional communication between two untagged ports work """ vlan_ids = vlan_ports_list[0]['permit_vlanid'].keys() tagged_test_vlan = vlan_ids[0] ports_for_test = [] for vlan_port in vlan_ports_list: if vlan_port['pvid'] != tagged_test_vlan: ports_for_test.append(vlan_port['port_index']) #take two tagged ports for test src_port = ports_for_test[0] dst_port = ports_for_test[-1] src_mac = ptfadapter.dataplane.get_mac(0, src_port[0]) dst_mac = ptfadapter.dataplane.get_mac(0, dst_port[0]) transmit_untagged_pkt = build_icmp_packet(vlan_id=0, src_mac=src_mac, dst_mac=dst_mac) return_transmit_untagged_pkt = build_icmp_packet(vlan_id=0, src_mac=dst_mac, dst_mac=src_mac) logger.info("Untagged packet to be sent from port {} to port {}".format( src_port[0], dst_port)) testutils.send(ptfadapter, src_port[0], transmit_untagged_pkt) try: testutils.verify_packets_any(ptfadapter, transmit_untagged_pkt, ports=dst_port) except Exception as detail: if "Did not receive expected packet on any of ports" in str(detail): logger.error("Expected packet was not received") raise logger.info("One Way Untagged Packet Transmission Works") logger.info( "Untagged packet successfully sent from port {} to port {}".format( src_port[0], dst_port)) logger.info("Untagged packet to be sent from port {} to port {}".format( dst_port[0], src_port)) testutils.send(ptfadapter, dst_port[0], return_transmit_untagged_pkt) try: testutils.verify_packets_any(ptfadapter, return_transmit_untagged_pkt, ports=src_port) except Exception as detail: if "Did not receive expected packet on any of ports" in str(detail): logger.error("Expected packet was not received") raise logger.info("Two Way Untagged Packet Transmission Works") logger.info( "Untagged packet successfully sent from port {} to port {}".format( dst_port[0], src_port))