当前位置:网站首页>AOSP ~ NTP (Network Time Protocol)
AOSP ~ NTP (Network Time Protocol)
2022-07-03 11:56:00 【Nanke is cute】
Network time protocol NTP(Network Time Protocol) yes TCP/IP An application layer protocol in the protocol family , It is used to synchronize the clock between the client and the server , Provide high-precision time correction .NTP Server from authoritative clock source ( For example, atomic clock 、GPS) Receive precise coordinated universal time UTC, The client requests and receives time from the server .
NTP be based on UDP Message transmission , The use of UDP The port number is 123.
Why is clock synchronization important ?
For many reasons , Accurate time is crucial to the network , such as :
- Network management : When analyzing log information collected from different network devices , It needs to be based on time . If the system time on different devices is inconsistent , It will bring obstacles to fault location due to problems such as sequence .
- Billing system : Billing business is particularly time sensitive , The time of all equipment is required to be consistent , Otherwise, the billing will be inaccurate , Cause users to question 、 Complaints, etc .
- Collaborative processing : Multiple systems work together to deal with the same complex event , In order to ensure the correct execution sequence , Multiple systems must refer to the same clock .
- system time : Some applications or services need accurate time to mark user login 、 Transaction and other operation information , Ensure traceability records .
- Therefore, a unified standard time is of great significance for the network .
NTP It is a protocol used to synchronize the clocks of all hosts in the network , He synchronizes the clock of the host to coordinated universal time UTC, Its accuracy is in LAN Reachable within the network 1 In milliseconds , stay WAN It can reach tens of milliseconds on the network .
NTP Development history of the agreement
NTP It's the United States Delaware university David L .Mills Designed by Professor , It is one of the earliest standards for clock synchronization in the network .NTP From time agreement and ICMP Timestamp message evolved ,NTP The version evolution of is as follows .
NTP Clock hierarchy
NTP Allow clients to request and receive time from the server , And the server starts from the authoritative clock source ( For example, atomic clock 、GPS) Receive precise coordinated universal time UTC.
NTP Organize the model structure hierarchically , Each layer in the hierarchy is called Stratum. Usually, clock synchronization will be obtained from the authoritative clock NTP The number of layers of the server is set to Stratum 1, And use it as the main time server , Provide clock synchronization for other devices in the network . and Stratum 2 From Stratum 1 Acquisition time ,Stratum 3 from Stratum 2 Acquisition time , And so on . The value range of clock layers is 1~16, The smaller the value , The higher the accuracy of the clock . The number of layers is 1~15 Your clock is in sync ; The number of layers is 16 The clock of is considered to be unsynchronized , Can't use .
NTP Synchronization principle
NTP The most typical way of timing is Client/Server The way , As shown in the figure below .
- The client first sends a message to the server NTP Request message , It contains the timestamp of the message leaving the client t1;
- NTP The request message arrives at NTP The server , here NTP The time of the server is t2. When the server receives the message ,NTP After server processing , On t3 Always send out NTP Reply message . The reply message carries the message to leave NTP Time stamp at client time t1、 arrive NTP Time stamp of server t2、 Leave NTP Time stamp of server t3;
- When the client receives the response message , Record the timestamp returned by the message t4.
- The client uses the above 4 One timestamp parameter can calculate 2 Key parameters :
- NTP Round trip delay of message from client to server delay.

- The time difference between the client and the server offset.
According to the equations :
It can be solved that the time difference is :
NTP The client gets offset To adjust your clock , Realization and NTP Server clock synchronization .
AOSP
- Change the time zone
When compiling, for example device.mk Add the following... To the file To modify the default time zone .
PRODUCT_PROPERTY_OVERRIDES += \
persist.sys.timezone=Asia/Shanghai
- modify NTP Server address :
stay frameworks/base/core/res/res/values/config.xml In file find
<string translatable="false" name="config_ntpServer">ntp7.aliyun.com</string>
ADB
adb shell "settings put global ntp_server ntp1.aliyun.com"
边栏推荐
- Kibana - installation and configuration of kibana
- 简单工厂和工厂方法模式
- 836. 合并集合(DAY 63)并查集
- 836. Merge sets (day 63) and search sets
- R语言使用data.table包进行数据聚合统计计算滑动窗口统计值(Window Statistics)、计算滑动分组中位数(median)并合并生成的统计数据到原数据集中
- 导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....
- 错排问题 (抽奖,发邮件)
- R language uses the aggregate function to calculate the mean value (sum) of dataframe data grouping aggregation without setting na The result of RM calculation. If the group contains the missing value
- Notes on 32-96 questions of sword finger offer
- Vulnhub's Tomato (tomato)
猜你喜欢
![Capturing and sorting out external Fiddler -- Conversation bar and filter [2]](/img/04/e9cc027d753e7049f273d866eefdce.png)
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]

Duplicate numbers in the array of sword finger offer 03

鸿蒙第三次培训(项目实训)

牛牛的组队竞赛

This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
![抓包整理外篇fiddler———— 会话栏与过滤器[二]](/img/04/e9cc027d753e7049f273d866eefdce.png)
抓包整理外篇fiddler———— 会话栏与过滤器[二]

(数据库提权——Redis)Redis未授权访问漏洞总结

Groovy测试类 和 Junit测试

Vulnhub geminiinc V2

《剑指offer 03》数组中重复的数字
随机推荐
Mysql根据时间搜索常用方法整理
OpenStack中的测试分类
优化接口性能
【mysql专项】读锁和写锁
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
在CoreOS下部署WordPress实例教程
VS2015的下载地址和安装教程
PHP基础
Kubernetes 三打探针及探针方式
Simple factory and factory method mode
vulnhub之Ripper
小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
cgroup简介
vulnhub之raven2
《剑指offer 03》数组中重复的数字
After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
Solve msvcp120d DLL and msvcr120d DLL missing
MCDF实验1
Momentum of vulnhub
Duplicate numbers in the array of sword finger offer 03