NTP Client porting to OpenWrt

Source: Internet
Author: User
Tags openssl
first, the hardware platform

1, Controller: MT7620 (A9 Core) II, software platform

1, development environment: ubuntu12.04

2, OpenWrt version: 15.05
3, NTP source package version: 4.2.8P7
NTP source Download Link: http://www.ntp.org/downloads.html
4, cross-compilation tool chain version: OpenWrt source package matching version toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_glibc-2.21

Iii. Description

NTP is the Network Time Protocol (network), which is the protocol used to synchronize the time of each computer in the network.


Four, compile the step

This article's NTP source code, puts in the directory/home/sky/ntp/

1, decompression Source: tar-vxf ntp-4.2.8p7.tar.gz

2, create a folder, for storing NTP source code after compiling files: mkdir ntp_out

3, access to the source directory: CD NTP-4.2.8P7

4. Compiling source code

(1) configuration of the source code, because more parameters, the use of "\" branch.

Attention:

A. The cross-compilation tool chain in this article, the path is:/home/sky/develop/openwrt/openwrt/staging_dir/

B. Because OpenWrt's cross compilation tool chain is special, many libraries are under the "target-mipsel_24kec+dsp_glibc-2.21" path rather than the "toolchain-mipsel_24kec+dsp_ gcc-4.8-linaro_glibc-2.21 "directory, so you need to specifically specify the path of the OpenSSL, or compile will be prompted to find the appropriate file, the compilation failed.

./configure--prefix=/home/sky/ntp/ntp_out \
--enable-shared \
--disable-static \
with-yielding-select=manual \
--disable-main \
--host=mipsel-openwrt-linux \
cc=/home/sky/develop/ openwrt/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_glibc-2.21/bin/ MIPSEL-OPENWRT-LINUX-GNU-GCC \
--with-openssl-incdir=/home/sky/develop/openwrt/openwrt/staging_dir/ target-mipsel_24kec+dsp_glibc-2.21/usr/include/

(2) compiling

Make


(3) Installation

Make install

After the execution is complete, the generated files are in the. /out_ntp/directory, we need the file for ... /out_ntp/bin/ntpdate


v. Test NTP client

Download the ntpdate to the Development Board for testing.

1, modify the system time, set a time arbitrarily:

root@openwrt:/tmp# date-s "2015-8-9 18:54:32"
Sun Aug 9 18:54:32 UTC 2015

So, the time was modified to 2015-8-9 18:54:32


2, check the current time, confirm whether the time has been modified successfully, as shown below, the system time has been modified to Sun Aug 9 18:54:35 UTC 2015

root@openwrt:/tmp# Date
Sun Aug 9 18:54:35 UTC 2015


3, Ntpdate synchronization time

(1) Synchronization time, may take a few seconds or longer to have results, depending on the network and NTP server.

root@openwrt:/tmp#./ntpdate time.buptnet.edu.cn
3 June 09:17:43 ntpdate[1270]: Step time server 202.112.10.60 offset 25798865.779885 sec


(2) Confirm whether the time has been synchronized

root@openwrt:/tmp# Date
Fri June 3 09:22:46 UTC 2016

The current UTC time is compared to the system time, indicating that ntpdate can be successfully ported.


(3) NTP server description

Description: time.buptnet.edu.cn is a Beijing time NTP server (ip:202.112.10.60)

Sometimes the NTP server does not ping, and other NTP servers are available at this time.

List of currently available national NTP servers

[INTERNATIONAL NTP server list.]

area [Zone] domain name [domain] IP pools [IP pool]
Chinese [China] cn.ntp.org.cn [202.108.6.95] [202.112.29.82] [110.75.190.198] [115.28.122.198] [182.92.12.11]
[120.25.108.11] [110.75.186.249] [110.75.186.248] [110.75.186.247]
Taiwan, China [Chinataiwan] tw.ntp.org.cn [120.119.28.1]
United States [America] us.ntp.org.cn [24.56.178.140] [131.107.13.100]
Singapore [Singapore] sgp.ntp.org.cn [139.162.20.174] [103.11.143.248]
Korea [Korea] kr.ntp.org.cn [218.234.23.44] [211.233.40.78]
Germany [Germany] de.ntp.org.cn [131.188.3.220] [131.188.3.223]
Japan [Japanese] jp.ntp.org.cn [133.243.238.243] [157.7.152.213]



          

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.