コード例 #1
0
ファイル: Discovery.cs プロジェクト: lanicon/FlowNet
        public void HandleLldpPacket(LLDPPacket packet, OfpPacketIn packetIn, IConnection connection)
        {
            if (packet.TlvCollection.Count < 3)
            {
                _controller.LogError($"[{connection.Mac}] LLDP TLV not enough");
                return;
            }
            ulong dpid = 0;
            var   ch   = packet.TlvCollection[0] as ChassisID;
            var   po   = packet.TlvCollection[1] as PortID;

            if (packet.TlvCollection.Count >= 4)
            {
                var sd = packet.TlvCollection[3] as SystemDescription;
                dpid = ulong.Parse(sd.Description, NumberStyles.AllowHexSpecifier);
            }
            if (dpid == 0)
            {
                dpid = ch.MACAddress.GetDatapathId();
            }
            ushort port = 0;

            if (po != null && po.SubTypeValue != null)
            {
                port = BitConverter.ToUInt16((byte[])po.SubTypeValue, 0);
            }
            _controller.LogDebug($"[{connection.Mac}:{packetIn.InPort}] is connected with [{ch?.MACAddress}:{port}] (Get LLDP)");

            //Update Topo
            _controller.Topo.AddTwoWayLink(dpid, port, connection.SwitchFeatures.DatapathId, packetIn.InPort);
        }
コード例 #2
0
        public void BinarySerialization()
        {
            var dev = new CaptureFileReaderDevice("../../CaptureFiles/lldp.pcap");

            dev.Open();

            RawCapture rawCapture;
            bool       foundlldp = false;

            while ((rawCapture = dev.GetNextPacket()) != null)
            {
                Packet p    = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
                var    lldp = (LLDPPacket)p.Extract(typeof(LLDPPacket));
                if (lldp == null)
                {
                    continue;
                }
                foundlldp = true;

                var             memoryStream = new MemoryStream();
                BinaryFormatter serializer   = new BinaryFormatter();
                serializer.Serialize(memoryStream, lldp);

                memoryStream.Seek(0, SeekOrigin.Begin);
                BinaryFormatter deserializer = new BinaryFormatter();
                LLDPPacket      fromFile     = (LLDPPacket)deserializer.Deserialize(memoryStream);

                Assert.AreEqual(lldp.Bytes, fromFile.Bytes);
                Assert.AreEqual(lldp.BytesHighPerformance.Bytes, fromFile.BytesHighPerformance.Bytes);
                Assert.AreEqual(lldp.BytesHighPerformance.BytesLength, fromFile.BytesHighPerformance.BytesLength);
                Assert.AreEqual(lldp.BytesHighPerformance.Length, fromFile.BytesHighPerformance.Length);
                Assert.AreEqual(lldp.BytesHighPerformance.NeedsCopyForActualBytes, fromFile.BytesHighPerformance.NeedsCopyForActualBytes);
                Assert.AreEqual(lldp.BytesHighPerformance.Offset, fromFile.BytesHighPerformance.Offset);
                Assert.AreEqual(lldp.Color, fromFile.Color);
                Assert.AreEqual(lldp.Header, fromFile.Header);
                Assert.AreEqual(lldp.PayloadData, fromFile.PayloadData);

                for (int i = 0; i < lldp.TlvCollection.Count; i++)
                {
                    Assert.AreEqual(lldp.TlvCollection[i].Bytes, fromFile.TlvCollection[i].Bytes);
                    Assert.AreEqual(lldp.TlvCollection[i].Length, fromFile.TlvCollection[i].Length);
                    Assert.AreEqual(lldp.TlvCollection[i].TotalLength, fromFile.TlvCollection[i].TotalLength);
                    Assert.AreEqual(lldp.TlvCollection[i].Type, fromFile.TlvCollection[i].Type);
                }

                //Method Invocations to make sure that a deserialized packet does not cause
                //additional errors.

                lldp.ParseByteArrayIntoTlvs(new byte[] { 0, 0 }, 0);
                lldp.PrintHex();
                lldp.UpdateCalculatedValues();
            }

            dev.Close();
            Assert.IsTrue(foundlldp, "Capture file contained no lldp packets");
        }
コード例 #3
0
ファイル: Discovery.cs プロジェクト: lanicon/FlowNet
        public LLDPPacket TryLldpPacket(Packet packet)
        {
            LLDPPacket lp = null;

            if (packet != null)
            {
                lp = packet.Extract(typeof(LLDPPacket)) as LLDPPacket;
            }
            return(lp);
        }
コード例 #4
0
ファイル: PacketInfoBase.cs プロジェクト: LiXiaoRan/Watch
        /// <summary>
        /// 以太网
        /// </summary>
        /// <param name="packet"></param>
        private void Ethernet(Packet packet)
        {
            EthernetPacket e = EthernetPacket.GetEncapsulated(packet);

            if (EthernetNode == null)
            {
                EthernetNode                    = new TreeNode("EthernetII");
                EthernetNode.Name               = "Ethernet";
                EthernetNode.ImageIndex         = 0;
                EthernetNode.SelectedImageIndex = 0;
            }
            EthernetNode.Nodes.Clear();

            EthernetNode.Nodes.Add("Destination: " + Format.MacFormat(e.DestinationHwAddress.ToString()));
            EthernetNode.Nodes.Add("Source: " + Format.MacFormat(e.SourceHwAddress.ToString()));
            EthernetNode.Nodes.Add("Type: " + e.Type.ToString() + " [0x" + e.Type.ToString("X") + "]");
            Tree.Nodes.Add(EthernetNode);

            switch (e.Type)
            {
            case EthernetPacketType.Arp:    //ARP协议
                ARPPacket arp = ARPPacket.GetEncapsulated(packet);
                Arp(arp);
                break;

            case EthernetPacketType.IpV4:    //IP协议
            case EthernetPacketType.IpV6:
                IpPacket ip = IpPacket.GetEncapsulated(packet);
                IP(ip);
                break;

            case EthernetPacketType.WakeOnLan:    //网络唤醒协议
                WakeOnLanPacket wake = WakeOnLanPacket.GetEncapsulated(packet);
                Wake_on_Lan(wake);
                break;

            case EthernetPacketType.LLDP:    //链路层发现协议
                LLDPPacket ll = LLDPPacket.GetEncapsulated(packet);
                LLDPProtocol(ll);
                break;

            case EthernetPacketType.PointToPointProtocolOverEthernetDiscoveryStage:
            case EthernetPacketType.PPPoE:
                PPPoEPacket pppoe = PPPoEPacket.GetEncapsulated(packet);
                PPPOE(pppoe);
                break;

            case EthernetPacketType.None:    //无可用协议
            default:
                PayLoadData = e.PayloadData;
                break;
            }
        }
