在/proc/net/protocols中的统计数据是什么意思?

4
在Linux操作系统中,/proc/net/protocols中的统计信息是什么意思?
cat /proc/net/protocols
protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
PACKET     888      0      -1   NI       0   no   kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n
UNIX       752     40      -1   NI       0   yes  kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n
UDP-Lite   816      0      -1   NI       0   yes  kernel      y  y  y  n  y  y  y  n  y  y  y  y  y  n  y  y  y  y  n
RAW        792      0      -1   NI       0   yes  kernel      y  y  y  n  y  y  y  n  y  y  y  y  n  y  y  y  y  n  n
UDP        816      4       2   NI       0   yes  kernel      y  y  y  n  y  n  y  n  y  y  y  y  y  n  y  y  y  y  n
TCP       1656     29       1   no     272   yes  kernel      y  y  y  y  y  y  y  y  y  y  n  y  n  n  y  y  y  y  y
NETLINK    752      1      -1   NI       0   no   kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n
1个回答

6
它包含每个协议的统计信息以及Linux中每个协议的摘要方法。
不幸的是,在RHEL 6.5上,/proc/net/protocols没有在man 5 proc中有任何说明。因此,我查看了源代码:http://lxr.free-electrons.com/source/net/core/sock.c?v=2.6.29#L2202http://lxr.free-electrons.com/source/include/net/sock.h#L924
2169 static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
2170 {
2171         seq_printf(seq, "%-9s %4u %6d  %6d   %-3s %6u   %-3s  %-10s "
2172                         "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
2173                    proto->name,
2174                    proto->obj_size,
2175                    sock_prot_inuse_get(seq_file_net(seq), proto),
2176                    proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1,
2177                    proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI",
2178                    proto->max_header,
2179                    proto->slab == NULL ? "no" : "yes",
2180                    module_name(proto->owner),
2181                    proto_method_implemented(proto->close),
2182                    proto_method_implemented(proto->connect),
2183                    proto_method_implemented(proto->disconnect),
2184                    proto_method_implemented(proto->accept),
2185                    proto_method_implemented(proto->ioctl),
2186                    proto_method_implemented(proto->init),
2187                    proto_method_implemented(proto->destroy),
2188                    proto_method_implemented(proto->shutdown),
2189                    proto_method_implemented(proto->setsockopt),
2190                    proto_method_implemented(proto->getsockopt),
2191                    proto_method_implemented(proto->sendmsg),
2192                    proto_method_implemented(proto->recvmsg),
2193                    proto_method_implemented(proto->sendpage),
2194                    proto_method_implemented(proto->bind),
2195                    proto_method_implemented(proto->backlog_rcv),
2196                    proto_method_implemented(proto->hash),
2197                    proto_method_implemented(proto->unhash),
2198                    proto_method_implemented(proto->get_port),
2199                    proto_method_implemented(proto->enter_memory_pressure));
2200 }

那么这是每个协议提供的有关自身的信息。

让我们从最后几节开始,它们有很多“y”和“n”。

2164 static char proto_method_implemented(const void *method)
2165 {
2166         return method == NULL ? 'n' : 'y';
2167 }

因此,如果某种方法是否在协议中实现就只是信息。例如,“cl”列是用于关闭方法的。例如,由于TCP中“y”是“close”列,因此TCP协议实现了close(),其proto strcut在'close'成员中具有非空指针:

924 struct proto {
925         void                    (*close)(struct sock *sk,
926                                         long timeout);

一些输出结果的首列:
  1. 协议名称
  2. 协议特定套接字结构大小
  3. sockets - 当前该类型套接字的数量
  4. 内存 - 当前分配的内存
  5. press - 内存压力 - 标志着在内存压力下工作
目前为止,您可以自己查看源代码。
有用的链接:

“memory - Current allocated memory” 的单位是什么? - hello.co
我不确定100%,但在分析core.c代码并阅读“man tcp”部分“tcp_mem:这是一个由3个整数组成的向量:[low,pressure,high]。以系统页面大小为单位测量的这些边界用于TCP跟踪其内存使用情况。”后,我认为它是系统页面的数量。 - user184968

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接