There are local MTU size and Path MTU (see RFC 1191). You can use commands like
ping -f -l 1464 www.stackoverflow.com
ping -f -l 1465 www.stackoverflow.com
to determine a Path MTU. Take in consideration the header size of ICMP packages and IP headers. See http://stackoverflow.com/questions/1605084/path-mtu-discovery for API solution.
UPDATED: Please no more such questions! It was very interesting for me to find the answer and I spend some hours for this. But... I found! To receive correct value of MTU size you should use GetIpInterfaceTable
API which returns PMIB_IPINTERFACE_TABLE
structure which has array of MIB_IPINTERFACE_ROW
structures. MIB_IPINTERFACE_ROW
hat InterfaceIndex
which helps you to identify IP interface, it is the same as in other well known IP Helper functions. You can also use ConvertInterfaceLuidToNameW
function to receive from another field InterfaceLuid
the interface name.
But the most interesting thing is NlMtu field
typedef struct _MIB_IPINTERFACE_ROW {
ADDRESS_FAMILY Family;
NET_LUID InterfaceLuid;
NET_IFINDEX InterfaceIndex;
// ...
ULONG NlMtu;
// ...
};
In the documentation (see http://msdn.microsoft.com/en-us/library/aa814496(v=VS.85).aspx) it is described as "The network layer MTU size, in bytes.". The same text and no more you will find also in Windows Driver Kit documentation (see http://msdn.microsoft.com/en-us/library/ff559254(VS.85).aspx). This field NlMtu is what you are searching for. My computer for example is connected to the Internet through a DSL router and NlMtu
is not 1500 like it would be without the router, but has the correct value 1492 instead. In your case it must be 1300.
If you have one of the last versions of Microsoft SDK installed, then you will find in C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\netds\iphelp\Netinfo directory an example which use GetIpInterfaceTable
API. Just set a brakepoint on the line about 270 in the netinfo.c file and you will see in InterfaceTable->Table[i].NlMtu
the correct value of IP MTU of the corresponding interface adapter. If you verify in registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces{34407201-997C-41FF-9EBF-1B7D6DF92B38} which value has MTU REG_DWORD for your Interfaces card ({34407201-997C-41FF-9EBF-1B7D6DF92B38} in my case) it must be the same value.
The function GetIpInterfaceTable
exists starting with Vista, but how you can see from the name PMIB_IPINTERFACE_TABLE
the values come from MIB information of TCP adapter see (Windows DDK). Some years ago it was no IP helper DLL at all and to receive the information which displays IpConfig.exe one has to use CreateFile and DeviceIoControl to give such informations from TCP TDI driver (see constants like L"\Device\Tcp" and IOCTL_TCP_QUERY_INFORMATION_EX in tcpioctl.h). So perhaps it is possible to give the same information on Windows XP, but it is not important.