Skip to content

端口号 ​

🔢 TCP/UDP 端口号在 r0capture 里的处理。

常见端口 ​

端口协议
80HTTP
443HTTPS
21FTP 控制
25/465SMTP/SMTPS
110/995POP3/POP3S
143/993IMAP/IMAPS
5222/5223XMPP/XMPPS

r0capture 的处理 ​

javascript
message[src_dst[i] + "_port"] = (sockAddr.port & 0xFFFF)

sockAddr.port & 0xFFFF:取低 16 位(端口是 16 位)。

与地址的区别 ​

维度端口IP 地址
宽度16 位32 位
字节序转换不需要(已是主机序 int)ntohl(小端→大端)
存储直接 intuint32 网络序

端口 sockAddr.port 已是主机序整数,直接存;IP 需 ipToNumber + ntohl 转。

五元组 ​

r0capture 的 message 含五元组:{src_addr, src_port, dst_addr, dst_port, protocol(TCP)},pcap 里每个包都有,Wireshark 据此显示连接。

相关文档 ​

基于 VitePress 构建 · 教学用途