11/*------------------------------------------------------------------------------
22 * MDK Middleware - Component ::Network
3- * Copyright (c) 2004-2025 Arm Limited (or its affiliates). All rights reserved.
3+ * Copyright (c) 2004-2026 Arm Limited (or its affiliates). All rights reserved.
44 *------------------------------------------------------------------------------
55 * Name: net_tcp.c
66 * Purpose: Transmission Control Protocol
@@ -490,14 +490,18 @@ netStatus net_tcp_send (int32_t socket, uint8_t *buf, uint32_t len) {
490490
491491 net_mem_shrink (frame , TCP_DATA_OFFS + len );
492492 tcp_s -> Flags |= TCP_IFLAG_DACK ;
493+ /* Check queue retransmit status */
493494 if (!(tcp_s -> Flags & TCP_IFLAG_RESEND )) {
494- /* Not in retransmit , send a frame now */
495+ /* Not active , send a frame now */
495496 tcp_s -> Flags |= TCP_IFLAG_PUSH ;
496497 tcp_s -> Flags &= ~TCP_IFLAG_KALIVE ;
497498 tcp_send_data (tcp_s , frame , len );
498- /* Calculate RTO and set a retransmit timer */
499- tcp_s -> RetryTimer = (uint16_t )((tcp_s -> RttSa >> 3 ) + tcp_s -> RttSv );
500- tcp_s -> Retries = tcp -> MaxRetry ;
499+ /* Check timeout recovery status */
500+ if (!(tcp_s -> Flags & TCP_IFLAG_TIMEOUT )) {
501+ /* Inactive, set retry timer and counter */
502+ tcp_s -> RetryTimer = (uint16_t )((tcp_s -> RttSa >> 3 ) + tcp_s -> RttSv );
503+ tcp_s -> Retries = tcp -> MaxRetry ;
504+ }
501505 tcp_s -> AliveTimer = tcp_s -> ConnTout ;
502506 }
503507 else {
@@ -1207,8 +1211,9 @@ void net_tcp_socket_run (void) {
12071211 }
12081212 /* Make sure fast recovery mode is not active */
12091213 tcp_s -> DupAcks = 0 ;
1210- /* Retransmit all frames from the queue */
12111214 tcp_s -> Flags &= ~TCP_IFLAG_FAST ;
1215+ /* Initialize the queue for timeout recovery */
1216+ tcp_s -> Flags |= TCP_IFLAG_TIMEOUT ;
12121217 tcp_que_init (tcp_s );
12131218 tcp_que_resend (tcp_s );
12141219 return ;
@@ -2453,7 +2458,7 @@ static void tcp_proc_acknr (NET_TCP_INFO *tcp_s, uint32_t acknr) {
24532458 tcp_s -> SendChk = acknr ;
24542459 }
24552460
2456- /* Release the acked data from the queue */
2461+ /* Calculate RTT estimation */
24572462 next = tcp_s -> unack_list ;
24582463 if (TCP_QUE (next )-> ticks ) {
24592464 /* Timestamp exists, do RTT estimation calculations. This */
@@ -2470,12 +2475,17 @@ static void tcp_proc_acknr (NET_TCP_INFO *tcp_s, uint32_t acknr) {
24702475 DEBUG_INFO (tcp_s );
24712476 EvrNetTCP_ShowRttVariables (tcp_s -> Id , tcp_s -> RttSa , tcp_s -> RttSv );
24722477 }
2473- tcp_s -> unack_list = NULL ;
24742478 if (frame != NULL ) {
2475- /* Markup the release edge (next = NULL) */
2479+ /* Mark the release edge (next = NULL) */
24762480 tcp_s -> unack_list = TCP_QUE (frame )-> next ;
2477- TCP_QUE (frame )-> next = NULL ;
2481+ TCP_QUE (frame )-> next = NULL ;
24782482 }
2483+ else {
2484+ /* All data in the queue is acked */
2485+ tcp_s -> unack_list = NULL ;
2486+ tcp_s -> Flags &= ~TCP_IFLAG_TIMEOUT ;
2487+ }
2488+ /* Release the acked data from the queue */
24792489 for (frame = next ; frame ; frame = next ) {
24802490 next = TCP_QUE (frame )-> next ;
24812491 net_mem_free (frame );
0 commit comments