From d6f18182c43287c180e637046c044e8bff5e7064 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 8 Mar 2020 21:52:23 +0100 Subject: [PATCH] Always announce the receive window size as the size of the receive buffer. Since UTCP requires the application to handle incoming in-sequence data immediately, the start of the receive buffer is always right after the last ACKed byte, so we can always announce the size of the receive buffer as the maximum receive window size. --- utcp.c | 9 ++++----- utcp_priv.h | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/utcp.c b/utcp.c index 5d63069..d2a777c 100644 --- a/utcp.c +++ b/utcp.c @@ -382,7 +382,6 @@ static struct utcp_connection *allocate_connection(struct utcp *utcp, uint16_t s #endif c->snd.una = c->snd.iss; c->snd.nxt = c->snd.iss + 1; - c->rcv.wnd = utcp->mtu; c->snd.last = c->snd.nxt; c->snd.cwnd = utcp->mtu; c->utcp = utcp; @@ -468,7 +467,7 @@ struct utcp_connection *utcp_connect_ex(struct utcp *utcp, uint16_t dst, utcp_re pkt.hdr.dst = c->dst; pkt.hdr.seq = c->snd.iss; pkt.hdr.ack = 0; - pkt.hdr.wnd = c->rcv.wnd; + pkt.hdr.wnd = c->rcvbuf.maxsize; pkt.hdr.ctl = SYN; pkt.hdr.aux = 0x0101; pkt.init[0] = 1; @@ -538,7 +537,7 @@ static void ack(struct utcp_connection *c, bool sendatleastone) { pkt->hdr.src = c->src; pkt->hdr.dst = c->dst; pkt->hdr.ack = c->rcv.nxt; - pkt->hdr.wnd = c->snd.wnd; + pkt->hdr.wnd = c->rcvbuf.maxsize; pkt->hdr.ctl = ACK; pkt->hdr.aux = 0; @@ -697,7 +696,7 @@ static void retransmit(struct utcp_connection *c) { pkt->hdr.src = c->src; pkt->hdr.dst = c->dst; - pkt->hdr.wnd = c->rcv.wnd; + pkt->hdr.wnd = c->rcvbuf.maxsize; pkt->hdr.aux = 0; switch(c->state) { @@ -1073,7 +1072,7 @@ synack: pkt.hdr.dst = c->dst; pkt.hdr.ack = c->rcv.irs + 1; pkt.hdr.seq = c->snd.iss; - pkt.hdr.wnd = c->rcv.wnd; + pkt.hdr.wnd = c->rcvbuf.maxsize; pkt.hdr.ctl = SYN | ACK; if(init) { diff --git a/utcp_priv.h b/utcp_priv.h index 6c5c1f8..c23279d 100644 --- a/utcp_priv.h +++ b/utcp_priv.h @@ -129,7 +129,6 @@ struct utcp_connection { struct { uint32_t nxt; - uint32_t wnd; uint32_t irs; } rcv; -- 2.39.5