From 4f6345726724732b564dd55b20ecb3e20a127bd0 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 4 May 2020 08:36:44 +0200 Subject: [PATCH] Ensure we retransmit the SYNACK packet if we didn't get an ACK back for it. We didn't start the retransmission timer when we got an incoming connection, and we didn't send an ACK back when we received a retransmitted SYNACK without any data. --- utcp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/utcp.c b/utcp.c index 5eca4d3..47acf22 100644 --- a/utcp.c +++ b/utcp.c @@ -890,7 +890,7 @@ static void retransmit(struct utcp_connection *c) { struct utcp *utcp = c->utcp; - if (utcp->retransmit) { + if(utcp->retransmit) { utcp->retransmit(c); } @@ -1352,6 +1352,8 @@ synack: print_packet(c, "send", &pkt, sizeof(hdr)); utcp->send(utcp, &pkt, sizeof(hdr)); } + + start_retransmit_timer(c); } else { // No, we don't want your packets, send a RST back len = 1; @@ -1713,7 +1715,7 @@ skip_ack: } c->rcv.irs = hdr.seq; - c->rcv.nxt = hdr.seq; + c->rcv.nxt = hdr.seq + 1; if(c->shut_wr) { c->snd.last++; @@ -1722,7 +1724,6 @@ skip_ack: set_state(c, ESTABLISHED); } - // TODO: notify application of this somehow. break; case SYN_RECEIVED: @@ -1736,8 +1737,8 @@ skip_ack: case CLOSING: case LAST_ACK: case TIME_WAIT: - // Ehm, no. We should never receive a second SYN. - return 0; + // This could be a retransmission. Ignore the SYN flag, but send an ACK back. + break; default: #ifdef UTCP_DEBUG @@ -1745,9 +1746,6 @@ skip_ack: #endif return 0; } - - // SYN counts as one sequence number - c->rcv.nxt++; } // 6. Process new data -- 2.39.5