Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Lost in Sockets

Posted by oneguyindc on January 10, 2019

My application sucessfully can send data via UDP sockets all day long Ocassionally when there is a back to back attempt at sending more than one UDP packet - The attempt to create a FreeRTOSsocket fails - /* Create the socket. */ xClientSocket = FreeRTOSsocket( FREERTOSAFINET, FREERTOSSOCKDGRAM, FREERTOSIPPROTOUDP ); configASSERT( xClientSocket != FREERTOSINVALIDSOCKET );

I am assuming that the sockets are dynamically create on the heap and more than one socket can be available at at time. As far as I can tell I have plenty of heap so I am at a loss what could cause the call to FreeRTOS_socket to fail.

Is there a config parameter that specifies how many UDP sockets can be active at one time

Lost in Sockets


Lost in Sockets

Posted by rtel on January 10, 2019

Looking at the FreeRTOSsocket() function (which you have the source code for, and can step through in the debugger), it seems like the only reasons FREERTOSINVALID_SOCKET would get returned are:

1) prvDetermineSocketSize() fails. You can look through this function to see the reasons this could fail - basically network is not ready or an input parameter is wrong.

2) The socket structure cannot be created (is pvPortMallocSocket() just mapped to pvPortMalloc(), which is the default? If so, which memory allocater are you using? Heap1, heap2, etc.)

3) xEventGroupCreate() fails, which again is just a memory allocation, so same as #2.


Lost in Sockets

Posted by heinbali01 on January 10, 2019

Hi Pedro, I am not sure what to answer here.

Remember that with configASSERT() defined, your application will halt if any of the calls to prvPortMalloc() fails, provided that you use one module out of portable/MemMang/heap_[1..5].c.

The number of UDP sockets that you create is under your control. So you have to put a limit to it. I am not sure why you open more than one UDP socket? Do you advertise so many UDP ports?

Normally, when you create a UDP-server, you'd open just one UDP socket and use that for every request. You can handle each request and send a reply to the sender.

If you want, attach some code that illustrates what you are doing.

There is special UDP protection tough, which becomes active if you define e.g. in your FreeRTOSIPConfig.h:

~~~

define ipconfigUDPMAXRX_PACKETS 4

~~~

With this example, each UDP socket will never store more that 4 received packets. For individual sockets, you can changes this limit with FreeRTOS_setsockopt() (FREERTOS_SO_UDP_MAX_RX_PACKETS);

This option can protect your device against malicious attacks from outside.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner