fix: kcp 协议内部日志细节

This commit is contained in:
2026-03-25 15:09:32 +08:00
parent be013b701b
commit 665a908421
15 changed files with 1117 additions and 42 deletions

View File

@@ -10,15 +10,26 @@ import (
// KCPPacketDebugRecord 是 KCP 底层 UDP packet kernel timestamp 的一条 JSONL 调试记录。
type KCPPacketDebugRecord struct {
Event string `json:"event"`
NodeRole string `json:"node_role,omitempty"`
NodeID string `json:"node_id,omitempty"`
LocalAddr string `json:"local_addr,omitempty"`
RemoteAddr string `json:"remote_addr,omitempty"`
PacketBytes int `json:"packet_bytes"`
UDPTXID *uint32 `json:"udp_tx_id,omitempty"`
KCPConv *uint32 `json:"kcp_conv,omitempty"`
TSUnixNano int64 `json:"ts_unix_nano"`
Event string `json:"event"`
NodeRole string `json:"node_role,omitempty"`
NodeID string `json:"node_id,omitempty"`
LocalAddr string `json:"local_addr,omitempty"`
RemoteAddr string `json:"remote_addr,omitempty"`
PacketBytes int `json:"packet_bytes"`
UDPTXID *uint32 `json:"udp_tx_id,omitempty"`
KCPConv *uint32 `json:"kcp_conv,omitempty"`
Segments []KCPPacketDebugSegment `json:"segments,omitempty"`
TSUnixNano int64 `json:"ts_unix_nano"`
}
// KCPPacketDebugSegment 是一个 UDP datagram 中解析出的 KCP segment 头信息。
type KCPPacketDebugSegment struct {
Cmd uint8 `json:"cmd"`
SN uint32 `json:"sn"`
UNA uint32 `json:"una"`
Frg uint8 `json:"frg"`
Wnd uint16 `json:"wnd"`
Len uint32 `json:"len"`
}
// KCPPacketDebugLogger 接收 KCP packet 级调试记录。