UDT Reference: Congestion Control Class |
The following class CCC (some details are omitted) is the base class that a 3rd party congestion control algorithm should inherit from and overload the proper functions.
The class definition is in ccc.h, all new control algorithms definition should include this header file.
class CCC
virtual void
close()
{}
virtual
void onTimeout()
{}
void
setRTO(const int&
usRTO);
const UDT::TRACEINFO* getPerfInfo(); |
This is the callback function to be called at the start of a UDT connection. It can be used to initialize the packet sending period, initial sending rate, etc. It can also be used to start timer thread. It is RECOMMENDED that the initializations are done in this method, rather than in the constructor.
The clear-ups can be done in this method.
This is the callback function to be called when an ACK is received. The parameter of ack is the acknowledged packet sequence number.
This callback function is called when the sender detects a loss event, e.g., by duplicate ACK or explicit loss report. losslist is the packet sequence numbers of the lost packets and size the length of the loss list.
This callback function is called when a timeout event occurs if there is unacknowledged data in the sender side.
This callback function is called when a data packet is sent. All the packet information can be accessed though the pkt pointer. This callback function is useful to record the packet timestamp in a delay-based approach and compute RTT in onACK(), because UDT does not compute RTT for all packets.
See UDT specification and ./src/packet.cpp for the packet structure.
This callback function is called when a data packet is received. Packet information can be accessed through pkt.
This callback function tells UDT how to process user defined control message (pkt).
This method is used to enable timer-based acknowledging and set the ACK timer. It should be called by an inherited class (for example, in init()) if the new congestion control need timer-based acknowledging. msINT is the ACK timer in millisecond. Note that the highest precision of the ACK timer depends on the specific platform, and cannot exceed 1 millisecond.
This method is used to configure the number of packets to be received before an ACK is sent. This is the default acknowledging method and by default every packet will be acknowledged. Packet-based and timer-based acknowledging are exclusive. pktINT is the packet interval.
This method is used to set timeout value. The value usRTO is measured by microseconds.
The method can be used to send a user defined control message. The control message pkt must conform to the packet format defined in ./src/packet.cpp. IMPORTANT: This message is sent through UDP; therefore, it is not guaranteed to be sent successfully nor in order.
const UDT::TRACEINFO* getPerfInfo()
The internal UDT parameters and flow statistics can be read using this method. This is similar to the perfmon() method.
This is the packet sending period that should be updated by a rate control algorithm. If a pure window based algorithm is used, fix this variable to 0. It is measured by microsecond.
This is the congestion window size that should updated by window control algorithm. If a pure rate control algorithm is used, fix this variable to infinite.