Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: tcp/tcpsend.c
- Revision:
- 82:20781198d26d
- Parent:
- 80:4ef1500fca1d
- Child:
- 83:08c983006a6e
--- a/tcp/tcpsend.c Thu Nov 15 17:36:08 2018 +0000 +++ b/tcp/tcpsend.c Thu Nov 15 18:42:42 2018 +0000 @@ -14,6 +14,7 @@ #include "tcpsend.h" #define TIMEOUT_RETRANSMISSION 2 +#define MAX_RETRANSMISSIONS 10 #define TIMEOUT_KEEP_ALIVE 60 #define TIMEOUT_BROKEN_LINK 600 @@ -208,14 +209,14 @@ if (pLocIpScope) *pLocIpScope = pTcb->locIpScope; //Close old ones - if (TcbElapsed > pTcb->timeLastRcvd + TIMEOUT_KEEP_ALIVE) + if (TcbElapsed >= pTcb->timeLastRcvd + TIMEOUT_KEEP_ALIVE) { if (TcpTrace) LogTimeF("TCP - Closing TCB port %hu - after keep alive\r\n", pTcb->remPort); return TcpSendClose(pSize, pPacket, pTcb); } //Reap old ones - if (TcbElapsed > pTcb->timeLastRcvd + TIMEOUT_BROKEN_LINK) + if (TcbElapsed >= pTcb->timeLastRcvd + TIMEOUT_BROKEN_LINK) { if (TcpTrace) LogTimeF("TCP - Reaping TCB port %hu - broken link\r\n", pTcb->remPort); pTcb->state = TCB_EMPTY; @@ -226,11 +227,23 @@ if (pTcb->bytesSentToRem == pTcb->bytesAckdByRem) { pTcb->timeSendsBeingAcked = TcbElapsed; + pTcb->countSendsNotAcked = 0; } //Check if have unacknowledged send bytes after the RTO - if (TcbElapsed > pTcb->timeSendsBeingAcked + TIMEOUT_RETRANSMISSION) + if (TcbElapsed >= pTcb->timeSendsBeingAcked + TIMEOUT_RETRANSMISSION) { + pTcb->countSendsNotAcked++; + if (pTcb->countSendsNotAcked > MAX_RETRANSMISSIONS) + { + if (TcpTrace) + { + if (NetTraceNewLine) Log("\r\n"); + LogTimeF("TCP - Resending seq %lu on port %hu reached maximum retransmissions\r\n", pTcb->bytesAckdByRem, pTcb->remPort); + pTcb->state = TCB_EMPTY; + return TcpSendReset(pSize, pPacket, pTcb); + } + } if (TcpTrace) { if (NetTraceNewLine) Log("\r\n");