2

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.

uLtRaLoVeR
  • 53
  • 8

1 Answers1

3

If you had to do this from scratch for your implementation for whatever reason;

Try to ping the otherwise, wait for an ack; timeout if you don't receive an ack within a time period; try the other path. Any reason you aren't using TCP? Implementing reliability atop UDP is basically what TCP is over IP.

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:

import socket
import sctp

sk = sctpsocket_tcp(socket.AF_INET)
sk.connect("10.0.1.1")

And implements most of the same interfaces as socket

James Mills
  • 18,669
  • 3
  • 49
  • 62
  • Then you have some *learning* to do. You have to develop a way to determine if the other link is still alive. If you have already implemented *reliable* file transmission this shouldn't be *that* hard. Also SCTP != TCP. – James Mills May 27 '15 at 10:54
  • You may do what is done in clustering, which is have one connection for the actual data transfer, and another for a "stay alive" status check. Good luck @James. – boardrider May 27 '15 at 11:03
  • @boardrider Haha thanks but this is my advice; not my problem to solve :) Although I admit it would be interesting to implement :) – James Mills May 27 '15 at 11:21
  • Sorry, @James, mea culpa: I was supposed to put `@ uLtRaLoVeR` at the end of my comment. – boardrider May 27 '15 at 12:36
  • No problems :) No harm! – James Mills May 27 '15 at 12:37