private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (LoopMechan.isLoop(packt)) { // 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); } } } }
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); } }