NTP 对等体状态的选择字段中的 8 表示什么?

NTP 对等体状态的选择字段中的 8 表示什么?

我已经完成ntpq,然后运行associations并收到以下内容:

ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 12097  c811   yes  none   yes    reject    mobilize  1

从 (Peer Status) 的文档中man ntp-decode,我了解到第一位数字表示Status,第二位数字表示Select,第三位数字表示Count,第四位数字表示Code

我尝试查找 Select Status该手册的相应部分并发现以下内容:

The Select Field displays the current selection status. (The T Field in the following table gives the corresponding tally codes used in the ntpq peers dis-
play.) The values are coded as follows:

+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        Code             |            Message                    |            T             |            Description                                      |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        0                |            sel_reject                 |                          |            discarded as not valid (TEST10-TEST13)           |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        1                |            sel_falsetick              |            x             |            discarded by intersection algorithm              |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        2                |            sel_excess                 |            .             |            discarded by table overflow (not used)           |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        3                |            sel_outlyer                |            -             |            discarded by the cluster algorithm               |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        4                |            sel_candidate              |            +             |            included by the combine algorithm                |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        5                |            sel_backup                 |            #             |            backup (more than tos maxclock sources)          |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        6                |            sel_sys.peer               |            *             |            system peer                                      |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+
|        7                |            sel_pps.peer               |            o             |            PPS peer (when the prefer peer is valid)         |
+-------------------------+---------------------------------------+--------------------------+-------------------------------------------------------------+

那么,这个8数字代表什么Select Status意思呢?

答案1

文档中对同级状态代码的解释表示状态字段“为 5 位宽,并与 3 位宽的选择字段组合以创建对等状态字的第一个完整字节”。选择字段为 3 位,因此其值只能为 0-7。第二位数字中的 8 是状态字段中的最低有效位,而不是选择字段中的最高有效位。

因此c8意味着“持久关联”、“已启用身份验证”和“广播关联”(位 0、1 和 4,按大端计算)。您可以ntpq使用命令来解释这些字段。以下是我的笔记本电脑的一个示例,它配置为在模式下readvar使用:[0-3].ubuntu.pool.ntp.orgpool

# ntpq -n
ntpq> peers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
...
ntpq> assoc

ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 32962  8811   yes  none  none    reject    mobilize  1
  2 32963  8811   yes  none  none    reject    mobilize  1
...
ntpq> readvar 32962
associd=32962 status=8811 conf, bcast, sel_reject, 1 event, mobilize,
srcadr=0.0.0.0, srcport=0, srchost="0.ubuntu.pool.ntp.org",
dstadr=0.0.0.0, dstport=0, leap=11, stratum=16, precision=-24,
rootdelay=0.000, rootdisp=0.000, refid=POOL,
reftime=00000000.00000000  Thu, Feb  7 2036 16:28:16.000,
...

请注意“conf”(永久配置关联)和“bcast”(广播关联),它们是状态字段的简短解释。(显然,当广播的 refid 为 POOL 时,它的含义不仅仅只是广播。)

相关内容