Understanding of TCP flags
TCP flags are control bits in the TCP header that manage how TCP connections are established, maintained, and terminated. There are 9 TCP flags in modern TCP:
| Flag | Full Name | Purpose |
|---|---|---|
| SYN | Synchronize | Initiates a TCP connection and synchronizes sequence numbers. |
| ACK | Acknowledgment | Indicates the acknowledgment field is valid. Used in most TCP packets after connection setup. |
| FIN | Finish | Gracefully terminates a TCP connection. |
| RST | Reset | Abruptly terminates or rejects a connection. |
| PSH | Push | Requests immediate delivery of data to the receiving application. |
| URG | Urgent | Indicates urgent data is present; the Urgent Pointer is valid. |
| ECE | ECN Echo | Used with Explicit Congestion Notification (ECN) to indicate network congestion. |
| CWR | Congestion Window Reduced | Indicates the sender has reduced its congestion window after receiving an ECE. |
| NS | Nonce Sum | Rarely used; supports ECN protection (experimental/obsolete in practice). |
Common TCP Flag Combinations
| Flags | Meaning |
|---|---|
| SYN | Connection request |
| SYN, ACK | Connection accepted |
| ACK | Acknowledgment of received data |
| PSH, ACK | Data should be immediately passed to the application |
| FIN, ACK | Graceful connection termination |
| RST, ACK | Forcefully reset the connection |
TCP Three-Way Handshake
Client Server
| ------ SYN ------------> |
| <---- SYN, ACK --------- |
| ------ ACK ------------> |
Connection Established
TCP Connection Termination (Four-Way Handshake)
Client Server
| ------ FIN ------------> |
| <------- ACK ----------- |
| <------ FIN ------------ |
| ------- ACK -----------> |
Connection Closed
TCP Flags in Wireshark
Some common Wireshark representations are:
-
[SYN] -
[SYN, ACK] -
[ACK] -
[PSH, ACK] -
[FIN, ACK] -
[RST]
Typical Uses
- SYN: Start a connection.
- ACK: Confirm receipt of packets.
- FIN: Close a connection gracefully.
- RST: Immediately terminate a connection (e.g., closed port or protocol error).
- PSH: Deliver data to the application without waiting.
- URG: Mark urgent data (rarely used today).
- ECE/CWR: Handle congestion using ECN.
- NS: Experimental; seldom seen in modern networks.
Understanding these flags is essential for troubleshooting TCP connections, analyzing packet captures, and detecting network scans or attacks such as SYN floods or TCP reset attacks.
Comments
Post a Comment