2006-07-29 Complication

* Treat NTP responses from unexpected stratums like failures
This commit is contained in:
complication
2006-07-30 05:08:20 +00:00
committed by zzz
parent 1e9e7dd345
commit 3c09ca3359
3 changed files with 14 additions and 3 deletions

View File

@ -112,11 +112,19 @@ public class NtpClient {
// Process response
NtpMessage msg = new NtpMessage(packet.getData());
double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
(msg.receiveTimestamp-msg.transmitTimestamp);
double localClockOffset = ((msg.receiveTimestamp - msg.originateTimestamp) +
(msg.transmitTimestamp - destinationTimestamp)) / 2;
socket.close();
// Stratum must be between 1 (atomic) and 15 (maximum defined value)
// Anything else is right out, treat such responses like errors
if ((msg.stratum < 1) || (msg.stratum > 15)) {
//System.out.println("Response from NTP server of unacceptable stratum " + msg.stratum + ", failing.");
return(-1);
}
long rv = (long)(System.currentTimeMillis() + localClockOffset*1000);
//System.out.println("host: " + address.getHostAddress() + " rtt: " + roundTripDelay + " offset: " + localClockOffset + " seconds");

View File

@ -1,4 +1,7 @@
$Id: history.txt,v 1.502 2006-07-28 23:43:04 jrandom Exp $
$Id: history.txt,v 1.503 2006-07-29 13:03:16 jrandom Exp $
2006-07-29 Complication
* Treat NTP responses from unexpected stratums like failures
* 2006-07-28 0.6.1.24 released

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.441 $ $Date: 2006-07-28 23:41:16 $";
public final static String ID = "$Revision: 1.442 $ $Date: 2006-07-29 13:03:17 $";
public final static String VERSION = "0.6.1.24";
public final static long BUILD = 0;
public final static long BUILD = 1;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);