Transport and networkLayer 4RFC 9293

TCP: reliable delivery

How two computers agree to talk, keep the data in order and close the line politely.

Ports and use: Used by HTTP (80), HTTPS (443), SSH (22) and more

In one sentenceTCP makes an unreliable network feel reliable by numbering data, confirming it and resending what is lost.

Think of it like thisIt is a phone call: you both say hello first, you repeat what you did not catch, and you say goodbye at the end.

Watch it happen

7 steps and 3 byte-by-byte decodes. Use the buttons or the arrow keys. Hover or focus a field to find its bytes.

  1. Your laptop
  2. Web server
  1. SYN: "Can we talk?"Your laptop to Web server
  2. SYN-ACK: "Yes, and you?"Web server to Your laptop
  3. ACK: "Agreed"Your laptop to Web server
  4. Data: the requestYour laptop to Web server
  5. ACK: "Got it up to here"Web server to Your laptop
  6. FIN: "I am finished"Your laptop to Web server
  7. FIN and ACKWeb server to Your laptop

Step 1 of 7 SYN: "Can we talk?"

Your laptop → Web server

Your laptop picks a random starting number (the sequence number) and sends a segment with only the SYN flag set.

SYN segment 24 bytes

c9 3a 00 50 1a 2b 3c 4d 00 00 00 00 60 02 fa f0 7f 7a 00 00 02 04 05 b4

FieldBytesWhat it means
Source portc9 3a51514: the sender's port, which tells replies which program to reach.
Destination port00 5080: the program the packet is for. 80 is a web server.
Sequence number1a 2b 3c 4d0x1a2b3c4d: a random starting number for the data this side will send.
Acknowledgement number00 00 00 000: nothing to acknowledge yet.
Header length and flags60 02Header length 6 words (24 bytes). The only flag set is SYN, which means "start a connection".
Window sizefa f064240: this side can receive 64,240 bytes before it must wait.
Checksum7f 7aLets the receiver detect damage. It also covers the source and destination IP addresses.
Urgent pointer00 00Rarely used. Zero.
Option: maximum segment size02 04 05 b4Kind 2, length 4, value 1460: "send me at most 1460 bytes of data per segment".

Step 2 of 7 SYN-ACK: "Yes, and you?"

Web server → Your laptop

The server picks its own starting number and confirms yours by acknowledging your number plus one.

SYN-ACK segment 24 bytes

00 50 c9 3a 5e 6f 7a 8b 1a 2b 3c 4e 60 12 ff ff a1 5f 00 00 02 04 05 b4

FieldBytesWhat it means
Source port00 5080: the sender's port, which tells replies which program to reach.
Destination portc9 3a51514: the program the packet is for. 80 is a web server.
Sequence number5e 6f 7a 8b0x5e6f7a8b: the server's own random starting number.
Acknowledgement number1a 2b 3c 4e0x1a2b3c4e: your number plus one, meaning "I got your SYN, send the next byte".
Header length and flags60 12SYN and ACK flags are both set.
Window sizeff ff65535: the server can receive up to 65,535 bytes at once.
Checksuma1 5fLets the receiver detect damage. It also covers the source and destination IP addresses.
Urgent pointer00 00Rarely used. Zero.
Option: maximum segment size02 04 05 b4Kind 2, length 4, value 1460: "send me at most 1460 bytes of data per segment".

Step 3 of 7 ACK: "Agreed"

Your laptop → Web server

Your laptop confirms the server's number. The connection is open, and data can flow in both directions.

ACK segment 20 bytes

c9 3a 00 50 1a 2b 3c 4e 5e 6f 7a 8c 50 10 fa f0 be 2b 00 00

FieldBytesWhat it means
Source portc9 3a51514: the sender's port, which tells replies which program to reach.
Destination port00 5080: the program the packet is for. 80 is a web server.
Sequence number1a 2b 3c 4e0x1a2b3c4e: the first data byte this side will send.
Acknowledgement number5e 6f 7a 8c0x5e6f7a8c: the server's number plus one.
Header length and flags50 10Header length 5 words (20 bytes). Only the ACK flag is set.
Window sizefa f064240: unchanged.
Checksumbe 2bLets the receiver detect damage. It also covers the source and destination IP addresses.
Urgent pointer00 00Rarely used. Zero.

Step 4 of 7 Data: the request

Your laptop → Web server

Your browser sends its HTTP request. Each byte has a number, so the server knows the order and can spot gaps.

Step 5 of 7 ACK: "Got it up to here"

Web server → Your laptop

The server acknowledges how far it has received. If an acknowledgement does not arrive in time, the sender transmits that data again.

Step 6 of 7 FIN: "I am finished"

Your laptop → Web server

When your browser is done, it sends a FIN. This closes your side of the connection.

Step 7 of 7 FIN and ACK

Web server → Your laptop

The server acknowledges and closes its own side. After a short wait, both computers forget the connection.

Where you meet it

  • Web pages, email, file downloads and remote logins all use TCP.
  • Databases and APIs use it so that no part of a message goes missing.
  • Anything where correctness matters more than a tiny delay.

Common mistakes

  • Thinking TCP is slow. The handshake costs one round trip, which is small on a fast network but noticeable across continents.
  • Blaming the application when the real problem is lost packets causing retransmissions.
  • Ignoring ports: two programs on the same computer are told apart only by their port numbers.
  • Forgetting that a connection can stay half-open when one side crashes.

Try it yourself

Run these on your own computer and compare the output with the lesson above.

  • ss -tnLinux: lists your open TCP connections.
  • netstat -anWindows and macOS: the same idea.
  • sudo tcpdump -n -i any "tcp[tcpflags] & tcp-syn != 0" -c 5Shows the next five SYN packets on your machine.

Back to Network Lab

Addresses and values in the examples are made up for teaching (the 203.0.113.x range is reserved for documentation). Real traffic carries more options and details. Check the standard named above for the full rules.