Jump to: navigation, search

Table of Contents >> Programmer's Reference

#include <trsocket.h>

int tfSetIfMtu (
ttUserInterface interfaceId,
int ifMtu

Function Description

This function is used to set the Maximum Transmission Unit (MTU) for a device. For Ethernet and PPP, this is typically set to 1500 bytes. The link MTU is always the size of the largest IP packet which can be sent unfragmented over the link, which is the maximum link-layer frame size minus any link-layer header and trailer overhead. For PPP and Ethernet, this value can be changed via Path MTU Discovery to allow larger frames and to prevent IP datagram fragmentation.


  • interfaceHandle
    The interface handle of the device we wish to set the MTU on.
  • ifMtu
    The MTU for the device.


    One of the parameters is invalid.

Note Note: By default, the path MTU discovery code is enabled. If you do not need path MTU in your <trsystem.h>, define:

This will prevent the compilation of the path MTU discovery code.

Note Note: Using this function to support large Ethernet frames may require modifications to TCP defaults. By design TCP is inefficient when socket send and receive queues are smaller than 2*MTU. The default size for socket send and receive queue is 8KB. When using tfSetIfMtu to enable Jumbo Ethernet frames, Treck recommends changing the default socket send and receive queue sizes at compile time. This can be done by defining the following macros in <trsystem.h>:
#define TM_SOC_SEND_Q_BYTES 35840
#define TM_SOC_RECV_Q_BYTES 35840

Turning off the path MTU discovery mechanism with setsockopt()

If the path MTU discovery code has been compiled in, and there is a need to disable path MTU discovery on a given connection, the user can call the Berkeley socket API setsockopt() on the connection or listening socket prior to the connection establishment, with the IP_PROTOTCP protocol level and TCP_MAXSEG option name. If the option value is less than 64 bytes, then the Treck stack will set the TCP MSS to the default value, which is the outgoing device IP MTU minus 40 bytes.

Turning off the path MTU discovery mechanism wtih tfDisablePathMtuDisc()

Another way of turning off the Path MTU discovery mechanism for a given destination IP address is to use the new API tfDisablePathMtuDisc(). This function will disable path MTU discovery for the route to the given destination IP address.

Path MTU estimates timeout values

When Path MTU discovery is enabled for an indirect TCP destination IP address, the Treck stack will try to increase the path MTU estimate (up to the device IP MTU) after the current path MTU estimate times out. Two new options have been added to tfSetTreckOptions() to allow the user to change the default timeout values for path MTU estimates.

Table of Contents >> Programmer's Reference