コード例 #5
0
ファイル: PacketInfoBase.cs プロジェクト: LiXiaoRan/Watch
        /// <summary>
        /// GRE封装的下层协议
        /// </summary>
        /// <param name="data"></param>
        /// <param name="e"></param>
        private void NextGRE(byte[] data, EthernetProtocolType e)
        {
            if (data.Length <= 0)
            {
                return;
            }
            switch (e)
            {
            case EthernetProtocolType.PPP:
                var ppp = new TwzyProtocol.PPPPacket(data);
                if (ppp != null)
                {
                    PPP(ppp);
                }
                break;

            case EthernetProtocolType.Arp:    //ARP协议
                ARPPacket arp = ARPPacket.GetEncapsulated(packet);
                Arp(arp);
                break;

            case EthernetProtocolType.IpV4:    //IP协议
            case EthernetProtocolType.IpV6:
                IpPacket ip = IpPacket.GetEncapsulated(packet);
                IP(ip);
                break;

            case EthernetProtocolType.WakeOnLan:    //网络唤醒协议
                WakeOnLanPacket wake = WakeOnLanPacket.GetEncapsulated(packet);
                Wake_on_Lan(wake);
                break;

            case EthernetProtocolType.LLDP:    //链路层发现协议
                LLDPPacket ll = LLDPPacket.GetEncapsulated(packet);
                LLDPProtocol(ll);
                break;

            case EthernetProtocolType.PointToPointProtocolOverEthernetDiscoveryStage:
            case EthernetProtocolType.PPPoE:
                PPPoEPacket pppoe = PPPoEPacket.GetEncapsulated(packet);
                PPPOE(pppoe);
                break;

            case EthernetProtocolType.None:    //无可用协议
                break;
            }
        }
コード例 #6
0
ファイル: Discovery.cs プロジェクト: lanicon/FlowNet
        public byte[] GenerateLldpPacket(PhysicalAddress portMac, uint portNum, ulong dpid)
        {
            LLDPPacket packet = new LLDPPacket();

            packet.TlvCollection.Add(new ChassisID(dpid.GetPhysicalAddress()));
            packet.TlvCollection.Add(new PortID(PortSubTypes.PortComponent, BitConverter.GetBytes(portNum)));
            packet.TlvCollection.Add(new TimeToLive(Ttl));
            packet.TlvCollection.Add(new SystemDescription(dpid.ToString("X")));
            packet.TlvCollection.Add(new EndOfLLDPDU());
            packet = new LLDPPacket(new ByteArraySegment(packet.Bytes));

            EthernetPacket ethernet = new EthernetPacket(portMac, EthernetAddress.NDP_MULTICAST, EthernetPacketType.LLDP);

            ethernet.PayloadPacket = packet;

            return(ethernet.Bytes);
        }
コード例 #7
0
ファイル: PacketInfoBase.cs プロジェクト: LiXiaoRan/Watch
        private void LLDPProtocol(LLDPPacket lldp)
        {
            if (LLDPNode == null)
            {
                LLDPNode                    = new TreeNode("LLDP [链路层发现协议]");
                LLDPNode.ImageIndex         = 0;
                LLDPNode.SelectedImageIndex = 0;
                LLDPNode.Name               = "LLDP";
            }
            LLDPNode.Nodes.Clear();

            LLDPNode.Nodes.Add("Length: " + lldp.Length.ToString());
            foreach (var l in lldp.TlvCollection)
            {
                LLDPNode.Nodes.Add("Type: " + l.Type.ToString() + " Length: " + l.TotalLength.ToString());
            }
            Tree.Nodes.Add(LLDPNode);
        }
