gpt4 book ai didi

linux - UDP套接字状态列表?

转载 作者:太空狗 更新时间:2023-10-29 11:29:25 24 4
gpt4 key购买 nike

我目前正在编写一个脚本,从 /proc/net/tcp/proc/net/udp 中提取数据,我需要转换它们的连接状态十六进制代码转换成有意义的东西。

示例内容:

  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode ref pointer drops
37: 00000000:2710 00000000:0000 07 00000000:00000000 00:00000000 00000000 0 0 862948 2 ffff8800109dbac0 0
54: 00000000:00A1 00000000:0000 07 00000000:00000000 00:00000000 00000000 0 0 2055110 2 ffff8800109db780 0

到目前为止,我已经找到了 this answer这将我指向相关的内核头文件,但没有匹配的 udp_states.hudp.hip.h 中的任何内容.

在哪里可以找到 UDP 套接字的连接状态列表?

最佳答案

UDP“连接”是无状态的。来自iptables manual :

UDP connections are in themselves not stateful connections, but rather stateless. There are several reasons why, mainly because they don't contain any connection establishment or connection closing; most of all they lack sequencing. Receiving two UDP datagrams in a specific order does not say anything about the order in which they were sent. It is, however, still possible to set states on the connections within the kernel.

查看此 udp programming tutorial这也有助于解释为什么像 ss -ua 这样的命令将 udp 服务器套接字显示为 UNCONN(对于 tcp 连接也称为 CLOSE)。

总而言之,我确实相信/proc/net 中显示的 udp“状态”是从 tcp 连接状态回收的,但它们的含义略有不同。

关于linux - UDP套接字状态列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23817178/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com