TCP ‐ Transport Control Protocol - O-LavenderAshburn/Knowledgebase_NetworkAndConnectivity GitHub Wiki
TCP (Transmission Control Protocol) is a connection-oriented protocol used in the transport layer of the OSI and TCP/IP models which provides reliable, ordered, and error-checked delivery of data between applications. TCP 3-way handshake is used to establish a reliable connection between a client and server.
TCP 3-Way Handshake
Client Server
| |
| ----------- SYN (Seq = x) ------------------------>|
| |
|<--------- SYN-ACK (Seq = y, Ack = x + 1) ----------|
| |
| ----------- ACK (Ack = y + 1) -------------------->|
| |
Connection Established
Packet Structure
Packet Bits
0 15|16 31
|__________________________________|________________________________|
| Source Port (0-15) | Destination Port (16-31) |
|-------------------------------------------------------------------|
| Sequence Number |
| (0-31) |
|-------------------------------------------------------------------|
| Acknowlegment Number |
| (0-31) |
|-------------------------------------------------------------------|
|Data | Resvd |N|C|E|U|A|P|R|S|F| |
| Offset | |S|W|C|R|C|S|S|Y|I| Window Size |
| (0-4) | (4-7) | |R|E|G|K|H|T|N|N| (16-31) |
|-------------------------------------------------------------------|
| Checkusm (0-15) | Urgent Pointers (16-31) |
--------------------------------------------------------------------|
| Data |
| (0-31) |
---------------------------------------------------------------------
-
Source port: Identifies the port number on the sender's device.
-
Destination port: Identifies the port number on the receivening device.
-
Sequence Number: If not initial sequence number (SYN Flag is set), then the accumulated sequence number of the first data byte of this segment for the current session.
-
Acknowlegment Number: If the ACK flag is set, this value tells the sender which byte is expected next.
-
Data Offset: Specifies the length of the TCP header in 32-bit words.
-
Reserved: Reserved for future use.
-
Flags: Determine behaviour.
-
Window Size: Specifies the size of the receive window.
-
Checksum: Used to verify integrity of header and data. Ensures the segment wasn’t corrupted in transit.
-
Urgent Pointer: Points to the end of urgent data if the URG flag is set.
-
Data: Contains the payload (e.g., part of an HTTP request/response).
TCP Congestion control
Are algorithms within TCP to control congestion over the internet.