Quality RTOS & Embedded Software

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




Loading

freeRTOS 9.0+ TCP/IP keepalive

Posted by liuzs on January 22, 2017

In my TCP/IP project , I can not modify keepalive times&period of a socket by modify ipconfigTCPKEEPALIVE_INTERVAL. need help! thanks!


freeRTOS 9.0+ TCP/IP keepalive

Posted by rtel on January 22, 2017

We would like to help, but unfortunately your post doesn't say what the problem is. For example, can not modify could mean keepalive isn't working at all, keepalive is working but you can't change the period, you can change the period but the period is not accurate.......or simply that the file is read only so you can't save changes. Please help us help you!


freeRTOS 9.0+ TCP/IP keepalive

Posted by liuzs on January 22, 2017

thanks for your answers and sorry for my question. My keepalive is working (in socket client and server ), the period is about 20s , but I modify ipconfigTCPKEEPALIVEINTERVAL to 2 or 3 or 8 or 20 or ... ,the period is about 20s always. In LWIP ,I can change it by modify some parameters. And the other parameter "ipconfigTCPHANGPROTECTIONTIME" is 10 now , I modify it ,but no use for anything. (sorry for my english)


freeRTOS 9.0+ TCP/IP keepalive

Posted by heinbali01 on January 22, 2017

Hi,

It sounds like a problem with compiling your project.

In the demo projects, ipconfigTCP_KEEP_ALIVE_INTERVAL is defined as 20 seconds. When you observe that the actual keep alive messages are sent every 20 seconds, it looks like FreeRTOS_TCP_IP.c doesn't see your new value.

You should make the setting in your FreeRTOSIPConfig.h. Make sure that the include path for the compiler points to the proper FreeRTOSIPConfig.h.

Advice: never put private files into the public include directories, such as FreeRTOS-Plus-TCP/include or FreeRTOS/source/include.

You could write the following in your FreeRTOSIPConfig.h:

~~~~ #warning setting keep-alive #define ipconfigTCPKEEPALIVE_INTERVAL 120 ~~~~

and make sure the the compilere sees the #warning :-)


freeRTOS 9.0+ TCP/IP keepalive

Posted by rtel on January 23, 2017

Which platform are you using? In some Xilinx SDK versions changing a header file necessitates a complete clean and rebuild for the new value to get used.


freeRTOS 9.0+ TCP/IP keepalive

Posted by liuzs on January 23, 2017

hi, My platform is stm32f107RC + keil mdk 5.22 and compiler is v5.06(update 4) . I do your test,and see #warning .... so ....

I set ipconfigTCPKEEPALIVEINTERVAL =40 , keep alive messages is 40s I set ipconfigTCPKEEPALIVEINTERVAL =30 , keep alive messages is 40s I set ipconfigTCPKEEPALIVEINTERVAL =20 , keep alive messages is 20s I set ipconfigTCPKEEPALIVEINTERVAL =15 , keep alive messages is 20s I set ipconfigTCPKEEPALIVEINTERVAL <10 , keep alive messages is 20s I set ipconfigTCPKEEPALIVEINTERVAL =60 , keep alive messages is 60s I set ipconfigTCPKEEPALIVE_INTERVAL =50 , keep alive messages is 60s

and the period of keepalive is variable , about 2s~10s ......


freeRTOS 9.0+ TCP/IP keepalive

Posted by heinbali01 on January 23, 2017

Good, so changing the value of ipconfigTCP_KEEP_ALIVE_INTERVAL does make a difference. What you observe is that the actual times are being rounded up to a multiple of 20 seconds. That is caused by the function prvTCPNextTimeout(), which let's the socket 'sleep' for 20 seconds when it is idle. If you want, I will prepare a patch in which this sleeping time will be configurable. Regards.


freeRTOS 9.0+ TCP/IP keepalive

Posted by liuzs on January 23, 2017

Thanks. Could you do a new version to improve and perfect it and Release new version to all ? I think this function is very important for checking socket ok or not.

I hope get your patch at first :) My e-mail: liuzhisong@139.com

And this TCP/IP lib is better than LWIP. Thanks for your work!


freeRTOS 9.0+ TCP/IP keepalive

Posted by heinbali01 on January 23, 2017

Normally I would set the keep-alive period ìpconfigTCP_KEEP_ALIVE_INTERVAL at least 60 seconds. Only when a keep-alive message is not responded to (and ucKeepRepCount increases), the intervals will be much shorter. After three times now answer, the socket will be forcefully closed.

I have sent you an email with patched source code. If you test it we can make it an official change.

Note that for an embedded TCP application, the keep-alive messages are essential. It avoids that sockets stack in a connected state for hours, thus occupying valuable resources. The keep-alive messages do not always work, some routers might refuse to pass them through.

Thanks, Hein


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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