Example #1
0
        public ReportSinkPositionMessage(SinksAgentsRow reportSinkPosition)
        {
            // node should not be a hightier
            if (!reportSinkPosition.AgentNode.IsHightierNode)
            {
                counter = new NetworkOverheadCounter();
                double x = (reportSinkPosition.AgentNode.CenterLocation.X + reportSinkPosition.AgentNode.CenterLocation.Y) / 2;
                reportSinkPosition.ClosestPointOnTheDiagonal = new Point(x, x);
                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);
            }
        }
Example #2
0
        private void RecivePacket(Sensor Reciver, Packet packt)
        {
            packt.Path += ">" + Reciver.ID;

            if (new LoopMechanizimAvoidance(packt).isLoop)
            {
                // drop the packet:
                counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop);
            }
            else
            {
                packt.ReTransmissionTry = 0;

                if (Reciver.IsHightierNode) // packet is recived.
                {
                    packt.Destination = Reciver;

                    counter.SuccessedDeliverdPacket(packt);
                    counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver);
                    counter.DisplayRefreshAtReceivingPacket(Reciver);
                    // share:
                    ShareSinkPositionIntheHighTier xma = new ShareSinkPositionIntheHighTier(Reciver, packt.ReportSinkPosition);
                }
                else
                {
                    counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver);
                    if (packt.Hops <= packt.TimeToLive)
                    {
                        SendPacket(Reciver, packt);
                    }
                    else
                    {
                        counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive);
                    }
                }
            }
        }