To retrieve a timestamp from an NTP server using unicast UDP, follow these steps:

1. Configure the NTP Server IP and Create a UDP Socket
Set the NTP server’s IP address and port number. For standard NTP communication, use UDP port 123.
In this example, the NTP server IP is 10.152.4.60.
2. Construct and Send an NTP Request Packet
An NTP request is a 48-byte packet sent to UDP port 123. The basic structure is:
- Byte 1: LI (Leap Indicator), VN (Version Number), Mode
Example: 0x1B (LI=0, VN=3, Mode=3 for client mode) - Bytes 2–48: Typically zero-filled
This results in a 48-byte request where the first byte is 27 in decimal (from 0x1B), and the remaining bytes are zeros.
3. Receive the Response and Extract the Transmit Timestamp
The NTP response is also a 48-byte packet. The last 8 bytes contain the Transmit Timestamp:
- First 4 bytes: Integer part of the timestamp
- Last 4 bytes: Fractional part, which should be divided by 232232 to get the decimal portion
4. Convert NTP Time to LabVIEW Timestamp
To convert the NTP time to a LabVIEW timestamp, use the following formulas:
- UNIX Time = NTP Time − 2208988800
- LabVIEW Timestamp = UNIX Time + 2082844800
- Therefore:
LabVIEW Timestamp = NTP Time − 126144000