Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MagicSize 为魔数字节长度。 MagicSize = 4 // HeaderSize 为二进制头长度(魔数 + seq + dir)。 HeaderSize = 9 )
DirUL 与 DirDL 为数据包方向常量。
Variables ¶
This section is empty.
Functions ¶
func DecodePacket ¶
DecodePacket 解析数据包,返回 seq、dir、payload 长度(不含头)。
func EncodePacket ¶
EncodePacket 构造 UDP 负载:头 + payloadLen 字节零填充。
Types ¶
type StartMessage ¶
type StartMessage struct {
Cmd string `json:"cmd"`
TestID string `json:"test_id"`
DLSize int `json:"dl_size"`
DLIntervalNs int64 `json:"dl_interval_ns"`
ULIntervalNs int64 `json:"ul_interval_ns"`
DurationSec float64 `json:"duration_s"`
TimeDeltaNs int64 `json:"time_delta_ns"`
ULPacketCount int64 `json:"ul_packet_count"`
DLPacketCount int64 `json:"dl_packet_count"`
PcapReplay bool `json:"pcap_replay,omitempty"`
PcapPlanName string `json:"pcap_plan_name,omitempty"`
ReplayAnchorNs int64 `json:"replay_anchor_unix_ns,omitempty"`
PcapPlanSHA256 string `json:"pcap_plan_sha256,omitempty"`
// PcapReplaySpeed 回放时间缩放,>0;1 为原速;omitempty 时按 1 处理。
PcapReplaySpeed float64 `json:"pcap_replay_speed,omitempty"`
}
StartMessage 为客户端发往服务端的 START JSON(见 docs/design-pulse.md)。
func DecodeStart ¶
func DecodeStart(data []byte) (StartMessage, error)
DecodeStart 反序列化并校验 START 消息。
func (StartMessage) PcapReplayMode ¶
func (m StartMessage) PcapReplayMode() bool
PcapReplayMode 为 true 时服务端按 plan 墙钟发 DL。
Source Files
¶
- packet.go
- start.go
Click to show internal directories.
Click to hide internal directories.