|
@@ -31,7 +31,10 @@ public class Ping_protocol implements Protocol {
|
|
sender = null;
|
|
sender = null;
|
|
target = null;
|
|
target = null;
|
|
}
|
|
}
|
|
- short sequence = 0;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Ping sequence number
|
|
|
|
+ */
|
|
|
|
+ private short sequence = 0;
|
|
@Override
|
|
@Override
|
|
public Collection<Packet> generateNextPackets(Port port, long timestep, boolean packetLost) {
|
|
public Collection<Packet> generateNextPackets(Port port, long timestep, boolean packetLost) {
|
|
/**
|
|
/**
|
|
@@ -47,15 +50,14 @@ public class Ping_protocol implements Protocol {
|
|
|
|
|
|
if(port == sender && target != null){
|
|
if(port == sender && target != null){
|
|
packets.add(new Ping_packet(timestep, sender, target, Ping_packet.EchoRequest, sequence));
|
|
packets.add(new Ping_packet(timestep, sender, target, Ping_packet.EchoRequest, sequence));
|
|
- if(target.getStatus() >= Port.OPEN){
|
|
|
|
- packets.add(new Ping_packet(timestep+target.getResponseTime()+(short)(target.getJitter()*Math.random()), target, sender, Ping_packet.EchoReply, sequence));
|
|
|
|
|
|
+ if(target.getStatus() >= Port.OPEN && !packetLost){
|
|
|
|
+ packets.add(new Ping_packet(timestep+target.getResponseTime()+(short)(target.getJitter()*Math.random()), target, sender, Ping_packet.EchoReply, sequence++));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if(port == target && sender != null){
|
|
|
|
- packets.add(new Ping_packet(timestep, target, sender, Ping_packet.EchoRequest, sequence));
|
|
|
|
- if(sender.getStatus() >= Port.OPEN){
|
|
|
|
- packets.add(new Ping_packet(timestep+sender.getResponseTime()+(short)(sender.getJitter()*Math.random()), sender, target, Ping_packet.EchoReply, sequence));
|
|
|
|
- }
|
|
|
|
|
|
+ else if(port == target){
|
|
|
|
+ /**
|
|
|
|
+ * Target should not initialize ping
|
|
|
|
+ */
|
|
}
|
|
}
|
|
return packets;
|
|
return packets;
|
|
}
|
|
}
|