I am developing a tftp client and server, and I want to dynamically select the udp payload size in order to improve transfer performance.
I tested it using two Linux machines (one of them has a gigabit network card, and the other has a fast Ethernet network). I changed the MTU of the gigabit card to 2048 bytes and left the other to 1500.
I used setsockopt(sockfd, IPPROTO_IP, IP_MTU_DISCOVER, &optval, sizeof(optval))to set the flag MTU_DISCOVERto IP_PMTUDISC_DO.
From what I read, this parameter should set the bit DFto one, and therefore it should be possible to find the minimum network MTU (host MTU with the lowest MTU). However, this thing only gives me an error when I send a packet that is larger than the MTU of the machine with which I send packets.
Also, another machine (the server in this case) does not receive large packets (the server has MTU 1500). All UDP packets are discarded, the only way is to send packets of 1472 bytes.
Why do hosts do this? From what I read, if I send a packet that exceeds the MTU, the ip layer should fragment it.
source
share