Network Time Protocol Client Design Example



The network time protocol (NTP) client design example demonstrates a user datagram protocol (UDP) client using the industry-standard sockets interface to transmission control protocol/Internet protocol (TCP/IP). This is a minimal implementation of a simple network time protocol (SNTP) client (RFC 2030). This design example serves as a good starting point for Lightweight IP (LWIP) designs running on Nios® II processors.

The design example displays the current UTC time on the LCD display. On startup, the LCD displays the epoch time. Once the current time is acquired, the system time is set, and the current time is displayed on the LCD. Periodically, the client sends another request to the NTP server for the current time.

Using This Design Example

Ensure that you have installed a Nios II development kit. Download the NTP Client design example and unzip the files into a directory under <Nios II kit path>/examples/software (for example, <Nios II kit path>/examples/software/ntp_client). If installed in this directory, the design example is available as a Nios II integrated development environment (IDE) project template. The NTP client design example includes the project settings required to run this design example on the supported target hardware configuration. To use the NTP client design example, simply create a new C/C++ application project in the IDE and choose the desired project template.

The use of this design is governed by, and subject to, the terms and conditions of the Intel® Design Example License Agreement.

Hardware Requirements

The NTP client design example requires the following devices to be present in the target hardware design:

  • Joint Test Action Group (JTAG) UART
  • Timer
  • LCD character display

You can run the NTP client design example on the following Nios II hardware design examples:

  • Stratix® design examples
    • Standard
    • Full-featured
  • Cyclone® design examples
    • Standard
    • Full-featured

Host Machine Requirements

The Nios II development board used to run this design must have access to an NTP server. The NTP server can be a server on a network, or it can be connected directly to a host machine running NTP server software via a crossover cable. The NTP server must be on the same subnet as the Nios II development board. If there is no NTP server on the network, or a direct connection is being made, there is a freeware version of an NTP software package located here: or

The NTP client attempts to use DHCP to acquire an IP address. If there is no DHCP server on the network or a direct connection is being used, then the static IP address, gateway, and subnetmask must be set in user.h and recompiled.