OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 12:35 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: how to properly implment path MTU discovery?
PostPosted: Sat Jul 16, 2016 7:28 am 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
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?


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Mon Jul 18, 2016 8:01 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
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.


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Tue Jul 19, 2016 2:12 am 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
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).


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Tue Jul 19, 2016 7:25 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
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


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Tue Jul 19, 2016 8:34 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Tue Jul 19, 2016 4:52 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
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.


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Tue Jul 19, 2016 5:23 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
that makes sense thanks


Top
 Profile  
 
 Post subject: Re: how to properly implment path MTU discovery?
PostPosted: Fri Jul 22, 2016 8:54 am 
Offline
Member
Member

Joined: Fri May 11, 2012 11:54 am
Posts: 53
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group