views:

105

answers:

5

Problem:

I need to design a networking application that can handle network failures and switch to another network in case of failure.

Suppose I am using three ethernet connections and one wireless also . At a particular moment only one connection is being used.

How should I design my system so that it can switch to another network in case of failure.

I know this is very broad question but any pointers will help!

A: 

Create a domain model for this, describing the network elements, the kind of failures you want to be able to detect and handle, and demonstrate that it works. Then plug in the network code.

Stephan Eggermont
A: 

have one class polling for the connection. If poll timeout fires switch the ethernet settings. For wireless, set the wifi settings to autoconnect and then just enable/disable the wificard.

(But I dont know how you switch the ethernet connection)

PoweRoy
+1  A: 

I'd typically make sure that there's routing on the network and run one (or more) routing protocol instances on the host. That way network failure is (mostly) transparent to the application, as the host OS takes care of sending packets the right way.

On the open-source side, I have good experiences with zebra and quagga, at least on linux machines.

Vatine
A: 

First thing I would do is look for APIs that will give me network disconnection events. I'd also find a way to check the state of the network connections.

These would vary depending on the OS and the Language used so you might want to have this abstracted in your application.

Example:

RegisterDisconnectionEvent(DisconnectionHandler);

function DisconnectionHandler()
{
   FindActiveNetworkConnection();
   // do something else...
}
ksuralta
A: 

A primitive way to do it would be to look out for network disconnection events. Your sequence would be: Register/poll for network connections status changes. Maintain a list of all active network connections. Use the first available network connection (Alternately you could sort it based on interface bandwidths, and use the one with highest bandwidth). When you detect a down connection, use the next active one.

However, if there are implications to the functionality of your application, based on which network connection you use, you are much better off, having either a routing protocol do the job for you, or have a tracking application within your application. This tracking application would track network paths (through various methods like ping, traceroute, etc) across all your available interfaces to see which one can reach the ultimate destination, and use the appropriate network interface.

Also, you could monitor your network interfaces for not just status changes, but also for input/output errors, and change your selection accordingly. This would help you use the most efficient network at any given point of time. But this would need to be balanced with the churn caused by switching a network connection.

Harty