CN113489564A - 一种实现sntp客户端时间同步的方法 - Google Patents

一种实现sntp客户端时间同步的方法 Download PDF

Info

Publication number
CN113489564A
CN113489564A CN202110754046.2A CN202110754046A CN113489564A CN 113489564 A CN113489564 A CN 113489564A CN 202110754046 A CN202110754046 A CN 202110754046A CN 113489564 A CN113489564 A CN 113489564A
Authority
CN
China
Prior art keywords
time
synchronization
server
time synchronization
channel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110754046.2A
Other languages
English (en)
Inventor
武斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xinhe Semiconductor Technology Wuxi Co Ltd
Original Assignee
Xinhe Semiconductor Technology Wuxi Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xinhe Semiconductor Technology Wuxi Co Ltd filed Critical Xinhe Semiconductor Technology Wuxi Co Ltd
Priority to CN202110754046.2A priority Critical patent/CN113489564A/zh
Publication of CN113489564A publication Critical patent/CN113489564A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • H04J3/0667Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种实现SNTP客户端时间同步的方法,步骤是:sntp客户端配置;判断通道;得到通道wan接口的DNS地址及device;进入时间同步服务器循环;DNS解析时间服务器;如果解析失败,则取下一个时间服务器,循环操作直至解析成功,取得IP;connect连接,连接失败则取下一个时间服务器,循环操作直至IP连接成功;采用select阻塞间隔进行时间同步,如果出现同步失败,则退出循环,取第二时间服务器。本发明避免了单一时间服务器同步失败,具备主备,最大支持了5个ntp时间服务器。支持间隔同步对时,目前很多都是上电第一次对时,还有是不固定间隔的同步对时,间隔对时能更好的维护。

Description

一种实现SNTP客户端时间同步的方法
技术领域
本发明涉及家庭网关设备技术领域,具体是一种实现SNTP客户端时间同步的方法。
背景技术
NTP(Network Time Procotol,网络时间协议)是由RFC 1305定义的时间同步协议,用来在分布时间服务器和客户端之间进行时间同步。
目前ntp同步对时存在一下缺点:1.随着家庭光猫组网结构的调整,如果INTERNET连接为桥接组网方式或者INTERNET通道没有时间服务器,通过默认路由无法实现时间同步;2.以往通过单一服务器进行同步,时常出现无法同步的情况;3.sntp客户端只有在第一次上电的时候进行一次同步或者是不固定的同步,没有进行周期性同步。
现有专利号为201510617535.8的专利公开了一种实现SNTP客户端时间同步的方法及***的技术方案,该方案使用的是策略路由方式,能够解决上面缺点中的第一点,但是剩下的两点无法都解决。
因此本发明提出使用静态路由方式的一种实现SNTP客户端时间同步的方法,来解决上述三个缺点问题。
发明内容
本发明的目的在于提供一种实现SNTP客户端时间同步的方法,以解决上述背景技术中提出的问题。
为实现上述目的,本发明提供如下技术方案:
一种实现SNTP客户端时间同步的方法,其步骤是:
(1)sntp客户端界面配置,界面配置时间同步通道、同步间隔时间及最多五个NTP时间服务器。
(2)界面配置好,点击保存,进入流程处理。
判断时间同步通道,如果为INTERNET及其他通道,通过默认路由,得到DNS地址与wan接口device;如果为TR069及VOIP,遍历所有IP及PPP连接,判断其X_CT_COM_ServiceList是否为TR069及VIOP,得到对应的DNS地址与wan接口device。
(3)根据配置的服务器,进入时间同步服务器循环。
(4)首先取得第一时间服务器,通过步骤二得到的DNS地址与wan接口device解析时间服务器域名,如果解析失败,则取第二时间服务器,类似操作。
(5)步骤(4)解析成功,取得IP,connect连接,连接失败则取第二时间服务器循环操作。
(6)如果IP连接成功,采用select阻塞间隔进行时间同步,如果出现同步失败,则退出循环,取第二时间服务器。
与现有技术相比,本发明的优点是:
1.当家庭光猫INTERNET通道没有时间服务器时,通过默认路由或者传统的时间同步机制无法实现时间同步。
2.避免了单一时间服务器同步失败,具备主备,最大支持了5个ntp时间服务器。
3.支持间隔同步对时,目前很多都是上电第一次对时,还有是不固定间隔的同步对时,间隔对时能更好的维护。
附图说明
图1为一种实现SNTP客户端时间同步的方法的流程图。
图2为本发明中sntp客户端界面配置图。
具体实施方式
下面结合具体实施方式对本专利的技术方案作进一步详细地说明。
请参阅图1,一种实现SNTP客户端时间同步的方法,其实现步骤如下:
(一)sntp客户端界面配置如下图2所示:
界面配置时间同步通道、同步间隔时间及最多五个NTP时间服务器;
(二)界面配置好,点击保存,进入流程图处理;
判断时间同步通道,如果为INTERNET及其他通道,通过默认路由,得到DNS地址与wan接口device;如果为TR069及VOIP,遍历所有IP及PPP连接,判断其X_CT_COM_ServiceList是否为TR069及VIOP,得到对应的DNS地址与wan接口device;
(三)根据配置的服务器,进入时间同步服务器循环;
(四)首先取得第一时间服务器,通过步骤二得到的DNS地址与wan接口device解析时间服务器域名,如果解析失败,则取第二时间服务器,其他服务器采用同类操作;
(五)步骤四解析成功,取得IP,connect连接,连接失败则取第二时间服务器循环操作;
(六)如果IP连接成功,采用select阻塞间隔进行时间同步,如果出现同步失败,则退出循环,取第二时间服务器。
本发明的技术方案,当多通道对时,可以选择从INTERNET上网通道、tr069、VOIP通道取得DNS并解析域名得到IP进行同步对时。本发明的技术方案支持多ntp服务器,一个服务器同步失败,可以转到备用服务器进行同步。
上面对本专利的较佳实施方式作了详细说明,但是本专利并不限于上述实施方式,在本领域的普通技术人员所具备的知识范围内,还可以在不脱离本专利宗旨的前提下作出各种变化。

