Mobile IP hack using IP over UDP (via ethertap on Linux)

Goals

I had a slow wireless network PCMCIA card for my laptop (2mbps). It was nice to be able to compute anywhere around my house without dragging along an ethernet cable, but sometimes, when transferring files or even just browsing the web, it was just too slow. In those cases I would much rather have 100mbps ethernet.

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.

Implementation

My laptop was running Linux, so I wrote a tunnel daemon that used ethertap to create a new network interface. I gave that interface a IP on a new subnet.
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!

Results

This works so well. My laptop's IP is 10.0.3.2, and never changes. When I change cards, the IP stays the same, it just happens to use one interface instead of the other non-existant to tunnel over.