feat:扩展了结构化日志输出

- 补充了传输层观测指标
  - 增加了 UDP 丢包相关统计
  - README 也同步更新了字段口径
This commit is contained in:
nnbcccscdscdsc
2026-03-17 20:53:43 +08:00
parent ed1cb20da8
commit 4b95d26f13
5 changed files with 823 additions and 12 deletions

View File

@@ -17,6 +17,10 @@ typedef struct OmniMetricSummary {
double sum;
} OmniMetricSummary;
#define OMNI_LOGGER_UDP_RANGES_SIZE 512u
#define OMNI_LOGGER_UDP_SEQ_SAMPLE_SIZE 512u
#define OMNI_LOGGER_UDP_WINDOW_DIST_SIZE 512u
/* 通过该结构体收集全局统计信息 */
typedef struct OmniStats {
uint64_t start_ms; /* 起始时间(毫秒) */
@@ -44,6 +48,15 @@ typedef struct OmniStats {
uint64_t kcp_data_segs_out; /* KCP 累计发送的数据分片数(含重传) */
uint64_t kcp_data_bytes_sent; /* KCP 累计发送的数据字节(含重传) */
uint64_t kcp_retrans_bytes; /* KCP 累计重传的数据字节 */
uint64_t udp_expected_chunks; /* UDP 文件接收侧预期分片数 */
uint64_t udp_received_chunks; /* UDP 文件接收侧实际收到的分片数 */
uint64_t udp_lost_chunks; /* UDP 文件接收侧推断丢失的分片数 */
uint64_t udp_loss_burst_count; /* UDP 丢包区间数量 */
uint64_t udp_loss_burst_max_len; /* UDP 最大连续丢包长度 */
double udp_loss_rate_pct; /* UDP 丢包率(百分比) */
char udp_loss_ranges[OMNI_LOGGER_UDP_RANGES_SIZE]; /* UDP 丢包区间摘要 */
char udp_loss_seq_sample[OMNI_LOGGER_UDP_SEQ_SAMPLE_SIZE]; /* UDP 丢包序号样本 */
char udp_recv_window_dist[OMNI_LOGGER_UDP_WINDOW_DIST_SIZE]; /* UDP 接收窗口分布 */
/* 延迟/耗时统计(单位:毫秒) */
double send_call_avg_ms; /* omni_send 平均耗时EWMA */
@@ -126,6 +139,15 @@ void logger_on_cwnd(double cwnd);
/* 记录任务总量与当前进度。 */
void logger_set_transfer_total(uint64_t total_bytes);
void logger_set_progress(uint64_t progress_bytes);
void logger_reset_transfer_observability(void);
void logger_on_udp_loss_summary(uint64_t expected_chunks,
uint64_t received_chunks,
uint64_t lost_chunks,
uint64_t burst_count,
uint64_t burst_max_len,
const char *ranges,
const char *seq_sample,
const char *recv_window_dist);
/* 计算当前吞吐量(返回:字节/秒) */
double logger_calculate_throughput(void);