How do I switch from ethernet to WIFI (and vice versa) without losing connection?

Solution 1:

Is there a way to switch between ethernet and WIFI connections without losing connection?

Not in practice. The "connection" between Firefox and the remote server means that there is a local port on your local address, bound to a remote port on the server address.

The "local address" is bound to the network device, and you cannot (easily) have two network devices having the same address - they would conflict. So you'd need to bring down one device, and bring up the other device, with the same address.

But this is not enough since the internal structures that keep track of port and data being sent and received were bound to the old network device and would be destroyed when it goes down.

So you would need either an operating system kernel that is aware of the possibility or a virtual network device that is also aware of the possibility, and can present a single network interface to the operating system while juggling the devices in the background. This is called "link aggregation".

On a "vanilla" system, I'm afraid you can do nothing.

I have tried bringing down a connection and moving the IP address on a different network device while downloading, but, even when Firefox is "frozen" before the down and "thawed" afterwards, the connection gets broken. I imagine this is because all the TCP connection parameters need to be reset, so the server must support resumption.

The connection does not go down if Firefox is connected to a router with three interfaces (one downlink to Firefox, two uplinks), and I juggle the two uplinks. The download stops briefly and I see packets being retried, and bounced; then the download resumes normally.

This is because, I believe, all the parameters "live" on the Firefox machine and on the server machine, and neither is affected by the juggle (the PC always sees the server at the same IP, and the server always sees the PC at the same IP via the NAT border router).

                              A-------------A
[ Firefox PC ] --e-- [ router ]             [ NAT ] --- [ server ]
                              B-------------B

Solution 2:

Generating a 'no route to host' error is the primary cause of reset TCP connections. To avoid this, there cannot be an instant where both interfaces are down. Also, there cannot be an instant when both interfaces are without an IP address, and a default route must remain in place at all times.

Make sure both your interface adapters are up, and have unique IP addresses.

Make sure default route is either not exclusive to a particular interface, or is present for both interfaces. On my Mac:

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.2.1        UGSc            5        4     en0
default            192.168.2.1        UGScI           0        0     en1

The second route is marked I for Inactive.

When I want to switch from en0 (wired) to en1 (wifi), I change the interface order in my System Preferences, putting WiFi above Ethernet. I then check my network traffic stats to confirm that traffic is going over WiFi, in both directions. I can then disconnect my Ethernet.

Using the same principles, this method will allow you to switch interfaces on other OSes:

Both interfaces must not go down at the same time and a valid default route has to always be in place.

This implies that both interfaces have to have their own unique IP addresses pre-assigned before switching.

Solution 3:

You may be asking for Multipath TCP, which as far as I know doesn't exist on Windows:

enter image description here

Software that might emulate it (all are commercial) but without guarantee as I never used them:

  • Speedify
  • WinGate