CRC 检查在 Tcp/Ip 上自动完成?
我想知道,在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
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.
TCP 中有一个校验和。但是,正如同一篇文章所说,
因此,如果您对此有所顾虑,也许添加另一项检查也没什么坏处。
There is a checksum in TCP. But, as the same article says,
So if you have concerns about that, maybe it won't hurt to add another checking.
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.
使用 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.