TCP的重传

最近在做TCP相关的分析, 在设计重传检测时,对于重传的具体规定有点犯糊涂了,RFC793是这么描述的:When the TCP transmits a segment containing data, it puts a copy on a retransmission queue and starts a timer; when the acknowledgment for that data is received, the segment is deleted from the queue.  If the acknowledgment is not received before the timer runs out, the segment is retransmitted. RFC里只简单地说segment需要被重传,如何重传呢?重传报文是否一定要于原报文完全一致呢?是否可以多个报文组成一个大报文重传呢?还是可以split成多个?重传的边界是否必须是和原报文一致呢?

       这些问题的答案严重影响设计的复杂程度,在网上搜索了一通,无果,于是发了条短信给以前的同事,呵呵,讨论了半天,也没得出确定的结论。今天又看了一下《TCP/IP Illustrated, Volume 1, The Protocols》,在21章居然提到了这个问题,“When TCP times out and retransmits, it does not have to retransmit the identical segment again. Instead, TCP is allowed to perform repacketization, sending a bigger segment, which can increase performance. (Naturally, this bigger segment cannot exceed the MSS announced by the other receiver.) This is allowed in the protocol because TCP identifies the data being sent and acknowledged by its byte number, not its segment number.” 所以说重传报文完全没有必要和原报文一致,是可以把多个报文重组为一个大的报文进行重传的。

       在网上下载了一个开源的TCP/IP协议栈 (http://sics.se/~sdam/lwip/), 研究了一下TCP的实现,因为TCP是基于字节流的,所以很自然就可以处理传输过程中出现的边界不对齐,一个报文分为多个处理,多个报文合并为一个等等情况,看来这些情况都是有可能出现,要做一个健壮的设计,这些情况都应该能够处理。

       一直以为自己对TCP协议还是比较了解的,结果发现一个重传问题都搞不定,关于TCP的RFC那么多,我一个都没有完整看过。今天翻看《TCP/IP Illustrated, Volume 1, The Protocols》时,发现不少知识点已经有点不认识我了,唉,看来还是应该扎扎实实多看点书地。。。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值