private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.ReportSinkPosition) { // neext hope: Sensor Reciver; sender.SwichToActive(); // switch on me. if (sender.RingNeighborRule.isNeighbor) { if (sender.RingNeighborRule.NearestRingNode != null) { RingNeighborSendPacket(sender, pck); return; } } Reciver = SelectNextHop(sender, pck); if (Reciver != null) { counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } else { // wait: counter.SaveToQueue(sender, pck); } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.ShareSinkPosition) { sender.SwichToActive(); // neext hope: // note: here the Reciver is null for two reasons: //1- it is in sleep mode. //- the current sender has no more right or left diaogonal nodes. if (pck.PacketDirection == PacketDirection.Right) { if (sender.RightVldNeighbor != null) { if (sender.RightVldNeighbor.CurrentSensorState == SensorState.Active) { counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, sender.RightVldNeighbor); counter.Animate(sender, sender.RightVldNeighbor, pck); RecivePacket(sender.RightVldNeighbor, pck); } else { // wait: counter.SaveToQueue(sender, pck); } } else { pck.Destination = sender; // arrived to dest. RecivePacket(null, pck); } } else { if (sender.LeftVldNeighbor != null) { if (sender.LeftVldNeighbor.CurrentSensorState == SensorState.Active) { counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, sender.LeftVldNeighbor); counter.Animate(sender, sender.LeftVldNeighbor, pck); RecivePacket(sender.LeftVldNeighbor, pck); } else { // wait: counter.SaveToQueue(sender, pck); } } else { pck.Destination = sender; // arrived to dest. RecivePacket(null, pck); } } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.ShareSinkPosition) { sender.SwichToActive(); List <Sensor> Recivers = Flood(sender, pck); if (Recivers != null) { foreach (Sensor Reciver in Recivers) { // overhead: counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.ShareSinkPosition) { Sensor destination; if (pck.PacketDirection == PacketDirection.Right) { destination = sender.RingNodesRule.AntiClockWiseNeighbor; } else { destination = sender.RingNodesRule.ClockWiseNeighbor; } if (destination != null) { if (!Operations.isInMyComunicationRange(sender, destination)) { pck.Destination = destination; SendANPISWithRelay(sender, pck); return; } if (destination.CurrentSensorState == SensorState.Active) { counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, destination); counter.Animate(sender, destination, pck); RecivePacket(destination, pck); } else { // wait: counter.SaveToQueue(sender, pck); } } else { //Drop the packet something went wrong counter.DropPacket(pck, sender, PacketDropedReasons.RingNodesError); } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.VirtualLineConstruction) { // neext hope: List <Sensor> Recivers = Flood(sender, pck); if (Recivers != null) { foreach (Sensor Reciver in Recivers) { // overhead: Reciver.Ellipse_nodeTypeIndicator.Fill = Brushes.LightSlateGray; // counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.ObtainSinkPosition) { // neext hope: sender.SwichToActive(); Sensor Reciver = SelectNextHop(sender, pck); if (Reciver != null) { // overhead: counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } else { counter.SaveToQueue(sender, pck); } } }
private void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.RingConstruction) { sender.SwichToActive(); // switch on me. // neext hope: Sensor Reciver = SelectNextHop(sender, pck.Destination); // overhead: counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); // make the indicate: sender.Ellipse_nodeTypeIndicator.Fill = Brushes.LightSlateGray; // sender.IsHightierNode = true; sender.RightVldNeighbor = Reciver; Reciver.LeftVldNeighbor = sender; // Operations.DrawLine(can,sender.CenterLocation, Reciver.CenterLocation); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } }
public void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.Data) { // neext hope: Sensor Reciver = SelectNextHop(sender, pck); if (Reciver != null) { // overhead: counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); //: RecivePacket(Reciver, pck); } else { counter.DropPacket(pck, sender, PacketDropedReasons.Loop); } } }
public void SendPacket(Sensor sender, Packet pck) { if (pck.PacketType == PacketType.Data) { sender.SwichToActive(); // neext hope: Sensor Reciver = SelectNextHop(sender, pck); if (Reciver != null) { // overhead: counter.ComputeOverhead(pck, EnergyConsumption.Transmit, sender, Reciver); counter.Animate(sender, Reciver, pck); RecivePacket(Reciver, pck); } else { counter.SaveToQueue(sender, pck); // save in the queue. } } }