Re: [asio-users] MTU value available through boost::asio?
Brought to you by:
chris_kohlhoff
|
From: Marsh R. <ma...@ex...> - 2011-11-24 19:33:11
|
On 11/24/2011 10:05 AM, Stéphane Charette wrote: > On Thu, Nov 24, 2011 at 01:39, Igor R <boo...@gm... > <mailto:boo...@gm...>> wrote: >> >> I don't have an answer to your question, but please note that the >> MTU is defined for the whole physical interface, rather than per >> socket. > > That doesn't sound right... If I have 2 sockets connected to 2 > different servers, one of which goes through a network with a much > smaller MTU, wouldn't the value be different for each one? MTU (Max Transmission Unit) is a maximum size parameter. The interface at each endpoint will have an MTU, as well as every network hop along the route between the endpoints. Often the *Path MTU* will be smaller than the endpoint's MTU. For example, VPN tunneling and encapsulation protocols add extensions on the link layer, IP, or TCP headers which reduce the space available in each packet for the application payload data. TCP attempts to determine path MTU for each link empirically through http://en.wikipedia.org/wiki/Path_MTU_Discovery Basically it starts out sending smaller packets, sets the 'don't fragment' bit, and gradually increases the size until they start dropping, then it backs off. > On linux, the MTU can be obtained by calling getsockopt( sockfd, > IPPROTO_IP, IP_MTU, ... ) on a connected socket. (I have no idea > how to do it on Windows, and I suspect Mac is probably similar to > Linux.) http://linux.die.net/man/7/ip : > IP_MTU (since Linux 2.2) Retrieve the current known path MTU of the > current socket. Only valid when the socket has been connected. > Returns an integer. Only valid as a getsockopt(2). So you may be able to use socket.get_option(...) to obtain this value a little more portably. At least you have socket.native_handle(). For Win32 the call is the getsockopt() call is the same > http://msdn.microsoft.com/en-us/library/windows/desktop/ms738544%28v=vs.85%29.aspx but the relevant option may be the one called "SO_MAX_MSG_SIZE". Like the broadcast question from the other day, sometimes these detail differ a little bit across platforms. - Marsh |