コード例 #8
0
ファイル: Base.cs プロジェクト: margusmaki/WinLLDPService
        /// <summary>
        /// Generate LLDP packet for adapter
        /// </summary>
        /// <param name="adapter"></param>
        private Packet CreateLLDPPacket(NetworkInterface adapter, PacketInfo pinfo)
        {
            Debug.IndentLevel = 2;

            PhysicalAddress MACAddress = adapter.GetPhysicalAddress();

            IPInterfaceProperties ipProperties = adapter.GetIPProperties();
            IPv4InterfaceProperties ipv4Properties = null; // Ipv4
            IPv6InterfaceProperties ipv6Properties = null;// Ipv6

            // IPv6
            if (adapter.Supports(NetworkInterfaceComponent.IPv6))
            {
                try
                {
                    ipv6Properties = ipProperties.GetIPv6Properties();
                }
                catch (NetworkInformationException e)
                {
                    // Adapter doesn't probably have IPv6 enabled
                    Debug.WriteLine(e.Message, EventLogEntryType.Warning);
                }
            }

            // IPv4
            if (adapter.Supports(NetworkInterfaceComponent.IPv4))
            {
                try
                {
                    ipv4Properties = ipProperties.GetIPv4Properties();
                }
                catch (NetworkInformationException e)
                {
                    // Adapter doesn't probably have IPv4 enabled
                    Debug.WriteLine(e.Message, EventLogEntryType.Warning);
                }
            }


            // System description
            Dictionary<string, string> systemDescription = new Dictionary<string, string>();
            systemDescription.Add("OS", pinfo.OperatingSystem);
            //systemDescription.Add("Ver", pinfo.OperatingSystemVersion);
            systemDescription.Add("Usr", pinfo.Username);
            systemDescription.Add("Up", pinfo.Uptime);

            // Port description
            Dictionary<string, string> portDescription = new Dictionary<string, string>();

            // adapter.Description is for example "Intel(R) 82579V Gigabit Network Connection"
            // Registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\<number>\Description value
            //jt
            //portDescription.Add("Vendor", adapter.Description);
            //portDescription.Add("Vendor", "");

            /*
             adapter.Id is GUID and can be found in several places: 
             In this example it is "{87423023-7191-4C03-A049-B8E7DBB36DA4}"
            
             Registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
             - \NetworkCards\<number>\ServiceName value (in same tree as adapter.Description!)
             - \NetworkList\Nla\Cache\Intranet\<adapter.Id> key
             - \NetworkList\Nla\Cache\Intranet\<domain>\<adapter.Id> key
            
             Registry: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion
             - \NetworkCards\<number>\ServiceName value
            
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007
               {4D36E972-E325-11CE-BFC1-08002BE10318} == Network and Sharing Center -> viewing adapter's "Properties" and selecting "Device class GUID" from dropdown menu
               {4D36E972-E325-11CE-BFC1-08002BE10318}\0007 == Network and Sharing Center -> viewing adapter's "Properties" and selecting "Driver key" from dropdown menu
             - \NetCfgInstanceId value
             - \Linkage\Export value (part of)
             - \Linkage\FilterList value (part of)
             - \Linkage\RootDevice value 
            
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{ad498944-762f-11d0-8dcb-00c04fc3358c}\##?#PCI#VEN_8086&DEV_1503&SUBSYS_849C1043&REV_06#3&11583659&0&C8#{ad498944-762f-11d0-8dcb-00c04fc3358c}\#{87423023-7191-4C03-A049-B8E7DBB36DA4}\SymbolicLink value (part of)
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{ 4D36E972 - E325 - 11CE - BFC1 - 08002BE10318}\{ 87423023 - 7191 - 4C03 - A049 - B8E7DBB36DA4}
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{ACB3F7A0-2E45-4435-854A-A4E120477E1D}\Connection\Name value (part of)
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\{ 87423023 - 7191 - 4C03 - A049 - B8E7DBB36DA4}
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\iphlpsvc\Parameters\Isatap\{ ACB3F7A0 - 2E45 - 4435 - 854A - A4E120477E1D}\InterfaceName value (part of)
            
             Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\<various names>\Linkage
             - \Bind value (part of)
             - \Export value (part of)
             - \Route value (part of)
            
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces\Tcpip_{87423023-7191-4C03-A049-B8E7DBB36DA4}
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Psched\Parameters\NdisAdapters\{87423023-7191-4C03-A049-B8E7DBB36DA4}
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\RemoteAccess\Interfaces\<number>\InterfaceName value
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Adapters\{87423023-7191-4C03-A049-B8E7DBB36DA4}\IpConfig value (part of)

            IPv4 information:
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\{87423023-7191-4C03-A049-B8E7DBB36DA4}

            IPv6 information:
            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\Interfaces\{87423023-7191-4c03-a049-b8e7dbb36da4}

            Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WfpLwf\Parameters\NdisAdapters\{87423023-7191-4C03-A049-B8E7DBB36DA4}

            */
            // jt
            //portDescription.Add("ID", adapter.Id);
            //portDescription.Add("ID", "");

            // Gateway
            if (ipProperties.GatewayAddresses.Count > 0)
            {
                portDescription.Add("GW", String.Join(", ", ipProperties.GatewayAddresses.Select(i => i.Address.ToString()).ToArray()));
            }
            else
            {
                portDescription.Add("GW", "-");
            }

            // CIDR
            if (ipProperties.UnicastAddresses.Count > 0)
            {
                int[] mask = ipProperties.UnicastAddresses
                    .Where(
                      w => w.IPv4Mask.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork
                    )
                    .Select(x => getCIDRFromIPMaskAddress(x.IPv4Mask))
                    .Where( m => m!= 0)
                    .ToArray()
                    ;


                portDescription.Add("NM", String.Join(", ", mask));
            }
            else
            {
                portDescription.Add("NM", "-");
            }

            /*
            // DNS server(s)
            if (ipProperties.DnsAddresses.Count > 0)
            {
                portDescription.Add("DNS", String.Join(", ", ipProperties.DnsAddresses.Select(i => i.ToString()).ToArray()));
            }
            else
            {
                portDescription.Add("DNS", "-");
            }
            */

            // DHCP server
            if (ipProperties.DhcpServerAddresses.Count > 0)
            {
                portDescription.Add("DHCP", String.Join(", ", ipProperties.DhcpServerAddresses.Select(i => i.ToString()).ToArray()));
            }
            else
            {
                portDescription.Add("DHCP", "-");
            }

            /*
            // WINS server(s)
            if (ipProperties.WinsServersAddresses.Count > 0)
            {
                portDescription.Add("WINS", String.Join(", ", ipProperties.WinsServersAddresses.Select(i => i.ToString()).ToArray()));
            }
            */

            // Link speed
            portDescription.Add("Spd", ReadableSize(adapter.Speed) + "ps");

            // Capabilities enabled
            List<CapabilityOptions> capabilitiesEnabled = new List<CapabilityOptions>();
            capabilitiesEnabled.Add(CapabilityOptions.StationOnly);

            if (ipv4Properties.IsForwardingEnabled)
            {
                capabilitiesEnabled.Add(CapabilityOptions.Router);
            }

            ushort expectedSystemCapabilitiesCapability = GetCapabilityOptionsBits(GetCapabilityOptions());
            ushort expectedSystemCapabilitiesEnabled = GetCapabilityOptionsBits(capabilitiesEnabled);

            string sysname = "";
            sysname = String.Format("{0}:{1}", Environment.MachineName, GetServiceTag());

            // Constuct LLDP packet 
            LLDPPacket lldpPacket = new LLDPPacket();
            lldpPacket.TlvCollection.Add(new ChassisID(ChassisSubTypes.MACAddress, MACAddress));
            lldpPacket.TlvCollection.Add(new PortID(PortSubTypes.LocallyAssigned, System.Text.Encoding.UTF8.GetBytes(adapter.Name)));
            lldpPacket.TlvCollection.Add(new TimeToLive(120));
            lldpPacket.TlvCollection.Add(new PortDescription(CreateTlvString(portDescription)));
            lldpPacket.TlvCollection.Add(new SystemName( sysname ));
            lldpPacket.TlvCollection.Add(new SystemDescription(CreateTlvString(systemDescription)));
            lldpPacket.TlvCollection.Add(new SystemCapabilities(expectedSystemCapabilitiesCapability, expectedSystemCapabilitiesEnabled));

            // Management
            var managementAddressObjectIdentifier = "Management";

            // Add management IPv4 address(es)
            if (null != ipv4Properties)
            {
                foreach (UnicastIPAddressInformation ip in ipProperties.UnicastAddresses)
                {
                    if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        lldpPacket.TlvCollection.Add(new ManagementAddress(new NetworkAddress(ip.Address), InterfaceNumbering.SystemPortNumber, Convert.ToUInt32(ipv4Properties.Index), managementAddressObjectIdentifier));
                    }
                }
            }

            // Add management IPv6 address(es)
            if (null != ipv6Properties)
            {
                foreach (UnicastIPAddressInformation ip in ipProperties.UnicastAddresses)
                {
                    if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
                    {
                        lldpPacket.TlvCollection.Add(new ManagementAddress(new NetworkAddress(ip.Address), InterfaceNumbering.SystemPortNumber, Convert.ToUInt32(ipv6Properties.Index), managementAddressObjectIdentifier));
                    }
                }
            }

            // == Organization specific TLVs

            // Ethernet
            lldpPacket.TlvCollection.Add(new OrganizationSpecific(new byte[] { 0x0, 0x12, 0x0f }, 5, new byte[] { 0x5 }));

            var expectedOrganizationUniqueIdentifier = new byte[3] { 0, 0, 0 };
            var expectedOrganizationSpecificBytes = new byte[] { 0, 0, 0, 0 };

            //int orgSubType = 0;

            // IPv4 Information:
            //if (null != ipv4Properties)
            //{
            //    lldpPacket.TlvCollection.Add((new StringTLV(TLVTypes.OrganizationSpecific, String.Format("IPv4 DHCP: {0}", ipv4Properties.IsDhcpEnabled.ToString()))));
            //lldpPacket.TlvCollection.Add(new OrganizationSpecific(expectedOrganizationSpecificBytes, new StringTLV(), System.Text.Encoding.UTF8.GetBytes(String.Format("IPv4 DHCP: {0}", ipv4Properties.IsDhcpEnabled.ToString()))));
            //}

            // End of LLDP packet
            lldpPacket.TlvCollection.Add(new EndOfLLDPDU());

            if (0 == lldpPacket.TlvCollection.Count)
            {
                throw new Exception("Couldn't construct LLDP TLVs.");
            }

            if (lldpPacket.TlvCollection.Last().GetType() != typeof(EndOfLLDPDU))
            {
                throw new Exception("Last TLV must be type of 'EndOfLLDPDU'!");
            }

            foreach (TLV tlv in lldpPacket.TlvCollection)
            {
                Debug.WriteLine(tlv.ToString(), EventLogEntryType.Information);
            }

            // Generate packet
            Packet packet = new EthernetPacket(MACAddress, destinationHW, EthernetPacketType.LLDP);
            packet.PayloadData = lldpPacket.Bytes;

            return packet;

        }
