The problem here is that when I unplugged my ethernet card and plugged in the wireless card (or the other way around), existing TCP connections on my laptop would die because the interface the sockets were associated with went down. Also, my IP address would change because the wireless network and the ethernet network were on diff subnets. The IP address change would surely kill my TCP connection since my endpoint 4-tuple would change.
The IP address problem could be solved with a bridge, but a bridge was unavilable to me at the time.
wireless network: 10.0.1.0/24 ethernet network: 10.0.2.0/24 mobile IP network: 10.0.3.0/24 |
wireless gateway card IP: 10.0.1.1 wireless laptop card IP: 10.0.1.2 |
ethernet gateway card IP: 10.0.2.1 ethernet laptop card IP: 10.0.2.2 |
mobile ip (ethertap) gateway IP: 10.0.3.1 mobile ip (ethertap) laptop IP: 10.0.3.2 |
so at any given time, I have 2 of the above interfaces running (ethernet + ethertap or wireless + ethertap). I also have a default route to gateway 10.0.3.1.
Now, I run this program on my laptop with 2 arguments: ./tunnel 10.0.2.1 10.0.1.1
This sends any pkts that were going to go over the ethertap interface to the IP addresses on the cmdline via UDP pkts on port 9998. It also listens on UDP port 9998 for pkts and injects them into the ethertap interface. On the wireless gateway machine, I run the same app with 2 arguments: ./tunnel 10.0.2.2 10.0.1.2
This should be self explanatory now. If its not, email me and I'll write more!