1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package org.coach.tracing.service.ntp; 26 27 import java.net.*; 28 29 35 public class NtpInfo { 36 39 public static final byte LI_NO_WARNING = 0; 40 43 public static final byte LI_POSITIVE_LEAP_SECOND = 1; 44 47 public static final byte LI_NEGATIVE_LEAP_SECOND = 2; 48 51 public static final byte LI_ALARM_CONDITION = 3; 52 55 public static final byte MODE_RESERVED = 0; 56 59 public static final byte MODE_SYMMETRIC_ACTIVE = 1; 60 63 public static final byte MODE_RESERVED_PASSIVE = 2; 64 67 public static final byte MODE_CLIENT = 3; 68 71 public static final byte MODE_SERVER = 4; 72 75 public static final byte MODE_BROADCAST = 5; 76 79 public static final byte MODE_RESERVED_FOR_NTP_CONTROL = 6; 80 83 public static final byte MODE_RESERVED_FOR_PRIVATE_USE = 7; 84 87 public static final byte STRATUM_UNSPECIFIED = 0; 88 91 public static final byte STRATUM_PRIMARY_REFERENCE = 1; 92 95 public InetAddress serverAddress; 96 99 public int leapYearIndicator; 100 106 public int versionNumber; 107 111 public int mode; 112 116 public int stratum; 117 120 public int pollInterval; 121 124 public double precision; 125 129 public double rootDelay; 130 134 public double rootDispersion; 135 147 public Object referenceIdentifier; 148 151 public TimeStamp referenceTimeStamp; 152 155 public long roundTripDelay; 156 161 public long offset; 162 public String toString() { 163 String s = "Server address : " + serverAddress + "\n" + "Leap year indicator : " + leapYearIndicator + "\n" + "Version number : " + versionNumber + "\n" + "Mode : " + mode + "\n" + "Stratum : " + stratum + "\n" + "Poll interval : " + pollInterval + " s\n" + "Precision : " + precision + " ms\n" + "Root delay : " + rootDelay + " ms\n" + "Root dispersion : " + rootDispersion + " ms\n"; 164 165 if (referenceIdentifier instanceof InetAddress) { 166 s = s + "Reference address : " + (InetAddress)referenceIdentifier + "\n"; 167 } else if (referenceIdentifier instanceof String ) { 168 s = s + "Reference code : " + (String )referenceIdentifier + "\n"; 169 } else { 170 byte[] temp = (byte[])referenceIdentifier; 171 s = s + "Reference data : " + temp[0] + " " + temp[1] + " " + temp[2] + " " + temp[3] + "\n"; 172 } 173 s = s + "Reference timestamp : " + referenceTimeStamp + "\n" + "Round trip delay : " + roundTripDelay + " ms\n" + "Offset : " + offset + " ms"; 174 return s; 175 } 176 } 177 | Popular Tags |