Here is the topology:
-----s0---s1-----
h1 --| |--h2
-----s2---s3-----
h1 pumps a file to h2 using UDP in a reliable way. The link between s0 and s1 may be down. Then it should continue to send the data using only the bottom path. Is there a way to detect that the link is down?
So far I created two python sockets in h1 and two in h2 for each path. Using select.select I can get the ready socket to read ack's. If timeout occurs I can retransmit. However, when the link is down, I cannot know that it is down.
If you had to do this from scratch for your implementation for whatever reason;
See The 3-way handshake for an illustration and guide on how TCP handshakes are established.
You could also consider using SCTP which is multihomed, stream based transmission control protocol. Quite a few platforms support it including Linux, BSD, Windows and others.
There is also a Python SCTP lirbary
It's as simple as:
And implements most of the same interfaces as socket