I am using a TM4C129 Connected Launchpad for TCP/IP communications back to a Windows host PC. The MCU is a TM4C129ENCPDT, rev A02. I have UDP and TCP/IP communications operating for start up static IP address assignment on a private network and basic data transfer works ok, so I think I have the basic peripheral setup correct. If I run at a low data rate of e.g. 2 Hz, sending a 255 byte data packet (max) over TCP/IP from the TM4C129 to the host PC, everything works well. I get the data that I expect at the rate that I expect it.
If I increase the data transmission rate to 10Hz, then I am able to run for a short - and apparently random - period of time (max 5 mins). After that short period of time, TCP/IP communications with the TM4C129 stop. When I debug the TM4C129 code, I find that I am stuck in a loop in tcp_input.c or tcp_output.c in lwIP v1.4.1. (the rest of the TI code is also from 2.1.1.71). My only way out is to reset the board.
More specificially, I get stuck either here:
tcp_output.c
err_t
tcp_output(struct tcp_pcb *pcb)
{
// some missing code
/* useg should point to last segment on unacked queue */
useg = pcb->unacked;
if (useg != NULL) {
for (; useg->next != NULL; useg = useg->next); // <= I get stuck here, useg->next is never NULL
}
// some more missing code
}
OR I get stuck here
tcp_in.c:
static void
tcp_receive(struct tcp_pcb *pcb)
{
// some missing code
/* Remove segment from the unacknowledged list if the incoming
ACK acknowlegdes them. */
while (pcb->unacked != NULL &&
TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) +
TCP_TCPLEN(pcb->unacked), ackno)) {
// do lwIP work // I get stuck in this while loop, pcb->unacked != NULL is always true
}
// some more missing code
}
So
(a) I realize that this code is in lwIP
(b) I have tried manipulating some of the lwIP options in lwipopts.h. Increasing the number of buffers, or increasing their size delays the issue but does not solve it.
(c) I need to run at 10Hz to satisfy requirements in my Windows app, running at 2Hz is not an option for me
(d) it seems to me as though the buffer list is being corrupted somehow in that when this event occurs, there is never a NULL pcb at the end of the UNACK list.
I am pretty sure that the issue is on the TM4C129 side of the code in terms of buffer handling. I think that the Windows app is ok.
I was wondering if anyone else has seen similar events and if so, can you give some suggestions for how to proceed? Is it a case of following the logic through lwIP and finding where the UNACK queue is being adjusted (presumably incorrectly)?
Simon