#ifndef __UDT_BASE_H__ #define __UDT_BASE_H__ #ifndef WIN32 #include #include #include #else #ifdef __MINGW__ #include #include #endif #include #endif #ifdef WIN32 #ifndef __MINGW__ // Explicitly define 32-bit and 64-bit numbers typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int32 uint32_t; #ifndef LEGACY_WIN32 typedef unsigned __int64 uint64_t; #else // VC 6.0 does not support unsigned __int64: may cause potential problems. typedef __int64 uint64_t; #endif #ifdef UDT_EXPORTS #define UDT_API __declspec(dllexport) #else #define UDT_API __declspec(dllimport) #endif #else #define UDT_API #endif #else //#define UDT_API __attribute__ ((visibility("default"))) #define UDT_API // to make SWIG happy #endif #define NO_BUSY_WAITING #ifdef WIN32 #ifndef __MINGW__ typedef SOCKET SYSSOCKET; #else typedef int SYSSOCKET; #endif #else typedef int SYSSOCKET; #endif typedef SYSSOCKET UDPSOCKET; typedef int UDTSOCKET; //////////////////////////////////////////////////////////////////////////////// enum EPOLLOpt { // this values are defined same as linux epoll.h // so that if system values are used by mistake, they should have the same effect UDT_EPOLL_IN = 0x1, UDT_EPOLL_OUT = 0x4, UDT_EPOLL_ERR = 0x8 }; enum UDTSTATUS {INIT = 1, OPENED, LISTENING, CONNECTING, CONNECTED, BROKEN, CLOSING, CLOSED, NONEXIST}; //////////////////////////////////////////////////////////////////////////////// enum UDTOpt { UDT_MSS, // the Maximum Transfer Unit UDT_SNDSYN, // if sending is blocking UDT_RCVSYN, // if receiving is blocking UDT_CC, // custom congestion control algorithm UDT_FC, // Flight flag size (window size) UDT_SNDBUF, // maximum buffer in sending queue UDT_RCVBUF, // UDT receiving buffer size UDT_LINGER, // waiting for unsent data when closing UDP_SNDBUF, // UDP sending buffer size UDP_RCVBUF, // UDP receiving buffer size UDT_MAXMSG, // maximum datagram message size UDT_MSGTTL, // time-to-live of a datagram message UDT_RENDEZVOUS, // rendezvous connection mode UDT_SNDTIMEO, // send() timeout UDT_RCVTIMEO, // recv() timeout UDT_REUSEADDR, // reuse an existing port or create a new one UDT_MAXBW, // maximum bandwidth (bytes per second) that the connection can use UDT_STATE, // current socket state, see UDTSTATUS, read only UDT_EVENT, // current avalable events associated with the socket UDT_SNDDATA, // size of data in the sending buffer UDT_RCVDATA // size of data available for recv }; //////////////////////////////////////////////////////////////////////////////// struct CPerfMon { // global measurements int64_t msTimeStamp; // time since the UDT entity is started, in milliseconds int64_t pktSentTotal; // total number of sent data packets, including retransmissions int64_t pktRecvTotal; // total number of received packets int pktSndLossTotal; // total number of lost packets (sender side) int pktRcvLossTotal; // total number of lost packets (receiver side) int pktRetransTotal; // total number of retransmitted packets int pktSentACKTotal; // total number of sent ACK packets int pktRecvACKTotal; // total number of received ACK packets int pktSentNAKTotal; // total number of sent NAK packets int pktRecvNAKTotal; // total number of received NAK packets int64_t usSndDurationTotal; // total time duration when UDT is sending data (idle time exclusive) // local measurements int64_t pktSent; // number of sent data packets, including retransmissions int64_t pktRecv; // number of received packets int pktSndLoss; // number of lost packets (sender side) int pktRcvLoss; // number of lost packets (receiver side) int pktRetrans; // number of retransmitted packets int pktSentACK; // number of sent ACK packets int pktRecvACK; // number of received ACK packets int pktSentNAK; // number of sent NAK packets int pktRecvNAK; // number of received NAK packets double mbpsSendRate; // sending rate in Mb/s double mbpsRecvRate; // receiving rate in Mb/s int64_t usSndDuration; // busy sending time (i.e., idle time exclusive) // instant measurements double usPktSndPeriod; // packet sending period, in microseconds int pktFlowWindow; // flow window size, in number of packets int pktCongestionWindow; // congestion window size, in number of packets int pktFlightSize; // number of packets on flight double msRTT; // RTT, in milliseconds double mbpsBandwidth; // estimated bandwidth, in Mb/s int byteAvailSndBuf; // available UDT sender buffer size int byteAvailRcvBuf; // available UDT receiver buffer size }; typedef enum UDTOpt SOCKOPT; typedef struct CPerfMon TRACEINFO; UDT_API extern const UDTSOCKET INVALID_SOCK; #undef ERROR UDT_API extern const int ERROR; #endif