To learn about NTP Client, click here
This project is a NTP client which is similar in nature to ntpdate
but does not accept any command line arguments
nor does it update the system clock. Note that this NTP client does not use any NTP libraries
but rather works directly at the NTP protocol level.
This project is based on Let's make a NTP Client in C by David Lettier.
C program can be written and executed on any machine that has a suitable environment to run the program. Clanfg, MinGW compiler (Minimalist GNU for Windows), Portable 'C' compiler, and Turbo C are popular compilers available. I am using GCC Compiler. It is recommended using an IDE to run C programs. An IDE includes a compiler, editor and debugger.
Firstly, use the following command to check if your system has gcc installed or not:
gcc -v
If your system doesn't have the gcc installed, here is the link to download GCC complier for Windows, Linux and Mac. Moreover, you can download Code::Blocks (IDE) which bundles a compiler (gcc offered by Free Software Foundation GNU), editor and debugger in a neat package.
Compile:
gcc main.c -o ntpClient.out
Run:
./ntpClient.out
This NTP client can communicate with a remote NTP server using UDP on port 123. The message format is a 48 byte structure that is partially filled out and then, sent to the server. The server will reply with a same sized message and response is parsed to extract the current time-stamp.
MIT License Copyright (c) 2021 Daljeet Singh
Refer to LICENSE file for full information.