コード例 #9
0
        public void ConstructFromValues()
        {
            var expectedChassisIDType           = ChassisSubTypes.NetworkAddress;
            var expectedChassisIDNetworkAddress = new NetworkAddress(new IPAddress(new byte[4] {
                0x0A, 0x00, 0x01, 0x01
            }));
            var expectedPortIDBytes = new byte[15] {
                0x30, 0x30, 0x31, 0x42, 0x35, 0x34, 0x39, 0x34, 0x35, 0x41, 0x38, 0x42, 0x3a, 0x50, 0x32
            };
            ushort expectedTimeToLive                   = 120;
            string expectedPortDescription              = "Port Description";
            string expectedSystemName                   = "SystemName";
            string expectedSystemDescription            = "System Description";
            ushort expectedSystemCapabilitiesCapability = 18;
            ushort expectedSystemCapabilitiesEnabled    = 16;
            var    managementAddressNetworkAddress      = new NetworkAddress(new IPAddress(new byte[4] {
                0x0A, 0x00, 0x01, 0x01
            }));
            var  managementAddressObjectIdentifier = "Object Identifier";
            uint managementAddressInterfaceNumber  = 0x44060124;

            var expectedOrganizationUniqueIdentifier = new byte[3] {
                0x24, 0x10, 0x12
            };
            var expectedOrganizationSubType       = 2;
            var expectedOrganizationSpecificBytes = new byte[4] {
                0xBA, 0xAD, 0xF0, 0x0D
            };

            var valuesLLDPPacket = new LLDPPacket();

            Console.WriteLine("valuesLLDPPacket.ToString() {0}", valuesLLDPPacket.ToString());
            valuesLLDPPacket.TlvCollection.Add(new ChassisID(expectedChassisIDType, expectedChassisIDNetworkAddress));
            Console.WriteLine("valuesLLDPPacket.ToString() {0}", valuesLLDPPacket.ToString());
            //valuesLLDPPacket.TlvCollection.Add(new PortID(lldpPacket, PortSubTypes.MACAddress, new PhysicalAddress(new byte[6] { 0x00, 0x1C, 0x23, 0xAF, 0x08, 0xF3 })));
            valuesLLDPPacket.TlvCollection.Add(new PortID(PortSubTypes.LocallyAssigned, expectedPortIDBytes));
            valuesLLDPPacket.TlvCollection.Add(new TimeToLive(expectedTimeToLive));
            valuesLLDPPacket.TlvCollection.Add(new PortDescription(expectedPortDescription));
            valuesLLDPPacket.TlvCollection.Add(new SystemName(expectedSystemName));
            valuesLLDPPacket.TlvCollection.Add(new SystemDescription(expectedSystemDescription));
            valuesLLDPPacket.TlvCollection.Add(new SystemCapabilities(expectedSystemCapabilitiesCapability, expectedSystemCapabilitiesEnabled));
            valuesLLDPPacket.TlvCollection.Add(new ManagementAddress(managementAddressNetworkAddress,
                                                                     InterfaceNumbering.SystemPortNumber,
                                                                     managementAddressInterfaceNumber,
                                                                     managementAddressObjectIdentifier));
            valuesLLDPPacket.TlvCollection.Add(new OrganizationSpecific(expectedOrganizationUniqueIdentifier,
                                                                        expectedOrganizationSubType,
                                                                        expectedOrganizationSpecificBytes));
            valuesLLDPPacket.TlvCollection.Add(new EndOfLLDPDU());

            var lldpBytes = valuesLLDPPacket.Bytes;

            Console.WriteLine("valuesLLDPPacket.ToString() {0}", valuesLLDPPacket.ToString());

            // reparse these bytes back into a lldp packet
            var lldpPacket = new LLDPPacket(new ByteArraySegment(lldpBytes));

            Console.WriteLine("lldpPacket.ToString() {0}", lldpPacket.ToString());

            int expectedTlvCount = 10;

            Assert.AreEqual(expectedTlvCount, lldpPacket.TlvCollection.Count);

            int count = 1;

            foreach (TLV tlv in lldpPacket.TlvCollection)
            {
                Console.WriteLine("Type: " + tlv.GetType().ToString());
                switch (count)
                {
                case 1:
                    Assert.AreEqual(typeof(ChassisID), tlv.GetType());
                    var chassisID = (ChassisID)tlv;
                    Assert.AreEqual(ChassisSubTypes.NetworkAddress, chassisID.SubType);
                    Assert.AreEqual(typeof(NetworkAddress), chassisID.SubTypeValue.GetType());
                    Console.WriteLine(expectedChassisIDNetworkAddress.ToString());
                    Console.WriteLine(chassisID.SubTypeValue.ToString());
                    Assert.AreEqual(expectedChassisIDNetworkAddress, chassisID.SubTypeValue);
                    break;

                case 2:
                    Assert.AreEqual(typeof(PortID), tlv.GetType());
                    var portID = (PortID)tlv;
                    Assert.AreEqual(PortSubTypes.LocallyAssigned, portID.SubType);
                    Assert.AreEqual(expectedPortIDBytes, portID.SubTypeValue);
                    //Assert.AreEqual(PortSubTypes.MACAddress, portID.SubType);
                    //var macAddress = new PhysicalAddress(new byte[6] { 0x00, 0x1C, 0x23, 0xAF, 0x08, 0xF3 });
                    //Assert.AreEqual(macAddress, portID.SubTypeValue);
                    break;

                case 3:
                    Assert.AreEqual(typeof(TimeToLive), tlv.GetType());
                    Assert.AreEqual(expectedTimeToLive, ((TimeToLive)tlv).Seconds);
                    break;

                case 4:
                    Assert.AreEqual(typeof(PortDescription), tlv.GetType());
                    Assert.AreEqual(expectedPortDescription, ((PortDescription)tlv).Description);
                    break;

                case 5:
                    Assert.AreEqual(typeof(SystemName), tlv.GetType());
                    Assert.AreEqual(expectedSystemName, ((SystemName)tlv).Name);
                    break;

                case 6:
                    Assert.AreEqual(typeof(SystemDescription), tlv.GetType());
                    Assert.AreEqual(expectedSystemDescription, ((SystemDescription)tlv).Description);
                    break;

                case 7:
                    Assert.AreEqual(typeof(SystemCapabilities), tlv.GetType());
                    var capabilities = (SystemCapabilities)tlv;
                    Assert.IsTrue(capabilities.IsCapable(CapabilityOptions.Repeater));
                    Assert.IsTrue(capabilities.IsEnabled(CapabilityOptions.Router));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.Bridge));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.DocsisCableDevice));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.Other));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.StationOnly));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.Telephone));
                    Assert.IsFalse(capabilities.IsCapable(CapabilityOptions.WLanAP));
                    break;

                case 8:
                    Assert.AreEqual(typeof(ManagementAddress), tlv.GetType());
                    var mgmtAdd = (ManagementAddress)tlv;
                    Assert.AreEqual(AddressFamily.IPv4, mgmtAdd.AddressSubType);
                    Assert.AreEqual(managementAddressNetworkAddress, mgmtAdd.MgmtAddress);
                    Assert.AreEqual(InterfaceNumbering.SystemPortNumber, mgmtAdd.InterfaceSubType);
                    Assert.AreEqual(managementAddressInterfaceNumber, mgmtAdd.InterfaceNumber);
                    int expectedObjIdLength = managementAddressObjectIdentifier.Length;
                    Assert.AreEqual(expectedObjIdLength, mgmtAdd.ObjIdLength);
                    Assert.AreEqual(managementAddressObjectIdentifier, mgmtAdd.ObjectIdentifier);
                    break;

                case 9:
                    Assert.AreEqual(typeof(OrganizationSpecific), tlv.GetType());
                    var orgSpecifig = (OrganizationSpecific)tlv;
                    Assert.AreEqual(expectedOrganizationUniqueIdentifier, orgSpecifig.OrganizationUniqueID);
                    Assert.AreEqual(expectedOrganizationSubType, orgSpecifig.OrganizationDefinedSubType);
                    Assert.AreEqual(expectedOrganizationSpecificBytes, orgSpecifig.OrganizationDefinedInfoString);
                    break;

                case 10:
                    Assert.AreEqual(typeof(EndOfLLDPDU), tlv.GetType());
                    break;

                default:
                    throw new ArgumentException();
                }

                // increment the counter
                count++;
            }
        }
