What Happens When You Connect to a Website?
Websites use the TCP protocol, or transmission control protocol, to exchange information from two computers, typically your computer and the Internet. The exchange starts with a three-way handshake, which looks like this:
- SYN - your browser sends a synchronize call to initiate a connection.
- SYN/ACK - the server acknowledges your browser's SYN call and sends it's SYN on its own.
- ACK - your browser acknowledges the server's TCP Packet.
When sending data, each client keeps track of a sequence number to determine how much data has been sent over the wire. The sequence number and acknowledgment number should change upon each packet interchange and is usually incremented by the number of bytes being sent over the wire. For example, when a client sends 40 bytes over the wire, the receiving client may increment its acknowledgment number by 40. Then when that client sends the next TCP packet out, the new sequence number is often the previous acknowledgment number. While TCP has a max size of 65,535 bytes, you can use the window scale option to scale that beyond that number. The back and forth between two computers over TCP continues until the final client sends a FIN TCP packet, which is used to end the connection. It must be acknowledged on both sides.