コード例 #1
0
ファイル: Program.cs プロジェクト: ozzi7/DHT-Crawler
        static void Main(string[] args)
        {
            IPAddress  bootstrapIP  = IPAddress.Parse("67.215.246.10"); // router.bittorrent.com:6881
            IPEndPoint bootstrapAdr = new IPEndPoint(bootstrapIP, 6881);

            dhtBucketM = new DHTBucketManager(bootstrapAdr, 3245);

            // temporary
            DHTNode dhtNode1 = new DHTNode(3244);

            Console.Read();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: supertanglang/DHTCrawler-1
        static void Main(string[] args)
        {
            threads = new List<Thread>();

            // Get number of threads
            Console.Write("Enter number of sending threads (default 4): ");
            string input = Console.ReadLine();
            bool result = Int32.TryParse(input, out MAX_DHT_NODES);
            if (!result)
                MAX_DHT_NODES = 4;

            // Get number of packets per second sending
            Console.Write("Enter number of packets send per second for each thread (default 10000): ");
            input = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_PACKETS_PER_SECOND_DHT_NODE);
            if (!result)
                MAX_PACKETS_PER_SECOND_DHT_NODE = 10000;

            // Get number of starting nodes per thread
            Console.Write("Enter number of starting nodes per thread (default 1.5 million): ");
            input = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_STARTING_NODES);
            if (!result)
                MAX_STARTING_NODES = 1500000; /* 1500000*/

            // Get number of starting nodes per thread
            Console.Write("Enter number of infohashes queried per loop (default 20 - determines size of SQL queries): ");
            input = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_INFOHASHES_PER_NODE);
            if (!result)
                MAX_INFOHASHES_PER_NODE = 20; /* 1500000*/

            // Get bucket radius
            Console.Write("Enter number of neighbor buckets to check in each direction (default 1): ");
            input = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_BUCKET_RADIUS);
            if (!result)
                MAX_BUCKET_RADIUS = 1;

            // Get number of passes
            Console.Write("Enter number of times to ask all nodes (default 3): ");
            input = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_PASSES);
            if (!result)
                MAX_PASSES = 3;


            for (int i = 0; i < MAX_DHT_NODES; ++i)
            {
                DHTNode dhtNode = new DHTNode(i * 2 + 3244);
                Thread child = new Thread(t => { dhtNode.Run(); });
                threads.Add(child);
                child.Start();
            }

            // None of the childs will return
            foreach(Thread t in threads)
               t.Join();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            threads = new List <Thread>();

            // Get number of threads
            Console.Write("Enter number of sending threads (default 4): ");
            string input  = Console.ReadLine();
            bool   result = Int32.TryParse(input, out MAX_DHT_NODES);

            if (!result)
            {
                MAX_DHT_NODES = 4;
            }

            // Get number of packets per second sending
            Console.Write("Enter number of packets send per second for each thread (default 10000): ");
            input  = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_PACKETS_PER_SECOND_DHT_NODE);
            if (!result)
            {
                MAX_PACKETS_PER_SECOND_DHT_NODE = 10000;
            }

            // Get number of starting nodes per thread
            Console.Write("Enter number of starting nodes per thread (default 1.5 million): ");
            input  = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_STARTING_NODES);
            if (!result)
            {
                MAX_STARTING_NODES = 1500000; /* 1500000*/
            }
            // Get number of starting nodes per thread
            Console.Write("Enter number of infohashes queried per loop (default 20 - determines size of SQL queries): ");
            input  = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_INFOHASHES_PER_NODE);
            if (!result)
            {
                MAX_INFOHASHES_PER_NODE = 20; /* 1500000*/
            }
            // Get bucket radius
            Console.Write("Enter number of neighbor buckets to check in each direction (default 1): ");
            input  = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_BUCKET_RADIUS);
            if (!result)
            {
                MAX_BUCKET_RADIUS = 1;
            }

            // Get number of passes
            Console.Write("Enter number of times to ask all nodes (default 3): ");
            input  = Console.ReadLine();
            result = Int32.TryParse(input, out MAX_PASSES);
            if (!result)
            {
                MAX_PASSES = 3;
            }


            for (int i = 0; i < MAX_DHT_NODES; ++i)
            {
                DHTNode dhtNode = new DHTNode(i * 2 + 3244);
                Thread  child   = new Thread(t => { dhtNode.Run(); });
                threads.Add(child);
                child.Start();
            }

            // None of the childs will return
            foreach (Thread t in threads)
            {
                t.Join();
            }
        }