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 NicheStack® 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 Nios II Embedded Design Suite (EDS) version 9.1 or later. Download the NTP Client design example and unzip the files into a directory under <NiosEDS>/examples/software/ (for example, <NiosEDS>/examples/software/ntp_client). If installed in this directory, the design example is available as a Nios II Software Build Tools for Eclipse 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 Nios II Application and BSP from "Template" in the Nios II Software Build Tools for Eclipse and choose the NTP project template.
The use of this design is governed by, and subject to, the terms and conditions of the Altera Hardware Reference Design License Agreement.
The NTP client design example requires the following devices to be present in the target hardware design:
- Ethernet MAC
- JTAG UART
- LCD character display (optional)
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. If using a direct connection, the NTP server must be on the same subnet as the Nios II development board. If there is no NTP server available, there is a freeware version of an NTP software package located here: http://sourceforge.net/projects/nettime or http://www.ntp.org/links.html.
The NTP client attempts to use DHCP to acquire an IP address. If there is no DHCP server available, then the static IP address, gateway, and subnet mask must be set in ntp_client.h and recompiled.
Design Examples Disclaimer
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.