From 36994569d1ba6839207761591964189d189c92d1 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 27 Mar 2020 22:12:20 +0100 Subject: [PATCH] Add better debugging of UDP style connections. Report packets that are out of order, either because of reordering or packet loss. --- utcp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utcp.c b/utcp.c index 72bb41d..50c7e36 100644 --- a/utcp.c +++ b/utcp.c @@ -1252,6 +1252,19 @@ synack: // Otherwise, continue processing. len = 0; } + } else { +#if UTCP_DEBUG + int32_t rcv_offset = seqdiff(hdr.seq, c->rcv.nxt); + + if(rcv_offset) { + debug(c, "packet out of order, offset %u bytes", rcv_offset); + } + + if(rcv_offset >= 0) { + c->rcv.nxt = hdr.seq + len; + } + +#endif } c->snd.wnd = hdr.wnd; // TODO: move below -- 2.39.5