Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significance of MTU for loopback interface

I'm exploring/benchmarking various IPC mechanisms for low latency communication between two processes in the same system. I'm using RHEL 6 system for benchmarking.

I'm currently looking into socket based communication through loopback. Since it is the loopback device, the packets do not even hit the NIC. Instead, the loopback linux driver loopbacks the packets to the destination.

However looking into the results of netstat -i, I see an MTU defined for the loopback. What's the role of this and the potential impact on bandwidth?

Name  Mtu   Network       Address            Ipkts Ierrs    Opkts Oerrs  Coll
lo0   16384 localhost   ::1                   1738     -     1738     -     -
like image 370
KodeWarrior Avatar asked Dec 11 '14 20:12

KodeWarrior


Video Answer


1 Answers

loopback isn't a physical interface, but still the tcp/ip stack runs a lot of operations on it.

To increase performances on local transfers, kernel developers bumped its mtu from 16 Kb to 64 Kb.

See this commit in the Linux kernel and its rationale:

loopback current mtu of 16436 bytes allows no more than 3 MSS TCP segments per frame, or 48 Kbytes. Changing mtu to 64K allows TCP stack to build large frames and significantly reduces stack overhead.

Performance boost on bulk TCP transferts can be up to 30 %, partly because we now have one ACK message for two 64KB segments, and a lower probability of hitting /proc/sys/net/ipv4/tcp_reordering default limit.

--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
static void loopback_setup(struct net_device *dev)
{
-       dev->mtu                = (16 * 1024) + 20 + 20 + 12;
+       dev->mtu                = 64 * 1024;
like image 148
Massimo Avatar answered Oct 28 '22 15:10

Massimo