public void PingRouteTest()
        {
            TcpSubnetProtocol p1 = new TcpSubnetProtocol(localIP, port, 1);
            TcpSubnetProtocol p2 = new TcpSubnetProtocol(localIP, port, 2);
            ID      ourID        = ID.RandomID;
            Contact c1           = new Contact(p1, ourID);
            Node    n1           = new Node(c1, new VirtualStorage());
            Node    n2           = new Node(new Contact(p2, ID.RandomID), new VirtualStorage());

            server.RegisterProtocol(p1.Subnet, n1);
            server.RegisterProtocol(p2.Subnet, n2);
            server.Start();

            p2.Ping(c1);
        }
Exemple #2
0
        protected void InitializeDhts()
        {
            dhts = new List<Dht>();
            dhtPos = new List<Rectangle>();
            peerColor = new Dictionary<BigInteger, Color>();

            NUM_DHT.ForEach((n) =>
            {

#if USE_TCP_SUBNET_PROTOCOL
                IProtocol protocol = new TcpSubnetProtocol("http://127.0.0.1", 2720, n);
#else
                IProtocol protocol = new VirtualProtocol();
#endif

                Dht dht = new Dht(ID.RandomID, protocol, () => new VirtualStorage(), new Router());
                peerColor[dht.ID.Value] = Color.Green;

#if USE_TCP_SUBNET_PROTOCOL
                server.RegisterProtocol(n, dht.Node);
#else
                ((VirtualProtocol)protocol).Node = dht.Node;
#endif

                dhts.Add(dht);
                dhtPos.Add(new Rectangle(XOFFSET + rnd.Next(-JITTER, JITTER) + (n % ITEMS_PER_ROW) * XSPACING, YOFFSET + rnd.Next(-JITTER, JITTER) + (n / ITEMS_PER_ROW) * YSPACING, SIZE, SIZE));
            });
        }