Documentation
¶
Overview ¶
Package pcapplan 从 PCAP 文件生成 replay plan(IPv4 UDP/TCP)。
Index ¶
- func BuildFromFile(pcapPath, clientEp, serverEp string, includeZeroLen bool) (*replayplan.Plan, error)
- func BuildFromFileWithAutoEndpoints(pcapPath string, includeZeroLen bool, clientIPPrefix string) (*replayplan.Plan, net.IP, net.IP, int64, error)
- func BuildFromReader(r io.Reader, clientEp, serverEp string, includeZeroLen bool) (*replayplan.Plan, error)
- func GuessClientServerFromFile(pcapPath string, includeZeroLen bool, clientIPPrefix string) (client net.IP, server net.IP, flowBytes int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFromFile ¶
func BuildFromFile(pcapPath, clientEp, serverEp string, includeZeroLen bool) (*replayplan.Plan, error)
BuildFromFile 读取 PCAP / PCAPNG 路径并生成 plan(文件可 Seek:NG 失败时回绕重试)。 clientEp / serverEp 可为 IPv4、IPv4:PORT 或 IPv4:0;端口省略或为 0 时该侧匹配任意端口。 includeZeroLen 为 true 时保留 TCP/UDP payload 长度为 0 的包。
func BuildFromFileWithAutoEndpoints ¶
func BuildFromFileWithAutoEndpoints(pcapPath string, includeZeroLen bool, clientIPPrefix string) (*replayplan.Plan, net.IP, net.IP, int64, error)
BuildFromFileWithAutoEndpoints 打开 PCAP/PCAPNG,先按最大流推断客户端/服务端 IP,再生成 plan(端口侧为 0,与仅写 IP 的 endpoint 一致)。 返回值 flowPayloadBytes 为该流上累计的 TCP/UDP 应用层 payload 字节(与 aggregate 口径一致)。
func BuildFromReader ¶
func BuildFromReader(r io.Reader, clientEp, serverEp string, includeZeroLen bool) (*replayplan.Plan, error)
BuildFromReader 从经典 **PCAP** 流生成 plan(不支持 pcapng;若需 NG 请用 BuildFromFile)。
func GuessClientServerFromFile ¶
func GuessClientServerFromFile(pcapPath string, includeZeroLen bool, clientIPPrefix string) (client net.IP, server net.IP, flowBytes int64, err error)
GuessClientServerFromFile 按 **IPv4 TCP/UDP 应用层 payload 总字节** 最大的无向流,推断客户端与服务端 IP。 includeZeroLen 与 BuildFromFile 一致:为 false 时长度为 0 的包不参与统计。 clientIPPrefix 非空时,匹配该前缀(CIDR 或点分前缀,见 parseClientPrefix)的一侧为客户端;两侧同时匹配或均不匹配则报错。 clientIPPrefix 为空时:优先 RFC1918 私网为客户端;否则较低知名端口(<=1024)一侧为服务端;仍无法区分则 **IP 字典序较小** 一侧为服务端。
Types ¶
This section is empty.
Source Files
¶
- guess.go
- iter_seekable.go
- pcapplan.go