TCP vs UDP
May 29, 2020 by Jane

 

TCP UDP

Reliable data transfer 

Utilises retransmission to ensure RDT and uses cumulative ACKs and fast retransmission to maximize sender utilization. Timeout is long but as soon as 3 duplicate ACKs are received it will re-send the packet with smallest unacked sequence#.

Unreliable data transfer
Flow control - traffic control, receiver won't be overwhelmed (this is done by the receiver giving information about available buffer space or "rwnd" value in TCP header. sender ensure to limit number of in-flight data to below the rwnd value No flow control

Congestion control -

TCP slow start (cwnd set to 1 MSS then doubled per RTT).

After cwnd reaches slow start threshold (ssthresh) it switches to congestion avoidance (CA) state where cwnd grows linearly until loss occurs (+ increase, * decrease or AIMD - additive increase multiplicative decrease)

cwnd += MSS every RTT till triple duplicate ACK detected then cwnd /= 2; Repeat.

If timeout occurred reset cwnd to MSS and ssthresh to 1/2 cwnd before the timeout.

  • MSS is max segment size
  • cwnd is congestion window size
No congestion control
Data received will be in order Data may be received out-of-order

Connection-oriented (3-way handshake)

1) Client -> SYN -> Server

2) Server -> SYNACK -> Client

3) Client -> ACK -> Server

Connectionless (Sender explicitly attaches IP destination addr and port # to each packet)

 

What do TCP and UDP have in common:

  • Utilizes sockets
  • A method to transfer data through the transport layer
  • No encryption, clear text passwords are sent (SSL is used to provide the encryption layer)