Claims (4)

1.一种实现SNTP客户端时间同步的方法,其特征在于,其实现步骤如下:
(1)配置sntp客户端界面,界面配置时间同步通道、同步间隔时间及多个NTP时间服务器;
(2)判断时间同步通道,得到通道wan接口的DNS地址及device;
(3)根据配置的服务器,进入时间同步服务器循环;
(4)首先取得第一时间服务器,通过步骤二得到的DNS地址与wan接口device解析时间服务器域名,如果解析失败,则取下一个时间服务器;
(5)步骤(4)解析成功,取得IP,connect连接,连接失败则取下一个时间服务器循环操作;
(6)如果IP连接成功,采用select阻塞间隔进行时间同步,如果出现同步失败,则退出循环,取第二时间服务器。
2.根据权利要求1所述的一种实现SNTP客户端时间同步的方法,其特征在于,所述步骤(1)中,NTP的时间服务器至多设置五个。
3.根据权利要求1所述的一种实现SNTP客户端时间同步的方法,其特征在于,其他时间服务器的操作采用与第二时间服务器选取时的同类操作。
4.根据权利要求1所述的一种实现SNTP客户端时间同步的方法,其特征在于,所述步骤(2)的具体判断如下:判断时间同步通道,如果为INTERNET及其他通道,通过默认路由,得到DNS地址与wan接口device;如果为TR069及VOIP,遍历所有IP及PPP连接,判断其X_CT_COM_ServiceList是否为TR069及VIOP,得到对应的DNS地址与wan接口device。
CN202110754046.2A 2021-07-04 2021-07-04 一种实现sntp客户端时间同步的方法 Pending CN113489564A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110754046.2A CN113489564A (zh) 2021-07-04 2021-07-04 一种实现sntp客户端时间同步的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110754046.2A CN113489564A (zh) 2021-07-04 2021-07-04 一种实现sntp客户端时间同步的方法

Publications (1)

Publication Number Publication Date
CN113489564A true CN113489564A (zh) 2021-10-08

Family

ID=77940708

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110754046.2A Pending CN113489564A (zh) 2021-07-04 2021-07-04 一种实现sntp客户端时间同步的方法

Country Status (1)

Country Link
CN (1) CN113489564A (zh)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1459940A (zh) * 2002-05-21 2003-12-03 深圳市中兴通讯股份有限公司上海第二研究所 一种宽带码分多址***中时间同步的方法
CN105119679A (zh) * 2015-09-24 2015-12-02 烽火通信科技股份有限公司 一种实现sntp客户端时间同步的方法及***

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1459940A (zh) * 2002-05-21 2003-12-03 深圳市中兴通讯股份有限公司上海第二研究所 一种宽带码分多址***中时间同步的方法
CN105119679A (zh) * 2015-09-24 2015-12-02 烽火通信科技股份有限公司 一种实现sntp客户端时间同步的方法及***

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LI88811: "windows***时间同步及同步频率设置", 《知乎》, pages 1 - 2 *
网络工程师笔记: "NTP时间同步技术详解", 《知乎》, pages 1 - 3 *

Similar Documents

Publication Publication Date Title
US11171914B2 (en) Systems and methods for automatic inventory and DNS record generation
CN107613037B (zh) 一种域名重定向方法和***
CN101582925B (zh) 一种网络地址转换的方法及***
US8305933B2 (en) Method and apparatus for detecting devices on a local area network
JP2007207231A (ja) ネットワークにおける分散サービスへのアクセス法
JP4361803B2 (ja) ネットワーク・アドレス・トランスレータ設定のためにパラメータを借りる方法及び装置
MacDonald et al. NAT behavior discovery using session traversal utilities for NAT (STUN)
WO2017161965A1 (zh) 一种动态域名***dns重定向方法、装置及***
JP2013500653A (ja) 情報を提供するための方法、ホームゲートウェイおよびホームネットワークシステム
EP2690832B1 (en) Communication device, communication system, and communication method
EP1418733B1 (fr) Procédé pour attribuer à un terminal un idientifiant de réseau virtuel, terminal et serveur de configuration dynamique d'un hôte pour la mise en oeuvre de ce procédé
Monir et al. Application and assessment of click modular firewall vs pox firewall in sdn/nfv framework
CN113489564A (zh) 一种实现sntp客户端时间同步的方法
CN105119679B (zh) 一种实现sntp客户端时间同步的方法及***
CN114900502B (zh) 网络注册方法、装置、电子设备及可读存储介质
CN115118700B (zh) 一种通信方法及通信***
US20200287784A1 (en) Priority based selection of time services
CN112532765B (zh) 一种网络访问方法及其***
Cisco Device Management
Cisco AppleTalk Commands
JP2007158608A (ja) Sipサーバ
KR19990050416A (ko) 비 인터넷 서비스망과 인터넷 서비스망간 완전 액세스를 제공하는 아이피 주소 변환방법
JP5054666B2 (ja) Vpn接続装置、パケット制御方法、及びプログラム
CN111030988B (zh) 一种自反馈调度导流方法及***
JP6001512B2 (ja) 通信制御システム及び通信制御方法

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination