gpt4 book ai didi

linux -/proc/net/protocols 中的统计信息是什么意思?

转载 作者:可可西里 更新时间:2023-11-01 02:47:01 26 4
gpt4 key购买 nike

Linux OS/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

最佳答案

里面有每个协议(protocol)的一些统计信息,以及Linux下每个协议(protocol)的总结方法。

不幸的是man 5 proc在 RHEL 6.5 上没有说明任何关于 /proc/net/protocols 的内容。所以我看了一下来源: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 }

所以这是每个协议(protocol)提供的关于自身的信息。

让我们从包含大量“y”和“n”的最后部分开始。

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

因此,如果特定方法是否在协议(protocol)中实现,这只是信息。例如,“cl”列用于关闭方法。例如,由于 TCP 具有“y”是“关闭”列,因此 TCP 协议(protocol)实现 close() 并且其原型(prototype) strcut 在“关闭”成员中具有非空指针:

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

输出坑中的一些第一列:

  1. 协议(protocol)名称
  2. 协议(protocol)特定套接字结构的大小
  3. sockets - 现在有多少个这种类型的sockets
  4. memory - 当前分配的内存
  5. press - memory_pressure - 它是一个标志,表示在内存压力下工作

到目前为止,你可以自己看源码

有用的链接:

关于linux -/proc/net/protocols 中的统计信息是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23531519/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com