使用 WebSockets 或 WebRTC 发送的数据是否需要 CRC?
Do data sent with WebSockets or WebRTC needs CRC?
我在某处读到,当您通过纯 UDP 发送数据时,必须使用循环冗余检查来检测数据在接收时是否未损坏。
WebSockets 和 WebRTC 是否也需要这样做,或者网络浏览器会为您做到这一点?
您不能将纯 UDP 与 WebRTC 一起使用:
- WebSockets 通过 TCP 工作。查看 RFC 793, page 16,它有一个校验和。因此,它是安全的。
- WebRTC 数据通道通过 UDP 上的 SCTP 工作。调查 RFC 4960, page 90 的 SCTP:
When sending an SCTP packet, the endpoint MUST strengthen the data
integrity of the transmission by including the CRC32c checksum value
calculated on the packet, as described below.
这意味着,所有通过 RTCDataChannel 发送的数据包都已经有 CRC,并且所有到达目的地的数据包都没有损坏。
因此,它也是安全的。
切记:
reliable: true
:检测并处理丢包(重传)
reliable: false
: 未检测到丢包。
我在某处读到,当您通过纯 UDP 发送数据时,必须使用循环冗余检查来检测数据在接收时是否未损坏。
WebSockets 和 WebRTC 是否也需要这样做,或者网络浏览器会为您做到这一点?
您不能将纯 UDP 与 WebRTC 一起使用:
- WebSockets 通过 TCP 工作。查看 RFC 793, page 16,它有一个校验和。因此,它是安全的。
- WebRTC 数据通道通过 UDP 上的 SCTP 工作。调查 RFC 4960, page 90 的 SCTP:
When sending an SCTP packet, the endpoint MUST strengthen the data integrity of the transmission by including the CRC32c checksum value calculated on the packet, as described below.
这意味着,所有通过 RTCDataChannel 发送的数据包都已经有 CRC,并且所有到达目的地的数据包都没有损坏。 因此,它也是安全的。
切记:
reliable: true
:检测并处理丢包(重传)reliable: false
: 未检测到丢包。