lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] LwIP stops sending data (but keeps retrying forever) -


From: Jeremy Spiller
Subject: Re: [lwip-users] LwIP stops sending data (but keeps retrying forever) - caused by buffer chaining
Date: Thu, 28 Mar 2013 12:44:19 -0400

The problem isn’t with the LwIP code, but with the Ethernet hardware driver (hdkif.c: hdkif_output).  The driver ensures that packets are always at least 60 bytes long.  The implementation I have (from TI for the Hercules Device – RM46L852) has this code:
 
  /* adjust the packet length if less than minimum required */
  if(p->tot_len < MIN_PKT_LEN) {
     p->tot_len = MIN_PKT_LEN;
     p->len = MIN_PKT_LEN;
  }
This works as long as buffers are not chained.  When the buffers are chained, the packet is permanently destroyed so re-transmits will always fail.  The fix is to change the above code to:
 
  /* adjust the packet length if less than minimum required */
  if(p->tot_len < MIN_PKT_LEN) {
   struct pbuf *temp_p;
   int diff_len = MIN_PKT_LEN - p->tot_len;
   for (temp_p = p;  temp_p->next != NULL;  temp_p = temp_p->next)
    temp_p->tot_len += diff_len;
   temp_p->tot_len += diff_len;
   temp_p->len += diff_len;
  }
I realize this isn’t an LwIP problem, but I bet a lot of people have this problem waiting to happen as soon as a short chained packet is sent. 
 
-Jeremy
 

reply via email to

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