Network disconect behaviour

Not necessarily. A link down may be a temporary situation that should according to the ISO/OSI model be transparent to higher layers. In many TCP/IP implementations, an ifdown event is being considered a significant event that may indeed shut down all connections communicating over the interface, but that can also be an overkill if the link comes up again quick. In your dsl connection at home, for example, you may have short link interruptions without your active connections (video streams etc) never being aware of it.

In reverse, it is also possible for a physical link to be up but all communications broken, nevertheless, for example, if your device is connected to a switch with an uplink on the switch failing but the link with your device port still active.

This is a very shady area of networking which almost every networking component or software treats individually.

Frequently there is an ifdown()/ifup() callback pair that you can use to customize the behavior of your stack. I do not know offhand if that is supported by FreeRTOS+TCP, but even if, it is only an indicator for the very next hop.

EDIT: Since your logs reveal dhcp activity, it is worth mentioning that frequently, the ifup() event following an ifdown() is used to renegotiate a dhcp address. Needless to say, if your device obtains a different IP address the next time, all of your existing communications are worthless because your end point is gone. However, dhcp recommends that a dhcp server should reuse the same IP address for identical MAC addresses if possible, meaning that logically, your open connections can still be used after a dhcp renegotiation. But not all dhcp servers follow that recommendation, so the best reaction to a link down event can be installation dependent.

3 Likes