gpt4 book ai didi

linux -/proc/net/tcp 中 tx_queue & rx_queue 的单位

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

在 Linux 2.6.32 上,我正在查看 /proc/net/tcp并想知道 tx_queue 的单位是什么和 rx_queue .

我找不到关于 receive-queue 的信息和 transmit-queuehttps://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt

也不在man 5 proc仅显示:

The "tx_queue" and "rx_queue" are the outgoing and incoming data queue in terms of kernel memory usage.

是字节吗?或缓冲区数量?还是我错过了有关此的重要文档?

谢谢

最佳答案

简答 - 这些计数字节。通过运行不同大小的 netperf TCP_RR,您可以看到 1 计数的准确值(在给定时间内只有 1 个数据包在空中)。该值将始终显示数据包大小。

更多信息:

根据这个post :

tx_queue:rx_queue

The size of the transmit and receive queues.

这是每个插槽。对于 TCP,值在 get_tcp4_sock() 函数中更新。 2.6.32和4.14有点不同,但是思路是一样的。根据套接字状态,rx_queue 值更新为 sk->sk_ack_backlog 或 tp->rcv_nxt - tp->copied_seq。第二个值可能为负,如果是,则在以后的内核中固定为 0。 sk_ack_backlog 计算未确认的段,这有点奇怪,因为这似乎不是以字节为单位。可能在这里遗漏了什么。

来自 tcp.h:

struct tcp_sock {
...
u32 rcv_nxt; /* What we want to receive next */
u32 copied_seq; /* Head of yet unread data */

两者都以字节为单位计数,因此 tp->rcv_nxt - tp->copied_seq 正在计算传入数据包接收缓冲区中的待处理字节数。tx_queue 设置为 tp->write_seq - tp->snd_una。同样来自 tcp.h:

struct tcp_sock {
...
u32 snd_una; /* First byte we want an ack for */
u32 write_seq; /* Tail(+1) of data held in tcp send buffer */

这里更清楚地看到计数是以字节为单位的。对于 UDP,它更简单。值在 udp4_format_sock() 中更新:

static void udp4_format_sock(struct sock *sp, struct seq_file *f,
int bucket)
{
...

seq_printf(f, "%5d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d",
bucket, src, srcp, dest, destp, sp->sk_state,
sk_wmem_alloc_get(sp),
sk_rmem_alloc_get(sp),

sk_wmem_alloca_get和sk_rmem_alloc_get分别返回sk_wmem_alloc和sk_rmem_alloc,都是字节。

希望这对您有所帮助。

关于linux -/proc/net/tcp 中 tx_queue & rx_queue 的单位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47102701/

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