Пример #1
0
        /// <summary>
        /// currentBifSensor: current node that has the packet.
        /// Branches: the branches
        /// isSourceAnAgent: the source is an agent for a sink. That is to say no need for clustering the source itslef this time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="Branches"></param>
        /// <param name="packet"></param>
        /// <param name="isSourceAnAgent"></param>
        public DataPacketMessages(Sensor sender, Packet packet)
        {
            counter = new NetworkOverheadCounter();

            // the source node creates new
            if (packet.PacketType == PacketType.ResponseSinkPosition) // i d
            {
                // create new: packet for each sink.
                foreach (SinksAgentsRow sinksAgents in packet.SinksAgentsList)
                {
                    if (sender.ID == sinksAgents.AgentNode.ID)
                    {
                        //skip the test here and send to the known sink by urself
                        //Hand of to the sink by urself this is me,
                        Packet pkt = GeneragtePacket(sender, sinksAgents); //
                        pkt.SinksAgentsList = packet.SinksAgentsList;
                        HandOffToTheSinkOrRecovry(sender, pkt);
                    }
                    else
                    {
                        Packet pck = GeneragtePacket(sender, sinksAgents); // duplicate.
                        pck.SinksAgentsList = packet.SinksAgentsList;
                        SendPacket(sender, pck);
                    }
                }
            }
            else if (packet.PacketType == PacketType.Data) // duplicate:
            {
                // recovery packets:
                Packet dupPck = Duplicate(packet, sender, false);
                SendPacket(sender, dupPck);
            }
        }
