Exemple #1
0
        internal static void PrepareOverlappedFakeContacts(Kademlia kademlia1, Kademlia kademlia2, int contacts)
        {
            for (int i = 0; i < contacts; i++)
            {
                var id = KademliaId.RandomId;
                var ni = new NodeInformation(new IPEndPoint(IPAddress.Loopback, 12345), id);

                RegisterFakeContact(kademlia1, ni);
            }
            for (int i = 0; i < contacts; i++)
            {
                var id = KademliaId.RandomId;
                var ni = new NodeInformation(new IPEndPoint(IPAddress.Loopback, 12345), id);

                RegisterFakeContact(kademlia2, ni);
            }
            for (int i = 0; i < contacts; i++)
            {
                var id = KademliaId.RandomId;
                var ni = new NodeInformation(new IPEndPoint(IPAddress.Loopback, 12345), id);

                RegisterFakeContact(kademlia1, ni);
                RegisterFakeContact(kademlia2, ni);
            }
        }
Exemple #2
0
        internal Node(ushort port, KyruApplication app)
        {
            Port = port;
            this.app = app;
            MetadataStorage = new MetadataStorage(this);
            Kademlia = new Kademlia(this);

            udp = new UdpClient(port);
            tcp = new TcpListener(IPAddress.Any, port);
            KyruTimer.Register(this, 1);
        }
Exemple #3
0
        internal static void RegisterFakeContact(Kademlia kademlia, NodeInformation ni)
        {
            var message = new UdpMessage();
            kademlia.HandleIncomingRequest(ni, message);

            if (message.ResponseCallback == null)
                return;

            var response = new UdpMessage();
            response.ResponseId = message.RequestId;
            response.SenderNodeId = ni.NodeId;
            message.ResponseCallback(response);
        }
        internal void PrepareKademlia()
        {
            node = new Node(null);
            kademlia = node.Kademlia;

            node2 = new Node(12345, null);
            kademlia2 = node2.Kademlia;

            targetId = node2.Id;

            var ni = new NodeInformation(new IPEndPoint(IPAddress.Loopback, 12345), targetId);
            TestHelper.RegisterFakeContact(kademlia, ni);

            // set LastSeen to a time beyond the ping interval
            var contact = Mirror.ForObject(kademlia)["FirstContact"].Invoke();
            Mirror.ForObject(contact)["LastSeen"].Value = DateTime.Now - TimeSpan.FromHours(1.1);
        }
        internal void PrepareKademlia()
        {
            node = new Node(null);
            kademlia = node.Kademlia;

            node2 = new Node(12345, null);
            kademlia2 = node.Kademlia;

            targetEndPoint = new IPEndPoint(IPAddress.Loopback, 12345);
            targetId = node2.Id;

            node.Start();
            node2.Start();

            kademlia.AddNode(new IPEndPoint(IPAddress.Loopback, 12345));
            Thread.Sleep(TestParameters.LocalhostCommunicationTimeout);
        }
Exemple #6
0
 internal AddNodeForm(Kademlia kademlia)
 {
     InitializeComponent();
     this.kademlia = kademlia;
 }
Exemple #7
0
 internal void PrepareKademlia()
 {
     node = new Node(null);
     kademlia = node.Kademlia;
 }