74 #if (BYTE_ORDER == LITTLE_ENDIAN)
85 uint8_t leapIndicator : 2,
105 uint64_t referenceTimestamp,
114 static_assert(
sizeof(ntp_header) == 48,
"ntp_header size is not 48 bytes");
116 #pragma pack(push, 1)
125 static_assert(
sizeof(ntp_v3_auth) == 12,
"ntp_v3_auth size is not 12 bytes");
127 #pragma pack(push, 1)
128 struct ntp_v4_auth_md5
136 static_assert(
sizeof(ntp_v4_auth_md5) == 20,
"ntp_v4_auth_md5 size is not 20 bytes");
138 #pragma pack(push, 1)
139 struct ntp_v4_auth_sha1
147 static_assert(
sizeof(ntp_v4_auth_sha1) == 24,
"ntp_v4_auth_sha1 size is not 24 bytes");
149 ntp_header* getNtpHeader()
const
151 return reinterpret_cast<ntp_header*
>(m_Data);
196 GOES = (
'G') | (
'O' << 8) | (
'E' << 16) | (
'S' << 24),
198 GPS = (
'G') | (
'P' << 8) | (
'S' << 16),
200 GAL = (
'G') | (
'A' << 8) | (
'L' << 16),
202 PPS = (
'P') | (
'P' << 8) | (
'S' << 16),
204 IRIG = (
'I') | (
'R' << 8) | (
'I' << 16) | (
'G' << 24),
206 WWVB = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'B' << 24),
208 DCF = (
'D') | (
'C' << 8) | (
'F' << 16),
210 HBG = (
'H') | (
'B' << 8) | (
'G' << 16),
212 MSF = (
'M') | (
'S' << 8) | (
'F' << 16),
214 JJY = (
'J') | (
'J' << 8) | (
'Y' << 16),
216 LORC = (
'L') | (
'O' << 8) | (
'R' << 16) | (
'C' << 24),
218 TDF = (
'T') | (
'D' << 8) | (
'F' << 16),
220 CHU = (
'C') | (
'H' << 8) | (
'U' << 16),
222 WWV = (
'W') | (
'W' << 8) | (
'V' << 16),
224 WWVH = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'H' << 24),
226 NIST = (
'N') | (
'I' << 8) | (
'S' << 16) | (
'T' << 24),
228 ACTS = (
'A') | (
'C' << 8) | (
'T' << 16) | (
'S' << 24),
230 USNO = (
'U') | (
'S' << 8) | (
'N' << 16) | (
'O' << 24),
232 PTB = (
'P') | (
'T' << 8) | (
'B' << 16),
234 MRS = (
'M') | (
'R' << 8) | (
'S' << 16),
236 XFAC = (
'X') | (
'F' << 8) | (
'A' << 16) | (
'C' << 24),
238 STEP = (
'S') | (
'T' << 8) | (
'E' << 16) | (
'P' << 24),
240 GOOG = (
'G') | (
'O' << 8) | (
'O' << 16) | (
'G' << 24),
243 DCFa = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'a' << 24),
246 DCFp = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'p' << 24),
249 GPSs = (
'G') | (
'P' << 8) | (
'S' << 16) | (
's' << 24),
252 GPSi = (
'G') | (
'P' << 8) | (
'S' << 16) | (
'i' << 24),
255 GLNs = (
'G') | (
'L' << 8) | (
'N' << 16) | (
's' << 24),
258 GLNi = (
'G') | (
'L' << 8) | (
'N' << 16) | (
'i' << 24),
260 LCL = (
'L') | (
'C' << 8) | (
'L' << 16),
262 LOCL = (
'L') | (
'O' << 8) | (
'C' << 16) | (
'L' << 24),
267 DCN = (
'D') | (
'C' << 8) | (
'N' << 16),
269 TSP = (
'T') | (
'S' << 8) | (
'P' << 16),
271 DTS = (
'D') | (
'T' << 8) | (
'S' << 16),
273 ATOM = (
'A') | (
'T' << 8) | (
'O' << 16) | (
'M' << 24),
275 VLF = (
'V') | (
'L' << 8) | (
'F' << 16)
282 ACST = (
'A') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
284 AUTH = (
'A') | (
'U' << 8) | (
'T' << 16) | (
'H' << 24),
286 AUTO = (
'A') | (
'U' << 8) | (
'T' << 16) | (
'O' << 24),
288 BCST = (
'B') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
290 CRYP = (
'C') | (
'R' << 8) | (
'Y' << 16) | (
'P' << 24),
292 DENY = (
'D') | (
'E' << 8) | (
'N' << 16) | (
'Y' << 24),
294 DROP = (
'D') | (
'R' << 8) | (
'O' << 16) | (
'P' << 24),
296 RSTR = (
'R') | (
'S' << 8) | (
'T' << 16) | (
'R' << 24),
298 INIT = (
'I') | (
'N' << 8) | (
'I' << 16) | (
'T' << 24),
300 MCST = (
'M') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
302 NKEY = (
'N') | (
'K' << 8) | (
'E' << 16) | (
'Y' << 24),
304 RATE = (
'R') | (
'A' << 8) | (
'T' << 16) | (
'E' << 24),
307 RMOT = (
'R') | (
'M' << 8) | (
'O' << 16) | (
'T' << 24),
309 STEP = (
'S') | (
'T' << 8) | (
'E' << 16) | (
'P' << 24),
318 :
Layer(data, dataLen, prevLayer, packet,
NTP)
Definition: IpAddress.h:28
The NTP packet consists of an integral number of 32-bit (4 octet) words in network byte order....
Definition: NtpLayer.h:69
double getTransmitTimestampInSecs() const
LeapIndicator
Warning of an impending leap second to be inserted or deleted in the last minute of the current month...
Definition: NtpLayer.h:157
@ Last61Secs
Last minute of the day has 61 seconds.
Definition: NtpLayer.h:161
@ Last59Secs
Last minute of the day has 59 seconds.
Definition: NtpLayer.h:163
@ NoWarning
Normal, no leap second.
Definition: NtpLayer.h:159
@ Unknown
Unknown (clock unsynchronized)
Definition: NtpLayer.h:165
void setTransmitTimestampInSecs(double val)
uint8_t getStratum() const
std::string getReceiveTimestampAsString()
void setRootDispersion(uint32_t val)
void setVersion(uint8_t val)
Set the version of NTP.
std::string getReferenceTimestampAsString()
void setReceiveTimestampInSecs(double val)
void setRootDelayInSecs(double val)
void setStratum(uint8_t val)
Set the value of stratum.
static std::string convertToIsoFormat(const uint64_t timestampInNTPformat)
uint64_t getOriginTimestamp() const
uint64_t getReferenceTimestamp() const
uint64_t getReceiveTimestamp() const
uint32_t getKeyID() const
static bool isDataValid(const uint8_t *data, size_t dataSize)
void setReferenceIdentifier(IPv4Address val)
static uint32_t convertToShortFormat(const double val)
void setRootDispersionInSecs(double val)
double getReferenceTimestampInSecs() const
std::string getOriginTimestampAsString()
static double convertFromTimestampFormat(const uint64_t val)
double getReceiveTimestampInSecs() const
void setReferenceTimestampInSecs(double val)
int8_t getPollInterval() const
double getPollIntervalInSecs() const
double getOriginTimestampInSecs() const
ClockSource
Definition: NtpLayer.h:192
@ HBG
LF Radio HBG Prangins, HB 75 kHz.
@ DCF
LF Radio DCF77 Mainflingen, DE 77.5 kHz.
@ ACTS
NIST telephone modem.
@ MRS
Multi Reference Sources.
@ IRIG
Inter-Range Instrumentation Group.
@ PPS
Generic pulse-per-second.
@ GOES
Geosynchronous Orbit Environment Satellite.
@ USNO
USNO telephone modem.
@ XFAC
Inter Face Association Changed.
@ WWV
HF Radio WWV Ft. Collins, CO.
@ MSF
LF Radio MSF Anthorn, UK 60 kHz.
@ JJY
LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz.
@ ATOM
Atomic clock (calibrated)
@ GPS
Global Position System.
@ LORC
MF Radio LORAN C station, 100 kHz.
@ WWVH
HF Radio WWVH Kauai, HI.
@ GAL
Galileo Positioning System.
@ DTS
Digital Time Service.
@ NIST
NIST telephone modem.
@ LCL
Meinberg Undisciplined local clock (Ref: https://www.meinbergglobal.com/english/info/ntp-refid....
@ CHU
HF Radio CHU Ottawa, Ontario.
@ LOCL
Meinberg Undisciplined local clock (Ref: https://www.meinbergglobal.com/english/info/ntp-refid....
@ DCN
DCN routing protocol.
@ PTB
European telephone modem.
@ TDF
MF Radio Allouis, FR 162 kHz.
@ GOOG
Google Refid used by Google NTP servers as time4.google.com.
@ WWVB
LF Radio WWVB Ft. Collins, CO 60 kHz.
@ VLF
VLF radio (OMEGA, etc.)
NtpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: NtpLayer.h:317
std::string getReferenceIdentifierString() const
void setTransmitTimestamp(uint64_t val)
void setRootDelay(uint32_t val)
static uint64_t convertToTimestampFormat(const double val)
std::string getModeString() const
void setOriginTimestamp(uint64_t val)
KissODeath
32-bit Kiss of Death (KoD) codes
Definition: NtpLayer.h:280
@ NKEY
No key found. Either the key was never installed or is not trusted.
@ RSTR
Access denied due to local policy.
@ DENY
Access denied by remote server.
@ CRYP
Cryptographic authentication or identification failed.
@ BCST
The association belongs to a broadcast server.
@ STEP
A step change in system time has occurred, but the association has not yet resynchronized.
@ RATE
Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshol...
@ MCST
The association belongs to a manycast server.
@ ACST
The association belongs to a anycast server.
@ DROP
Lost peer in symmetric mode.
@ AUTO
Autokey sequence failed.
@ AUTH
Server authentication failed.
@ INIT
The association has not yet synchronized for the first time.
std::string getDigest() const
void setReceiveTimestamp(uint64_t val)
static bool isNTPPort(uint16_t port)
Definition: NtpLayer.h:531
void setPollInterval(int8_t val)
void parseNextLayer() override
Parses the next layer. NTP is the always last so does nothing for this layer.
Definition: NtpLayer.h:539
LeapIndicator getLeapIndicator() const
OsiModelLayer getOsiModelLayer() const override
Definition: NtpLayer.h:553
int8_t getPrecision() const
uint32_t getReferenceIdentifier() const
void setReferenceIdentifier(KissODeath val)
size_t getHeaderLen() const override
Definition: NtpLayer.h:543
double getRootDispersionInSecs() const
void setReferenceIdentifier(ClockSource val)
uint64_t getTransmitTimestamp() const
void setMode(Mode val)
Set the mode.
Mode
Representing the NTP association modes.
Definition: NtpLayer.h:170
@ SymActive
Symmetrically active.
Definition: NtpLayer.h:174
@ Client
Client mode.
Definition: NtpLayer.h:178
@ Control
NTP control messages.
Definition: NtpLayer.h:184
@ Broadcast
Broadcasting mode.
Definition: NtpLayer.h:182
@ SymPassive
Symmetrically passive.
Definition: NtpLayer.h:176
@ PrivateUse
Reserved for private use.
Definition: NtpLayer.h:186
@ Server
Server mode.
Definition: NtpLayer.h:180
@ Reserved
Reserved variable.
Definition: NtpLayer.h:172
double getPrecisionInSecs() const
double getRootDelayInSecs() const
void setOriginTimestampInSecs(double val)
void setReferenceTimestamp(uint64_t val)
void setLeapIndicator(LeapIndicator val)
Set the leap indicator.
uint8_t getVersion() const
std::string toString() const override
std::string getTransmitTimestampAsString()
static std::string convertToIsoFormat(const double timestamp)
uint32_t getRootDispersion() const
void setPrecision(int8_t val)
static double convertFromShortFormat(const uint32_t val)
uint32_t getRootDelay() const
void computeCalculateFields() override
Does nothing for this layer.
Definition: NtpLayer.h:549
The main namespace for the PcapPlusPlus lib.
const ProtocolType NTP
Network Time (NTP) Protocol.
Definition: ProtocolType.h:161
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelApplicationLayer
Application layer (layer 7)
Definition: ProtocolType.h:239