Exemplo n.º 1
0
        public InfoTreeViewControl(Info rootInfo)
        {
            InitializeComponent();

            //Create UI-friendly wrappers around the
            //raw data objects(the view model)
            this.infoTree = new InfoTreeViewModel(rootInfo);

            //let the UI bind to the view-model
            base.DataContext = this.infoTree;
        }
Exemplo n.º 2
0
        private void AnalysisPacket(PacketDotNet.Packet tempPacket)
        {
            if (tempPacket is PacketDotNet.EthernetPacket)
            {
                var  ethernetPacket = tempPacket as PacketDotNet.EthernetPacket;
                Info tempRoot       = new Info();
                tempRoot.Detail  = "Ethernet, Src: ";
                tempRoot.Detail += ethernetPacket.SourceHwAddress.ToString();
                tempRoot.Detail += ", Dst: ";
                tempRoot.Detail += ethernetPacket.DestinationHwAddress.ToString();

                tempRoot.Children.Add(new Info
                {
                    Detail   = ethernetPacket.SourceHwAddress.ToString(),
                    Children =
                    {
                        new Info
                        {
                            Detail = ethernetPacket.SourceHwAddress.ToString(),
                        },
                    }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail   = ethernetPacket.DestinationHwAddress.ToString(),
                    Children =
                    {
                        new Info
                        {
                            Detail = ethernetPacket.DestinationHwAddress.ToString(),
                        },
                    }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = ethernetPacket.Type.ToString(),
                });

                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.IpPacket)
            {
                Info tempRoot = new Info();
                if (tempPacket is PacketDotNet.IPv4Packet)
                {
                    tempRoot.Detail = "Internet Protocol Version 4, Src: ";
                }
                else
                {
                    tempRoot.Detail = "Internet Protocol Version 6, Src: ";
                }
                var ipPacket = tempPacket as PacketDotNet.IpPacket;
                tempRoot.Detail += ipPacket.SourceAddress.ToString();
                tempRoot.Detail += ", Dst: ";
                tempRoot.Detail += ipPacket.DestinationAddress.ToString();

                tempRoot.Children.Add(new Info
                {
                    Detail = "Version: " + ipPacket.Version.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Header Length: " + ipPacket.HeaderLength.ToString(),
                });

                tempRoot.Children.Add(new Info
                {
                    Detail = "Total Length: " + ipPacket.TotalLength.ToString(),
                });

                if (ipPacket.Protocol.ToString().CompareTo("TCP") == 0)
                {
                    string flags     = ipPacket.Header[6].ToString();
                    int    flagvalue = 0;
                    for (int index = 0; index < flags.Length; ++index)
                    {
                        flagvalue *= 10;
                        flagvalue += (flags[index] - '0');
                    }
                    string flagString;
                    int    reserverdbit = 1;
                    string rdetail      = "";
                    int    dofragmentbit;
                    string dofragmentDetail = "";
                    int    morefragmentbit;
                    string morefragmentDetail = "";
                    if ((flagvalue & 128) != 0)
                    {
                        reserverdbit = 0;
                        rdetail      = "Not set";
                    }
                    else
                    {
                        reserverdbit = 1;
                        rdetail      = "Set";
                    }

                    if ((flagvalue & 64) == 0)
                    {
                        dofragmentbit    = 0;
                        dofragmentDetail = "Not set";
                        flagString       = "Don't frament";
                    }
                    else
                    {
                        dofragmentbit    = 1;
                        dofragmentDetail = "Set";
                        flagString       = "Frament";
                    }

                    if ((flagvalue & 32) == 0)
                    {
                        morefragmentbit    = 0;
                        morefragmentDetail = "Not set";
                    }
                    else
                    {
                        morefragmentbit    = 1;
                        morefragmentDetail = "Set";
                    }


                    tempRoot.Children.Add(new Info
                    {
                        Detail   = "Flags: 0x02 (" + flagString + ")",
                        Children =
                        {
                            new Info
                            {
                                Detail = reserverdbit + "... .... = Reserved bit: " + rdetail,
                            },
                            new Info
                            {
                                Detail = "." + dofragmentbit + ".. .... = Don't fragment: " + dofragmentDetail,
                            },
                            new Info
                            {
                                Detail = ".." + morefragmentbit + ". .... = More fragment: " + morefragmentDetail,
                            },
                        }
                    });
                }
                else if (ipPacket.Protocol.ToString().CompareTo("UDP") == 0)
                {
                    string flags     = ipPacket.Header[6].ToString();
                    int    flagvalue = 0;
                    for (int index = 0; index < flags.Length; ++index)
                    {
                        flagvalue *= 10;
                        flagvalue += (flags[index] - '0');
                    }

                    int    reserverdbit = 1;
                    string rdetail      = "";
                    int    dofragmentbit;
                    string dofragmentDetail = "";
                    int    morefragmentbit;
                    string morefragmentDetail = "";
                    if ((flagvalue & 128) != 0)
                    {
                        reserverdbit = 0;
                        rdetail      = "Not set";
                    }
                    else
                    {
                        reserverdbit = 1;
                        rdetail      = "Set";
                    }

                    if ((flagvalue & 64) == 0)
                    {
                        dofragmentbit    = 0;
                        dofragmentDetail = "Not set";
                    }
                    else
                    {
                        dofragmentbit    = 1;
                        dofragmentDetail = "Set";
                    }

                    if ((flagvalue & 32) == 0)
                    {
                        morefragmentbit    = 0;
                        morefragmentDetail = "Not set";
                    }
                    else
                    {
                        morefragmentbit    = 1;
                        morefragmentDetail = "Set";
                    }


                    tempRoot.Children.Add(new Info
                    {
                        Detail   = "Flags: 0x00 ",
                        Children =
                        {
                            new Info
                            {
                                Detail = reserverdbit + "... .... = Reserved bit: " + rdetail,
                            },
                            new Info
                            {
                                Detail = "." + dofragmentbit + ".. .... = Don't fragment: " + dofragmentDetail,
                            },
                            new Info
                            {
                                Detail = ".." + morefragmentbit + ". .... = More fragment: " + morefragmentDetail,
                            },
                        }
                    });
                }

                tempRoot.Children.Add(new Info
                {
                    Detail = "Time To Live: " + ipPacket.TimeToLive.ToString(),
                });

                tempRoot.Children.Add(new Info
                {
                    Detail = "Protocol: " + ipPacket.Protocol.ToString(),
                });

                tempRoot.Children.Add(new Info
                {
                    Detail = "Source: " + ipPacket.SourceAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination: " + ipPacket.DestinationAddress.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ARPPacket)
            {
                var  arpPacket = tempPacket as PacketDotNet.ARPPacket;
                Info tempRoot  = new Info();
                tempRoot.Detail = "Address Resolution Protocol (" + arpPacket.Operation.ToString() + ")";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Hardware type: " + arpPacket.HardwareAddressType.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Protocol type: " + arpPacket.ProtocolAddressType.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Hardware Size: " + arpPacket.HardwareAddressLength.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Protocol size: " + arpPacket.ProtocolAddressLength.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Opcode: " + arpPacket.Operation.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sender Mac address: " + arpPacket.SenderHardwareAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sender Ip address: " + arpPacket.SenderProtocolAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Target Mac address: " + arpPacket.TargetHardwareAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Target Ip address: " + arpPacket.TargetProtocolAddress.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.UdpPacket)
            {
                var  udpPacket = tempPacket as PacketDotNet.UdpPacket;
                Info tempRoot  = new Info();
                tempRoot.Detail = "User Datagram Protocol, Src Port: " + udpPacket.SourcePort.ToString() + ", Dst Port: " + udpPacket.DestinationPort.ToString();

                tempRoot.Children.Add(new Info
                {
                    Detail = "Source Port: " + udpPacket.SourcePort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination Port: " + udpPacket.DestinationPort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail   = "Checksum: " + udpPacket.Checksum.ToString(),
                    Children = { new Info
                                 {
                                     Detail = udpPacket.Checksum.ToString(),
                                 }, }
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
                if ((udpPacket.DestinationPort.ToString().CompareTo("80") == 0) || (udpPacket.DestinationPort.ToString().CompareTo("8080") == 0) || (udpPacket.DestinationPort.ToString().CompareTo("1900") == 0))
                {
                    Info temp = new Info();
                    temp.Detail = "Hypertext Transfer Protocol";
                    try
                    {
                        string str = System.Text.ASCIIEncoding.ASCII.GetString(tempPacket.Bytes);
                        temp.Children.Add(new Info
                        {
                            Detail = str,
                        });
                    }
                    catch
                    { }

                    InfoTreeViewControl ifvc1 = new InfoTreeViewControl(temp);
                    this.TreeViewStack.Children.Add(ifvc1);
                }
            }
            else if (tempPacket is PacketDotNet.TcpPacket)
            {
                var  tcpPacket = tempPacket as PacketDotNet.TcpPacket;
                Info tempRoot  = new Info();

                tempRoot.Detail = "Transmission Control Protocol, Src Port: " + tcpPacket.SourcePort.ToString() + ", Dst Port: " + tcpPacket.DestinationPort.ToString() + ", Seq: " + tcpPacket.SequenceNumber.ToString() + ", Ack: " + tcpPacket.Ack.ToString();
                tempRoot.Children.Add(new Info
                {
                    Detail = "Source Port: " + tcpPacket.SourcePort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination Port: " + tcpPacket.DestinationPort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sequence number: " + tcpPacket.SequenceNumber.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Acknowledgement number: " + tcpPacket.AcknowledgmentNumber.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Header length: " + tcpPacket.Header.Length.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail   = "Flags: ",
                    Children = { new Info
                                 {
                                     Detail = tcpPacket.AllFlags.ToString(),
                                 }, }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Window zise value: " + tcpPacket.WindowSize.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail   = "Checksum: " + tcpPacket.Checksum.ToString(),
                    Children = { new Info
                                 {
                                     Detail = tcpPacket.Checksum.ToString(),
                                 }, }
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);

                if ((tcpPacket.DestinationPort.ToString().CompareTo("80") == 0) || (tcpPacket.DestinationPort.ToString().CompareTo("8080") == 0) || (tcpPacket.DestinationPort.ToString().CompareTo("1900") == 0))
                {
                    Info temp = new Info();
                    temp.Detail = "Hypertext Transfer Protocol";
                    try
                    {
                        string str = System.Text.ASCIIEncoding.ASCII.GetString(tempPacket.Bytes);
                        temp.Children.Add(new Info
                        {
                            Detail = str,
                        });
                    }
                    catch
                    { }

                    InfoTreeViewControl ifvc1 = new InfoTreeViewControl(temp);
                    this.TreeViewStack.Children.Add(ifvc1);
                }
            }
            else if (tempPacket is PacketDotNet.ApplicationPacket)
            {
                var  applicationPacket = tempPacket as PacketDotNet.ApplicationPacket;
                Info tempRoot          = new Info();
                tempRoot.Detail = "Data";
                tempRoot.Children.Add(new Info
                {
                    Detail = applicationPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ICMPv4Packet)
            {
                var  iCMPv4Packet = tempPacket as PacketDotNet.ICMPv4Packet;
                Info tempRoot     = new Info();
                tempRoot.Detail = "Internet Control Message Protocol v4";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + iCMPv4Packet.Checksum.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ICMPv6Packet)
            {
                var  iCMPv6Packet = tempPacket as PacketDotNet.ICMPv6Packet;
                Info tempRoot     = new Info();
                tempRoot.Detail = "Internet Control Message Protocol v6";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + iCMPv6Packet.Checksum.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.Ieee80211RadioPacket)
            {
                var  ieee80211RadioPacket = tempPacket as PacketDotNet.Ieee80211RadioPacket;
                Info tempRoot             = new Info();
                tempRoot.Detail = "Ieee80211RadioPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = ieee80211RadioPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.DataLinkPacket)
            {
                var  dataLinkPacket = tempPacket as PacketDotNet.DataLinkPacket;
                Info tempRoot       = new Info();
                tempRoot.Detail = "DataLinkPacket";
                tempRoot.Children.Add(new Info
                {
                    // Detail = dataLinkPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.Ieee80211MacFrame)
            {
                var  ieee80211MacFrame = tempPacket as PacketDotNet.Ieee80211MacFrame;
                Info tempRoot          = new Info();
                tempRoot.Detail = "Ieee80211MacFrame";
                tempRoot.Children.Add(new Info
                {
                    // Detail = ieee80211MacFrame.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.IGMPv2Packet)
            {
                var  iGMPv2Packet = tempPacket as PacketDotNet.IGMPv2Packet;
                Info tempRoot     = new Info();
                tempRoot.Detail = "IGMPv2Packet";
                tempRoot.Children.Add(new Info
                {
                    //Detail = iGMPv2Packet.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.InternetPacket)
            {
                var  internetPacket = tempPacket as PacketDotNet.InternetPacket;
                Info tempRoot       = new Info();
                tempRoot.Detail = "InternetPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = internetPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.LLDPPacket)
            {
                var  lLDPPacket = tempPacket as PacketDotNet.LLDPPacket;
                Info tempRoot   = new Info();
                tempRoot.Detail = "LLDPPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = lLDPPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.PPPPacket)
            {
                var  pPPPacket = tempPacket as PacketDotNet.PPPPacket;
                Info tempRoot  = new Info();
                tempRoot.Detail = "PPPPacket";
                tempRoot.Children.Add(new Info
                {
                    // Detail = pPPPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.SessionPacket)
            {
                var  sessionPacket = tempPacket as PacketDotNet.SessionPacket;
                Info tempRoot      = new Info();
                tempRoot.Detail = "SessionPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = sessionPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.TransportPacket)
            {
                var  transportPacket = tempPacket as PacketDotNet.TransportPacket;
                Info tempRoot        = new Info();
                tempRoot.Detail = "TransportPacket";
                tempRoot.Children.Add(new Info
                {
                    Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.WakeOnLanPacket)
            {
                var  wakeOnLanPacket = tempPacket as PacketDotNet.WakeOnLanPacket;
                Info tempRoot        = new Info();
                tempRoot.Detail = "WakeOnLanPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else
            {
                Info tempRoot = new Info();
                tempRoot.Detail = "UnknowPacketType";
                tempRoot.Children.Add(new Info
                {
                    //Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
        }
Exemplo n.º 3
-1
        private void AnalysisPacket(PacketDotNet.Packet tempPacket)
        {
            if (tempPacket is PacketDotNet.EthernetPacket)
            {
                var ethernetPacket = tempPacket as PacketDotNet.EthernetPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "Ethernet, Src: ";
                tempRoot.Detail += ethernetPacket.SourceHwAddress.ToString();
                tempRoot.Detail += ", Dst: ";
                tempRoot.Detail += ethernetPacket.DestinationHwAddress.ToString();

                tempRoot.Children.Add(new Info
                {
                    Detail = ethernetPacket.SourceHwAddress.ToString(),
                    Children =
                    {
                        new Info
                        {
                            Detail = ethernetPacket.SourceHwAddress.ToString(),
                        },
                    }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = ethernetPacket.DestinationHwAddress.ToString(),
                    Children =
                    {
                        new Info
                        {
                            Detail = ethernetPacket.DestinationHwAddress.ToString(),
                        },
                    }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = ethernetPacket.Type.ToString(),
                });

                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.IpPacket)
            {
                Info tempRoot = new Info();
                if (tempPacket is PacketDotNet.IPv4Packet)
                {
                    tempRoot.Detail = "Internet Protocol Version 4, Src: ";
                }
                else
                {
                    tempRoot.Detail = "Internet Protocol Version 6, Src: ";
                }
                var ipPacket = tempPacket as PacketDotNet.IpPacket;
                tempRoot.Detail += ipPacket.SourceAddress.ToString();
                tempRoot.Detail += ", Dst: ";
                tempRoot.Detail += ipPacket.DestinationAddress.ToString();

                tempRoot.Children.Add(new Info
               {
                   Detail = "Version: " + ipPacket.Version.ToString(),
               });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Header Length: " + ipPacket.HeaderLength.ToString(),
                });

                tempRoot.Children.Add(new Info
                {
                    Detail = "Total Length: " + ipPacket.TotalLength.ToString(),
                });

                if (ipPacket.Protocol.ToString().CompareTo("TCP") == 0)
                {
                    string flags = ipPacket.Header[6].ToString();
                    int flagvalue = 0;
                    for (int index = 0; index < flags.Length; ++index)
                    {
                        flagvalue *= 10;
                        flagvalue += (flags[index] - '0');
                    }
                    string flagString;
                    int reserverdbit = 1;
                    string rdetail = "";
                    int dofragmentbit;
                    string dofragmentDetail = "";
                    int morefragmentbit;
                    string morefragmentDetail = "";
                    if ((flagvalue & 128) != 0)
                    {
                        reserverdbit = 0;
                        rdetail = "Not set";
                    }
                    else
                    {
                        reserverdbit = 1;
                        rdetail = "Set";
                    }

                    if ((flagvalue & 64) == 0)
                    {
                        dofragmentbit = 0;
                        dofragmentDetail = "Not set";
                        flagString = "Don't frament";
                    }
                    else
                    {
                        dofragmentbit = 1;
                        dofragmentDetail = "Set";
                         flagString = "Frament";
                    }

                    if ((flagvalue & 32) == 0)
                    {
                        morefragmentbit = 0;
                        morefragmentDetail = "Not set";
                    }
                    else
                    {
                        morefragmentbit = 1;
                        morefragmentDetail = "Set";
                    }

                    tempRoot.Children.Add(new Info
                    {
                        Detail = "Flags: 0x02 (" + flagString + ")",
                        Children =
                        {
                            new Info
                            {
                                Detail =reserverdbit+ "... .... = Reserved bit: " + rdetail,

                            },
                            new Info
                            {
                                Detail ="." +dofragmentbit+ ".. .... = Don't fragment: "+dofragmentDetail,
                            },
                            new Info
                            {
                                Detail =".."+ morefragmentbit+ ". .... = More fragment: "+morefragmentDetail,
                            },
                        }
                    });

                }
                else if (ipPacket.Protocol.ToString().CompareTo("UDP") == 0)
                {
                    string flags = ipPacket.Header[6].ToString();
                    int flagvalue = 0;
                    for (int index = 0; index < flags.Length; ++index)
                    {
                        flagvalue *= 10;
                        flagvalue += (flags[index] - '0');
                    }

                    int reserverdbit = 1;
                    string rdetail = "";
                    int dofragmentbit;
                    string dofragmentDetail = "";
                    int morefragmentbit;
                    string morefragmentDetail = "";
                    if ((flagvalue & 128) != 0)
                    {
                        reserverdbit = 0;
                        rdetail = "Not set";
                    }
                    else
                    {
                        reserverdbit = 1;
                        rdetail = "Set";
                    }

                    if ((flagvalue & 64) == 0)
                    {
                        dofragmentbit = 0;
                        dofragmentDetail = "Not set";
                    }
                    else
                    {
                        dofragmentbit = 1;
                        dofragmentDetail = "Set";
                    }

                    if ((flagvalue & 32) == 0)
                    {
                        morefragmentbit = 0;
                        morefragmentDetail = "Not set";
                    }
                    else
                    {
                        morefragmentbit = 1;
                        morefragmentDetail = "Set";
                    }

                    tempRoot.Children.Add(new Info
                    {
                        Detail = "Flags: 0x00 ",
                        Children =
                        {
                            new Info
                            {
                                Detail =reserverdbit+ "... .... = Reserved bit: " + rdetail,

                            },
                            new Info
                            {
                                Detail ="." +dofragmentbit+ ".. .... = Don't fragment: "+dofragmentDetail,
                            },
                            new Info
                            {
                                Detail =".."+ morefragmentbit+ ". .... = More fragment: "+morefragmentDetail,
                            },
                        }
                    });

                }

                tempRoot.Children.Add(new Info
               {
                   Detail = "Time To Live: " + ipPacket.TimeToLive.ToString(),
               });

                tempRoot.Children.Add(new Info
               {
                   Detail = "Protocol: " + ipPacket.Protocol.ToString(),
               });

                tempRoot.Children.Add(new Info
                {
                    Detail = "Source: " + ipPacket.SourceAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination: " + ipPacket.DestinationAddress.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ARPPacket)
            {
                var arpPacket = tempPacket as PacketDotNet.ARPPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "Address Resolution Protocol (" + arpPacket.Operation.ToString() + ")";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Hardware type: " + arpPacket.HardwareAddressType.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Protocol type: " + arpPacket.ProtocolAddressType.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Hardware Size: " + arpPacket.HardwareAddressLength.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Protocol size: " + arpPacket.ProtocolAddressLength.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Opcode: " + arpPacket.Operation.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sender Mac address: " + arpPacket.SenderHardwareAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sender Ip address: " + arpPacket.SenderProtocolAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Target Mac address: " + arpPacket.TargetHardwareAddress.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Target Ip address: " + arpPacket.TargetProtocolAddress.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.UdpPacket)
            {
                var udpPacket = tempPacket as PacketDotNet.UdpPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "User Datagram Protocol, Src Port: " + udpPacket.SourcePort.ToString() + ", Dst Port: " + udpPacket.DestinationPort.ToString();

                tempRoot.Children.Add(new Info
                {
                    Detail = "Source Port: " + udpPacket.SourcePort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination Port: " + udpPacket.DestinationPort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + udpPacket.Checksum.ToString(),
                    Children = { new Info
                    {
                        Detail = udpPacket.Checksum.ToString(),
                    },
                    }
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
                if ((udpPacket.DestinationPort.ToString().CompareTo("80") == 0) || (udpPacket.DestinationPort.ToString().CompareTo("8080") == 0) || (udpPacket.DestinationPort.ToString().CompareTo("1900") == 0))
                {
                    Info temp = new Info();
                    temp.Detail = "Hypertext Transfer Protocol";
                    try
                    {
                        string str = System.Text.ASCIIEncoding.ASCII.GetString(tempPacket.Bytes);
                        temp.Children.Add(new Info
                        {
                            Detail = str,
                        });
                    }
                    catch
                    { }

                    InfoTreeViewControl ifvc1 = new InfoTreeViewControl(temp);
                    this.TreeViewStack.Children.Add(ifvc1);
                }
            }
            else if (tempPacket is PacketDotNet.TcpPacket)
            {
                var tcpPacket = tempPacket as PacketDotNet.TcpPacket;
                Info tempRoot = new Info();

                tempRoot.Detail = "Transmission Control Protocol, Src Port: " + tcpPacket.SourcePort.ToString() + ", Dst Port: " + tcpPacket.DestinationPort.ToString() + ", Seq: " + tcpPacket.SequenceNumber.ToString() + ", Ack: " + tcpPacket.Ack.ToString();
                tempRoot.Children.Add(new Info
                {
                    Detail = "Source Port: " + tcpPacket.SourcePort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Destination Port: " + tcpPacket.DestinationPort.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Sequence number: " + tcpPacket.SequenceNumber.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Acknowledgement number: " + tcpPacket.AcknowledgmentNumber.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Header length: " + tcpPacket.Header.Length.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Flags: ",
                    Children = { new Info
                    {
                        Detail = tcpPacket.AllFlags.ToString(),
                    },
                    }
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Window zise value: " + tcpPacket.WindowSize.ToString(),
                });
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + tcpPacket.Checksum.ToString(),
                    Children = { new Info
                    {
                        Detail = tcpPacket.Checksum.ToString(),
                    },
                    }
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);

                if ((tcpPacket.DestinationPort.ToString().CompareTo("80") == 0) || (tcpPacket.DestinationPort.ToString().CompareTo("8080") == 0) || (tcpPacket.DestinationPort.ToString().CompareTo("1900") == 0))
                {
                    Info temp = new Info();
                    temp.Detail = "Hypertext Transfer Protocol";
                    try
                    {
                        string str = System.Text.ASCIIEncoding.ASCII.GetString(tempPacket.Bytes);
                        temp.Children.Add(new Info
                        {
                            Detail = str,
                        });
                    }
                    catch
                    { }

                    InfoTreeViewControl ifvc1 = new InfoTreeViewControl(temp);
                    this.TreeViewStack.Children.Add(ifvc1);
                }
            }
            else if (tempPacket is PacketDotNet.ApplicationPacket)
            {
                var applicationPacket = tempPacket as PacketDotNet.ApplicationPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "Data";
                tempRoot.Children.Add(new Info
                {
                    Detail = applicationPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ICMPv4Packet)
            {
                var iCMPv4Packet = tempPacket as PacketDotNet.ICMPv4Packet;
                Info tempRoot = new Info();
                tempRoot.Detail = "Internet Control Message Protocol v4";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + iCMPv4Packet.Checksum.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.ICMPv6Packet)
            {
                var iCMPv6Packet = tempPacket as PacketDotNet.ICMPv6Packet;
                Info tempRoot = new Info();
                tempRoot.Detail = "Internet Control Message Protocol v6";
                tempRoot.Children.Add(new Info
                {
                    Detail = "Checksum: " + iCMPv6Packet.Checksum.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.Ieee80211RadioPacket)
            {
                var ieee80211RadioPacket = tempPacket as PacketDotNet.Ieee80211RadioPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "Ieee80211RadioPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = ieee80211RadioPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.DataLinkPacket)
            {
                var dataLinkPacket = tempPacket as PacketDotNet.DataLinkPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "DataLinkPacket";
                tempRoot.Children.Add(new Info
                {
                    // Detail = dataLinkPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.Ieee80211MacFrame)
            {
                var ieee80211MacFrame = tempPacket as PacketDotNet.Ieee80211MacFrame;
                Info tempRoot = new Info();
                tempRoot.Detail = "Ieee80211MacFrame";
                tempRoot.Children.Add(new Info
                {
                    // Detail = ieee80211MacFrame.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.IGMPv2Packet)
            {
                var iGMPv2Packet = tempPacket as PacketDotNet.IGMPv2Packet;
                Info tempRoot = new Info();
                tempRoot.Detail = "IGMPv2Packet";
                tempRoot.Children.Add(new Info
                {
                    //Detail = iGMPv2Packet.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.InternetPacket)
            {
                var internetPacket = tempPacket as PacketDotNet.InternetPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "InternetPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = internetPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.LLDPPacket)
            {
                var lLDPPacket = tempPacket as PacketDotNet.LLDPPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "LLDPPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = lLDPPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.PPPPacket)
            {
                var pPPPacket = tempPacket as PacketDotNet.PPPPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "PPPPacket";
                tempRoot.Children.Add(new Info
                {
                    // Detail = pPPPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.SessionPacket)
            {
                var sessionPacket = tempPacket as PacketDotNet.SessionPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "SessionPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = sessionPacket.ToString(),
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.TransportPacket)
            {
                var transportPacket = tempPacket as PacketDotNet.TransportPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "TransportPacket";
                tempRoot.Children.Add(new Info
                {
                    Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else if (tempPacket is PacketDotNet.WakeOnLanPacket)
            {
                var wakeOnLanPacket = tempPacket as PacketDotNet.WakeOnLanPacket;
                Info tempRoot = new Info();
                tempRoot.Detail = "WakeOnLanPacket";
                tempRoot.Children.Add(new Info
                {
                    //Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
            else
            {
                Info tempRoot = new Info();
                tempRoot.Detail = "UnknowPacketType";
                tempRoot.Children.Add(new Info
                {
                    //Detail = "TransportPacket",
                });
                InfoTreeViewControl ifvc = new InfoTreeViewControl(tempRoot);
                this.TreeViewStack.Children.Add(ifvc);
            }
        }