r/linuxadmin • u/[deleted] • Mar 05 '24
3 way handshake
Can someone explain me three way handshake via TCP/IP.
47
u/deeseearr Mar 05 '24
"Knock knock"
"Who's there?"
"TCP connection!"
It's a TCP joke so if you don't get it at first it may take a few tries. I could also tell you a UDP joke, but I wouldn't really care if you got it or not. I could make it a Kerberos joke, but that's all in the timing. I would like to tell an IPv4 joke, but there aren't any left. I could tell you an IPv6 joke instead but I don't know if you would understand it.
1
10
u/_mick_s Mar 05 '24
I usually try to not be a dick but since it's been answered already, let me show you a great trick:
2
u/ZMcCrocklin Mar 05 '24
Oh...lmgtfy.com no longer exists? Boo! (Cert expired Aug last year for the redirect endpoint lmgtfy.app)
1
1
1
-3
u/rautenkranzmt Mar 05 '24
Client says to server, "Server, I would like some data X."
Server says back to client, "Client, you want data X?"
Client responds to server "Yes, Server, I would like data X."
Then the data transfer happens, with an equal amount of back and forth.
6
u/symcbean Mar 05 '24
with an equal amount of back and forth
It's very unusual for equal amounts of packets/data to flow in both directions.
UDP based protocols are sometimes designed to at least require the same number of packets in both directions to prevent amplification attacks - but that does not apply here.
0
u/rautenkranzmt Mar 05 '24
No, I think you've got the two confused. UDP is streams based, it's literally fire and forget.
TCP is packet based, and focused solely on assurance of delivery. It's extremely chatty, and if you transport large amounts of data over it, it can saturate upstream links very quickly.
There's a reason media is almost always transported over UDP with TCP being the control channel. Same reason QUIC uses UDP.
3
u/symcbean Mar 05 '24
No, I have not got them confused.
You have them backwards. TCP implements streams, UDP implements datagrams. They both run on top of packets. You might want to familiarize yourself with how selective acknowledgements work in TCP.
10
Mar 05 '24
[removed] — view removed comment
3
u/guzzijason Mar 05 '24
Hey Reddit, help me tie my shoes.
0
Mar 05 '24
[deleted]
1
u/guzzijason Mar 05 '24
I said Reddit, not YouTube. Don’t be so lazy! /s
1
u/doubled112 Mar 05 '24
To be fair, shoe tying is a pretty visual process. I'm not sure I could explain it in words.
1
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.