1 #ifndef PACKETPP_NTP_LAYER 2 #define PACKETPP_NTP_LAYER 79 #if (BYTE_ORDER == LITTLE_ENDIAN) 87 uint8_t leapIndicator:2,
107 uint64_t referenceTimestamp,
117 #pragma pack(push, 1) 127 #pragma pack(push, 1) 128 struct ntp_v4_auth_md5
137 #pragma pack(push, 1) 138 struct ntp_v4_auth_sha1
147 ntp_header *getNtpHeader()
const {
return (ntp_header *)m_Data; }
197 GOES = (
'G') | (
'O' << 8) | (
'E' << 16) | (
'S' << 24),
199 GPS = (
'G') | (
'P' << 8) | (
'S' << 16),
201 GAL = (
'G') | (
'A' << 8) | (
'L' << 16),
203 PPS = (
'P') | (
'P' << 8) | (
'S' << 16),
205 IRIG = (
'I') | (
'R' << 8) | (
'I' << 16) | (
'G' << 24),
207 WWVB = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'B' << 24),
209 DCF = (
'D') | (
'C' << 8) | (
'F' << 16),
211 HBG = (
'H') | (
'B' << 8) | (
'G' << 16),
213 MSF = (
'M') | (
'S' << 8) | (
'F' << 16),
215 JJY = (
'J') | (
'J' << 8) | (
'Y' << 16),
217 LORC = (
'L') | (
'O' << 8) | (
'R' << 16) | (
'C' << 24),
219 TDF = (
'T') | (
'D' << 8) | (
'F' << 16),
221 CHU = (
'C') | (
'H' << 8) | (
'U' << 16),
223 WWV = (
'W') | (
'W' << 8) | (
'V' << 16),
225 WWVH = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'H' << 24),
227 NIST = (
'N') | (
'I' << 8) | (
'S' << 16) | (
'T' << 24),
229 ACTS = (
'A') | (
'C' << 8) | (
'T' << 16) | (
'S' << 24),
231 USNO = (
'U') | (
'S' << 8) | (
'N' << 16) | (
'O' << 24),
233 PTB = (
'P') | (
'T' << 8) | (
'B' << 16),
235 DCFa = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'a' << 24),
237 DCFp = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'p' << 24),
239 GPSs = (
'G') | (
'P' << 8) | (
'S' << 16) | (
's' << 24),
241 GPSi = (
'G') | (
'P' << 8) | (
'S' << 16) | (
'i' << 24),
243 GLNs = (
'G') | (
'L' << 8) | (
'N' << 16) | (
's' << 24),
245 GLNi = (
'G') | (
'L' << 8) | (
'N' << 16) | (
'i' << 24),
247 LCL = (
'L') | (
'C' << 8) | (
'L' << 16),
249 LOCL = (
'L') | (
'O' << 8) | (
'C' << 16) | (
'L' << 24),
254 DCN = (
'D') | (
'C' << 8) | (
'N' << 16),
256 TSP = (
'T') | (
'S' << 8) | (
'P' << 16),
258 DTS = (
'D') | (
'T' << 8) | (
'S' << 16),
260 ATOM = (
'A') | (
'T' << 8) | (
'O' << 16) | (
'M' << 24),
262 VLF = (
'V') | (
'L' << 8) | (
'F' << 16)
594 static bool isDataValid(
const uint8_t *data,
size_t dataSize);
600 static bool isNTPPort(uint16_t port) {
return port == 123; }
HF Radio CHU Ottawa, Ontario.
Definition: NtpLayer.h:221
size_t getHeaderLen() const
Definition: NtpLayer.h:610
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:263
NIST telephone modem.
Definition: NtpLayer.h:227
int8_t getPollInterval() const
Unknown (clock unsynchronized)
Definition: NtpLayer.h:162
double getPollIntervalInSecs() const
void setOriginTimestampInSecs(double val)
void parseNextLayer()
Parses the next layer. NTP is the always last so does nothing for this layer.
Definition: NtpLayer.h:605
void setReferenceIdentifier(IPv4Address val)
void setRootDispersionInSecs(double val)
Last minute of the day has 59 seconds.
Definition: NtpLayer.h:160
uint8_t getStratum() const
Definition: ProtocolType.h:278
LeapIndicator getLeapIndicator() const
Inter-Range Instrumentation Group.
Definition: NtpLayer.h:205
uint32_t getRootDelay() const
double getRootDelayInSecs() const
Meinberg GPS/GLONASS (with interrupt based access) (Ref: https://www.meinbergglobal.com/english/info/ntp-refid.htm)
Definition: NtpLayer.h:245
NTP control messages.
Definition: NtpLayer.h:183
MF Radio Allouis, FR 162 kHz.
Definition: NtpLayer.h:219
static std::string convertToIsoFormat(const double timestamp)
HF Radio WWVH Kauai, HI.
Definition: NtpLayer.h:225
void setPrecision(int8_t val)
double getRootDispersionInSecs() const
std::string getOriginTimestampAsString()
LF Radio MSF Anthorn, UK 60 kHz.
Definition: NtpLayer.h:213
USNO telephone modem.
Definition: NtpLayer.h:231
void setOriginTimestamp(uint64_t val)
LF Radio DCF77 Mainflingen, DE 77.5 kHz.
Definition: NtpLayer.h:209
NtpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: NtpLayer.h:273
Global Position System.
Definition: NtpLayer.h:199
void setTransmitTimestamp(uint64_t val)
static double convertFromTimestampFormat(const uint64_t val)
The NTP packet consists of an integral number of 32-bit (4 octet) words in network byte order...
Definition: NtpLayer.h:73
static uint32_t convertToShortFormat(const double val)
uint32_t getReferenceIdentifier() const
Broadcasting mode.
Definition: NtpLayer.h:181
uint64_t getOriginTimestamp() const
double getReceiveTimestampInSecs() const
void setPollInterval(int8_t val)
HF Radio WWV Ft. Collins, CO.
Definition: NtpLayer.h:223
void setLeapIndicator(LeapIndicator val)
Last minute of the day has 61 seconds.
Definition: NtpLayer.h:158
std::string getReferenceIdentifierString() const
std::string getReferenceTimestampAsString()
Meinberg DCF77 with phase modulation)/pseudo random phase modulation (Ref: https://www.meinbergglobal.com/english/info/ntp-refid.htm)
Definition: NtpLayer.h:237
Generic pulse-per-second.
Definition: NtpLayer.h:203
Mode
Definition: NtpLayer.h:168
void setReferenceTimestamp(uint64_t val)
void setStratum(uint8_t val)
uint64_t getReferenceTimestamp() const
std::string getTransmitTimestampAsString()
ClockSource
Definition: NtpLayer.h:192
std::string getModeString() const
double getReferenceTimestampInSecs() const
Definition: IpAddress.h:27
Meinberg Undisciplined local clock (Ref: https://www.meinbergglobal.com/english/info/ntp-refid.htm)
Definition: NtpLayer.h:249
LF Radio WWVB Ft. Collins, CO 60 kHz.
Definition: NtpLayer.h:207
Meinberg GPS (with shared memory access) (Ref: https://www.meinbergglobal.com/english/info/ntp-refid...
Definition: NtpLayer.h:239
VLF radio (OMEGA, etc.)
Definition: NtpLayer.h:262
European telephone modem.
Definition: NtpLayer.h:233
DCN routing protocol.
Definition: NtpLayer.h:254
double getTransmitTimestampInSecs() const
Meinberg DCF77 with amplitude modulation (Ref: https://www.meinbergglobal.com/english/info/ntp-refid...
Definition: NtpLayer.h:235
uint64_t getReceiveTimestamp() const
uint32_t getKeyID() const
LeapIndicator
Definition: NtpLayer.h:153
Meinberg GPS (with interrupt based access) (Ref: https://www.meinbergglobal.com/english/info/ntp-refi...
Definition: NtpLayer.h:241
Symmetrically active.
Definition: NtpLayer.h:173
void setVersion(uint8_t val)
void setRootDelayInSecs(double val)
Symmetrically passive.
Definition: NtpLayer.h:175
void setRootDispersion(uint32_t val)
NIST telephone modem.
Definition: NtpLayer.h:229
void setReferenceTimestampInSecs(double val)
Meinberg GPS/GLONASS (with shared memory access) (Ref: https://www.meinbergglobal.com/english/info/ntp-refid.htm)
Definition: NtpLayer.h:243
Digital Time Service.
Definition: NtpLayer.h:258
Meinberg Undisciplined local clock (Ref: https://www.meinbergglobal.com/english/info/ntp-refid.htm)
Definition: NtpLayer.h:247
void setReceiveTimestamp(uint64_t val)
Reserved variable.
Definition: NtpLayer.h:171
std::string getDigest() const
std::string getReceiveTimestampAsString()
uint32_t getRootDispersion() const
void setReceiveTimestampInSecs(double val)
MF Radio LORAN C station, 100 kHz.
Definition: NtpLayer.h:217
void setRootDelay(uint32_t val)
OsiModelLayer getOsiModelLayer() const
Definition: NtpLayer.h:618
std::string toString() const
double getPrecisionInSecs() const
Server mode.
Definition: NtpLayer.h:179
LF Radio HBG Prangins, HB 75 kHz.
Definition: NtpLayer.h:211
Reserved for private use.
Definition: NtpLayer.h:185
uint64_t getTransmitTimestamp() const
Geosynchronous Orbit Environment Satellite.
Definition: NtpLayer.h:197
const ProtocolType NTP
Definition: ProtocolType.h:258
Atomic clock (calibrated)
Definition: NtpLayer.h:260
static bool isNTPPort(uint16_t port)
Definition: NtpLayer.h:600
Normal, no leap second.
Definition: NtpLayer.h:156
LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz.
Definition: NtpLayer.h:215
static double convertFromShortFormat(const uint32_t val)
void computeCalculateFields()
Does nothing for this layer.
Definition: NtpLayer.h:613
TSP time protocol.
Definition: NtpLayer.h:256
static bool isDataValid(const uint8_t *data, size_t dataSize)
Client mode.
Definition: NtpLayer.h:177
Galileo Positioning System.
Definition: NtpLayer.h:201
static uint64_t convertToTimestampFormat(const double val)
double getOriginTimestampInSecs() const
int8_t getPrecision() const
uint8_t getVersion() const
void setTransmitTimestampInSecs(double val)