lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] tcp_enqueue fails at more than two tcp_enqueue's


From: Jimi Simpson
Subject: Re: [lwip-users] tcp_enqueue fails at more than two tcp_enqueue's
Date: Tue, 4 May 2010 14:15:47 +0100

Hi Kieran,

Thank you for the response.

I have 4 threads running:

1) simple LED flasher

2) tcpip_thread through -> tcpip_init( prvEthernetConfigureInterface, NULL );

3) httpd - application thread

4) lpc17xx_ethernetif_input, created in low_level_init() - callback to pvrEthernetConfigureInterface is where I call: ----- netif_add(netif, &ip_addr, &netmask, &gw, NULL, lpc17xx_ethernetif_init, tcpip_input);

As I mentioned I am using FreeRTOS and the priorities are 1, 3, 2, 4 respectively.

I have enabled some debugging that I hope is of relevance, see /*** Start Debug Session ***/ some way down below. I have attached the pcap file for this session as an attachment. I am using v1.3.2 with netconn I/F, the port is for an LPC1768 - I used the LPC17xx uIP device driver as a start for this device driver, albeit I have made numerous modifications to this to support many more RX/TX EMAC DMA buffers - pretty sure this is all working good given the extent to which things are working. In the EMAC RX interrupt I use a binary semaphore to signal to lpc17xx_ethernetif_input() that data has arrived -> this in turn fetches the packet from the EMAC descriptor DMA buffers.

lwipopts.h contents are given immediately below.

Sorry for the lengthy email and lots of information, but your help is greatly appreciated.

Regards Jimi

My lwipopts.h has the following target specific settings:
// Application specific lwIP Options.
#define IPv6                            0
#define NO_SYS                          0
#define LWIP_ARP                        1
#define LWIP_RAW                        0
#define LWIP_UDP                        1
#define LWIP_TCP                        1
#define LWIP_DNS                        1
#define LWIP_DHCP                       1
#define LWIP_IGMP                       0
#define LWIP_SNMP                       0
#define LWIP_SOCKET                     0
#define LWIP_NETCONN                    1
#define LWIP_AUTOIP                     0
#define LWIP_CALLBACK_API               1

#define MEM_LIBC_MALLOC                 0
#define MEMP_MEM_MALLOC                 1
#define MEM_ALIGNMENT                   4
#define MEM_SIZE                      10000
#define MEM_POSITION __attribute((section("AHBSRAM1"),aligned))

#define ARP_QUEUEING                    0
#define LWIP_NETIF_HOSTNAME             1

#define ARP_TABLE_SIZE                  4

#define DNS_TABLE_SIZE                  1
#define DNS_USES_STATIC_BUF             0

#define IP_FRAG_USES_STATIC_BUF         0
#define LWIP_STATS                      0

#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC   1

#define TCP_MSS       630
#define TCP_SND_BUF      (4 * TCP_MSS)
#define TCP_WND                         (2 * TCP_MSS)
#define TCP_WND_UPDATE_THRESHOLD        (TCP_WND / 4)


/* TCP_SND_QUEUELEN needs to be a minimum of (2 * TCP_SND_BUF/TCP_MSS) */
#define TCP_SND_QUEUELEN               16

#define MEMP_NUM_TCP_PCB               10
#define MEMP_NUM_TCP_PCB_LISTEN         8
#define MEMP_NUM_TCP_SEG               16
#define MEMP_NUM_PBUF                  20
#define PBUF_POOL_SIZE                  6


/********************************Start Debug Session*************************/
tcp_input: packed for LISTENing connection.
tcp_parseopt: MSS
tcp_parseopt: NOP
tcp_parseopt: other
tcp_parseopt: NOP
tcp_parseopt: NOP
tcp_parseopt: other
tcp_enqueue(pcb=100058a0, arg=0, len=0, flags=12, apiflags=0)
tcp_enqueue: queueing 6510:6511 (0x12)
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510, i 0
tcp_output_segment: 6510:6510
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_receive: window update 65520
tcp_receive: slow start cwnd 631
tcp_receive: ACK for 6511, unacked->seqno 6510:6511
tcp_receive: removing 6510:6511 from pcb->unacked
tcp_output: nothing to send (0)
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, seg == NULL, ack 6511
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: nothing to send (0)
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, seg == NULL, ack 6511
tcp_write(pcb=100058a0, data=78d4, len=1262, apiflags=1)
tcp_enqueue(pcb=100058a0, arg=78d4, len=1262, flags=0, apiflags=1)
tcp_enqueue: queueing 6511:7141 (0x0)
tcp_enqueue: queueing 7141:7771 (0x0)
tcp_enqueue: queueing 7771:7773 (0x0)
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 630, seq 6511, ack 6511 tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 1260, seq 7141, ack 6511, i 1
tcp_output_segment: 7141:7771
tcp_enqueue(pcb=100058a0, arg=0, len=0, flags=1, apiflags=1)
tcp_enqueue: queueing 7773:7774 (0x1)
tcp_enqueue: chaining segments, new len 2
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 1262, seq 7771, ack 6511
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_receive: window update 65520
tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 1260, wnd 1260, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 630
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_receive: removing 7141:7771 from pcb->unsent
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511 tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511
tcp_slowtmr: cwnd 630 ssthresh 1260
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 630, seq 6511, ack 6511, i 0
tcp_output_segment: 6511:7141
-+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
tcp_output: snd_wnd 65520, cwnd 630, wnd 630, effwnd 1262, seq 7771, ack 6511


----- Original Message ----- From: "Kieran Mansley" <address@hidden>
To: "Mailing list for lwIP users" <address@hidden>
Sent: Tuesday, May 04, 2010 8:46 AM
Subject: Re: [lwip-users] tcp_enqueue fails at more than two tcp_enqueue's


On Fri, 2010-04-30 at 21:36 +0100, Jimi Simpson wrote:

I expect there may be too little information here for anyone to get a
true grasp of what might be happening, but if any one of you can
ask/state some obvious things to check/share then I am sure it's going
to be something silly.

The problem you describe is definitely incorrect behaviour - it should
work fine doing what you're doing.

Can you give more detail about the symptoms when it goes wrong?  If you
can see the output of printfs in your project you could try enabling the
lwIP debug statements which might give some hints.

When you try to send more data than can be sent immediately, some of it
will be queued and sent later.  It sounds like this action of queueing,
or perhaps of trying to send the queued data later, is causing your
problems.

The most common source of problems with lwIP is where people have used
the stack from too many threads, or not properly set up the interface to
the device driver so that interrupts collide with application threads in
the stack and corrupt the state.  Could you give details of:
- which lwIP port and version you are using?
- is your web server app based on one that we will be familiar with
(e.g. from lwIP contrib module)?
- your lwipopts.h setting
- a description of your threading module, and details of how packets
are passed to lwIP by the device driver.

Thanks

Kieran



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

Attachment: capture.pcap
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]