Пример #2
0
        /// <summary>
        /// currentBifSensor: current node that has the packet.
        /// Branches: the branches
        /// isSourceAnAgent: the source is an agent for a sink. That is to say no need for clustering the source itslef this time.
        /// </summary>
        /// <param name="currentBifSensor"></param>
        /// <param name="Branches"></param>
        /// <param name="packet"></param>
        /// <param name="isSourceAnAgent"></param>
        public MergedPathsMessages(Sensor currentBifSensor, List <Branch> Branches, Packet packet)
        {
            counter = new NetworkOverheadCounter();

            // the source node creates new
            if (packet.PacketType == PacketType.ResponseSinkPosition) // i d
            {
                // create new:
                foreach (Branch branch in Branches)
                {
                    // Create new packet
                    Packet pck = GeneragtePacket(currentBifSensor, branch); // new.
                    pck.TimeToLive           = branch.TimeToliveInBranch;
                    pck.SinksAgentsList      = packet.SinksAgentsList;
                    pck.SinkIDsNeedsRecovery = packet.SinkIDsNeedsRecovery; // in case for recovery.
                    SendPacket(currentBifSensor, pck);
                }
            }
            else if (packet.PacketType == PacketType.Data) // duplicate:
            {
                //
                foreach (Branch branch in Branches)
                {
                    Packet duplicatedPacket = Duplicate(packet, currentBifSensor, false);                            // reforward recovery packets.                                                             // duplicate the packet:
                    duplicatedPacket.Branch               = branch;
                    duplicatedPacket.TimeToLive           = duplicatedPacket.TimeToLive + branch.TimeToliveInBranch; // add.
                    duplicatedPacket.SinkIDsNeedsRecovery = packet.SinkIDsNeedsRecovery;                             // incase for recovery.
                    SendPacket(currentBifSensor, duplicatedPacket);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// currentBifSensor: current node that has the packet.
        /// Branches: the branches
        /// isSourceAnAgent: the source is an agent for a sink. That is to say no need for clustering the source itslef this time.
        /// </summary>
        /// <param name="currentBifSensor"></param>
        /// <param name="Branches"></param>
        /// <param name="packet"></param>
        /// <param name="isSourceAnAgent"></param>
        public DataPacketMessages(Sensor sender, Packet packet)
        {
            counter = new NetworkOverheadCounter();

            // the source node creates new
            if (packet.PacketType == PacketType.ResponseSinkPosition) //  the packet arrived to the source node. it was response. now we will generate of duplicate the packet.
            {
                // create new:
                foreach (SinksAgentsRow row in packet.SinksAgentsList)
                {
                    if (sender.ID == row.AgentNode.ID)
                    {
                        //skip the test here and send to the known sink by urself
                        //Hand of to the sink by urself
                        Packet pkt = GeneragtePacket(sender, row); //
                        pkt.SinksAgentsList = packet.SinksAgentsList;
                        HandOffToTheSinkOrRecovry(sender, pkt);
                    }
                    else
                    {
                        Packet pck = GeneragtePacket(sender, row); // duplicate.
                        pck.SinksAgentsList = packet.SinksAgentsList;
                        SendPacket(sender, pck);
                    }
                }
            }
            else if (packet.PacketType == PacketType.Data)
            {
                // recovery packets:
                Packet dupPck = Duplicate(packet, sender);
                SendPacket(sender, dupPck);
            }
        }
Пример #4
0
        public TestSendPacketsBetweenTwoNodesRandomlySelected(Sensor source, Sensor dist)
        {
            counter = new NetworkOverheadCounter();

            Packet packet = GeneragtePacket(source, dist);

            SendPacket(source, packet);
        }
Пример #5
0
        public ReportSinkPositionMessage(SinksAgentsRow reportSinkPosition)
        {
            counter = new NetworkOverheadCounter();
            reportSinkPosition.RingAccessPointDestination = reportSinkPosition.AgentNode.getDestinationForRingAccess();
            Packet ANPI = GeneratePacket(reportSinkPosition);

            SendPacket(reportSinkPosition.AgentNode, ANPI);
        }
Пример #6
0
 /// <summary>
 /// Sensor anchor1, Sensor anchor2 are the two points of the diagonal line.
 /// </summary>
 /// <param name="anchor1"></param>
 /// <param name="anchor2"></param>
 /// <param name="canvas"></param>
 public RingConstructionMessage(Sensor anchor1, Sensor anchor2, Canvas canvas)
 {
     if (anchor1 != null && anchor2 != null)
     {
         can     = canvas;
         counter = new NetworkOverheadCounter();
         Packet pck = GeneratePacket(anchor1, anchor2); //
         SendPacket(anchor1, pck);                      // start from the node 1
     }
 }
Пример #7
0
        /// <summary>
        /// The source node is an agent: needs to deliver the packet to the sink.
        /// no need for branch here.
        /// </summary>
        /// <param name="isSourceAnAgent"></param>
        /// <param name="sender"></param>
        /// <param name="packet"></param>
        public MergedPathsMessages(Sensor sender, Packet packet)
        {
            counter = new NetworkOverheadCounter();

            Packet selfPacket = GeneragtePacket(sender, null);

            selfPacket.SinksAgentsList      = packet.SinksAgentsList;
            selfPacket.SinkIDsNeedsRecovery = packet.SinkIDsNeedsRecovery; // incase for recovery.
            HandOffToTheSinkOrRecovry(sender, selfPacket);
        }
Пример #8
0
 /// <summary>
 /// Sensor anchor1, Sensor anchor2 are the two points of the diagonal line.
 /// </summary>
 /// <param name="anchor1"></param>
 /// <param name="anchor2"></param>
 /// <param name="canvas"></param>
 public LineConstructionMessage(Sensor starterNode, List <Point> rec, Canvas canvas)
 {
     if (starterNode != null)
     {
         _rec    = rec;
         can     = canvas;
         counter = new NetworkOverheadCounter();
         starterNode.IsHightierNode = true;                                   // this is the first node
         starterNode.Ellipse_nodeTypeIndicator.Fill = Brushes.LightSlateGray; //
         Packet pck = GeneratePacket(starterNode, rec);                       //
         SendPacket(starterNode, pck);                                        // start from the node 1
     }
 }
Пример #9
0
 /// <summary>
 /// the recovery process.
 /// the response from the hightierNode to the lowtiernode should include the SinkIDs only but not all sinks.
 /// </summary>
 /// <param name="hightierNode"></param>
 /// <param name="lowtiernode"></param>
 /// <param name="SinkIDs"></param>
 public ResonseSinkPositionMessage(Sensor hightierNode, Sensor lowtiernode, List <int> SinkIDs)
 {
     counter = new NetworkOverheadCounter();
     // the hightierNode=lowtiernode --> means that the high tier node itself has data to send.
     if (hightierNode.ID == lowtiernode.ID)
     {
         // here high tier has data to send.
         Packet responspacket = GeneragtePacket(hightierNode, hightierNode, SinkIDs, false);
         PreparDataTransmission(hightierNode, responspacket);
     }
     else
     {
         Packet responspacket = GeneragtePacket(hightierNode, lowtiernode, SinkIDs, true);
         SendPacket(hightierNode, responspacket);
     }
 }
Пример #10
0
        public ShareSinkPositionIntheHighTier(Sensor highTierGateWay, SinksAgentsRow reportSinkPositionRow)
        {
            if (highTierGateWay.IsHightierNode)
            {
                counter = new NetworkOverheadCounter();
                Packet leftpacket = GeneragtePacket(highTierGateWay, reportSinkPositionRow);
                leftpacket.PacketDirection = PacketDirection.Left;
                Packet righttpacket = GeneragtePacket(highTierGateWay, reportSinkPositionRow);
                righttpacket.PacketDirection = PacketDirection.Right;
                SendPacket(highTierGateWay, leftpacket);
                SendPacket(highTierGateWay, righttpacket);


                //: SAVE Sink positions.// this is not agent record. becarful here
                highTierGateWay.AddSinkRecordInHighTierNode(reportSinkPositionRow);
            }
        }
Пример #11
0
 /// <summary>
 ///  the hightierNode should response to the lowtiernode.
 ///  here the respnse should contain all sinks.
 /// </summary>
 /// <param name="hightierNode"></param>
 /// <param name="sourceNode"></param>
 public ResonseSinkPositionMessage(Sensor hightierNode, Sensor sourceNode)
 {
     counter = new NetworkOverheadCounter();
     // the hightierNode=lowtiernode --> means that the high tier node itself has data to send.
     if (hightierNode.ID == sourceNode.ID)
     {
         // here high tier has data to send.
         Packet responspacket = GeneragtePacket(hightierNode, hightierNode, null, true); // fack.
         counter.SuccessedDeliverdPacket(responspacket);                                 // count it as delivered
         PreparDataTransmission(hightierNode, responspacket);
     }
     else
     {
         Packet responspacket = GeneragtePacket(hightierNode, sourceNode, null, true);
         SendPacket(hightierNode, responspacket);
     }
 }
Пример #12
0
        public ShareSinkPositionIntheHighTier(Sensor ringNodeGateway, SinksAgentsRow reportSinkPositionRow)
        {
            if (ringNodeGateway.IsHightierNode)
            {
                ringNodeGateway.AddSinkRecordInHighTierNode(reportSinkPositionRow);


                counter = new NetworkOverheadCounter();
                Packet clock = GeneragtePacket(ringNodeGateway, reportSinkPositionRow);
                clock.PacketDirection = PacketDirection.Left;
                Packet anticlock = GeneragtePacket(ringNodeGateway, reportSinkPositionRow);
                anticlock.PacketDirection = PacketDirection.Right;
                SendPacket(ringNodeGateway, clock);
                SendPacket(ringNodeGateway, anticlock);


                //: SAVE Sink positions.// this is not agent record. becarful here
            }
        }
Пример #13
0
        /// <summary>
        /// obtian location for the sinks with IDs listed in SinkIDs.
        /// this is used in the recovery mechansim.
        /// when the agent node did not found its sinks.
        /// </summary>
        /// <param name="AgentNode"> the node that make the request.</param>
        /// <param name="SinkIDs"></param>
        public ObtainSinkFreshPositionMessage(Sensor AgentNode, List <int> SinkIDs)
        {
            counter = new NetworkOverheadCounter();

            // the high tier node has data.
            if (AgentNode.IsHightierNode)
            {
                Packet pack = GeneragtePacket(AgentNode, false);               // fack packet.
                pack.SinkIDsNeedsRecovery = SinkIDs;                           // not all sinks. this is for data recovery only.
                new ResonseSinkPositionMessage(AgentNode, AgentNode, SinkIDs); // recovery.
            }
            else
            {
                AgentNode.Ellipse_nodeTypeIndicator.Fill = Brushes.Yellow;
                Packet ObtainSinkPositionPacket = GeneragtePacket(AgentNode, true);
                ObtainSinkPositionPacket.SinkIDsNeedsRecovery = SinkIDs; // not all sinks. this is for data recovery only.
                SendPacket(AgentNode, ObtainSinkPositionPacket);
            }
        }
Пример #14
0
        /// <summary>
        /// obtian the position for all sinks.
        /// </summary>
        /// <param name="sensor"></param>
        public ObtainSinkFreshPositionMessage(Sensor sensor)
        {
            counter = new NetworkOverheadCounter();

            // the high tier node has data.
            if (sensor.IsHightierNode)
            {
                Packet pack = GeneragtePacket(sensor, false);
                pack.SinkIDsNeedsRecovery = null;
                new ResonseSinkPositionMessage(sensor, sensor);
            }
            else
            {
                sensor.Ellipse_nodeTypeIndicator.Fill = Brushes.Yellow;
                Packet ObtainSinkPositionPacket = GeneragtePacket(sensor, true);
                ObtainSinkPositionPacket.SinkIDsNeedsRecovery = null;
                SendPacket(sensor, ObtainSinkPositionPacket);
            }
        }
Пример #15
0
        public ReportSinkPositionMessage(SinksAgentsRow reportSinkPosition)
        {
            // node should not be a hightier
            if (!reportSinkPosition.AgentNode.IsHightierNode)
            {
                counter = new NetworkOverheadCounter();
                reportSinkPosition.ClosestPointOnTheDiagonal = ClosePointToMe.PerPendicaularPoint(reportSinkPosition.AgentNode);
                Packet packet = GeneragtePacket(reportSinkPosition);

                SendPacket(reportSinkPosition.AgentNode, packet);
                // check if the node isself is hightier node. here no need to generate ReportSinkPosition.
            }
            else
            {
                // node just generate sharesinkposition packet.
                // no need to report.
                ShareSinkPositionIntheHighTier xma = new ShareSinkPositionIntheHighTier(reportSinkPosition.AgentNode, reportSinkPosition);
            }
        }
Пример #16
0
        /// <summary>
        /// obtian location for the sinks with IDs listed in SinkIDs.
        /// this is used in the recovery mechansim.
        /// when the agent node did not found its sinks.
        /// </summary>
        /// <param name="AgentNode"> the node that make the request.</param>
        /// <param name="SinkIDs"></param>
        public ObtainSinkFreshPositionMessage(Sensor AgentNode, List <int> SinkIDs)
        {
            counter = new NetworkOverheadCounter();

            // the high tier node has data.
            if (AgentNode.IsHightierNode)
            {
                // response to him selef:
                Packet pack = GeneratePacket(AgentNode, false);
                pack.SinkIDsNeedsRecovery = SinkIDs;                           // not all sinks. this is for data recovery only.
                //counter.SuccessedDeliverdPacket(pack); // considere the obtian packet as delivred.
                new ResonseSinkPositionMessage(AgentNode, AgentNode, SinkIDs); // recovery.
            }
            else
            {
                AgentNode.Ellipse_nodeTypeIndicator.Fill = Brushes.Yellow;
                Packet ObtainSinkPositionPacket = GeneratePacket(AgentNode, true);
                ObtainSinkPositionPacket.SinkIDsNeedsRecovery = SinkIDs; // not all sinks. this is for data recovery only.
                SendPacket(AgentNode, ObtainSinkPositionPacket);
            }
        }
Пример #17
0
        public ShareSinkPositionIntheHighTier(Sensor highTierGateWay, SinksAgentsRow reportSinkPositionRow)
        {
            if (highTierGateWay.IsHightierNode)
            {
                counter = new NetworkOverheadCounter();


                Packet upPlacket  = GeneragtePacket(highTierGateWay, reportSinkPositionRow, PacketDirection.Up);
                Packet downpacket = GeneragtePacket(highTierGateWay, reportSinkPositionRow, PacketDirection.Down);


                SendPacket(highTierGateWay, upPlacket);
                SendPacket(highTierGateWay, downpacket);

                // floood:


                //: SAVE Sink positions.// this is not agent record. becarful here
                highTierGateWay.AddSinkRecordInHighTierNode(reportSinkPositionRow);
            }
        }
Пример #18
0
        /// <summary>
        /// obtian the position for all sinks.
        /// </summary>
        /// <param name="sourceNode"></param>
        public ObtainSinkFreshPositionMessage(Sensor sourceNode)
        {
            counter = new NetworkOverheadCounter();

            // the high tier node has data.
            if (sourceNode.RingNodesRule.isRingNode)
            {
                //Directly send data to the access nodes that u have
                //No need to send a query request and wait for response
                Packet pack = GeneratePacket(sourceNode, true);
                pack.SinkIDsNeedsRecovery = null;
                counter.SuccessedDeliverdPacket(pack); // considere the obtian packet as delivred.
                new ResonseSinkPositionMessage(sourceNode, sourceNode);
            }
            else
            {
                //Regular sensor node disseminating data start with QReq
                sourceNode.Ellipse_nodeTypeIndicator.Fill = Brushes.Yellow;
                Packet QReq = GeneratePacket(sourceNode, true);
                QReq.SinkIDsNeedsRecovery = null;
                SendPacket(sourceNode, QReq);
            }
        }
Пример #19
0
 /// <summary>
 /// we call this for HandelInQueuPacket
 /// </summary>
 public MergedPathsMessages()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #20
0
 public ResonseSinkPositionMessage()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #21
0
 /// <summary>
 /// just to handel the in queue packets.
 /// </summary>
 public ObtainSinkFreshPositionMessage()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #22
0
 public DataPacketMessages()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #23
0
 public GreedyRoutingMechansims()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #24
0
 public ShareSinkPositionIntheHighTier()
 {
     counter = new NetworkOverheadCounter();
 }
Пример #25
0
        /// <summary>
        /// preAgent send an obtian packet to ask for the new agent of the sink.
        /// </summary>
        /// <param name="preAgent"></param>
        /// <param name="SinksIDsRequiredRecovery"></param>
        public RecoveryMessage(Sensor preAgent, Packet packet)
        {
            // preAgent: if it has no record, then we obtian the sink position first.
            // if the preAgent did not sent an obtian message to the hightier node
            if (preAgent.RecoveryRow == null)
            {
                // obtian the recovery. obtian the sink location.
                Console.WriteLine("RecoveryMessage. >>>>Trying to recover the packet. Source ID=" + packet.Source.ID + " PID=" + packet.PID + " Path " + packet.Path);
                new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery);
            }
            else
            {
                // it has record. no need to resend an obtian: but you should wait.
                if (!preAgent.RecoveryRow.IsExpired)
                {
                    // not expired
                    List <Sensor> NewAents = new List <Sensor>(); // new agent for the recovery.
                    foreach (SinksAgentsRow newAgentRow in preAgent.RecoveryRow.RecoveryAgentList)
                    {
                        if (newAgentRow.AgentNode.ID != preAgent.ID)
                        {
                            bool isFound = Operations.FindInAlistbool(newAgentRow.AgentNode, NewAents);
                            if (!isFound)
                            {
                                packet.Destination = newAgentRow.AgentNode;
                                NewAents.Add(newAgentRow.AgentNode);
                            }
                        }
                    }

                    // if we found the new agent.
                    if (NewAents.Count > 0)
                    {
                        Console.WriteLine("RecoveryMessage. Source ID=" + packet.Source.ID + " PID=" + packet.PID + " Path " + packet.Path);
                        List <Branch> Branches = FindBranches.GetBranches(NewAents, preAgent.CenterLocation, PublicParamerters.MainWindow.Canvas_SensingFeild, Settings.Default.MaxClusteringThreshold);

                        packet.SinksAgentsList = preAgent.RecoveryRow.RecoveryAgentList;
                        new MergedPathsMessages(preAgent, Branches, packet);
                    }
                    else
                    {
                        if (preAgent.RecoveryRow.ObtainPacketsRetry >= 3)
                        {
                            // in case no new agent is found.
                            Console.WriteLine("RecoveryMessage. No agent is found during the recovery.Source ID = " + packet.Source.ID + " PID = " + packet.PID + " Path " + packet.Path);
                            NetworkOverheadCounter counter = new NetworkOverheadCounter();
                            // counter.DropPacket(packet, preAgent, PacketDropedReasons.RecoveryNoNewAgentFound);
                            counter.SaveToQueue(preAgent, packet);
                        }
                        else
                        {
                            Console.WriteLine("RecoveryMessage. Recovery period is expired. Old Agent is sending new obtain packet!" + " Path " + packet.Path);
                            new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery); // obtain
                        }
                    }
                }
                else
                {
                    // resent the obtian packet. 2 times.
                    if (preAgent.RecoveryRow.ObtainPacketsRetry <= 3)
                    {
                        Console.WriteLine("RecoveryMessage. Recovery period is expired. Old Agent is sending new obtain packet!" + " Path " + packet.Path);
                        new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery); // obtain
                    }
                    else
                    {
                        Console.WriteLine("RecoveryMessage. Recovery period is expired. we tryied to re-sent the obtian packet for three times and faild. The packet will be droped." + " Path " + packet.Path);
                        // drop the packet:
                        NetworkOverheadCounter counter = new NetworkOverheadCounter();
                        counter.DropPacket(packet, preAgent, PacketDropedReasons.RecoveryPeriodExpired);
                        preAgent.RecoveryRow = null;
                    }
                }
            }
        }
