Exemplo n.º 1
0
        private void PopulatePacketContent(Packet packet)
        {
            var ipPacket = packet.IpPacket;

            switch (ipPacket.Protocol)
            {
            case ProtocolType.Tcp:
                var tcpPacket = ipPacket.Extract <TcpPacket>();
                if (tcpPacket != null)
                {
                    PacketContent.Add(new TcpPacketTemplate(tcpPacket));
                }
                break;

            case ProtocolType.Udp:
                var udpPacket = ipPacket.Extract <UdpPacket>();
                if (udpPacket != null)
                {
                    PacketContent.Add(new UdpPacketTemplate(udpPacket));
                }
                break;

            case ProtocolType.IcmpV6:
                var icmpv6Packet = ipPacket.Extract <IcmpV6Packet>();
                if (icmpv6Packet != null)
                {
                    PacketContent.Add(new IcmpV6PacketTemplate(icmpv6Packet));
                }
                break;

            case ProtocolType.Igmp:
                var igmpPacket = ipPacket.Extract <IgmpV2Packet>();
                if (igmpPacket != null)
                {
                    PacketContent.Add(new IgmpPacketTemplate(igmpPacket));
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public IPv6HeaderTemplate(Packet packet)
        {
            PacketContent = new ObservableCollection <IPacketTemplate>();

            SourceIp      = packet.SourceIp;
            DestinationIp = packet.DestinationIP;
            Protocol      = packet.Protocol.ToUpperInvariant();
            Version       = packet.Version;
            Length        = packet.Lenght;

            if (packet.IpPacket.Version == IPVersion.IPv6)
            {
                var ipv6 = packet.IpPacket.Extract <IPv6Packet>();
                InternetHeaderLength = ipv6.HeaderLength.ToString();
                TimeToLive           = ipv6.TimeToLive.ToString();
                FlowLabel            = ipv6.FlowLabel.ToString();
                TrafficClass         = ipv6.TrafficClass.ToString();
                PayloadLength        = ipv6.PayloadLength.ToString();
            }

            PopulatePacketContent(packet);
        }
Exemplo n.º 3
0
        public IPv4HeaderTemplate(Packet packet)
        {
            PacketContent = new ObservableCollection <IPacketTemplate>();

            SourceIp      = packet.SourceIp;
            DestinationIp = packet.DestinationIP;
            Protocol      = packet.Protocol.ToUpperInvariant();
            Version       = packet.Version;
            Length        = packet.Lenght;

            if (packet.IpPacket.Version == IPVersion.IPv4)
            {
                var ipv4 = packet.IpPacket.Extract <IPv4Packet>();
                InternetHeaderLength = ipv4.HeaderLength.ToString();
                TypeOfService        = ipv4.TypeOfService.ToString();
                FragmentOffset       = ipv4.FragmentOffset.ToString();
                TimeToLive           = ipv4.TimeToLive.ToString();
                PayloadLength        = ipv4.PayloadLength.ToString();
                HeaderChecksum       = ipv4.Checksum.ToString();
            }

            PopulatePacketContent(packet);
        }