TCP Connection – How to Maintain Over a Changing IP Address

ipv4tcp

I remember when I connected to the internet via the phone line and a 56kbps modem, changing ISPs was as simple as changing the phone number dialled by the modem.

I remember that my IP address would change every 1 minute, without a break in connection. But I also remember downloading large files over HTTP, sometimes downloads would take hours to complete.

In a situation like this, how does the TCP connection remain open, while the IP address changes frequently?

Also, as a side question… I live in the UK, so it's all fibre optic and static IP's now, I'd be interested to know if other places in the world still rely on technology like this.

Best Answer

The TCP connection cannot stay open with a changing IP, because a connection is defined by source IP+Port and destination IP+Port. If one of these changes, then you don't have the same connection anymore.

If you need to maintain a connection when the IP to your ISP changes, then you should not use this IP as outgoing, but instead built a tunnel to some VPN server outside. The VPN will give you a constant IP, even if the IP you got from the ISP changes. Another option would be to write your application so that it notices changes of IP and reconnects and resumes traffic.