how to properly implment path MTU discovery?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

how to properly implment path MTU discovery?

Post by mariuszp »

does path MTU discovery have to be implemented separately for each transport-layer protocol?

I can see that for example for ICMP this is never necessary since all valid packets are below or at minimum PMTU.

for TCP it's easy, since whenever I receive a "packet too big" or "fragmentation needed" message, all I have to do is make the TCP segment smaller and retransmit.

but what about UDP? am i supposed keep outbound UDP packets in a "possible retransmit list" for a bit and wait for "packet too big" messages to potentially arrive? or do i just not keep track of outbound packets and simply decrease the PMTU when i get such a message, and simply tolerate the loss of the larger packets?

or is there a specific protocol to detect the PMTU before beginning communication with a socket?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: how to properly implment path MTU discovery?

Post by Brendan »

Hi,

I think the basic idea is reasonably well covered by the corresponding wikipiedia article.....


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: how to properly implment path MTU discovery?

Post by mariuszp »

I have read the article but what I don't understand is whether, for example, for UDP i'm supposed to retransmit the packets in fragments after I already sent them and discovered the size was too large; or do I simply accept that the packet was dropped (which would in theory work since UDP tolerates loss).
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: how to properly implment path MTU discovery?

Post by onlyonemac »

Don't retransmit UDP packets, the other machine has no way to know that they have been retransmitted. If you get a "too large" response, reduce the packet size and continue with the next packet.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: how to properly implment path MTU discovery?

Post by iansjack »

mariuszp wrote:I have read the article but what I don't understand is whether, for example, for UDP i'm supposed to retransmit the packets in fragments after I already sent them and discovered the size was too large; or do I simply accept that the packet was dropped (which would in theory work since UDP tolerates loss).
You can do either. The packet will have been dropped at some point, so it's as if it was never transmitted. As far as the client listening on the remote computer is concerned the first time that you send it, suitably fragmented, using the correct MTU is the first time it has been sent.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: how to properly implment path MTU discovery?

Post by Brendan »

Hi,

Also note that it's probably better to consider it "continuous MTU adjustment" (and not "once only MTU discovery"). There can be many different paths between 2 computers (each with a different MTU), and no guarantee that all packets will travel the same path.

Basically; whenever you're told "packet too big" reduce your packet size to suit; and then maybe for long running connections consider sending an occasional/rare "deliberately slightly over-sized" packet to determine if MTU could be increased.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: how to properly implment path MTU discovery?

Post by mariuszp »

that makes sense thanks
jbemmel
Member
Member
Posts: 53
Joined: Fri May 11, 2012 11:54 am

Re: how to properly implment path MTU discovery?

Post by jbemmel »

Unlike TCP, for UDP the OS cannot choose the packet size, it must deliver the UDP packet as requested by the application. Only if your OS would offer a higher-level interface ( like "streamvideo" ) you could consider to implement dynamic tuning of the packet size based on PMTU discovery ( i.e. setting the DF flag ). Normally, the Internet will fragment UDP packets that are too large ( and they might arrive, or might not, depending on firewalls and the likes )

See https://lists.opensuse.org/opensuse-bug ... 02451.html
Post Reply