I'm using lwIP 1.4.1 on a PIC32MZ and httpserver_raw, no OS. It works fine in general; I can send ping floods without a problem and the default SICS webpage works well even when I test it with an HTTP load tester. However if I construct a webpage (text only, no images) that is longer, it can't send all of it to the browser. I have only one html file that is used to make fsdata.c, and that html file is not quite 4kB long and *that's* too long. Occasionally the webpage will load successfully the very first time, but that's it.
Looking with Wireshark I see the client (Chrome) sends a GET / and lwIP responds with only two 1514 byte packets. The client then sends an ACK and nothing else happens for several seconds when the client attempts again.
I noticed I'm getting a lot of tcp.memerr when this occurs. Specifically, the line in tcp_out.c:
if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW))
is true because pcb->snd_queuelen is 65475! This seems very wrong. I however have been unable to track down the cause. httpserver_raw is as-is from the contrib-1.4.1 archive. Part of lwipopts.h is below. This config is by no means meant to be final, but rather I grossly increased some values to see if there's any improvement, of which there was none.
Any ideas as to what could be happening?
#define NO_SYS 1
#define MEM_ALIGNMENT 4
#define MEM_SIZE 16384
#define MEMP_NUM_PBUF 32
#define MEMP_NUM_RAW_PCB 20
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB_LISTEN 6
#define MEMP_NUM_REASSDATA 10
#define MEMP_NUM_IGMP_GROUP 1
#define PBUF_POOL_SIZE 60
#define ARP_TABLE_SIZE 4
#define LWIP_DHCP 1
#define LWIP_DNS 1
#define DNS_TABLE_SIZE 1
#define DNS_MAX_NAME_LENGTH 25
#define DNS_MAX_SERVERS 2
#define TCP_WND (TCP_MSS*4)
#define TCP_MAXRTX 5
#define TCP_MSS 1460
#define TCP_SND_BUF (TCP_MSS*20)
#define TCP_SND_QUEUELEN 50
#define PBUF_POOL_BUFSIZE 1520
#define LWIP_NETCONN 0
#define LWIP_SOCKET 0
#define LWIP_STATS 1
//#define LWIP_DBG_TYPES_ON LWIP_DBG_OFF
#define MEMP_NUM_TCP_PCB 4
#define LWIP_RAW 0
#define MEMP_NUM_TCP_SEG 60