Package org.drasyl.handler.sntp
Class SntpMessage
java.lang.Object
org.drasyl.handler.sntp.SntpMessage
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
NTP server is not synchronized.static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
abstract int
getMode()
abstract long
abstract int
getPoll()
abstract int
abstract long
abstract int
abstract long
abstract float
abstract float
abstract int
abstract long
abstract int
static SntpMessage
of
(int leapIndicator, int versionNumber, int mode, int stratum, int poll, int precision, float rootDelay, float rootDispersion, int referenceIdentifier, long referenceTimestamp, long originateTimestamp, long receiveTimestamp, long transmitTimestamp) static SntpMessage
of
(long transmitTimestamp) Creates a clientSntpMessage
.static long
toJavaTime
(long ntpTime) ConvertsntpTime
to the java time format.static long
toNTPTime
(long javaTime) ConvertsjavaTime
to the correct NTP time format as defined in RFC-1305.
-
Field Details
-
SIZE
public static final int SIZE- See Also:
-
VERSION_NUMBER
public static final int VERSION_NUMBER- See Also:
-
CLIENT_MODE
public static final int CLIENT_MODE- See Also:
-
SERVER_MODE
public static final int SERVER_MODE- See Also:
-
LI_NOT_SYNC
public static final int LI_NOT_SYNCNTP server is not synchronized. Typically, we do not want to use this kind of servers.- See Also:
-
TRANSMIT_TIMESTAMP_OFFSET
public static final int TRANSMIT_TIMESTAMP_OFFSET- See Also:
-
-
Constructor Details
-
SntpMessage
public SntpMessage()
-
-
Method Details
-
of
public static SntpMessage of(int leapIndicator, int versionNumber, int mode, int stratum, int poll, int precision, float rootDelay, float rootDispersion, int referenceIdentifier, long referenceTimestamp, long originateTimestamp, long receiveTimestamp, long transmitTimestamp) -
of
Creates a clientSntpMessage
.- Parameters:
transmitTimestamp
- the current timestamp in java format.- Returns:
- a client
SntpMessage
.
-
getLeapIndicator
public abstract int getLeapIndicator() -
getVersionNumber
public abstract int getVersionNumber() -
getMode
public abstract int getMode() -
getStratum
public abstract int getStratum() -
getPoll
public abstract int getPoll() -
getPrecision
public abstract int getPrecision() -
getRootDelay
public abstract float getRootDelay() -
getRootDispersion
public abstract float getRootDispersion() -
getReferenceIdentifier
public abstract int getReferenceIdentifier() -
getReferenceTimestamp
public abstract long getReferenceTimestamp() -
getOriginateTimestamp
public abstract long getOriginateTimestamp() -
getReceiveTimestamp
public abstract long getReceiveTimestamp() -
getTransmitTimestamp
public abstract long getTransmitTimestamp() -
toNTPTime
public static long toNTPTime(long javaTime) ConvertsjavaTime
to the correct NTP time format as defined in RFC-1305.- Parameters:
javaTime
- the time in java format- Returns:
- time in NTP format as defined in RFC-1305
-
toJavaTime
public static long toJavaTime(long ntpTime) ConvertsntpTime
to the java time format.- Parameters:
ntpTime
- time in format as defined in RFC-1305- Returns:
- time in java format
-