简体   繁体   English

通过WebSockets或WebRTC发送的数据是否需要CRC?

[英]Do data sent with WebSockets or WebRTC needs CRC?

I've read somewhere that when you sent data over plain UDP, then using cyclic redundancy check is a must to detect if the data isn't corrupted upon receival. 我读过某处的文章,当您通过纯UDP发送数据时,必须使用循环冗余校验来检测接收时数据是否没有损坏。

Is that also required for WebSockets and WebRTC, or web browsers do that for you? WebSockets和WebRTC是否也需要它,或者Web浏览器为您做到这一点?

You cannot use plain UDP with WebRTC: 您不能将纯UDP与WebRTC一起使用:

  • WebSockets works over TCP. WebSockets通过TCP工作。 Looking into RFC 793, page 16 , is has a checksum. 查看RFC 793(第16页 )有一个校验和。 Thus, it is safe. 因此,这是安全的。
  • WebRTC Data Channels work over SCTP over UDP. WebRTC数据通道通过UDP的SCTP进行工作。 Looking into RFC 4960, page 90 for SCTP: 查看RFC 4960,第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. 当发送SCTP数据包时,端点务必通过包括在数据包上计算出的CRC32c校验和值来增强传输的数据完整性,如下所述。

This means, all packets send over an RTCDataChannel do already have a CRC and all packets which arrive at the destination are not corrupted. 这意味着,通过RTCDataChannel发送的所有数据包都已经具有CRC,并且到达目的地的所有数据包都没有损坏。 Thus, it is safe as well. 因此,它也是安全的。

Keep in mind: 记住:

  • reliable: true : Packet loss is detected and handled (restransmission) reliable: true :检测并处理了丢包(重传)
  • reliable: false : Packet loss is not detected. reliable: false :未检测到数据包丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM