When I compare the code fragment that you show with the FreeRTOS+TCP code, I see these changes:
case eARPTimerEvent:
/* The ARP timer has expired, process the ARP cache. */
+ #if (arpGRATUITOUS_ARP_PERIOD == pdTRUE)
vARPAgeCache();
+ SafeRTOSNet_debug_printf( ( "prvIPTask running: Event Type = ARP timer has expired \r\n" ) );
+ #endif
break;
That is a bit unexpected: vARPAgeCache()
must be called unconditionally, and should not depend on any macro.
vARPAgeCache()
will work on the ARP cache table, refresh old entries and remove dead entries.
The macro arpGRATUITOUS_ARP_PERIOD
is only defined in FreeRTOR_ARP.c as a number, not a boolean pdTRUE or pdFALSE:
/** @brief The time between gratuitous ARPs. */
#ifndef arpGRATUITOUS_ARP_PERIOD
#define arpGRATUITOUS_ARP_PERIOD ( pdMS_TO_TICKS( 20000U ) )
#endif
So by default, a gratuitous ARP request will be send every 20 seconds. That is frequently.
You can overwrite that value in your FreeRTOSIPConfig.h:
Send a gratuitous ARP request every 2 minutes.
#define arpGRATUITOUS_ARP_PERIOD ( pdMS_TO_TICKS( 120000U ) )
You wrote:
caused the stack to crash, i.e the send/receive was not able to get network buffers
Does the IP-stack crash, get an exception? Or does it run out of network buffers?
What value have you assigned to the macro ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
?
How much is it now? Have you tried increasing it?
What platform are you using? Are you on a busy LAN?
Is the application receiving many UDP packets? And does receiving task get enough CPU time?
Are the UDP packets queueing up in the socket?
If there is a risk of receiving too many UDP packets, you can define ipconfigUDP_MAX_RX_PACKETS
, described here. Or you can use the socket option FREERTOS_SO_UDP_MAX_RX_PACKETS
.