コード例 #10
0
 public void RandomPacket()
 {
     LLDPPacket.RandomPacket();
 }
コード例 #11
0
        public void readLLDP(LLDPPacket packet, int port)
        {
            var tlvFields = packet.TlvCollection;

            LLDPNeighbour lldpRow = new LLDPNeighbour();

            lldpRow.LocalHostName = "HP PC";
            lldpRow.LocalPort     = port.ToString();

            byte[] lldpRec = packet.Bytes;
            int    i       = 0;

            while (lldpRec[i++] != 4)
            {
                i += lldpRec[i] + 1;
            }

            int portContentLength = lldpRec[i] - 1;

            byte[] portContent = new byte[portContentLength];

            i += 2;

            for (int j = portContentLength - 1; j >= 0; j--)
            {
                portContent[j] = lldpRec[i++];
            }

            lldpRow.RemotePort = Encoding.ASCII.GetString(portContent);

            while (lldpRec[i++] != 6)
            {
                i += lldpRec[i] + 1;
            }

            int timeLength = lldpRec[i++];

            byte[] timicek = new byte[timeLength];



            for (int j = timeLength - 1; j >= 0; j--)
            {
                timicek[j] = lldpRec[i++];
            }

            lldpRow.Timer = (int)BitConverter.ToInt16(timicek, 0);

            while (lldpRec[i] != 10 && lldpRec[i++] != 0)
            {
                i += lldpRec[i] + 1;
            }

            if (lldpRec[i++] != 0)
            {
                int    sysNameLength = lldpRec[i++];
                byte[] sysNameCon    = new byte[sysNameLength];

                for (int j = 0; j < sysNameLength; j++)
                {
                    sysNameCon[j] = lldpRec[i++];
                }

                lldpRow.RemoteHostname = Encoding.ASCII.GetString(sysNameCon);
            }

            //Console.WriteLine(lldpRow.RemoteHostname + " aha ze to ide");

            if (searchLLDP(lldpRow.RemoteHostname, lldpRow.Timer, lldpRow.RemotePort) == 1)
            {
                tableofLLDP.Add(lldpRow);
            }
        }