Пример #26
0
        /// <summary>
        /// preAgent: the packet will arrived to this  agent. This agent did not know the location of the new agent for the SinksIDsRequiredRecovery.
        /// </summary>
        /// <param name="preAgent"></param>
        /// <param name="SinksIDsRequiredRecovery"></param>
        public RecoveryMessage(Sensor preAgent, Packet packet)
        {
            // preAgent: if it has no record, then we obtian the sink position first.
            // if the preAgent did not sent an obtian message to the hightier node
            if (preAgent.RecoveryRow == null)
            {
                // obtian the recovery. obtian the sink location.
                new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery);  //
            }
            else
            {
                // it has record. no need to resend an obtian: but you should wait.
                if (!preAgent.RecoveryRow.IsExpired)
                {
                    // not expired
                    List <Sensor> NewAents = new List <Sensor>();                               // new agent for the recovery.
                    foreach (SinksAgentsRow row in preAgent.RecoveryRow.RecoveryAgentList)      // get the agents
                    {
                        if (row.AgentNode.ID != preAgent.ID)                                    // no the same agent. the new one should had diffrent ID
                        {
                            bool isFound = Operations.FindInAlistbool(row.AgentNode, NewAents); // no repeatation
                            if (!isFound)
                            {
                                packet.Destination = row.AgentNode; // update the packet destination.
                                NewAents.Add(row.AgentNode);
                            }
                        }
                    }

                    if (NewAents.Count > 0)
                    {
                        Console.WriteLine("RecoveryMessage. Source ID=" + packet.Source.ID + " PID=" + packet.PID + " Path " + packet.Path);
                        packet.SinksAgentsList = preAgent.RecoveryRow.RecoveryAgentList;
                        if (packet.Hops <= packet.TimeToLive)
                        {
                            new DataPacketMessages(preAgent, packet);
                        }
                        else
                        {
                            NetworkOverheadCounter counter = new NetworkOverheadCounter();
                            counter.DropPacket(packet, preAgent, PacketDropedReasons.Loop);
                        }
                    }
                    else
                    {
                        if (preAgent.RecoveryRow.ObtainPacketsRetry >= 3)
                        {
                            // in case no new agent is found.
                            Console.WriteLine("RecoveryMessage. No agent is found during the recovery.Source ID = " + packet.Source.ID + " PID = " + packet.PID + " Path " + packet.Path);
                            NetworkOverheadCounter counter = new NetworkOverheadCounter();
                            counter.DropPacket(packet, preAgent, PacketDropedReasons.RecoveryNoNewAgentFound);
                        }
                        else
                        {
                            Console.WriteLine("RecoveryMessage. Recovery period is expired. Old Agent is sending new obtain packet!" + " Path " + packet.Path);
                            new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery); // obtain
                        }
                    }
                }
                else
                {
                    // resent the obtian packet. 2 times.
                    if (preAgent.RecoveryRow.ObtainPacketsRetry <= 3)
                    {
                        Console.WriteLine("RecoveryMessage. Recovery period is expired. Old Agent is sending new obtain packet!" + " Path " + packet.Path);
                        new ObtainSinkFreshPositionMessage(preAgent, packet.SinkIDsNeedsRecovery); // obtain
                    }
                    else
                    {
                        Console.WriteLine("RecoveryMessage. Recovery period is expired. we tryied to re-sent the obtian packet for three times and faild. The packet will be droped." + " Path " + packet.Path);
                        // drop the packet:
                        NetworkOverheadCounter counter = new NetworkOverheadCounter();
                        counter.DropPacket(packet, preAgent, PacketDropedReasons.RecoveryPeriodExpired);
                        preAgent.RecoveryRow = null;
                    }
                }
            }
        }