private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (loopMechan.isLoop(packt)) { counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { packt.ReTransmissionTry = 0; if (packt.Destination.ID == Reciver.ID) { counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); HandOffToTheSinkOrRecovry(Reciver, packt); } else { counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (loopMechan.isLoop(packt)) { counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { packt.ReTransmissionTry = 0; if (Reciver.RingNodesRule.isRingNode) // 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); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (loopMechan.isLoop(packt)) { counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { packt.ReTransmissionTry = 0; if (Reciver == packt.Destination) { counter.SuccessedDeliverdPacket(packt); counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); Reciver.Ellipse_nodeTypeIndicator.Fill = Brushes.LightSlateGray; // mark Reciver.IsHightierNode = true; counter.DisplayRefreshAtReceivingPacket(Reciver); } else { if (packt.Hops <= packt.TimeToLive) { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { if (Reciver == null) // packet is recived. { counter.SuccessedDeliverdPacket(packt); counter.DisplayRefreshAtReceivingPacket(packt.Source); } else { packt.Path += ">" + Reciver.ID; packt.ReTransmissionTry = 0; counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); Reciver.AddSinkRecordInHighTierNode(packt.ReportSinkPosition); // keep track of the sink position if (packt.Hops <= packt.TimeToLive) { if (packt.PacketDirection == PacketDirection.Up) { Packet upPlacket = GeneragtePacket(Reciver, packt.ReportSinkPosition, PacketDirection.Up); SendPacket(Reciver, upPlacket); } else { // down: Packet downPlacket = GeneragtePacket(Reciver, packt.ReportSinkPosition, PacketDirection.Down); SendPacket(Reciver, downPlacket); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; packt.ReTransmissionTry = 0; if (Reciver.ID == packt.Destination.ID) // packet is recived. { counter.SuccessedDeliverdPacket(packt); counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); } else { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } }
private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (loopMechan.isLoop(packt)) { 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); // response to the source: if (packt.SinkIDsNeedsRecovery == null) // nomal { new ResonseSinkPositionMessage(Reciver, packt.Source); } else { // recovery packet. new ResonseSinkPositionMessage(Reciver, packt.Source, packt.SinkIDsNeedsRecovery); } if (Reciver.ReachedBatterThresh) { RingNodeChange rch = new RingNodeChange(); rch.ChangeRingNode(Reciver.RingNodesRule); } } else { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { if (Reciver == null) // packet is recived. { counter.SuccessedDeliverdPacket(packt); counter.DisplayRefreshAtReceivingPacket(packt.Source); } else { packt.Path += ">" + Reciver.ID; packt.ReTransmissionTry = 0; counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); Reciver.AddSinkRecordInHighTierNode(packt.ReportSinkPosition); // keep track of the sink position SendPacket(Reciver, packt); } }
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); // response to the source: if (packt.SinkIDsNeedsRecovery == null) // nomal { new ResonseSinkPositionMessage(Reciver, packt.Source); } else { // recovery packet. // we can also save the record new ResonseSinkPositionMessage(Reciver, packt.Source, packt.SinkIDsNeedsRecovery); } } else { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { if (LoopMechan.isLoop(packt)) { counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { // flooooding. if (Reciver.IsHightierNode == false) { // Recivece the packe and send it. counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); Reciver.IsHightierNode = true; // let each node send once. counter.DisplayRefreshAtReceivingPacket(Reciver); SendPacket(Reciver, packt); } } }
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.CenterLocation == packt.Destination) // packet is recived. { if (packt.SinksAgentsList.Count == 0) { Console.WriteLine("SinksAgentsList.Count == 0 " + "Source " + packt.Source.ID); } counter.SuccessedDeliverdPacket(packt); counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); Reciver.Ellipse_nodeTypeIndicator.Fill = Brushes.Transparent; PreparDataTransmission(Reciver, packt); // the merge path } else { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { packt.Path += ">" + Reciver.ID; if (loopMechan.isLoop(packt)) { counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { packt.ReTransmissionTry = 0; if (Reciver.IsHightierNode) { if (Reciver.AlreadyRecievedAgentInfo(packt.ReportSinkPosition)) // packet is recived. { // Console.WriteLine("****Success ANPIS : " + Reciver.ID); counter.SuccessedDeliverdPacket(packt); counter.DisplayRefreshAtReceivingPacket(packt.Source); } else { Reciver.AddSinkRecordInHighTierNode(packt.ReportSinkPosition); // keep track of the sink position counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); SendPacket(Reciver, packt); } } else { if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
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.ID == packt.Destination.ID) // packet is recived. { counter.SuccessedDeliverdPacket(packt); counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); Reciver.Ellipse_nodeTypeIndicator.Fill = Brushes.Transparent; PreparDataTransmission(Reciver, packt); // the merge path } else { // compute the overhead: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); } } } }
private void RecivePacket(Sensor Reciver, Packet packt) { // string cluster = packt.Branch.Cluster.MembersString; packt.Path += ">" + Reciver.ID; // if Reciver is an agent, then reciev the packet and remove the Reciver from the cluster // reFindBranches if the cluster still have more members. if (new LoopMechanizimAvoidance(packt).isLoop) { // drop the packet: packt.IsLooped = true; counter.DropPacket(packt, Reciver, PacketDropedReasons.Loop); } else { // not loop: packt.ReTransmissionTry = 0; if (Operations.FindInAlist(Reciver, packt.Branch.Cluster.Members) != null) { // Reciver is an agent: counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); counter.DisplayRefreshAtReceivingPacket(Reciver); // when the packet arrived to Reciver and holds more clustreds. this case reclustring process should be performed. if (packt.Branch.Cluster.Members.Count > 0) { packt.Branch.Cluster.Members.Remove(Reciver); List <Branch> Branches = FindBranches.GetBranches(packt.Branch.Cluster.Members, Reciver.CenterLocation, PublicParamerters.MainWindow.Canvas_SensingFeild, Settings.Default.MaxClusteringThreshold); if (Branches.Count > 0) { MergedPathsMessages merged = new MergedPathsMessages(Reciver, Branches, packt); } } HandOffToTheSinkOrRecovry(Reciver, packt); } else { double dis1 = Operations.DistanceBetweenTwoPoints(Reciver.CenterLocation, packt.Branch.EndPoint); double dis2 = Operations.DistanceBetweenTwoPoints(Reciver.CenterLocation, packt.Branch.Cluster.Centeriod); double disThre = PublicParamerters.CommunicationRangeRadius; if ((dis1 < disThre) && (packt.Branch.Cluster.Members.Count > 1)) { double clusteringThreshould = 0; if (dis2 <= disThre) { clusteringThreshould = Settings.Default.MinClusteringThreshold; } else { clusteringThreshould = Settings.Default.MaxClusteringThreshold; } counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); List <Branch> Branches = FindBranches.GetBranches(packt.Branch.Cluster.Members, Reciver.CenterLocation, PublicParamerters.MainWindow.Canvas_SensingFeild, clusteringThreshould); if (Branches.Count > 1) { MergedPathsMessages merged = new MergedPathsMessages(Reciver, Branches, packt); } else { counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); packt.Branch = Branches[0]; // the branch is not changed. only the end coordinat of the branch is changed. SendPacket(Reciver, packt); } } else { counter.ComputeOverhead(packt, EnergyConsumption.Recive, null, Reciver); if (packt.Hops <= packt.TimeToLive) { SendPacket(Reciver, packt); } else { counter.DropPacket(packt, Reciver, PacketDropedReasons.TimeToLive); // since we did not count PID during the generation, thuse we should add here: PublicParamerters.NumberofGeneratedPackets += 1; packt.PID = PublicParamerters.NumberofGeneratedPackets; counter.IncreasePacketsCounter(Reciver, PacketType.Data); // } } } } }