UDT Tutorial

Configurate the UDT options

Options of UDT are read and set through getsockopt and setsockopt methods. Before modifying any option, bear in mind that it is NOT required that you modify the default options. If the application has sound performance with the default options, just leave them alone.

UDT_MSS is used to configure the packet size. On most of time, the optimal UDT packet size is the network MTU size. The default value is 1500 bytes. A UDT connection will choose the smaller value of the MSS between the two peer sides. For example, if you want to set 9000-byte MSS, you have to set this option at both sides, and the one of the value has to be exactly equal to 9000, and the other must not be less than 9000.

UDT uses a different semantics of synchronization mode from traditional sockets. It can set the sending and receiving synchronization independently, which allows more flexibility. However, UDT does not allow non-blocking operation on connection setup and close.

The UDT buffer size is used to limit the size of temporary storage of sending/receiving data. The sending buffer size is only a limit. Memory is allocated upon necessary. The receiving buffer is statically allocated and the same amount of memory is allocated to the UDT throughout the UDT life. Generally, larger buffer (but not so large that the physical memory is used up) is better for performance the the buffer sizes for both sides should be at least Bandwidth*RTT.

UDT uses UDP as the data channel, so the UDP buffer size affects the performance. Again, a larger value is generally better, but the effects become smaller and disappear as the buffer size increases. Generally, the sending buffer size can be a small value, because it does not limit the packet sending much but a large value will increase the delay. On the other hand, the receiving buffer size should not be less than the UDT receiver buffer size, in order that the flow control is effective.

UDT_FC is actually an internal parameter and you should set it to not less than UDT_RCVBUF/UDT_MSS.

UDT_LINGER is similar to the SO_LINGER option on the regular sockets.

UDT_RENDEZVOUS is used to enable rendezvous connection setup.

UDT_SNDTIMEO and UDT_RCVTIMEO are similar to SO_SNDTIMEO and SO_RCVTIMEO, respectively.

Example: read current UDT settings

 

UDTSOCKET u;

...

bool block;

UDT::getsockopt(u, UDT_SNDSYN, 0, &block, sizeof(bool));

 

Example: modify UDT settings

 

UDTSOCKET u;

...

bool block = false;

UDT::setsockopt(u, UDT_SNDSYN, 0, &block, sizeof(bool));