TCP序列号

我想知道两个相同序列号的段是否到达目的地,哪一段会被接受?

例如:

客户端将数据包发送到服务器并等待确认。 但是它没有在时间线内收到确认(由于一些networking问题,这个段需要时间到达服务器),所以开始再次发送相同的段。 现在在服务器端,如果两个数据包同时到达会发生什么情况。

一个数据包被标记为重复和丢弃。 由于它们是相同的,所以哪一个并不重要。 请参阅https://stackoverflow.com/questions/12871760/packet-loss-and-packet-duplication

两个部分同时到达的前提是没有意义的。 一个会一直到另一个之前。 但是这些数据在下一次到达之前可能还没有传递给应用程序。

根据RFC 793 ,将使用来自第一部分的数据。

分段按顺序处理。 到达时的初始testing用于丢弃旧的重复,但进一步的处理是在SEG.SEQ命令中完成的。 如果一个段的内容跨越了新旧之间的边界,那么只有新的部分应该被处理。

也就是说,不难想象实际上的行为会有不同的performance。 特别是部分重叠的部分可能是相当有趣的。

基本上先处理的将被接受,随后的重复将被丢弃。

https://www.rfc-editor.org/rfc/rfc793.txt

…首先检查序列号

SYN-RECEIVED STATE ESTABLISHED STATE FIN-WAIT-1 STATE FIN-WAIT-2 STATE CLOSE-WAIT STATE CLOSING STATE LAST-ACK STATE TIME-WAIT STATE Segments are processed in sequence. Initial tests on arrival are used to discard old duplicates, but further processing is done in SEG.SEQ order. If a segment's contents straddle the boundary between old and new, only the new parts should be processed. There are four cases for the acceptability test for an incoming segment: Segment Receive Test Length Window ------- ------- ------------------------------------------- 0 0 SEG.SEQ = RCV.NXT 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND >0 0 not acceptable >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND If the RCV.WND is zero, no segments will be acceptable, but special allowance should be made to accept valid ACKs, URGs and RSTs. If an incoming segment is not acceptable, an acknowledgment should be sent in reply (unless the RST bit is set, if so drop the segment and return): <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK> After sending the acknowledgment, drop the unacceptable segment and return...