How can I use(or change) the <TCP Keep Alive Option>?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
StKi_2157971
Level 3
Level 3
First like received

I like to enable and change the socket-tcp-keepalive option.

Here is my environments.

- WICED SDK 2.3.1

- ThreadX/NetX Duo, BCMUSI11

Here is my source for <TCP Keep Alive>.

.......................

wiced_tcp_create_socket(&socket_tcp, interface);

nx_tcp_socket_keepalive_enabled = 1;

nx_tcp_socket_keepalive_timeout = 10; // 10Sec

nx_tcp_socket_keepalive_retries = 1;

.......................

But, after this implementation, WICED module didnt send <Keep Alive Packet>.

Is it wrong?

Thanks in advance

Steve

0 Likes
11 Replies
GregG_16
Employee
Employee
50 sign-ins 25 sign-ins 25 comments on KBA

Do you have same issue with 2.4.x SDK?

Let me know if this is still an issue.

0 Likes

Okay..

About this issue, I'll check it and let you know that.

0 Likes

It looks like that <tcp_keep_alive feature> is not supported yet.

I just checked the source of WICED SDK 2.4.0.

<Wiced/Network/NetXDuo/wiced/tcpip.c>

............

wiced_result_t wiced_tcp_enable_keepalive(wiced_tcp_socket_t* socket, uint16_t interval, uint16_t probes, uint16_t _time )

{

    UNUSED_PARAMETER(socket);

    UNUSED_PARAMETER(interval);

    UNUSED_PARAMETER(probes);

    UNUSED_PARAMETER(_time);

    /* Not supported in current version of SDK . TO DO */

    return WICED_SUCCESS;

}

............

Could you know me when I can use <tcp_keep_alive feature> in WICED?

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Attached is a 7zip with new NetX and NetX_Duo libraries that have been rebuilt with NX_TCP_ENABLE_KEEPALIVE defined. This turns on TCP keep alive for every TCP connection by default and cannot be turned off. There is no need to call wiced_tcp_enable_keepalive().

Can you please try these new libraries to see if they solve the problem.

0 Likes
Anonymous
Not applicable

Hi

I am testing using your library. But it is not well.

Could you let me know about keep alive interval, keep alive probes and keep alive time value?

0 Likes
Anonymous
Not applicable

Hi nikvh,

I have successfully used the above libraries to get TCP keepalive messages at two hour intervals, which from looking at the NetX_Duo UG, is the default setting.  I would like to change the time and retry settings, but neither the pre-processor macros as described in the UG, nor the variables ssekim points out above seem to change these settings.  Is there any way to change them without having you recompile the NetX_Duo library?

Thank you,

cg

0 Likes

Hi all

Is there any updates for this issue?

As cg said, it worked well as below, but 7200 seconds is very long....

keepalive.jpg

Could you let me know how I change the TCP-Keep-Alive settings?

Regards, Steve

0 Likes

Hello,

Agree 7200 may be a bit long, however; this setting is hard coded into NetX.

It is not possible to override since it is reset with every ACK.

So, this would need modification the source code, and as you know we are only allowed to provide binaries for NetX_Duo.

We will consider the side effects of making that a variable in the future.  This will allow you to set it at compile time.

In the meantime use probably use FreeRTOS and LWIP, to do what you need. Is this an option?

0 Likes
Anonymous
Not applicable

Hi Gangi,

How is the TCP keep alive support status for NetX/NetX_Duo in sdk-3.1?

Does sdk-3.1 has TCP keep alive support enable for NetX/NetX_Duo?

Does wiced_tcp_enable_keepalive() work for NetX/NetX_Duo in sdk-3.1?

Thanks.

0 Likes
Anonymous
Not applicable

sam.lin

For tcp keep_alive, I have  tested and got following result

tcp_keep_alive_wireshark.png

//        result = wiced_tcp_enable_keepalive( &( para_data->socket ), ex_ptr_dct_app->tcp_keep_alive_interval, ex_ptr_dct_app->tcp_keep_alive_probes, ex_ptr_dct_app->tcp_keep_alive_time );

                //result = wiced_tcp_enable_keepalive( &( para_data->socket ), 2, 2,2);

                result = wiced_tcp_enable_keepalive( &( para_data->socket ), 10, 3,10);

  In SDK 3.1.1 tcp_keep_enable_keepalive is working

      alive_interval : seems to work

      alive_time     : seems to work

      alive_probe   : seems not working properly

    while enable tcp_keep_alive enabled, when remote server socket closed,

    tcp_disconnect_callback is invoked almost 120 seconds,

   so keep_alive is not working with probe count, it seems to goes with maximum 120 seconds

FYI

Anonymous
Not applicable

Hi Alex Yoon,

Thanks a lot for your test report.