CRC 检查在 Tcp/Ip 上自动完成?

发布于 2024-12-18 04:27:23 字数 88 浏览 4 评论 0原文

我想知道,在使用 TcpClient 发送数据时,是否有任何形式的 CRC 检查自动运行的算法?或者我必须实现自己的算法并在数据未正确到达远程主机时重新发送数据?

I wonder, while sending data with TcpClient, is there any sort of CRC
checking algorithm that works automatically? Or I have to implement my own algorithm and resend the data if it doesn't arrive to remote host correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉世弥音 2024-12-25 04:27:23

TCP 校验和相当弱,但对于可靠的流协议来说足够。通常,在数据链路层执行更强大的校验和 - 即以太网 (IIRC) 使用 CRC-32。

如果您确实想自己动手,这里是该理论的详细指南和实施。

The TCP checksum is fairly weak, but considered good enough for a reliable stream protocol. Often, there are more robust checksums being performed at the data link layer - i.e., ethernet (IIRC) uses CRC-32.

If you really want to roll your own, here is a detailed guide to the theory and implementation.

凑诗 2024-12-25 04:27:23

TCP 中有一个校验和。但是,正如同一篇文章所说,

按照现代标准,TCP 校验和的检查能力较弱。具有高误码率的数据链路层可能需要额外的链路纠错/检测功能。弱校验和可通过在 TCP 和 IP 之下的第 2 层普遍使用 CRC 或更好的完整性检查(例如在 PPP 或以太网帧中使用)来部分补偿。

因此,如果您对此有所顾虑,也许添加另一项检查也没什么坏处。

There is a checksum in TCP. But, as the same article says,

The TCP checksum is a weak check by modern standards. Data Link Layers with high bit error rates may require additional link error correction/detection capabilities. The weak checksum is partially compensated for by the common use of a CRC or better integrity check at layer 2, below both TCP and IP, such as is used in PPP or the Ethernet frame.

So if you have concerns about that, maybe it won't hurt to add another checking.

紅太極 2024-12-25 04:27:23

TCP 包含校验和,TCP/IP 堆栈将检测损坏的数据包。因此,除非您愿意,否则您不需要自己实现任何错误检测算法。

TCP contains a checksum and the TCP/IP stack will detect broken packets. So you don't need to implement any error detection algorithms on your own unless you want to.

苍暮颜 2024-12-25 04:27:23

使用 TCP 的重点在于协议中内置了错误检查。所以您不必担心此类事情。

The whole point of using TCP is that the error checking is built in the protocol. So you don't have to worry about this kind of things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文