What is tcp_autocorking (tcp automatic capping)

Since the 3.14 kernel I see, there is another TCP optimization called tcp_autocorking.

What is the actual difference between tcp_cork and tcp_autocorking?

Is this just an automatic version of tcp_cork? I could not find any useful information other than this link:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=f54b311142a92ea2e42598e347b84e1655caf8e3

+8
source share
1 answer

Short answer: TCP_CORK is a socket option used in setsockopt () to force TCP closure. tcp_autocorking is a kernel flag for checking specific conditions and capping when these conditions are met.

Bottom line: Coding will be performed for each packet when TCP_CORK is enabled, it can be performed on packets when tcp_autocorking is enabled, and TCP_CORK is disabled and will not be performed on any packets if both parameters are disabled. Data aggregation can occur even if both options are disabled if the Nagle algorithm is enabled.

Details: This post describes (and criticized) TCP traffic jams: on TCP_CORK .

Also see this detailed description of TCP_CORK and TCP_NODELAY from Appleman1234

By calling TCP_CORK, the data will be aggregated into the same buffer (SKB) until the buffer is full. This parameter is stronger than TCP_NODELAY (i.e., disables the Nagle algorithm), so it will work even if the TCP_NODELAY parameter is set. The value associated with aggregating to the same buffer is that calls to the tcp_push () function (net / include / tcp.c) will not result in calls to the __tcp_push_pending_frames () (net / include / tcp_output.c) function that result (ultimately) to xmit function calls to the NIC driver. Instead, the payload of the next message coming from the application will be copied to the same buffer as the last. See the tcp_sendmsg () function (net / include / tcp.c) for message processing.

tcp_autocorking, on the other hand, will not lead to aggregation until the buffer is full, but rather will check the specific conditions for continued aggregation in the current buffer. The tcp_push () function calls the tcp_should_autocork () (net / include / tcp.c) function to check if the current buffer should be sent:

static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb, int size_goal) { return skb->len < size_goal && sysctl_tcp_autocorking && skb != tcp_write_queue_head(sk) && refcount_read(&sk->sk_wmem_alloc) > skb->truesize; } 

In English - there should be traffic jams if (the buffer is not full) and (auto-corking is enabled) and (there is at least one packet in Qdisc or NIC queues) and (not all packets in Qdisc / NIC queues are ACKs)

Function

tcp_push () checks for additional conditions that may interrupt the jam even when tcp_should_autocork () returns true.

Hope this helps.

+4
source

Source: https://habr.com/ru/post/1207706/


All Articles