pluggable congestion control stage1

This commit is contained in:
skywind3000
2026-05-14 09:55:55 +08:00
parent 8004f7eba5
commit ed6e480b0e

37
ikcp.h
View File

@@ -9,8 +9,8 @@
// + Lightweight, distributed as a single source file. // + Lightweight, distributed as a single source file.
// //
//===================================================================== //=====================================================================
#ifndef __IKCP_H__ #ifndef _IKCP_H_
#define __IKCP_H__ #define _IKCP_H_
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
@@ -261,6 +261,13 @@ typedef struct IQUEUEHEAD iqueue_head;
#endif #endif
//=====================================================================
// Predefine struct
//=====================================================================
struct IKCPCB;
typedef struct IKCPCB ikcpcb;
//===================================================================== //=====================================================================
// SEGMENT // SEGMENT
//===================================================================== //=====================================================================
@@ -283,6 +290,30 @@ struct IKCPSEG
}; };
//---------------------------------------------------------------------
// IKCPOPS - pluggable congestion control operations
//---------------------------------------------------------------------
struct IKCPOPS
{
const char *name;
int (*init)(ikcpcb *kcp);
void (*release)(ikcpcb *kcp);
void (*on_ack)(ikcpcb *kcp, IUINT32 acked_segs, IUINT32 prior_in_flight);
void (*on_fast_retransmit)(ikcpcb *kcp, IUINT32 fast_retrans,
IUINT32 inflight, IUINT32 prior_cwnd);
void (*on_timeout)(ikcpcb *kcp, IUINT32 prior_cwnd);
void (*on_tick)(ikcpcb *kcp);
void (*on_app_limited)(ikcpcb *kcp, IUINT32 inflight);
void (*on_rtt)(ikcpcb *kcp, IINT32 rtt);
void (*on_pkt_sent)(ikcpcb *kcp, IUINT32 sn, IUINT32 ts,
IUINT32 len, IUINT32 inflight);
void (*on_pkt_acked)(ikcpcb, IUINT32 sn, IUINT32 ts,
IUINT32 len, IINT32 rtt, IUINT32 xmit);
IUINT32 (*get_info)(ikcpcb *kcp, void *buf, IUINT32 bufsize);
IUINT32 (*pacing_rate)(ikcpcb *kcp);
};
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// IKCPCB // IKCPCB
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@@ -317,8 +348,6 @@ struct IKCPCB
}; };
typedef struct IKCPCB ikcpcb;
#define IKCP_LOG_OUTPUT 1 #define IKCP_LOG_OUTPUT 1
#define IKCP_LOG_INPUT 2 #define IKCP_LOG_INPUT 2
#define IKCP_LOG_SEND 4 #define IKCP_LOG_SEND 4