解析 UDP datagram headers
UDP headers 是 8 bytes: 源端口, 目标端口, 长度, 和 checksum. Learn 到解码 UDP 为协议分析.
- 1
UDP 头是 exactly 8 bytes: 源端口 (2 bytes), 目标端口 (2 bytes), 长度 (2 bytes, includes 头 + 数据), checksum (2 bytes, 可选在 IPv4). UDP 是 connectionless — 否 handshake, 否 flow control, 否 retransmission. 它是 used 为 DNS, DHCP, SNMP, 和实数-时间 protocols (RTP, QUIC).
- 2 十六进制解码器 →
解码 the hex representation of a UDP header. Bytes 0-1: source port, 2-3: destination port, 4-5: length (header + payload), 6-7: checksum. For example, 0035 0044 0010 0000 is source port 53 (DNS), dest port 68, length 16, no checksum.
- 3 二进制解码器 →
解码 the length and checksum fields. The length includes the 8-byte header plus payload. The checksum covers the pseudo-header (source/dest IP, protocol, length) + UDP header + data. In IPv4, checksum 0 means no checksum was computed.
常见问题
- 为什么 use UDP 而非 TCP?
- UDP 有下 开销 (8-字节头 vs 20+ 为 TCP) 和否 连接 setup delay. 它是 ideal 为: 实数-时间数据 (视频, voice) where retransmission 是 worse than 损失, 简单查询-响应 (DNS), 广播/multicast, 和当 应用 handles reliability itself (QUIC).
- 是 UDP checksum 可选?
- 在 IPv4, 是 — checksum 的 0 means "不 computed". 在 IPv6, checksum 是强制. 总是计算 checksum 为 reliability — missing checksum means corrupted 数据将 是 delivered undetected.