Skip to content
Advertisement

Units of tx_queue & rx_queue in /proc/net/tcp

On a Linux 2.6.32, i’m looking at /proc/net/tcp and wondering what is the unit of tx_queue and rx_queue.

I can’t find this information about receive-queue and transmit-queue in https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt

Nor in man 5 proc which shows only:

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

Is it bytes? or number of buffers? or maybe i missed a great documentation about this?

Thanks

Advertisement

Answer

Short answer – These count bytes. By running netperf TCP_RR with different sizes you could see the exact value of 1 count (only 1 packet in the air in a given time). This value would always show the packet size.

More info:

According to this post:

tx_queue:rx_queue

The size of the transmit and receive queues.

This is per socket. For TCP, the values are updated in get_tcp4_sock() function. It is a bit different in 2.6.32 and 4.14, but the idea is the same. According to the socket state the rx_queue value is updated to either sk->sk_ack_backlog or tp->rcv_nxt – tp->copied_seq. The second value might be negative and is fixed in later kernels to 0 if it is. sk_ack_backlog counts the unacked segments, this is a bit strange since this doesn’t seem to be in bytes. Probably missing something here.

From tcp.h:

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

Both count in bytes, so tp->rcv_nxt – tp->copied_seq is counting the pending bytes in the receive buffer for incoming packets. tx_queue is set to tp->write_seq – tp->snd_una. Again from 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 */

Here is a bit more clear to see the count is in bytes. For UDP, it is simpler. The values are updated in 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 and sk_rmem_alloc_get return sk_wmem_alloc and sk_rmem_alloc respectively, both are in bytes.

Hope this helps.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement