feat: 增加链路统计信息,两个链路分别显示在前端,D向A汇报D与B的信息
This commit is contained in:
@@ -33,8 +33,19 @@ VIDEO_DEFAULTS = {
|
||||
"mtu": 1400,
|
||||
}
|
||||
|
||||
TELEMETRY_DEFAULTS = {
|
||||
"nodelay": 0,
|
||||
"interval_ms": 50,
|
||||
"resend": 0,
|
||||
"nc": 0,
|
||||
"sndwnd": 64,
|
||||
"rcvwnd": 64,
|
||||
"mtu": 1400,
|
||||
}
|
||||
|
||||
__all__ = [
|
||||
"CONTROL_DEFAULTS",
|
||||
"TELEMETRY_DEFAULTS",
|
||||
"VIDEO_DEFAULTS",
|
||||
"MSG_TYPE_BINARY",
|
||||
"MSG_TYPE_ERROR",
|
||||
|
||||
@@ -88,27 +88,52 @@ static PyObject *build_stats_dict(const omnisocket_session_stats_t *stats) {
|
||||
}
|
||||
|
||||
static PyObject *build_kcp_stats_dict(const omnisocket_session_kcp_stats_t *stats) {
|
||||
return Py_BuildValue(
|
||||
"{s:i,s:I,s:I,s:i,s:i,s:I,s:I,s:I,s:I}",
|
||||
"connected",
|
||||
stats->connected,
|
||||
"conv",
|
||||
stats->conv,
|
||||
"rto_ms",
|
||||
stats->rto_ms,
|
||||
"srtt_ms",
|
||||
stats->srtt_ms,
|
||||
"srttvar_ms",
|
||||
stats->srttvar_ms,
|
||||
"snd_queue",
|
||||
stats->snd_queue,
|
||||
"rcv_queue",
|
||||
stats->rcv_queue,
|
||||
"snd_buffer",
|
||||
stats->snd_buffer,
|
||||
"xmit_total",
|
||||
stats->xmit_total
|
||||
);
|
||||
PyObject *dict = PyDict_New();
|
||||
PyObject *value = NULL;
|
||||
|
||||
if (dict == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define SET_KCP_STAT(key, expr) \
|
||||
do { \
|
||||
value = (expr); \
|
||||
if (value == NULL) { \
|
||||
Py_DECREF(dict); \
|
||||
return NULL; \
|
||||
} \
|
||||
if (PyDict_SetItemString(dict, (key), value) != 0) { \
|
||||
Py_DECREF(value); \
|
||||
Py_DECREF(dict); \
|
||||
return NULL; \
|
||||
} \
|
||||
Py_DECREF(value); \
|
||||
value = NULL; \
|
||||
} while (0)
|
||||
|
||||
SET_KCP_STAT("connected", PyLong_FromLong(stats->connected));
|
||||
SET_KCP_STAT("conv", PyLong_FromUnsignedLong(stats->conv));
|
||||
SET_KCP_STAT("rto_ms", PyLong_FromUnsignedLong(stats->rto_ms));
|
||||
SET_KCP_STAT("srtt_ms", PyLong_FromLong(stats->srtt_ms));
|
||||
SET_KCP_STAT("srttvar_ms", PyLong_FromLong(stats->srttvar_ms));
|
||||
SET_KCP_STAT("snd_wnd", PyLong_FromUnsignedLong(stats->snd_wnd));
|
||||
SET_KCP_STAT("rmt_wnd", PyLong_FromUnsignedLong(stats->rmt_wnd));
|
||||
SET_KCP_STAT("inflight", PyLong_FromUnsignedLong(stats->inflight));
|
||||
SET_KCP_STAT("window_limit", PyLong_FromUnsignedLong(stats->window_limit));
|
||||
SET_KCP_STAT("window_pressure_pct", PyFloat_FromDouble(stats->window_pressure_pct));
|
||||
SET_KCP_STAT("snd_queue", PyLong_FromUnsignedLong(stats->snd_queue));
|
||||
SET_KCP_STAT("rcv_queue", PyLong_FromUnsignedLong(stats->rcv_queue));
|
||||
SET_KCP_STAT("snd_buffer", PyLong_FromUnsignedLong(stats->snd_buffer));
|
||||
SET_KCP_STAT("out_segs_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->out_segs_total));
|
||||
SET_KCP_STAT("retrans_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->retrans_total));
|
||||
SET_KCP_STAT("fast_retrans_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->fast_retrans_total));
|
||||
SET_KCP_STAT("lost_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->lost_total));
|
||||
SET_KCP_STAT("repeat_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->repeat_total));
|
||||
SET_KCP_STAT("xmit_total", PyLong_FromUnsignedLong(stats->xmit_total));
|
||||
|
||||
#undef SET_KCP_STAT
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
static PyObject *PyOmniSession_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
|
||||
|
||||
@@ -267,9 +267,19 @@ void omnisocket_session_kcp_stats_snapshot(omnisocket_session_t *session, omniso
|
||||
out_stats->rto_ms = runtime_stats.rto_ms;
|
||||
out_stats->srtt_ms = runtime_stats.srtt_ms;
|
||||
out_stats->srttvar_ms = runtime_stats.srttvar_ms;
|
||||
out_stats->snd_wnd = runtime_stats.snd_wnd;
|
||||
out_stats->rmt_wnd = runtime_stats.rmt_wnd;
|
||||
out_stats->inflight = runtime_stats.inflight;
|
||||
out_stats->window_limit = runtime_stats.window_limit;
|
||||
out_stats->window_pressure_pct = runtime_stats.window_pressure_pct;
|
||||
out_stats->snd_queue = runtime_stats.snd_queue;
|
||||
out_stats->rcv_queue = runtime_stats.rcv_queue;
|
||||
out_stats->snd_buffer = runtime_stats.snd_buffer;
|
||||
out_stats->out_segs_total = runtime_stats.out_segs_total;
|
||||
out_stats->retrans_total = runtime_stats.retrans_total;
|
||||
out_stats->fast_retrans_total = runtime_stats.fast_retrans_total;
|
||||
out_stats->lost_total = runtime_stats.lost_total;
|
||||
out_stats->repeat_total = runtime_stats.repeat_total;
|
||||
out_stats->xmit_total = runtime_stats.xmit_total;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,19 @@ typedef struct omnisocket_session_kcp_stats {
|
||||
uint32_t rto_ms;
|
||||
int32_t srtt_ms;
|
||||
int32_t srttvar_ms;
|
||||
uint32_t snd_wnd;
|
||||
uint32_t rmt_wnd;
|
||||
uint32_t inflight;
|
||||
uint32_t window_limit;
|
||||
double window_pressure_pct;
|
||||
uint32_t snd_queue;
|
||||
uint32_t rcv_queue;
|
||||
uint32_t snd_buffer;
|
||||
uint64_t out_segs_total;
|
||||
uint64_t retrans_total;
|
||||
uint64_t fast_retrans_total;
|
||||
uint64_t lost_total;
|
||||
uint64_t repeat_total;
|
||||
uint32_t xmit_total;
|
||||
} omnisocket_session_kcp_stats_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user