lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] crash on a lot of outgoing packets


From: Sathya Thammanur
Subject: Re: [lwip-users] crash on a lot of outgoing packets
Date: Thu, 15 Dec 2005 10:58:15 -0800

Hi Kyle,
One thing that can be done to send the data fast is to keep checking the TCP send buffer to see if how much space is left. Based on the amount of space left, the tcp_write() function can be called to send more data. Here is a snippet of a send function:

void
send_data(struct tcp_pcb *pcb, struct echo_state *ps)
{
  err_t err = ERR_OK;
  u16_t len;

  /* We cannot send more data than space available in the send
     buffer. */    
  if (tcp_sndbuf(pcb) < ps->left) {
    len = tcp_sndbuf(pcb);
  } else {
    len = ps->left;
  }

  if (len > 0) {
    err = tcp_write(pcb, ps->buf_p, len, 1);
  }

}

Keep track of the data sent in the echo_state variable and update the state in the echo_sent function that would be called by lwIP whenever an acknowledgement has been received for data sent. The send_data() function can be called more frequently that will cause more data to be sent as and where is space available in the TCP send buffer.

Hope this helps

Sathya





On 12/14/05, Leon Woestenberg <address@hidden> wrote:
Hello Kyle,

kyle treleaven wrote:

>Hi all,
>
>I'm using the RAW api, in a Xilinx port of lwip to their ppc405 in
>virtex4 FPGA.  I mimicked the following process for sending out data
>from a basic echo server example (there seems to be a real scarcity of
>raw api examples out there).  The whole thing works ok, but if I start
>trying to send packets faster than they can actually go out, I go into
>an infinite loop of bad pbuf_alloc's.
>
Two things here:

1) Infinite? Not good. Your Ethernet outgoing queue should eventually
free the pbufs that were put on the wire and memory
should be available again.

2) Somewhere you should make a blocking call that waits for your
Ethernet queue to become non-full again, as lwIP does
not know about this. Typically, you would wait for an interrupt from the
MAC if you work async, or just block until room
is available in the MAC before you submit the packet to it.

Regards,

Leon.


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


reply via email to

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