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

前端之家收集整理的这篇文章主要介绍了linux – 确定TCP套接字是否在内核空间中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我没有问题找出一个套接字属于用户空间 – 我只是扫描/ proc /看看哪个PID拥有[套接字].但是在内核空间中打开TCP套接字时,/ proc /中没有条目(因为内核没有PID).
我认为假设仅仅因为在/ proc中找不到套接字是不安全的,它是由内核启动的.
我虽然关于/ proc / net / tcp的最终未记载的7列.也许其中一个人可以提供太多套接字来源的提示?我无法破译内核的源代码来弄清楚这7个字段代表什么.

请有人借给我一些帮助.

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

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

选项是:

  1. -w,--raw
  2. Show raw sockets.
  3.  
  4. -t,--tcp
  5. Show TCP protocol sockets.
  6.  
  7. -p,--program
  8. Show the PID and name of the program to which each socket
  9. belongs.
  10.  
  11. -e,--extend
  12. Display additional information. Use this option twice for
  13. maximum detail.
  14.  
  15. -a,--all
  16. Show both listening and non-listening sockets. With the
  17. --interfaces option,show interfaces that are not up
  18.  
  19. --verbose,-v
  20. Tell the user what is going on by being verbose. Especially
  21. print some useful informa tion about unconfigured address
  22. families.

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

  1. 1000 0 54165785 4 cd1e6040 25 4 27 3 -1
  2. | | | | | | | | | |--> slow start size threshold,| | | | | | | | | or -1 if the threshold
  3. | | | | | | | | | is >= 0xFFFF
  4. | | | | | | | | |----> sending congestion window
  5. | | | | | | | |-------> (ack.quick<<1)|ack.pingpong
  6. | | | | | | |---------> Predicted tick of soft clock
  7. | | | | | | (delayed ACK control data)
  8. | | | | | |------------> retransmit timeout
  9. | | | | |------------------> location of socket in memory
  10. | | | |-----------------------> socket reference count
  11. | | |-----------------------------> inode
  12. | |----------------------------------> unanswered 0-window probes
  13. |---------------------------------------------> uid

猜你在找的Linux相关文章