FreeRTOS Plus TCP wrong frame size with BufferAllocation_1.c

Hello there,

I’ve spent some time debugging my TCP implementation. I’m using TMS570LC435 copy Ethernet driver for FreeRTOS**+**TCP V4.3.2 and static buffer allocation (BufferAllocation_1.c).

To test the integration. I implemented a simple echo server. When testing it the TCP handshake worked fine, but afterwards no payload was transported.

For me it seems like the error is in src\os\freertos\freertos-plus\freertos-plus-tcp\source\FreeRTOS_TCP_Transmission.c:prvTCPBufferResize().

  • In prvTCPBufferResize() I have xBufferAllocFixedSize != pdFALSE as I’m using BufferAllocation_1.c so uxNeeded is ipTOTAL_ETHERNET_FRAME_SIZE
  • ipTOTAL_ETHERNET_FRAME_SIZE is ( uint32_t ) ipconfigNETWORK_MTU ) + ( ( uint32_t ) ipSIZE_OF_ETH_HEADER ) + ipSIZE_OF_ETH_CRC_BYTES + ipSIZE_OF_ETH_OPTIONAL_802_1Q_TAG_BYTES )
  • That equals in my case 1500

A bit later pxGetNetworkBufferWithDescriptor() is called with uxNeeded as xRequestedSizeBytes

  • This causes the check if( ( xNetworkBufferSemaphore != NULL ) && ( xRequestedSizeBytes <= ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) ) ) { to fail as ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER is in my case 1514.

My solution was changing FreeRTOS_IP.h to

#define ipTOTAL_ETHERNET_FRAME_SIZE ( ( ( uint32_t ) ipconfigNETWORK_MTU ) + ( ( uint32_t ) ipSIZE_OF_ETH_HEADER ) )

Now it works. Do you now a better solution to fix this?

Best,
Sven

I assume you are talking about this check which compares against uxMaxNetworkInterfaceAllocatedSizeBytes which is returned by uxNetworkInterfaceAllocateRAMToBuffers. Can you share your definition of uxNetworkInterfaceAllocateRAMToBuffers from your network interface or share your compelete network interface implementation?

Modifying FreeRTOS_IP.h is not the right thing to do. We can decide what is best once you share these details.

Thank you for your reply. It explained already a lot. It was a bug that was already fixed in the release of V4.3.3.

1 Like

Thank you for reporting back!