UDT Tutorial: Configuration

Configuration

Options of UDT is read and set through getOpt and setOpt methods. The UDT options can be classified as 3 categories: address, transfer mode, and buffer size.

Before modifying any option, bear in mind that it is NOT a must to do modify default options. If the application has a sound performance with default options, just leave them alone.

Address setting is equivalent to set the same parameters in open method. Port number is often fixed at the udt side, so it is needed to be explicitly set (together with UDT_PCH option, telling UDT that the port number cannot be changed). IP address setting is usually necessary for multi-homed host. 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 mode, for blocking or non-blocking, respectively. Unlike socket, the transfer mode can be set separately for sending and receiving in UDT.

The semantics of non-blocking sending is NOT same as socket. Non-blocking sending of UDT always returns immediately without waiting for the completeness of data sending.

The UDT_MFLAG option is for the convenience of programmer. 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. Set 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 set up the maximum window size, or the maximum number of unacknowledged packets. It is definitely NOT the larger, the better. A sound value should be bandwidth * max(RTT + 0.01) or greater.  A smaller value will limit the performance.

The UDT buffer is for temporally storing received data. So larger value is better. But be sure that the buffer size should not be too large comparing to the physical memory size.

UDT uses UDP as data channel, so the UDP buffer size affects the performance. Again, a larger value is generally better, but the effects becomes smaller and disappears as the buffer size increases. Generally, sending buffer should be less than receiving buffer.

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_PORT, &intval, sizeof(int));
boolval = false;
udt->setOpt(UDT_PCH, &boolval, sizeof(bool));

boolval = false;
udt->setOpt(UDT_SNDSYN, &boolval, sizeof(bool));
boolval = true;
udt->setOpt(UDT_RCVSYN, &boolval, sizeof(bool));
intval = 1;
udt->setOpt(UDT_MFLAG, &intval, sizeof(int));

intval = 25600;

udt->setOpt(UDT_FC, &intval, sizeof(int));

intval = 40960000;
udt->setOpt(UDT_BUF, &intval, sizeof(int));

intval = 256000;
udt->setOpt(UDT_USB, &intval, sizeof(int));
udt->setOpt(UDT_URB, &intval, sizeof(int));

intval = 4;
udt->setOpt(UDT_IPV, &intval, sizeof(int));

char* ip = "206.220.241.13";
udt->setOpt(UDT_ADDR, ip, 16);