Introduction

UDT Reference: CCC

### Base Congestion Control Class

The following class CCC (some details are omitted) is the base class that a user-define 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
{
public:
CCC();
virtual ~CCC() {}

public:
virtual void init() {}
virtual void close() {}
virtual void onACK(const int& ack) {}
virtual void onLoss(const int* losslist, const int& size) {} virtual void onTimeout() {}
virtual void onPktSent(const CPacket* pkt) {}
virtual void onPktReceived(const CPacket* pkt) {}
virtual void processCustomMsg(const CPacket& pkt) {}
protected:
void setACKTimer(const int& msINT);
void setACKInterval(const int& pktINT);
void setRTO(const int& usRTO);
void sendCustomMsg(CPacket& pkt) const;
const UDT::TRACEINFO* getPerfInfo();
protected:
double m_dPktSndPeriod;
double m_dCWndSize;
int m_iMSS;
int m_iRTT;
};

void init()

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.

void close()

The clear-ups can be done in this method.

void onACK(ack)

This is the callback function to be called when an ACK is received. The parameter of ack is the acknowledged packet sequence number.

void onLoss(losslist, size)

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.

void onTimeout()

This callback function is called when a timeout event occurs if there is unacknowledged data in the sender side.

void onPktSent(pkt)

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.

void onPktReceived(pkt)

This callback function is called when a data packet is received. Packet information can be accessed through pkt.

void processCustomMsg(pkt)

This callback function tells UDT how to process user defined control message (pkt).

void setACKTimer(msINT)

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.

void setACKInterval(pktINT)

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.

void setRTO(usRTO)

This method is used to set timeout value. The value usRTO is measured by microseconds.

void sendCustomMsg(pkt)

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.

double m_dPktSndPeriod

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.

double m_dCWndSize

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.

##### See Also

User-defined congestion controls