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

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

请有人帮我一下。

尝试使用其他参数的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末尾的列logging在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