anchao commented on a change in pull request #5598:
URL: https://github.com/apache/incubator-nuttx/pull/5598#discussion_r813578014



##########
File path: net/tcp/tcp_send_buffered.c
##########
@@ -574,6 +547,37 @@ static uint16_t psock_send_eventhandler(FAR struct 
net_driver_s *dev,
           ninfo("ACK: wrb=%p seqno=%" PRIu32 " pktlen=%u sent=%u\n",
                 wrb, TCP_WBSEQNO(wrb), TCP_WBPKTLEN(wrb), TCP_WBSENT(wrb));
         }
+
+#ifdef CONFIG_NET_TCP_FAST_RETRANSMIT
+      /* Fast Retransmit (RFC 5681): an acknowledgment is considered a
+       * "duplicate" when (a) the receiver of the ACK has outstanding data,
+       * (b) the incoming acknowledgment carries no data, (c) the SYN and
+       * FIN bits are both off, (d) the acknowledgment number is equal to
+       * the greatest acknowledgment received on the given connection
+       * and (e) the advertised window in the incoming acknowledgment equals
+       * the advertised window in the last incoming acknowledgment.
+       */
+
+      if (conn->tx_unacked < conn->sent &&
+          (flags & TCP_NEWDATA) == 0 &&
+          (tcp->flags & (TCP_SYN | TCP_FIN)) == 0 &&
+          ackno == conn->snd_prev_ack &&
+          conn->snd_wnd == conn->snd_prev_wnd)
+        {

Review comment:
       There is another problem here. If the segment loss occurs before 
multiple segments are sent, it will trigger more invalid retransmissions:
   
   e.g:
   ```
   1     ->   good
   2     ->   lost
   3     ->   good
   4     ->   good
   5     ->   good
   6     ->   good
   7     ->   good
   8     ->   good
   9     ->   good
   10     ->   good
   
   snd_dup_acks 0    <-  1 (ACK 1)
   snd_dup_acks 1    <-  2 (DUP ACK 1)
   snd_dup_acks 2    <-  3 (DUP ACK 1)
   snd_dup_acks 3    <-  4 (DUP ACK 1)
   2     -> rexmit(snd_dup_acks = 0)
   snd_dup_acks 1    <-  5 (DUP ACK 1)
   snd_dup_acks 2    <-  6 (DUP ACK 1)
   snd_dup_acks 3    <-  7 (DUP ACK 1)
   2     -> rexmit(snd_dup_acks = 0)
   snd_dup_acks 1    <-  8 (DUP ACK 1)
   snd_dup_acks 2    <-  9 (DUP ACK 1)
   snd_dup_acks 3    <-  10 (DUP ACK 1)
   2     -> rexmit(snd_dup_acks = 0)
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to