Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing able to resolve my issue but why ? What this command does?

I was not able to upload files larger than 1.2 kB to my website from my system(Ubuntu) request just keeps on stalling. Than somehow i found this command echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing and now I am able to upload any file size from my desktop to my website. I don't know what this command does and why is this happening. Please help me identify this problem.

I ran echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing on my desktop and it worked I haven't changed anything on server.

like image 387
Vaibhav Ajay Gupta Avatar asked Feb 06 '23 22:02

Vaibhav Ajay Gupta


1 Answers

According to man 7 tcp:

tcp_mtu_probing (integer; default: 0; since Linux 2.6.17):

This parameter controls TCP Packetization-Layer Path MTU Discovery. The following values may be assigned to the file:

0 Disabled

1 Disabled by default, enabled when an ICMP black hole detected

2 Always enabled, use initial MSS of tcp_base_mss.

It means that once enabled, your OS try to find the MTU between your client and your server using Path MTU discovery mechanism. It probably increase the default MTU (1500 on Linux) in your case, allowing bigger packets to be sent.

You can check the MTU on your interface by running ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN # <= here MTU is 16436 bytes
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
 # below MTU is 1500 bytes
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:28:fd:4c brd ff:ff:ff:ff:ff:ff
    inet 192.168.50.2/24 brd 192.168.50.255 scope global eth0
    inet6 fe80::20c:29ff:fe28:fd4c/64 scope link
       valid_lft forever preferred_lft forever

This was a strange behaviour that you couldn't transfer files as IP fragmentation and TCP segmentation normally take care of chunking your file before sending it over the network. Maybe you should check what are the default fragmentation/segmentation configuration on your machine.

like image 148
Jeff Bencteux Avatar answered Feb 09 '23 11:02

Jeff Bencteux