- TCP/IP Primer: How Packet Filtering Works
- TCP and UDP Ports
- TCP's Three-way Handshake
- The Cisco Router as a Packet Filter
- An Alternative Packet Filter: IPChains
- The Cisco ACL
- Effective Uses of Packet-Filtering Devices
- Egress Filtering
- Tracking Rejected Traffic
- Problems with Packet Filters
- Dynamic Packet Filtering and the Reflexive Access List
- Summary
- References
TCP's Three-way Handshake
To begin communicating, connection-oriented TCP uses what's known as the three-way handshake. When Host A wants to connect to Host B to transfer data, it has to let Host B know that it wants to connect. Host A does this by sending a packet to Host B with the SYN (or synchronization) flag set, meaning, "I want to start a new conversation." If Host B can and wants to converse back to Host A, it returns a packet with the SYN and ACK (or acknowledgment) flags set, meaning, "I want to start a conversation with you, too, and I am acknowledging that I will be a part of your conversation." Finally, Host A returns the third part of the handshake, a packet with just the ACK flag set, meaning, "I will also take part in your conversation, so let's start talking!" With that, data begins transferring. In a simplified view, the two hosts are simply exchanging SYN flagged packets to say they want to start a conversation and ACK flagged packets to say they acknowledge the receipt of the SYN. The second host simply "piggybacks" its acknowledgment onto the same packet that contains its initiating SYN.
Packet-filtering systems can use these flags to determine the stage of the current three-way handshake. For example, if you didn't want to allow new connections from the outside, you could choose to only permit traffic flagged with ACK; the packets starting a new connection contain the SYN flag only.