diff -Nur lwip-2.1.3-org/src/core/init.c lwip-2.1.3/src/core/init.c --- lwip-2.1.3-org/src/core/init.c 2022-12-06 14:40:45.280000000 +0000 +++ lwip-2.1.3/src/core/init.c 2022-12-06 14:41:01.452000000 +0000 @@ -306,7 +306,7 @@ #if TCP_SNDLOWAT >= TCP_SND_BUF #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif -#if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS)) +#if TCP_SNDLOWAT >= (0xFFFFFFFF - (4 * TCP_MSS)) #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!" #endif #if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN diff -Nur lwip-2.1.3-org/src/core/pbuf.c lwip-2.1.3/src/core/pbuf.c --- lwip-2.1.3-org/src/core/pbuf.c 2022-12-06 14:40:45.280000000 +0000 +++ lwip-2.1.3/src/core/pbuf.c 2022-12-06 14:46:04.860000000 +0000 @@ -869,13 +869,13 @@ /* proceed to last pbuf of chain */ for (p = h; p->next != NULL; p = p->next) { /* add total length of second chain to all totals of first chain */ - p->tot_len = (u16_t)(p->tot_len + t->tot_len); + p->tot_len = p->tot_len + t->tot_len; } /* { p is last pbuf of first h chain, p->next == NULL } */ LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); LWIP_ASSERT("p->next == NULL", p->next == NULL); /* add total length of second chain to last pbuf total of first chain */ - p->tot_len = (u16_t)(p->tot_len + t->tot_len); + p->tot_len = p->tot_len + t->tot_len; /* chain last pbuf of head (p) with first of tail (t) */ p->next = t; /* p->next now references t, but the caller will drop its reference to t, @@ -1181,7 +1181,7 @@ if (r != NULL) { /* Update the tot_len field in the first part */ for (i = p; i != NULL; i = i->next) { - i->tot_len = (u16_t)(i->tot_len - r->tot_len); + i->tot_len = tot_len_front; LWIP_ASSERT("tot_len/len mismatch in last pbuf", (i->next != NULL) || (i->tot_len == i->len)); } @@ -1192,6 +1192,9 @@ /* tot_len field in rest does not need modifications */ /* reference counters do not need modifications */ *rest = r; + r->tot_len = r->len; + }else{ + p->tot_len = tot_len_front; } } } diff -Nur lwip-2.1.3-org/src/include/lwip/opt.h lwip-2.1.3/src/include/lwip/opt.h --- lwip-2.1.3-org/src/include/lwip/opt.h 2022-12-06 14:40:45.292000000 +0000 +++ lwip-2.1.3/src/include/lwip/opt.h 2022-12-06 14:41:01.456000000 +0000 @@ -1482,7 +1482,7 @@ * send window while having a small receive window only. */ #if !defined LWIP_WND_SCALE || defined __DOXYGEN__ -#define LWIP_WND_SCALE 0 +#define LWIP_WND_SCALE 1 #define TCP_RCV_SCALE 0 #endif diff -Nur lwip-2.1.3-org/src/include/lwip/pbuf.h lwip-2.1.3/src/include/lwip/pbuf.h --- lwip-2.1.3-org/src/include/lwip/pbuf.h 2022-12-06 14:40:45.284000000 +0000 +++ lwip-2.1.3/src/include/lwip/pbuf.h 2022-12-06 14:46:36.720000000 +0000 @@ -197,7 +197,7 @@ * For non-queue packet chains this is the invariant: * p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ - u16_t tot_len; + u32_t tot_len; /** length of this buffer */ u16_t len; diff -Nur lwip-2.1.3-org/src/include/lwipopts.h lwip-2.1.3/src/include/lwipopts.h --- lwip-2.1.3-org/src/include/lwipopts.h 2022-12-06 14:40:45.292000000 +0000 +++ lwip-2.1.3/src/include/lwipopts.h 2022-12-06 14:41:01.456000000 +0000 @@ -97,7 +97,7 @@ #define TCP_WND (40 * TCP_MSS) -#define TCP_SND_BUF (40 * TCP_MSS) +#define TCP_SND_BUF (2500 * TCP_MSS) #define TCP_SND_QUEUELEN (8191)