public static bool TryGetPacket(out Packets.AbstractPacket packet, System.Type packetType, Frame parentFrame, int startIndex, int endIndex)
        {
            packet = null;
            try {
                if (packetType.Equals(typeof(Packets.Ethernet2Packet)))
                {
                    packet = new Packets.Ethernet2Packet(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.IPv4Packet)))
                {
                    IPv4Packet.TryParse(parentFrame, startIndex, endIndex, out packet);
                    //packet = new Packets.IPv4Packet(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.IPv6Packet)))
                {
                    packet = new Packets.IPv6Packet(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.TcpPacket)))
                {
                    packet = new Packets.TcpPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.IEEE_802_11Packet)))
                {
                    packet = new Packets.IEEE_802_11Packet(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.IEEE_802_11RadiotapPacket)))
                {
                    packet = new Packets.IEEE_802_11RadiotapPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.CiscoHdlcPacket)))
                {
                    packet = new Packets.CiscoHdlcPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.LinuxCookedCapture)))
                {
                    packet = new Packets.LinuxCookedCapture(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.PrismCaptureHeaderPacket)))
                {
                    packet = new Packets.PrismCaptureHeaderPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.PpiPacket)))
                {
                    packet = new Packets.PpiPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.PointToPointPacket)))
                {
                    packet = new Packets.PointToPointPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.NullLoopbackPacket)))
                {
                    packet = new Packets.NullLoopbackPacket(parentFrame, startIndex, endIndex);
                }
                else if (packetType.Equals(typeof(Packets.ErfFrame)))
                {
                    packet = new Packets.ErfFrame(parentFrame, startIndex, endIndex);
                }

                if (packet == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception) {
                packet = new Packets.RawPacket(parentFrame, startIndex, endIndex);
                return(false);
            }
        }
 public static bool TryGetPacket(out Packets.AbstractPacket packet, PcapFrame.DataLinkTypeEnum dataLinkType, Frame parentFrame, int startIndex, int endIndex)
 {
     return(TryGetPacket(out packet, GetPacketType(dataLinkType), parentFrame, startIndex, endIndex));
 }