做了一些谷歌搜索并查看了手册页,但没有找到这个数字的具体答案。
例如,
# ip -d -stat ne show dev eth1 | column -t | sort -V
192.168.200.41 used 1034/4635/1032 probes 6 FAILED
192.168.200.44 lladdr 00:c0:b7:xx:xx:xx used 1037/1032/266 probes 1 STALE
192.168.20.5 lladdr 00:40:9d:xx:xx:xx used 25080/25050/25021 probes 1 STALE
192.168.20.6 lladdr 00:40:9d:xx:xx:xx used 25076/25047/25018 probes 4 STALE
答案1
看完之后iproute2源代码,第五个字段给出了ARP
缓存条目的计时器信息:
X/./.
ARP
:自上次输入以来的秒数用过的./X/.
ARP
:自上次输入以来的秒数确认的././X
ARP
:自上次输入以来的秒数更新
这些计时器主要用于管理过时的条目并决定何时应发出ARP
新请求。ARP
参考这个富有洞察力的答案有关ARP
年龄超时的更多信息。
答案2
我曾经strace
检查过 ip-neighbour 实际上做了什么。当我过滤命令strace
输出中的数字的输出时ip
,我发现存在调用 sendmsg 和 recvmsg 的序列。这些消息很有趣:
sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=36, type=RTM_GETNEIGH, flags=NLM_F_REQUEST|NLM_F_DUMP, seq=1539003976, pid=0}, {ndm_family=AF_UNSPEC, ndm_ifindex=0, ndm_state=0, ndm_flags=0, ndm_type=RTN_UNSPEC}, {{nla_len=8, nla_type=NDA_IFINDEX}, if_nametoindex("enp0s8")}}, iov_len=36}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0)
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{{len=76, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=8, nla_type=NDA_DST}, 224.0.0.22}, {{nla_len=10, nla_type=NDA_LLADDR}, 1.0.94.0}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192723, ndm_used=2186723, ndm_updated=2186723, ndm_refcnt=0}}]}, {{len=76, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=8, nla_type=NDA_DST}, 224.0.0.251}, {{nla_len=10, nla_type=NDA_LLADDR}, 1.0.94.0}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192699, ndm_used=2186699, ndm_updated=2186699, ndm_refcnt=0}}]}, {{len=76, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_STALE, ndm_flags=0, ndm_type=RTN_UNICAST}, [{{nla_len=8, nla_type=NDA_DST}, 10.11.0.23}, {{nla_len=10, nla_type=NDA_LLADDR}, 8.0.39.3}, {{nla_len=8, nla_type=NDA_PROBES}, 1}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=206484, ndm_used=206707, ndm_updated=202203, ndm_refcnt=0}}]}, {{len=88, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET6, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=20, nla_type=NDA_DST}, ff02::1:ff4b:3614}, {{nla_len=10, nla_type=NDA_LLADDR}, "\x33\x33\xff\x4b\x36\x14"}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192670, ndm_used=2186670, ndm_updated=2186670, ndm_refcnt=0}}]}, {{len=88, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET6, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=20, nla_type=NDA_DST}, ff02::16}, {{nla_len=10, nla_type=NDA_LLADDR}, "\x33\x33\x00\x00\x00\x16"}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192723, ndm_used=2186723, ndm_updated=2186723, ndm_refcnt=0}}]}, {{len=88, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET6, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=20, nla_type=NDA_DST}, ff02::fb}, {{nla_len=10, nla_type=NDA_LLADDR}, "\x33\x33\x00\x00\x00\xfb"}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192536, ndm_used=2186536, ndm_updated=2186536, ndm_refcnt=0}}]}, {{len=88, type=RTM_NEWNEIGH, flags=NLM_F_MULTI|NLM_F_DUMP_FILTERED, seq=1539003976, pid=15530}, {ndm_family=AF_INET6, ndm_ifindex=if_nametoindex("enp0s8"), ndm_state=NUD_NOARP, ndm_flags=0, ndm_type=RTN_MULTICAST}, [{{nla_len=20, nla_type=NDA_DST}, ff02::2}, {{nla_len=10, nla_type=NDA_LLADDR}, "\x33\x33\x00\x00\x00\x02"}, {{nla_len=8, nla_type=NDA_PROBES}, 0}, {{nla_len=20, nla_type=NDA_CACHEINFO}, {ndm_confirmed=2192568, ndm_used=2186568, ndm_updated=2186568, ndm_refcnt=0}}]}], iov_len=580}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0)
ip neigh
当我尝试在 strace 输出中查找命令中的数字时,我发现ip neigh
显示了 ndm_used、ndm_confirmed、ndm_updated 值除以 100。
这导致我man 7 rtnetlink
:
Rtnetlink 允许读取和更改内核的路由表(...)。网络路由、IP地址、链路参数、邻居设置、排队规则、流量类别和数据包分类器都可以通过 NETLINK_ROUTE 套接字进行控制。它基于 netlink 消息。
然后:
RTM_NEWNEIGH、RTM_DELNEIGH、RTM_GETNEIGH 添加、删除或接收有关邻居表条目(例如,ARP 条目)的信息。该消息包含 ndmsg 结构。 结构 ndmsg { 无符号字符 ndm_family; int ndm_ifindex; /* 接口索引 */ __u16 ndm_状态; /* 状态 */ __u8 ndm_flags; /* 标志 */ __u8 ndm_类型; }; 结构 nda_cacheinfo { __u32 ndm_确认; __u32 ndm_used; __u32 ndm_更新; __u32 ndm_refcnt; }; ndm_state 是以下状态的位掩码: NUD_INCOMPLETE 当前正在解析的缓存条目 NUD_REACHABLE 已确认的工作缓存条目 NUD_STALE 过期的缓存条目 NUD_DELAY 等待计时器的条目 NUD_PROBE 当前重新探测的缓存条目 NUD_FAILED 无效的缓存条目 NUD_NOARP 没有目标缓存的设备 NUD_PERMANENT 静态条目 有效的 ndm_flags 是: NTF_PROXY 代理 arp 条目 NTF_ROUTER IPv6 路由器 rtattr 结构体的 rta_type 字段具有以下含义: NDA_UNSPEC 未知类型 NDA_DST 邻居缓存 n/w 层目标地址 NDA_LLADDR 邻居缓存链路层地址 NDA_CACHEINFO 缓存统计信息。 如果 rta_type 字段是 NDA_CACHEINFO,则后面跟着 struct nda_cacheinfo 标头。
nda_cacheinfo结构体定义在<linux/neighbour.h>
如果您想知道这个值表示什么,则评论<linux/neighbour.h>
不是很有帮助,而且我也未能在互联网上找到它。