This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

lwIP udp_sendto Problem in lwip-1.4.0 on BeagleBone Black

Hello,

I have been playing around with StarterWare on the BeagleBone Black and wanted to send UDP packets as fast as possible in a tight loop.  The 1.4.0 version of lwIP has the fix described in the thread listed below so I'm not losing packets:

http://e2e.ti.com/support/embedded/starterware/f/790/t/171893.aspx

My loop is very similar to Jay Larson's main while(1) loop but there is something I don't understand.

When I have a delay between sending packets, I have no problem and all the packets are sent and correctly received by the receiver at a bandwidth of about 4 MByte/S.  However, if the delay is too short, something happens which temporarily blocks the transmission every 3 packets and as a result, the overall bandwidth drops to something like 300kbps.

I've traced the issue to the function cpswif_output() in ports/cpsw/netif/cpswif.c.  In cpswif_output(), just after the call to cpswif_transmit(), there is a call to SYS_ARCH_UNPROTECT().

After SYS_ARCH_UNPROTECT() is called, the cpswif_transmit() function is supposed to return but doesn't.  Another packet is queued to be sent.  At this point, there is a huge delay every third packet that is sent by the main loop.

I haven't succeeded in enabling the lwip debug traces so it's difficult to know what is being executed and when.  I'm still trying...

For my loop, I don't want to use a fixed delay, I just want to send packets sequentially as fast as possible so I either need to:

1. Find a way to do a 'blocking' send (or poll a flag) so the main loop isn't executed faster than the maximum bandwidth of the Ethernet link.

or 

2. Use another mechanism or configuration to send UDP packets.

Could someone suggest an alternative or explain what I'm doing wrong?

Many thanks,

Vic.

  • Vic,

    Processing of the buffer descriptors in Isr may be the cause of this problem. If the packets processing within the Isr is optimised it may help to increase bandwidth. But in this case take care of sync between buffer descriptors and handler.

    Regards,

    Ramesh D

  • Ok, but which functions of lwIP are actually run in interrupt?  At the moment, I don't actually do any processing, I just have a buffer full of data that I send repeatedly.

    When you talk about synchronisation between buffer descriptors and handler, are you talking about the pbuf structures?  If so, is there some detailed description of how to use pbufs efficiently?

    Vic

  • Vic,

    I was talking about handling buffer descriptors in Isr. For a single thread operation handling of this case is very much use case dependent. Interrupt pacing feature shall help to address such cases. This is not supported in current version of StarterWare.

    Regards,

    Ramesh D