I want to deploy an application on mobile devices participating in a WiFi ad hoc network that improves information robustness. The primary task is pretty simple: Send data (may be of bigger size) from a node S (source) to node D (destination). Here is my sample topology:
--- N1 ---
/ | \
/ | \
S ----- N2 ----- N4 ----- D
\ | /
\ | /
--- N3 ---
By simply using TCP, I can set up a reliable communication channel from S over N2 and N4 to D. That's ok.
My problem now is: I want that N1 and N3 can also get (overhear) the messages sent by S, N2 and N4, but they don't need to get it reliably. You can think of it as a flow of packets. For example, S wants to send a packet to D. But this packet may be useful for N[1-4], too - and should therefore be stored.
This is of course possible by using the promiscuous WiFi mode on all nodes, but that would be an overkill - because it would mean that every node would have to parse all packets to see if they can store them.
A simple solution would be to send UDP packets:
- S sends UDP broadcast packet with a time-to-live of 1 to N2 with additional information.
- N1, N2 and N3 can receive and store the packet, but only N2 resends the information to N4.
- This behaviour repeats itself until D gets the package.
But then I have to somehow reimplement TCP in terms of packet ordering, congestion control and reliable communication - which is bad.
So my question is: Do you know about a protocol which supports this behaviour?
I have done what you are saying, and there are a couple of ways to do it. Using linux is the easiest, and the only platform where I have actually implemented this.
On linux there are two ways you can do this. 1., use iptables and NQUEUE and pass received packets to an application process that do whatever you want with them. Use iptables rules to only pass up packets you are interested in, such as those with IP dst N2, N4 etc. 2. use libpcap, and link you program with this library and configure a capture filter to capture the packets you are interested in.