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