TCP 100%可靠吗? [英] Is TCP 100% reliable?

查看:167
本文介绍了TCP 100%可靠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管TCP是一种可靠的协议,它提供了重新传输和确认机制,但是我相信它不是100%可靠的,因为send()的成功返回不能确保数据已到达目标端点,而仅意味着该数据是复制到内核缓冲区.

Although TCP is a reliable protocol which provides retransmission and acknowledgement mechanisms but I believe its not 100% reliable since the successful return of send() doesn't ensure that the data has reached the destination endpoint and only means that the data is copied to the kernel buffer.

应用程序是否有任何机制可以知道数据是否已成功到达目的地?

Is there any mechanism for the application to know whether data has reached successfully to the destination?

一种可能的解决方案是在应用程序层中建立一些确认机制?

One possible solution could be to have some acknowledgement mechanism build up into the application layer?

推荐答案

TCP是可靠的,从某种意义上说,发送的消息将要么

TCP is reliable in the sense that messages sent will either

  1. 在发送时收到(相同的顺序,相同的内容);假设内置校验和不会碰巧失败,这可能是因为它只有16位 OR
  2. 根本不会收到

使用TCP,收到的消息绝不会出现混乱或中间消息丢失的情况.

Using TCP, messages received should never be out-of-order or missing intermediate messages.

要区分情况1和2,您应该实现确认机制.还可以确保比CRC消息更好的完整性的一个好主意是发回MD5或传入消息的其他散列.

To distinguish cases 1 and 2, you should implement an acknowledgement mechanism. A good idea that would also ensure better-than-CRC message integrity is to send back an MD5 or other hash of the incoming message.

这篇关于TCP 100%可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