UDT Tutorial: Configuration |
Options of UDT are read and set through getOpt and setOpt methods. The UDT options can be classified in 3 categories: address, transfer mode, and buffer size.
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.
Address setting is equivalent to setting the same parameters in the open method. Port number is often fixed at the udt server side, so it needs to be explicitly set (together with the UDT_PCH option, telling UDT that the port number cannot be changed). IP address setting is usually necessary for multi-homed hosts. If it is not set, UDT will use the first one found by getaddrinfo.
Setting transfer mode is usually a policy issue. First of all, the application may want to choose IPv4 or IPv6, using the UDT_IPV option. Applications may also need to configure sending and receiving modes, for blocking or non-blocking, respectively. Unlike sockets, the transfer mode can be set separately for sending and receiving in UDT.
The semantics of non-blocking sending is NOT the same as sockets. Non-blocking sending of UDT always returns immediately without waiting for the complete data sending.
The UDT_MFLAG option is for the convenience of programmers. In the situation that the application uses non-blocking sending, it is hard to trace when the buffer is successfully received by the peer side and it is safe to release the memory. (Note that UDT does NOT replicate the user buffer.) By setting this flag UDT will release it automatically after the data is sent. However, be careful that sometimes the memory is not allowed to be released (e.g., a static array) or the application does not want it to be released.
Flow control is something like the TCP window control. The UDT_FC option sets up the maximum window size, or the maximum number of unacknowledged packets. A sound value should be bandwidth * (RTT + 0.01) or greater. A smaller value will limit the performance.
The UDT buffer is for temporally storing received data. So larger values are better. But be sure that the buffer size is not too large compared to the physical memory size.
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 should be smaller than the receiving buffer size.
Example: read current UDT settings
int intval; bool boolval; int vallen;
// read UDT configurations // udt is a pointer to a UDT entity udt->getOpt(UDT_PORT, &intval, vallen); udt->getOpt(UDT_PCH, &boolval, vallen); udt->getOpt(UDT_SNDSYN, &boolval, vallen); udt->getOpt(UDT_RCVSYN, &boolval, vallen); udt->getOpt(UDT_MFLAG, &intval, vallen); udt->getOpt(UDT_FC, &intval, vallen); udt->getOpt(UDT_SBUF, &intval, vallen); udt->getOpt(UDT_USB, &intval, vallen); udt->getOpt(UDT_URB, &intval, vallen); udt->getOpt(UDT_IPV, &intval, vallen); |
Example: modify UDT settings
int intval; bool boolval; int vallen;
intval = 9000;
udt->setOpt(UDT_FC, &intval, sizeof(int)); |