TCP vs UDP: Difference between TCP and UDP explained

neotam Avatar

TCP vs UDP: Difference between TCP and UDP explained
Posted on :

Tags :

IP layer is the service provider for transport layer that is for both UDP and TCP protocols. In OSI model, transport layer is responsible for end to end communication or process to process to communication. Major protocols in the Transport layer are TCP and UDP. Both TCP and UDP use the port number to identify the process while IP protocol uses the logical address (IP Address) to identify the host.

Typical format TCP or UDP segment is that it contains both header and data which is encapsulated into IP datagram.

TCP Protocol

TCP is connection oriented protocol also known as stream-oriented protocol

  • Protocol is designed to ensure packets are received error-free and in sequence on the receiving end
  • Offers the reliable stream delivery service
  • Transport Layer Protocol
  • Stateful Protocol
  • Connection oriented protocol
  • Stream oriented protocols, allows sender to send data as stream of bytes
  • Buffers are used to allow sender and receiver to operate at different speeds
  • Three way handshake is used to establish two way connection
  • Complex
  • Slow
  • Reliable
  • Full Duplex: TCP offer full duplex communication where data can be communicated in both directions simultaneously
  • Acknowledgement
  • Error Control: Corruption, lost and duplicate segments, out of order segments. It is achieved by using checksum, ack and time out
  • Flow Control
  • Windows in TCP are used for flow and error control
  • Congestion Control
  • Provides process to process communication using port addresses
  • Packets are delivered in order
  • Checksum is mandatory which is used part of error control
  • Security/Encryption: SSL/TLS protocols
  • TCP uses the variable length header. Where, minimum size of 20 bytes and maximum size of 60 byte while allowing 40 bytes for options & padding in the header
  • TCP packet is encapsulated into the IP datagram payload which is illustrated as follows
TCP Encapsulation and TCP Header Format

UDP Protocol

  • Transport Layer Protocol
  • Connectionless protocol
  • Stateless Protocol
  • Offers the fast time real-time deliver of data
  • No Handshake is performed
  • There is no mechanism of connection establishment or termination
  • Simple
  • Minimal overhead
  • Throughput
  • Fast
  • Unreliable
  • No Duplicate Protection
  • Packets may not be delivered in the order
  • There is no mechanism of checking of errors
  • There is no mechanism of re-transmission
  • No flow and congestion control
  • No mechanism of acknowledgement
  • Error packets are discarded
  • Provides process to process communication using port addresses
  • Uses fixed header of size 8 bytes
  • Each user datagram or packet sent is independent
  • Each datagrams can take different path to the destination
  • Sender is not aware of message delivered or lost
  • Uses UDP Queuing: incoming and outgoing queue are associated with each UDP port
  • Optional source port number: 0 for no port
  • Use of checksum field in UDP packet is optional
  • Secured version of UDP is DTLS
  • Supports the Broadcast and Multicast
  • UDP packet is encapsulated into the IP datagram payload which is illustrated as follows
UDP Segment Encapsulation and UDP Header Format

Leave a Reply

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