FreeRTOS+Ip Network goes Up and Down

eduardo1966 wrote on Thursday, May 02, 2019:

Hi

I’m using FreeRTOS+IP on an ATMEL SAME70.

The code below is used as an handler for when the Network goes UP printing IP addresses info.

/* Called by FreeRTOS+TCP when the network connects or disconnects.  Disconnect
events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];

    printf ( "vApplicationIPNetworkEventHook: event %ld"EOL, eNetworkEvent );
    /* If the network has just come up...*/
    if( eNetworkEvent == eNetworkUp )
    {
        printf ("Network is UP"EOL);
        /* Print out the network configuration, which may have come from a DHCP server. */
        FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );

        FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );             printf( "IP Address: %s"EOL, cBuffer );
        FreeRTOS_inet_ntoa( ulNetMask, cBuffer );               printf( "Subnet Mask: %s"EOL, cBuffer );
        FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );        printf( "Gateway Address: %s"EOL, cBuffer );
        FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );      printf( "DNS Server Address: %s"EOL, cBuffer );
    }
}

On the network I have the FreRTOS system connected to a network with a Hirschmann Octopus POE switcher. The switcher is also providing a DHCP service.
At the beginning the switcher gives a DHCP address to the FreeRTOS system but no long after (2 or 3 minutes) it seems that the network goes DOWN and immediately UP with the same address.

I would like to know what event makes the FreeRTOS IP stack to consider the network going DOWN and UP? This could be I guess a bad/incomplete configuration of the switcher…
We have other switchers from Westermo and I don’t see these causing the same problem.

Usually the output of the vApplicationIPNetworkEventHook() function above is:

vApplicationIPNetworkEventHook: event 0
Network is UP
IP Address: 10.183.200.51
Subnet Mask: 255.240.0.0
Gateway Address: 0.0.0.0
DNS Server Address: 0.0.0.0

But once I got an address equal to 0.0.0.0 although the subnet mask was as expected!!!

vApplicationIPNetworkEventHook: event 0
Network is UP
IP Address: 0.0.0.0
Subnet Mask: 255.240.0.0
Gateway Address: 0.0.0.0
DNS Server Address: 0.0.0.0

Any ideas how an address 0.0.0.0 can be given/accepted?

thanks

rtel wrote on Thursday, May 02, 2019:

‘Down’ events would normally come from the driver, but some drivers are
just for demo purposes rather than being full implementations, so don’t
actually pass on all events. You can set a break point in the event
handler you posted for the case where the event is a ‘down’ event, then
step out of the function (or view the call stack) to see the cause.

eduardo1966 wrote on Friday, May 03, 2019:

thanks for the answer.
regarding the
IP Address: 0.0.0.0
would there be any reason for such address?

thanks

heinbali01 wrote on Friday, May 03, 2019:

It would be interesting to look with a program like WireShark to see the original packets on the wire.
But as this is a conversation between a router and an embedded device, you will only see half of it (the broadcasts).
If you’re experienced with the W32 demo, you could run the DHCP conversation from your laptop, just to see if it behaves well.
There was a bugreport that the DHCP-client doesn’t process the last option in the list of options. That has recently be repaired in PR #559

heinbali01 wrote on Friday, May 03, 2019:

I showed a link to the reported issue. Here is the link to PR560 that: “Fix(es) handling of an option at the end of the DHCP response packet”