AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 473919
Accepted
Rabin
Rabin
Asked: 2018-10-08 23:40:52 +0800 CST2018-10-08 23:40:52 +0800 CST 2018-10-08 23:40:52 +0800 CST

“ip -stat neighbor show”输出中的第五列代表什么?

  • 772

做了一些谷歌搜索并查看了手册页,但没有找到这个数字的具体答案。

例如,

# 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
linux
  • 2 2 个回答
  • 2131 Views

2 个回答

  • Voted
  1. Best Answer
    Gohu
    2018-10-09T06:24:04+08:002018-10-09T06:24:04+08:00

    在查看iproute2 源代码后,第五个字段给出了有关ARP缓存条目的计时器信息:

    • X/./.: 自上次使用ARP条目以来的秒数
    • ./X/.: 自上次确认ARP条目以来的秒数
    • ././X: 自上次更新ARP条目以来的秒数

    这些计时器主要用于管理过时ARP的条目并决定何时发出新ARP请求。有关年龄超时的更多信息,请参阅此有见地的答案。ARP

    • 5
  2. mrc02_kr
    2018-10-09T06:19:38+08:002018-10-09T06:19:38+08:00

    我曾经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 neighstrace 输出中的命令中查找数字时,我发现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_state;/* 状态 */
               __u8 ndm_flags; /* 标志 */
               __u8 ndm_type;
           };
    
           结构 nda_cacheinfo {
               __u32 ndm_confirmed;
               __u32 ndm_used;
               __u32 ndm_updated;
               __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>不是很有帮助,我也没有在互联网上找到它。

    • 1

相关问题

  • 有没有办法让 ls 只显示某些目录的隐藏文件?

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

  • 需要一些系统调用

  • astyle 不会更改源文件格式

  • 通过标签将根文件系统传递给linux内核

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve