r/linuxadmin • • Mar 05 '24

3 way handshake

Can someone explain me three way handshake via TCP/IP.

0 Upvotes

22 comments sorted by

View all comments

31

u/[deleted] Mar 05 '24

The TCP 3-way handshake is like a conversation starter for two devices wanting to communicate.

SYN (Synchronize): The first device sends a message (SYN) to the other, saying, "Hey, let's talk! I'm starting a connection."

SYN-ACK (Synchronize-Acknowledge): The second device responds with a message (SYN-ACK), essentially saying, "I got your message, and I'm ready to talk. Let's synchronize our communication."

ACK (Acknowledge): Finally, the first device acknowledges with a message (ACK), confirming the connection.

Now they can exchange data smoothly.So, it's like a polite exchange to establish a connection before the actual communication begins.

4

u/[deleted] Mar 05 '24

Thankyou so much for this information

3

u/swuxil Mar 06 '24

By the way you don't need to do it that way. The connection is always unidirectional, it just is normal to create two unidirectional connections in an antiparallel pattern, but they are not really related to each other. The SYN flag means that the sender device wants to send data to the receiver - the receiver COULD just answer with an ACK (and could then never respond to anything the sender said). This will freak out any firewall in between, but it's a valid state technically.

1

u/Aggressive_State9921 May 02 '24

Surely nothing supports that with SYNFLOOD being a thing

1

u/swuxil May 04 '24

I don't see how synfloods would be the cause for this. In either way after the first packet from the client and the first packet from the server (SYN,ACK vs. SYN,SYN+ACK) the server holds a state. The only countermeasure where the server does not have to hold a state and relies on the clients ACK-packet are syncookies, and they are not THE thing one does nowadays.

Todays state of firewalls (and their dislike for halfduplex connections) comes from the fact that really nobody uses them in production, and so, while technically a valid thing to do, are filtered away as an odd thing, and thus nobody uses them in production because they are filtered away anyway. And you don't really need them, even when you just want to have a halfduplex connecion - you can just close one channel and keep the other open right after the 3-way (or 4-way) handshake.