コード例 #12
0
        public void sendPacketLLDP(WinPcapDevice device, char devNum)
        {
            //System.Threading.Thread.Sleep(5000);

            // var packetToSend = PacketDotNet.LLDPPacket.RandomPacket();

            LLDPPacket packetik = new LLDPPacket();

            packetik.TlvCollection.Add(new ChassisID("HP shitty PC"));
            packetik.TlvCollection.Add(new PortID(PortSubTypes.MACAddress, device.MacAddress));
            packetik.TlvCollection.Add(new TimeToLive(10));
            packetik.TlvCollection.Add(new EndOfLLDPDU());

            String systemnm = "HP shitty PC";
            String portDesc = device.Description;
            String srcMAC   = device.MacAddress.ToString();
            ushort timicek  = 10;


            byte[] chasiss         = BitConverter.GetBytes((long)(Math.Pow(2, 9) + 7));
            byte[] portID          = BitConverter.GetBytes((long)(Math.Pow(2, 10) + 2));
            byte[] timetolive      = BitConverter.GetBytes((long)Math.Pow(2, 10) + (long)Math.Pow(2, 9) + 2);
            byte[] portdescription = BitConverter.GetBytes((long)Math.Pow(2, 11) + portDesc.Length);
            byte[] systemName      = BitConverter.GetBytes((long)Math.Pow(2, 11) + systemnm.Length + (long)Math.Pow(2, 9));


            byte[] chasContent = hovno(srcMAC);
            byte[] timeContent = BitConverter.GetBytes(timicek);

            Byte[] lldpRamec = new Byte[chasContent.Length + portDesc.Length + systemnm.Length + 17];

            int i = 0;

            for (int j = 1; j >= 0; j--)
            {
                lldpRamec[i++] = chasiss[j];
            }

            lldpRamec[i++] = 4;

            for (int j = 0; j < chasContent.Length; j++)
            {
                lldpRamec[i++] = chasContent[j];
            }

            for (int j = 1; j >= 0; j--)
            {
                lldpRamec[i++] = portID[j];
            }

            lldpRamec[i++] = 5;

            lldpRamec[i++] = Convert.ToByte(devNum);

            for (int j = 1; j >= 0; j--)
            {
                lldpRamec[i++] = timetolive[j];
            }

            lldpRamec[i++] = timeContent[1];
            lldpRamec[i++] = timeContent[0];

            lldpRamec[i++] = portdescription[1];
            lldpRamec[i++] = portdescription[0];

            for (int j = 0; j < portDesc.Length; j++)
            {
                lldpRamec[i++] = Convert.ToByte(portDesc[j]);
            }

            lldpRamec[i++] = systemName[1];
            lldpRamec[i++] = systemName[0];

            for (int j = 0; j < systemnm.Length; j++)
            {
                lldpRamec[i++] = Convert.ToByte(systemnm[j]);
            }

            //var lldpBytes = packetik.Bytes;
            // var lldpPacket = new PacketDotNet.LLDPPacket(new ByteArraySegment(lldpBytes));

            //Console.WriteLine("Krasne LLDP: " + lldpPacket.ToString());
            //Console.WriteLine("Krasne LLDP: " + lldpBytes[0].ToString());


            // Console.WriteLine("TUTTTTTTTTTU " + device.Addresses[2].Addr.ToString());
            var ethernetPacket = new EthernetPacket(device.Addresses[2].Addr.hardwareAddress, PhysicalAddress.Parse("01-80-C2-00-00-0E"), EthernetPacketType.LLDP);

            ethernetPacket.PayloadData = lldpRamec;

            while (true)
            {
                lock (locker)
                {
                    // Console.WriteLine("LLDP is on the way");
                    device.SendPacket(ethernetPacket);
                }
                System.Threading.Thread.Sleep(5000);
            }
        }
