public static string Get(string url) { request += "GET " + GetResource(url) + " HTTP/1.1\n" + "Host: " + GetHost(url) + "\n" + "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0\n" + ""; using (var xClient = new DnsClient()) { xClient.Connect(dns); //DNS Server address /** Send DNS ask for a single domain name **/ xClient.SendAsk(GetHost(url)); /** Receive DNS Response **/ Address destination = xClient.Receive(); //can set a timeout value xClient.Close(); tcpc.Connect(destination, 80); tcpc.Send(Encoding.ASCII.GetBytes(request)); endPoint.address = destination; endPoint.port = 80; return(Encoding.ASCII.GetString(tcpc.Receive(ref endPoint))); } }
/// <summary> /// CommandDns /// </summary> /// <param name="arguments">Arguments</param> public override ReturnInfo Execute(List <string> arguments) { try { var dnsClient = new DnsClient(); var tcpClient = new TcpClient(80); //Uri uri = new Uri(arguments[0]); Missing plugs dnsClient.Connect(DNSConfig.Server(0)); dnsClient.SendAsk(arguments[0]); Address address = dnsClient.Receive(); dnsClient.Close(); tcpClient.Connect(address, 80); string httpget = "GET / HTTP/1.1\r\n" + "User-Agent: Wget (CosmosOS)\r\n" + "Accept: */*\r\n" + "Accept-Encoding: identity\r\n" + "Host: " + arguments[0] + "\r\n" + "Connection: Keep-Alive\r\n\r\n"; tcpClient.Send(Encoding.ASCII.GetBytes(httpget)); var ep = new EndPoint(Address.Zero, 0); var data = tcpClient.Receive(ref ep); tcpClient.Close(); string httpresponse = Encoding.ASCII.GetString(data); Kernel.console.WriteLine(httpresponse); } catch (Exception ex) { Kernel.console.WriteLine("Exception: " + ex); } return(new ReturnInfo(this, ReturnCode.OK)); }
/// <summary> /// CommandDns /// </summary> /// <param name="arguments">Arguments</param> public override ReturnInfo Execute(List <string> arguments) { var xClient = new DnsClient(); string domainname; if (arguments.Count < 1 || arguments.Count > 2) { return(new ReturnInfo(this, ReturnCode.ERROR_ARG)); } else if (arguments.Count == 1) { xClient.Connect(DNSConfig.Server(0)); Kernel.console.WriteLine("DNS used : " + DNSConfig.Server(0).ToString()); xClient.SendAsk(arguments[0]); domainname = arguments[0]; } else { xClient.Connect(Address.Parse(arguments[0])); xClient.SendAsk(arguments[1]); domainname = arguments[1]; } Address address = xClient.Receive(); xClient.Close(); if (address == null) { return(new ReturnInfo(this, ReturnCode.ERROR, "Unable to find " + arguments[0])); } else { Kernel.console.WriteLine(domainname + " is " + address.ToString()); } return(new ReturnInfo(this, ReturnCode.OK)); }
/// <summary> /// CommandDns /// </summary> /// <param name="arguments">Arguments</param> public override ReturnInfo Execute(List <string> arguments) { var xClient = new DnsClient(); string domainname; if (arguments.Count < 1 || arguments.Count > 2) { return(new ReturnInfo(this, ReturnCode.ERROR_ARG)); } else if (arguments.Count == 1) { xClient.Connect(NetworkConfig.CurrentConfig.Value.DefaultDNSServer); xClient.SendAsk(arguments[0]); domainname = arguments[0]; } else { xClient.Connect(Address.Parse(arguments[0])); xClient.SendAsk(arguments[1]); domainname = arguments[1]; } Address address = xClient.Receive(); xClient.Close(); if (address == null) { return(new ReturnInfo(this, ReturnCode.ERROR, "Unable to get URL for " + arguments[0])); } else { Console.WriteLine(domainname + " is " + address.ToString()); } return(new ReturnInfo(this, ReturnCode.OK)); }
/// <summary> /// CommandEcho /// </summary> /// <param name="arguments">Arguments</param> public override ReturnInfo Execute(List <string> arguments) { int PacketSent = 0; int PacketReceived = 0; int PacketLost = 0; int PercentLoss; Address source; Address destination = Address.Parse(arguments[0]); if (destination != null) { source = IPConfig.FindNetwork(destination); } else //Make a DNS request if it's not an IP { var xClient = new DnsClient(); xClient.Connect(DNSConfig.Server(0)); xClient.SendAsk(arguments[0]); destination = xClient.Receive(); xClient.Close(); if (destination == null) { return(new ReturnInfo(this, ReturnCode.ERROR, "Failed to get DNS response for " + arguments[0])); } source = IPConfig.FindNetwork(destination); } try { Console.WriteLine("Sending ping to " + destination.ToString()); var xClient = new ICMPClient(); xClient.Connect(destination); for (int i = 0; i < 4; i++) { xClient.SendEcho(); PacketSent++; var endpoint = new EndPoint(Address.Zero, 0); int second = xClient.Receive(ref endpoint, 4000); if (second == -1) { Console.WriteLine("Destination host unreachable."); PacketLost++; } else { if (second < 1) { Console.WriteLine("Reply received from " + endpoint.address.ToString() + " time < 1s"); } else if (second >= 1) { Console.WriteLine("Reply received from " + endpoint.address.ToString() + " time " + second + "s"); } PacketReceived++; } } xClient.Close(); } catch { return(new ReturnInfo(this, ReturnCode.ERROR, "Ping process error.")); } PercentLoss = 25 * PacketLost; Console.WriteLine(); Console.WriteLine("Ping statistics for " + destination.ToString() + ":"); Console.WriteLine(" Packets: Sent = " + PacketSent + ", Received = " + PacketReceived + ", Lost = " + PacketLost + " (" + PercentLoss + "% loss)"); return(new ReturnInfo(this, ReturnCode.OK)); }
protected override void Run() { /** * Packet creation and parsing tests **/ /** Ethernet Packet Parsing Test **/ byte[] ethernetPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00 }; EthernetPacket ethernetPacket = new EthernetPacket(ethernetPacketData); Equals(ethernetPacketData, ethernetPacket.RawData); /** IP Packet Parsing Test **/ byte[] ipPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00, 0x45, 0x00, 0x01, 0x16, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x39, 0xD8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; IPPacket ipPacket = new IPPacket(ipPacketData); Equals(ipPacketData, ipPacket.RawData); /** UDP Packet Parsing Test **/ byte[] udpPacketData = new byte[] { 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0xD8, 0xCE, 0x3A, 0x89, 0x3E, 0xD9, 0x08, 0x00, 0x45, 0x00, 0x00, 0x22, 0x0C, 0x74, 0x40, 0x00, 0x40, 0x11, 0xAA, 0xBE, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8, 0x01, 0x46, 0x10, 0x92, 0x10, 0x92, 0x00, 0x0E, 0x37, 0x22, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21 }; UDPPacket udpPacket = new UDPPacket(udpPacketData); Equals(udpPacketData, udpPacket.RawData); /** DNS Packet Parsing Test **/ byte[] dnsPacketData = new byte[] { 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x38, 0xC3, 0x1C, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0xC0, 0xA8, 0x01, 0xFE, 0xF0, 0x66, 0x00, 0x35, 0x00, 0x24, 0x84, 0xCA, 0xD6, 0x80, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x69, 0x74, 0x74, 0x65, 0x72, 0x03, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x01, 0x00, 0x01 }; DNSPacket dnsPacket = new DNSPacket(dnsPacketData); Equals(dnsPacketData, dnsPacket.RawData); /** DHCP Packet Parsing Test **/ byte[] dhcpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x00, 0x45, 0xC0, 0x01, 0x59, 0x46, 0x3F, 0x00, 0x00, 0x40, 0x11, 0x6F, 0xEF, 0xC0, 0xA8, 0x01, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x43, 0x00, 0x44, 0x01, 0x45, 0xD3, 0xC8, 0x02, 0x01, 0x06, 0x00, 0x84, 0xA9, 0x5A, 0x66, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x47, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x34, 0xE1, 0x2D, 0xA3, 0x06, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x05, 0x36, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x33, 0x04, 0x00, 0x01, 0x51, 0x80, 0x3A, 0x04, 0x00, 0x00, 0xA8, 0xC0, 0x3B, 0x04, 0x00, 0x01, 0x27, 0x50, 0x1C, 0x04, 0xC0, 0xA8, 0x01, 0xFF, 0x51, 0x12, 0x03, 0xFF, 0xFF, 0x44, 0x45, 0x53, 0x4B, 0x54, 0x4F, 0x50, 0x2D, 0x49, 0x51, 0x48, 0x4A, 0x33, 0x31, 0x43, 0x06, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x0F, 0x03, 0x6C, 0x61, 0x6E, 0x03, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0x00, 0xFF }; DHCPPacket dhcpPacket = new DHCPPacket(dhcpPacketData); Equals(dhcpPacketData, dhcpPacket.RawData); /** TCP Packet Parsing Test **/ byte[] tcpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x00, 0x45, 0x00, 0x00, 0x3C, 0x64, 0x92, 0x40, 0x00, 0x40, 0x06, 0x51, 0xA2, 0xC0, 0xA8, 0x01, 0xD3, 0xC0, 0xA8, 0x01, 0x64, 0xA8, 0xAB, 0x10, 0x92, 0x67, 0x7C, 0xCE, 0x18, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x02, 0x72, 0x10, 0x5F, 0xF0, 0x00, 0x00, 0x02, 0x04, 0x05, 0xB4, 0x04, 0x02, 0x08, 0x0A, 0x58, 0x1A, 0xAA, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07 }; TCPPacket tcpPacket = new TCPPacket(tcpPacketData); Equals(tcpPacket.SourcePort, 43179); Equals(tcpPacket.DestinationPort, 4242); Equals(tcpPacket.SequenceNumber, 0x677CCE18); Equals(tcpPacket.AckNumber, 0); Equals(tcpPacket.TCPFlags, Flags.SYN); Equals(tcpPacket.WindowSize, 29200); Equals(tcpPacket.Checksum, 0x5FF0); Equals(tcpPacket.UrgentPointer, 0); /** ARP Packet Parsing Test **/ byte[] arpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ARPPacket arpPacket = new ARPPacket(arpPacketData); Equals(arpPacketData, arpPacket.RawData); TestController.Completed(); /** * Clients tests **/ var dhcpCLient = new DHCPClient(); dhcpCLient.Close(); var dnsClient = new DnsClient(); dnsClient.Close(); var udpClient = new UdpClient(); udpClient.Close(); var tcpClient = new TcpClient(4242); tcpClient.Close(); var icmpClient = new ICMPClient(); icmpClient.Close(); }
/// <summary> /// CommandEcho /// </summary> /// <param name="arguments">Arguments</param> public override ReturnInfo Execute(List <string> arguments) { int PacketSent = 0; int PacketReceived = 0; int PacketLost = 0; int PercentLoss; Address source; Address destination = Address.Parse(arguments[0]); if (destination != null) { source = Config.FindNetwork(destination); } else //Make a DNS request if it's not an IP { var xClient = new DnsClient(); xClient.Connect(NetworkConfig.CurrentConfig.Value.DefaultDNSServer); xClient.SendAsk(arguments[0]); destination = xClient.Receive(); xClient.Close(); if (destination == null) { return(new ReturnInfo(this, ReturnCode.ERROR, "Unable to get URL for " + arguments[0])); } source = Config.FindNetwork(destination); } try { int _deltaT = 0; int second; Console.WriteLine("Sending ping to " + destination.ToString()); for (int i = 0; i < 4; i++) { second = 0; try { ICMPEchoRequest request = new ICMPEchoRequest(source, destination, 0x0001, 0x50); //this is working OutgoingBuffer.AddPacket(request); //Aura doesn't work when this is called. NetworkStack.Update(); } catch (Exception ex) { return(new ReturnInfo(this, ReturnCode.ERROR, ex.ToString())); } PacketSent++; while (true) { if (ICMPPacket.recvd_reply != null) { if (second < 1) { Console.WriteLine("Reply received from " + ICMPPacket.recvd_reply.SourceIP.ToString() + " time < 1s"); } else if (second >= 1) { Console.WriteLine("Reply received from " + ICMPPacket.recvd_reply.SourceIP.ToString() + " time " + second + "s"); } PacketReceived++; ICMPPacket.recvd_reply = null; break; } if (second >= 5) { Console.WriteLine("Destination host unreachable."); PacketLost++; break; } if (_deltaT != Cosmos.HAL.RTC.Second) { second++; _deltaT = Cosmos.HAL.RTC.Second; } } } } catch { return(new ReturnInfo(this, ReturnCode.ERROR, "Ping process error.")); } PercentLoss = 25 * PacketLost; Console.WriteLine(); Console.WriteLine("Ping statistics for " + destination.ToString() + ":"); Console.WriteLine(" Packets: Sent = " + PacketSent + ", Received = " + PacketReceived + ", Lost = " + PacketLost + " (" + PercentLoss + "% loss)"); return(new ReturnInfo(this, ReturnCode.OK)); }
protected override void Run() { NetworkStack.Update(); Console.Write("> "); var input = Console.ReadLine(); if (input.ToLower().StartsWith("sendpkt")) { var x = new UdpClient(128); x.Connect(Address.Zero, 128); x.Send(Encoding.ASCII.GetBytes("Hello from cosmos!")); x.Close(); } else if (input.ToLower().StartsWith("getip")) { Console.WriteLine("Connecting to DNS Server"); xClient.Connect(new Address(8, 8, 4, 4)); Console.WriteLine("Asking IP for github.com"); xClient.SendAsk("github.com"); Console.WriteLine("Waiting for data"); var addr = xClient.Receive(); if (addr == null) { Console.WriteLine("Error: connection timed out"); } else { Console.WriteLine("Got data: " + addr.ToString()); } } else if (input.ToLower().StartsWith("gettime")) { NTPClient client = new NTPClient(); var t = client.GetNetworkTime(); if (t == null) { Console.WriteLine("NTPClient.GetNetworkTime() Returned null!"); } else { Console.WriteLine("NTPClient.GetNetworkTime() Returned " + t); } } else if (input.ToLower().StartsWith("ping")) { string s = input.Replace("ping ", ""); if (input.ToLower() == "ping" | string.IsNullOrEmpty(s)) { Console.WriteLine("Invaild synax. Usage: ping <ip address or site>"); return; } Address dest = Address.Parse(s); if (dest == null) { //make a DNS request xClient.Connect(DNSConfig.Server(0)); xClient.SendAsk(s); dest = xClient.Receive(); xClient.Close(); if (dest == null) { Console.WriteLine("ERROR: Cannot find " + s); return; } } int PacketSent = 0; int PacketReceived = 0; int PacketLost = 0; int PercentLoss; try { Console.WriteLine("Sending ping to " + dest.ToString()); var xClient = new ICMPClient(); xClient.Connect(dest); for (int i = 0; i < 4; i++) { xClient.SendEcho(); PacketSent++; var endpoint = new EndPoint(Address.Zero, 0); int second = xClient.Receive(ref endpoint, 4000); if (second == -1) { Console.WriteLine("Destination host unreachable."); PacketLost++; } else { if (second < 1) { Console.WriteLine("Reply received from " + endpoint.address.ToString() + " time < 1s"); } else if (second >= 1) { Console.WriteLine("Reply received from " + endpoint.address.ToString() + " time " + second + "s"); } PacketReceived++; } } xClient.Close(); } catch (Exception x) { Console.WriteLine("Ping error: " + x.Message); } PercentLoss = 25 * PacketLost; Console.WriteLine(); Console.WriteLine("Ping statistics for " + dest.ToString() + ":"); Console.WriteLine(" Packets: Sent = " + PacketSent + ", Received = " + PacketReceived + ", Lost = " + PacketLost + " (" + PercentLoss + "% loss)"); } else if (input.ToLower().StartsWith("ipconfig")) { ipconfig(); } else if (input.ToLower().StartsWith("help")) { Console.WriteLine("MishaNetworkDemoOS Commands"); Console.WriteLine("ipconfig - Gets current IP config"); Console.WriteLine("getip - Gets IP address of github.com"); Console.WriteLine("sendpkt - Sends a packet"); Console.WriteLine("gettime - Get UTC time from time.windows.com"); } else if (string.IsNullOrEmpty(input)) { } else { Console.WriteLine("Unknown command."); } NetworkStack.Update(); }
protected override void Run() { /** * Packet creation and parsing tests **/ /** Ethernet Packet Parsing Test **/ byte[] ethernetPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00 }; EthernetPacket ethernetPacket = new EthernetPacket(ethernetPacketData); Equals(ethernetPacketData, ethernetPacket.RawData); /** IP Packet Parsing Test **/ byte[] ipPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00, 0x45, 0x00, 0x01, 0x16, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x39, 0xD8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; IPPacket ipPacket = new IPPacket(ipPacketData); Equals(ipPacketData, ipPacket.RawData); /** UDP Packet Parsing Test **/ byte[] udpPacketData = new byte[] { 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0xD8, 0xCE, 0x3A, 0x89, 0x3E, 0xD9, 0x08, 0x00, 0x45, 0x00, 0x00, 0x22, 0x0C, 0x74, 0x40, 0x00, 0x40, 0x11, 0xAA, 0xBE, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8, 0x01, 0x46, 0x10, 0x92, 0x10, 0x92, 0x00, 0x0E, 0x37, 0x22, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21 }; UDPPacket udpPacket = new UDPPacket(udpPacketData); Equals(udpPacketData, udpPacket.RawData); /** DNS Packet Parsing Test **/ byte[] dnsPacketData = new byte[] { 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x38, 0xC3, 0x1C, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0xC0, 0xA8, 0x01, 0xFE, 0xF0, 0x66, 0x00, 0x35, 0x00, 0x24, 0x84, 0xCA, 0xD6, 0x80, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x69, 0x74, 0x74, 0x65, 0x72, 0x03, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x01, 0x00, 0x01 }; DNSPacket dnsPacket = new DNSPacket(dnsPacketData); Equals(dnsPacketData, dnsPacket.RawData); /** DHCP Packet Parsing Test **/ byte[] dhcpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x00, 0x45, 0xC0, 0x01, 0x59, 0x46, 0x3F, 0x00, 0x00, 0x40, 0x11, 0x6F, 0xEF, 0xC0, 0xA8, 0x01, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x43, 0x00, 0x44, 0x01, 0x45, 0xD3, 0xC8, 0x02, 0x01, 0x06, 0x00, 0x84, 0xA9, 0x5A, 0x66, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x47, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x34, 0xE1, 0x2D, 0xA3, 0x06, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x05, 0x36, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x33, 0x04, 0x00, 0x01, 0x51, 0x80, 0x3A, 0x04, 0x00, 0x00, 0xA8, 0xC0, 0x3B, 0x04, 0x00, 0x01, 0x27, 0x50, 0x1C, 0x04, 0xC0, 0xA8, 0x01, 0xFF, 0x51, 0x12, 0x03, 0xFF, 0xFF, 0x44, 0x45, 0x53, 0x4B, 0x54, 0x4F, 0x50, 0x2D, 0x49, 0x51, 0x48, 0x4A, 0x33, 0x31, 0x43, 0x06, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x0F, 0x03, 0x6C, 0x61, 0x6E, 0x03, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0x00, 0xFF }; DHCPPacket dhcpPacket = new DHCPPacket(dhcpPacketData); Equals(dhcpPacketData, dhcpPacket.RawData); /** ARP Packet Parsing Test **/ byte[] arpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ARPPacket arpPacket = new ARPPacket(arpPacketData); Equals(arpPacketData, arpPacket.RawData); TestController.Completed(); /** * Clients tests **/ var dhcpCLient = new DHCPClient(); dhcpCLient.Close(); var dnsClient = new DnsClient(); dnsClient.Close(); var udpClient = new UdpClient(); udpClient.Close(); var icmpClient = new ICMPClient(); icmpClient.Close(); }