IpAddrByVal ipaddr = new IpAddrByVal();
ipaddr.bytes = subject.getAddress().getAddress();
int sendDataSize = 56;
int replyDataSize = sendDataSize + (new IcmpEchoReply().size()) + 10;
Pointer sendData = new Memory(sendDataSize);
sendData.clear(sendDataSize);
Pointer replyData = new Memory(replyDataSize);
PingResult result = new PingResult(subject.getAddress());
try {
for (int i = 1; i <= count && !currentThread().isInterrupted(); i++) {
int numReplies = dll.IcmpSendEcho(handle, ipaddr, sendData, (short) sendDataSize, null, replyData, replyDataSize, timeout);
IcmpEchoReply echoReply = new IcmpEchoReply(replyData);
if (numReplies > 0 && echoReply.status == 0 && Arrays.equals(echoReply.address.bytes, ipaddr.bytes)) {
result.addReply(echoReply.roundTripTime);
result.setTTL(echoReply.options.ttl & 0xFF);
}
}