发送到 NTP 服务器的 '\x1b' + 47 * '\0' 消息是什么意思? [英] What does the '\x1b' + 47 * '\0' message sent to an NTP server mean?

查看:123
本文介绍了发送到 NTP 服务器的 '\x1b' + 47 * '\0' 消息是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 NTP 客户端.其他一些线程表明包含 "\x1b' + 47 * '\0" 的消息被发送到 NTP 服务器,但这些线程都没有解释该消息的实际含义或发送的原因.我曾尝试查看 NTP RFC,但我也无法在其中找到任何相关信息.

I am working on an NTP Client. A few other threads indicate that the a message containing "\x1b' + 47 * '\0" is sent to the NTP server, but none of these threads give an explanation about what this message actually means or why it is sent. I've tried looking at the NTP RFC but I was unable to find any information about it in there either.

推荐答案

"\x1b' + 47 * '\0" 表示一个 48 字节的数据字段.0x1B 后跟 47 次<代码>0.48 字节是 NTP UDP 数据包的大小.第一个字节 (0x1B) 指定 LIVNMode.

"\x1b' + 47 * '\0" represents a data field of 48 bytes. 0x1B followed by 47 times 0. 48 bytes is the size of an NTP UDP packet. The first byte (0x1B) specifies LI, VN, and Mode.

RFC 5905 NTP 规范(7.3. 包头变量) 指定消息标题如下:

RFC 5905 NTP Specification (7.3. Packet Header Variables) specifies the message header as follows:

     0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |LI | VN  |Mode |    Stratum     |     Poll      |  Precision   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

设置数据的第一个字节为0x1B00 011 011表示

Setting the first byte of the data to 0x1B or 00 011 011 means

LI   = 0    (Leap indicator)
VN   = 3    (Version number)
Mode = 3    (Mode, mode 3 is client mode)

您也可以使用更新的版本(VN = 4).这将需要将第一个标头字节设置为0x23 (00 100 011).

You may also use the more recent version (VN = 4). This would require the first header byte to be set to 0x23 (00 100 011).

模式定义为

     +-------+--------------------------+
     | Value | Meaning                  |
     +-------+--------------------------+
     | 0     | reserved                 |
     | 1     | symmetric active         |
     | 2     | symmetric passive        |
     | 3     | client                   |
     | 4     | server                   |
     | 5     | broadcast                |
     | 6     | NTP control message      |
     | 7     | reserved for private use |
     +-------+--------------------------+

指定 Mode = 3 表示该消息为客户端请求消息.

Specifying Mode = 3 indicates the message as a client request message.

将这样的数据包发送到 NTP 服务器的 123 端口将强制服务器发送回复包.

Sending such a packet to port 123 of an NTP server will force the server to send a reply package.

这篇关于发送到 NTP 服务器的 '\x1b' + 47 * '\0' 消息是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