【正文】
extseqnum = initial_sequence number 02 03 loop (forever) { 04 switch(event) 05 event: data received from application above 06 create TCP segment with sequence number nextseqnum 07 start timer for segment nextseqnum 08 pass segment to IP 09 nextseqnum = nextseqnum + length(data) 10 event: timer timeout for segment with sequence number y 11 retransmit segment with sequence number y 12 pue new timeout interval for segment y 13 restart timer for sequence number y 14 event: ACK received, with ACK field value of y 15 if (y sendbase) { /* cumulative ACK of all data up to y */ 16 cancel all timers for segments with sequence numbers y 17 sendbase = y 18 } 19 else { /* a duplicate ACK for already ACKed segment */ 20 increment number of duplicate ACKs received for y 21 if (number of duplicate ACKS received for y == 3) { 22 /* TCP fast retransmit */ 23 resend segment with sequence number y 24 restart timer for segment y 25 } 26 } /* end of loop forever */ 簡化的 TCP 發(fā)送方 主講人: 西安交通大學 程向前 第 4講 傳輸層之二 47 TCP ACK 規(guī)則 [RFC 1122, RFC 2581] 事件 有序數(shù)據(jù)段到達 , 沒有缺失的段 , 所有其他數(shù)據(jù)段已經(jīng) ACKed 有序數(shù)據(jù)段到達 , 沒有缺失的段 , 有一個延遲 ACK 等待 失序數(shù)據(jù)段到達 seq. 高于預期值 測到間隔 到達的數(shù)據(jù)段部分或全部填滿了缺失的段 TCP 接收方的動作 延遲 ACK. 等待 500ms 看是否還有數(shù)據(jù)段到達 . 如果沒有 , 發(fā)送 ACK 立即發(fā)送一個 積欠的 ACK 發(fā)送重復的 ACK, 說明 seq. 為下一個期望的字節(jié) 立即 ACK, 如果數(shù)據(jù)段處于缺失的段的較低端 主講人: 西安交通大學 程向前 第 4講 傳輸層之二 48 TCP: 重傳場景 Host A loss timeout time 丟失 ACK 場景 Host B X Host A Seq=92 timeout time 過早超時 , 積欠 ACKs Host B Seq=100 timeout 主講人: 西安交通大學 程向前 第 4講 傳輸層之二 49 TCP 流量控制 接收端 : 顯式通知發(fā)送端 (動態(tài)變化