コード例 #13
0
ファイル: DataBuilder.cs プロジェクト: Charming199/UserWatch
        //标记当前数据是否有效

        #region 构建数据行
        /// <summary>
        /// DataGridRow
        /// </summary>
        /// <returns>返回字符串数据</returns>
        public string[] Row(RawCapture rawPacket, uint packetID)
        {
            string[] rows = new string[7];

            rows[0] = string.Format("{0:D7}", packetID); //编号
            rows[1] = "Unknown";
            rows[2] = rawPacket.Data.Length.ToString();  //数据长度bytes
            rows[3] = "--";
            rows[4] = "--";
            rows[5] = "--";
            //rows[6] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");
            rows[6] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Packet packet = Packet.ParsePacket(rawPacket.LinkLayerType, rawPacket.Data);

            EthernetPacket ep = EthernetPacket.GetEncapsulated(packet);

            if (ep != null)
            {
                rows[1] = "Ethernet(v2)";
                rows[3] = Format.MacFormat(ep.SourceHwAddress.ToString());
                rows[4] = Format.MacFormat(ep.DestinationHwAddress.ToString());
                rows[5] = "[" + ep.Type.ToString() + "]";

                #region IP
                IpPacket ip = IpPacket.GetEncapsulated(packet);
                if (ip != null)
                {
                    if (ip.Version == IpVersion.IPv4)
                    {
                        rows[1] = "IPv4";
                    }
                    else
                    {
                        rows[1] = "IPv6";
                    }
                    rows[3] = ip.SourceAddress.ToString();
                    rows[4] = ip.DestinationAddress.ToString();
                    rows[5] = "[下层协议:" + ip.NextHeader.ToString() + "] [版本:" + ip.Version.ToString() + "]";

                    TcpPacket tcp = TcpPacket.GetEncapsulated(packet);
                    if (tcp != null)
                    {
                        rows[1]  = "TCP";
                        rows[3] += " [" + tcp.SourcePort.ToString() + "]";
                        rows[4] += " [" + tcp.DestinationPort.ToString() + "]";

                        #region 25:smtp协议;80, 8080, 3128: Http; 21: FTP;
                        if (tcp.DestinationPort.ToString() == "25" || tcp.SourcePort.ToString() == "25")
                        {
                            rows[1] = "SMTP";
                        }
                        else if (tcp.DestinationPort.ToString() == "80" || tcp.DestinationPort.ToString() == "8080" || tcp.DestinationPort.ToString() == "3128")
                        {
                            rows[1] = "HTTP";
                        }
                        else if (tcp.DestinationPort.ToString() == "21")
                        {
                            rows[1] = "FTP";
                        }
                        else if (tcp.DestinationPort.ToString() == "143")
                        {
                            rows[1] = "POP3";
                        }
                        #endregion
                        return(rows);
                    }
                    UdpPacket udp = UdpPacket.GetEncapsulated(packet);
                    if (udp != null)
                    {
                        if (rawPacket.Data[42] == ((byte)02))
                        {
                            rows[1] = "OICQ";
                        }
                        else
                        {
                            rows[1] = "UDP";
                        }
                        rows[3] += " [" + udp.SourcePort.ToString() + "]";
                        rows[4] += " [" + udp.DestinationPort.ToString() + "]";
                        return(rows);
                    }

                    ICMPv4Packet icmpv4 = ICMPv4Packet.GetEncapsulated(packet);
                    if (icmpv4 != null)
                    {
                        rows[1] = "ICMPv4";
                        rows[5] = "[校验:" + icmpv4.Checksum.ToString() + "] [类型:" + icmpv4.TypeCode.ToString() + "] [序列号:" + icmpv4.Sequence.ToString() + "]";
                        return(rows);
                    }
                    ICMPv6Packet icmpv6 = ICMPv6Packet.GetEncapsulated(packet);
                    if (icmpv6 != null)
                    {
                        rows[1] = "ICMPv6";
                        rows[5] = "[Code:" + icmpv6.Code.ToString() + "] [Type" + icmpv6.Type.ToString() + "]";
                        return(rows);
                    }
                    IGMPv2Packet igmp = IGMPv2Packet.GetEncapsulated(packet);
                    if (igmp != null)
                    {
                        rows[1] = "IGMP";
                        rows[5] = "[只适用于IGMPv2] [组地址:" + igmp.GroupAddress.ToString() + "]  [类型:" + igmp.Type.ToString() + "]";
                        return(rows);
                    }
                    return(rows);
                }
                #endregion

                ARPPacket arp = ARPPacket.GetEncapsulated(packet);
                if (arp != null)
                {
                    rows[1] = "ARP";
                    rows[3] = Format.MacFormat(arp.SenderHardwareAddress.ToString());
                    rows[4] = Format.MacFormat(arp.TargetHardwareAddress.ToString());
                    rows[5] = "[Arp操作方式:" + arp.Operation.ToString() + "] [发送者:" + arp.SenderProtocolAddress.ToString() + "] [目标:" + arp.TargetProtocolAddress.ToString() + "]";
                    return(rows);
                }
                WakeOnLanPacket wp = WakeOnLanPacket.GetEncapsulated(packet);
                if (wp != null)
                {
                    rows[1] = "Wake On Lan";
                    rows[3] = Format.MacFormat(ep.SourceHwAddress.ToString());
                    rows[4] = Format.MacFormat(wp.DestinationMAC.ToString());
                    rows[5] = "[唤醒网络地址:" + wp.DestinationMAC.ToString() + "] [有效性:" + wp.IsValid().ToString() + "]";
                    return(rows);
                }
                PPPoEPacket poe = PPPoEPacket.GetEncapsulated(packet);
                if (poe != null)
                {
                    rows[1] = "PPPoE";
                    rows[5] = poe.Type.ToString() + " " + poe.Version.ToString();
                    return(rows);
                }
                LLDPPacket llp = LLDPPacket.GetEncapsulated(packet);
                if (llp != null)
                {
                    rows[1] = "LLDP";
                    rows[5] = llp.ToString();
                    return(rows);
                }
                return(rows);
            }
            //链路层
            PPPPacket ppp = PPPPacket.GetEncapsulated(packet);
            if (ppp != null)
            {
                rows[1] = "PPP";
                rows[3] = "--";
                rows[4] = "--";
                rows[5] = "协议类型:" + ppp.Protocol.ToString();
                return(rows);
            }
            //PPPSerial
            PppSerialPacket ppps = PppSerialPacket.GetEncapsulated(packet);
            if (ppps != null)
            {
                rows[1] = "PPP";
                rows[3] = "--";
                rows[4] = "0x" + ppps.Address.ToString("X2");
                rows[5] = "地址:" + ppps.Address.ToString("X2") + " 控制:" + ppps.Control.ToString() + " 协议类型:" + ppps.Protocol.ToString();
                return(rows);
            }
            //Cisco HDLC
            CiscoHDLCPacket hdlc = CiscoHDLCPacket.GetEncapsulated(packet);
            if (hdlc != null)
            {
                rows[1] = "Cisco HDLC";
                rows[3] = "--";
                rows[4] = "0x" + hdlc.Address.ToString("X2");
                rows[5] = "地址:" + hdlc.Address.ToString("X2") + " 控制:" + hdlc.Control.ToString() + " 协议类型:" + hdlc.Protocol.ToString();
                return(rows);
            }
            #region
            //SmtpPacket smtp = SmtpPacket.
            #endregion

            PacketDotNet.Ieee80211.MacFrame ieee = Packet.ParsePacket(rawPacket.LinkLayerType, rawPacket.Data) as PacketDotNet.Ieee80211.MacFrame;
            if (ieee != null)
            {
                rows[1] = "IEEE802.11 MacFrame";
                rows[3] = "--";
                rows[4] = "--";
                rows[5] = "帧校验序列:" + ieee.FrameCheckSequence.ToString() + " 封装帧:" + ieee.FrameControl.ToString();
                return(rows);
            }
            PacketDotNet.Ieee80211.RadioPacket ieeePacket = Packet.ParsePacket(rawPacket.LinkLayerType, rawPacket.Data) as PacketDotNet.Ieee80211.RadioPacket;
            if (ieeePacket != null)
            {
                rows[1] = "IEEE Radio";
                rows[5] = "Version=" + ieeePacket.Version.ToString();
            }
            LinuxSLLPacket linux = Packet.ParsePacket(rawPacket.LinkLayerType, rawPacket.Data) as LinuxSLLPacket;
            if (linux != null)
            {
                rows[1] = "LinuxSLL";
                rows[5] = "Tyep=" + linux.Type.ToString() + " Protocol=" + linux.EthernetProtocolType.ToString();
            }
            return(rows);
        }
