Exemplo n.º 1
0
        public void foo()
        {
            Interlocked.Increment(ref id);

            var x = new DNSDatagram();

            Parallel.ForEach(_rootServers, (rootServer) =>
            {
                var ep = new IPEndPoint(IPAddress.Parse(rootServer), 53);

                udpClient.Send(x.asByteArray(), x.asByteArray().Length, ep);

                var rc = udpClient.Receive(ref ep);
                Console.WriteLine(new Tuple <string, byte[]>(ep.ToString(), rc));
            }
                             );

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void enter(String IpServer, String url)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var x = new DNSDatagram();

            var ep = new IPEndPoint(IPAddress.Parse(IpServer), 53);

            udpClient.Send(x.asByteArray(url), x.asByteArray(url).Length, ep);

            var rc = udpClient.Receive(ref ep);

            int i = 12;

            while (rc[i] != 0)
            {
                i++;
            }

            i += 6;

            for (int j = 0; j < rc[9]; j++)
            {
                i += 10;

                int jump = rc[i];

                i += jump + 2;
            }
            i += 11;

            String resul = "";
            int    w     = 0;

            while (true)
            {
                resul += rc[i];
                i++;
                w++;
                if (w == 4)
                {
                    break;
                }
                resul += ".";
            }

            stopWatch.Stop();

            Tuple <String, String> t = new Tuple <string, string>(ep.ToString(), formatTime(stopWatch));

            Log.Add(t);

            if (rc[7] == 0)
            {
                enter(resul, url);
            }
            else
            {
                var k = 44;
                k    += rc[k];
                k    += 13;
                w     = 0;
                resul = "";
                while (true)
                {
                    resul += rc[k];
                    k++;
                    w++;
                    if (w == 4)
                    {
                        break;
                    }
                    resul += ".";
                }
                Console.Write("IP Address: ");
                Console.WriteLine(resul);
            }
        }
Exemplo n.º 3
0
        public void foo(String rootServer)
        {
            Interlocked.Increment(ref id);

            var x = new DNSDatagram();

            var url = "play.google.com";

            Console.WriteLine("Realizando a tradução do nome: " + url +
                              "\nUtilizando o servidor raiz: " + rootServer + "\n");

            Stopwatch stopWatchTotal = new Stopwatch();

            stopWatchTotal.Start();

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var ep = new IPEndPoint(IPAddress.Parse(rootServer), 53);

            udpClient.Send(x.asByteArray(url), x.asByteArray(url).Length, ep);

            var rc = udpClient.Receive(ref ep);


            int i = 12;

            while (rc[i] != 0)
            {
                i++;
            }
            i += 6;
            for (int j = 0; j < rc[9]; j++)
            {
                i += 10;

                int jump = rc[i];

                i += jump + 2;
            }

            i += 11;

            String resul = "";
            int    w     = 0;

            while (true)
            {
                resul += rc[i];
                i++;
                w++;
                if (w == 4)
                {
                    break;
                }
                resul += ".";
            }

            stopWatch.Stop();

            Tuple <String, String> t = new Tuple <string, string>(ep.ToString(), formatTime(stopWatch));

            Log.Add(t);

            enter(resul, url);

            stopWatchTotal.Stop();
            Console.WriteLine();
            Console.WriteLine("Log para cada consulta");
            Log.ForEach(Console.WriteLine);;
            Console.WriteLine();
            Console.Write("Tempo total de execucao: ");
            Console.WriteLine(formatTime(stopWatchTotal));



            Console.ReadKey();

            Console.Clear();
        }