Deep Dive Into TCP/UDP Protocol



Similar Posts:


Q: Difference between socket VS TCP?

A: Socket are a method of IPC that allow data to be exchanged between applications. Socket connection implies two peer connected with each other, Protocol can be TCP, UDP or others.

TCP/IP Network

Link: Any difference between socket connection and tcp connection?

Q: TCP establish connection: 3-way handshakes

A:
TCP 3-way handshake

Q: To establish TCP connection, why not only 2-way handshakes, instead of 3-way handshakes?

A: TCP is a bi-directional communication protocol, which means either end ought to be able to send data reliably.

Link: Why do we need a 3-way handshake? Why not just 2-way?

Q: TCP terminate connection: 4-way handshake

A:
TCP 3-way handshake

Q: Why 3-way handshakes for establish a TCP connection, but 4-way for terminate a TCP connection?

A: Like SYN-ACK, why not having a FIN-ACK segment?

TCP is a bidirectional and full-duplex protocol.

When establishing bidirectional connection, SYN(request opening the source end) is the natural next step of ACK(acknowledge opening the server end). So combining them as one SYN-ACK is a safe performance tuning.

However when client requests terminating connection, server may have some data haven’t got enough time sending to the client.

Two use cases when client have to terminate a TCP connection.

  1. Server doesn’t have unsent data. In this case, server can merge FIN(request closing the source end) and ACK(acknowledge closing the server end) as one package.
  2. Server has unsent data. The data need to be sent to client, before terminating the connection. In this case, FIN and ACK can’t be merged.

Link: Why tcp connect termination need 4-way-handshake?

Q: After terminating a TCP connection, why socket state would be set to TIME_WAIT?

A: The purpose of TIME_WAIT is to allow the networking to distinguish packets that arrive as belong to the “old, existing” connection from a new one.

Q: How does TCP sliding window work for congestion control?

A: TODO

Q: TCP VS UDP?

A: Both TCP and UDP are popular transport-layer protocols.

  • Reliable or not: TCP is a reliable, bi-directional communication protocol
  • Connections: UDP doesn’t need to establish and terminate connections for communication
  • UDP permit broadcasting and multicasting; UDP server can receive(and reply to) datagrams from multiple clients
  • TCP provide guarantees about in-order delivery

Share It, If You Like It.

Leave a Reply

Your email address will not be published. Required fields are marked *