linux – 确定TCP套接字是否在内核空间中

linux – 确定TCP套接字是否在内核空间中,第1张

概述我没有问题找出一个套接字属于用户空间 – 我只是扫描/ proc /看看哪个PID拥有[套接字].但是在内核空间中打开TCP套接字时,/ proc /中没有条目(因为内核没有PID). 我认为假设仅仅因为在/ proc中找不到套接字是不安全的,它是由内核启动的. 我虽然关于/ proc / net / tcp的最终未记载的7列.也许其中一个人可以提供太多套接字来源的提示?我无法破译内核的源代码来弄 我没有问题找出一个套接字属于用户空间 – 我只是扫描/ proc /看看哪个PID拥有[套接字].但是在内核空间中打开TCP套接字时,/ proc /中没有条目(因为内核没有PID).
我认为假设仅仅因为在/ proc中找不到套接字是不安全的,它是由内核启动的.
我虽然关于/ proc / net / tcp的最终未记载的7列.也许其中一个人可以提供太多套接字来源的提示?我无法破译内核的源代码来弄清楚这7个字段代表什么.

请有人借给我一些帮助.

解决方法 尝试使用附加args的netstat:
sudo netstat -wtpeav

sudo是为了确保你以root身份运行它,否则它不会向你展示一切.

选项是:

-w,--raw    Show raw sockets.-t,--tcp    Show TCP protocol sockets.-p,--program    Show the PID and name of the program to which each socket    belongs.-e,--extend    display additional information. Use this option twice for    maximum detail.-a,--all    Show both Listening and non-Listening sockets. With the    --interfaces option,show interfaces that are not up--verbose,-v   Tell the user what is going on by being verbose. Especially   print some useful informa‐ tion about unconfigured address   familIEs.

此外,/ proc / net / tcp末尾的列记录在Documentation/networking/proc_net_tcp.txt的内核源代码树中.结束字段为:

1000        0 54165785 4 cd1e6040 25 4 27 3 -1 |          |    |     |    |     |  | |  | |--> slow start size threshold,|          |    |     |    |     |  | |  |      or -1 if the threshold |          |    |     |    |     |  | |  |      is >= 0xFFFF |          |    |     |    |     |  | |  |----> sending congestion window |          |    |     |    |     |  | |-------> (ack.quick<<1)|ack.Pingpong |          |    |     |    |     |  |---------> Predicted tick of soft clock |          |    |     |    |     |              (delayed ACK control data) |          |    |     |    |     |------------> retransmit timeout |          |    |     |    |------------------> location of socket in memory |          |    |     |-----------------------> socket reference count |          |    |-----------------------------> inode |          |----------------------------------> unanswered 0-window probes |---------------------------------------------> uID
总结

以上是内存溢出为你收集整理的linux – 确定TCP套接字是否在内核空间中全部内容,希望文章能够帮你解决linux – 确定TCP套接字是否在内核空间中所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1034421.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存