コード例 #14
0
 private void lbxCapturedPacketList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         gbxPacketInfo.Visibility = Visibility.Visible;
         Packet packet = lbxCapturedPacketList.SelectedItem as Packet;
         Console.WriteLine(packet.GetType());
         TcpPacket       tcp      = (TcpPacket)packet.Extract(typeof(TcpPacket));
         IpPacket        ip       = (IpPacket)packet.Extract(typeof(IpPacket));
         EthernetPacket  ethernet = (EthernetPacket)packet.Extract(typeof(EthernetPacket));
         UdpPacket       udp      = (UdpPacket)packet.Extract(typeof(UdpPacket));
         ICMPv4Packet    icmpv4   = (ICMPv4Packet)packet.Extract(typeof(ICMPv4Packet));
         ICMPv6Packet    icmpv6   = (ICMPv6Packet)packet.Extract(typeof(ICMPv6Packet));
         ICMPv6Packet    igmp     = (ICMPv6Packet)packet.Extract(typeof(ICMPv6Packet));
         PPPoEPacket     PPPoE    = (PPPoEPacket)packet.Extract(typeof(PPPoEPacket));
         PPPPacket       pppp     = (PPPPacket)packet.Extract(typeof(PPPPacket));
         LLDPPacket      LLDP     = (LLDPPacket)packet.Extract(typeof(LLDPPacket));
         WakeOnLanPacket WOL      = (WakeOnLanPacket)packet.Extract(typeof(WakeOnLanPacket));
         if (tcp != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = tcp.ToString(StringOutputType.Verbose);
             }));
         }
         if (ip != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = ip.ToString(StringOutputType.Verbose);
             }));
         }
         if (ethernet != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = ethernet.ToString(StringOutputType.Verbose);
             }));
         }
         if (udp != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = udp.ToString(StringOutputType.Verbose);
             }));
         }
         if (icmpv4 != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = icmpv4.ToString(StringOutputType.Verbose);
             }));
         }
         if (icmpv6 != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = icmpv6.ToString(StringOutputType.Verbose);
             }));
         }
         if (igmp != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = igmp.ToString(StringOutputType.Verbose);
             }));
         }
         if (PPPoE != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = PPPoE.ToString(StringOutputType.Verbose);
             }));
         }
         if (pppp != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = pppp.ToString(StringOutputType.Verbose);
             }));
         }
         if (LLDP != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = LLDP.ToString(StringOutputType.Verbose);
             }));
         }
         if (WOL != null)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {
                 tbxInfo.Text = WOL.ToString(StringOutputType.Verbose);
             }));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("{0} Exception caught.", ex);
     }
 }