Ejemplo n.º 1
0
        public void ReceiveJoinReply(JoinReply reply)
        {
            if (this.Name == reply.Source)
            {
                Console.WriteLine("Source received JR");
                //Task.Delay(sendDelay + 1300).ContinueWith(t => this.SendPacket(null));
                //this.SendPacket(null);
                return;
            }

            if (reply.NextHop == this.Name)
            {
                Console.WriteLine(this.Name + " received JR");
                this.FG_FLAG = true;

                var routingEntry = routingTable.Find(x => x.Destination == reply.Source);

                var jr = new JoinReply()
                {
                    Source  = reply.Source,
                    NextHop = routingEntry.NextNode,
                };

                foreach (var node in ConnectedNodes)
                {
                    Task.Delay(sendDelay).ContinueWith(t => node.ReceiveJoinReply(jr));
                }
            }
            else
            {
                Console.WriteLine(this.Name + " Received JR and Dropped");
            }
        }
Ejemplo n.º 2
0
        public void SendJoinReply(JoinQuery joinQuery)
        {
            var reply = new JoinReply()
            {
                Source  = joinQuery.Source,
                NextHop = joinQuery.LastHop
            };

            Console.WriteLine(this.Name + " transmitting JR");

            foreach (Node node in ConnectedNodes)
            {
                Task.Delay(sendDelay).ContinueWith(t => node.ReceiveJoinReply(reply));
            }
        }