/***************************************************************************** Copyright © 2001 - 2006, The Board of Trustees of the University of Illinois. All Rights Reserved. UDP-based Data Transfer Library (UDT) version 3 Laboratory for Advanced Computing (LAC) National Center for Data Mining (NCDM) University of Illinois at Chicago http://www.lac.uic.edu/ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. *****************************************************************************/ /***************************************************************************** This header file contains the definition of UDT/CCC base class. *****************************************************************************/ /***************************************************************************** written by Yunhong Gu [gu@lac.uic.edu], last updated 03/23/2006 *****************************************************************************/ #ifndef __UDT_CCC_H__ #define __UDT_CCC_H__ #include "udt.h" #include "packet.h" class UDT_API CCC { friend class CUDT; public: CCC(); virtual ~CCC() {} public: //static const int m_iCCID = 0; public: // Functionality: // Callback function to be called (only) at the start of a UDT connection. // note that this is different from CCC(), which is always called. // Parameters: // None. // Returned value: // None. virtual void init() {} // Functionality: // Callback function to be called when a UDT connection is closed. // Parameters: // None. // Returned value: // None. virtual void close() {} // Functionality: // Callback function to be called when an ACK packet is received. // Parameters: // 0) [in] ackno: the data sequence number acknowledged by this ACK. // Returned value: // None. virtual void onACK(const int32_t&) {} // Functionality: // Callback function to be called when a loss report is received. // Parameters: // 0) [in] losslist: list of sequence number of packets, in the format describled in packet.cpp. // 1) [in] size: length of the loss list. // Returned value: // None. virtual void onLoss(const int32_t*, const int&) {} // Functionality: // Callback function to be called when a timeout event occurs. // Parameters: // None. // Returned value: // None. virtual void onTimeout() {} // Functionality: // Callback function to be called when a data is sent. // Parameters: // 0) [in] seqno: the data sequence number. // 1) [in] size: the payload size. // Returned value: // None. virtual void onPktSent(const CPacket*) {} // Functionality: // Callback function to be called when a data is received. // Parameters: // 0) [in] seqno: the data sequence number. // 1) [in] size: the payload size. // Returned value: // None. virtual void onPktReceived(const CPacket*) {} // Functionality: // Callback function to Process a user defined packet. // Parameters: // 0) [in] pkt: the user defined packet. // Returned value: // None. virtual void processCustomMsg(const CPacket*) {} protected: // Functionality: // Set periodical acknowldging and the ACK period. // Parameters: // 0) [in] msINT: the period to send an ACK. // Returned value: // None. void setACKTimer(const int& msINT); // Functionality: // Set packet-based acknowldging and the number of packets to send an ACK. // Parameters: // 0) [in] pktINT: the number of packets to send an ACK. // Returned value: // None. void setACKInterval(const int& pktINT); // Functionality: // Set RTO value. // Parameters: // 0) [in] msRTO: RTO in macroseconds. // Returned value: // None. void setRTO(const int& usRTO); // Functionality: // Send a user defined control packet. // Parameters: // 0) [in] pkt: user defined packet. // Returned value: // None. void sendCustomMsg(CPacket& pkt) const; // Functionality: // retrieve performance information. // Parameters: // None. // Returned value: // Pointer to a performance info structure. const CPerfMon* getPerfInfo(); protected: double m_dPktSndPeriod; // Packet sending period, in microseconds double m_dCWndSize; // Congestion window size, in packets private: UDTSOCKET m_UDT; // The UDT entity that this congestion control algorithm is bound to int m_iACKPeriod; // Periodical timer to send an ACK, in milliseconds int m_iACKInterval; // How many packets to send one ACK, in packets int m_iRTO; // RTO value CPerfMon m_PerfInfo; // protocol statistics information }; class CCCVirtualFactory { public: virtual ~CCCVirtualFactory() {} virtual CCC* create() = 0; virtual CCCVirtualFactory* clone() = 0; }; template class CCCFactory: public CCCVirtualFactory { public: virtual ~CCCFactory() {} virtual CCC* create() {return new T;} virtual CCCVirtualFactory* clone() {return new CCCFactory;} }; #endif