Difference between TCP and UDP

In networking, a protocol refers to a standardized method of performing specific tasks and organizing data to enable effective communication and comprehension between two or more devices. Various network protocols and standards are necessary to ensure seamless communication between computers, even if they are geographically distant from each other. Network protocol suites are typically organized into layers, following the OSI (Open Systems Interconnect) Reference Model designed by the International Standards Organization (ISO). This model comprises multiple layers that interact to facilitate data transmission and reception. Among these layers, the Internet Protocol (IP) plays a crucial role in the protocol hierarchy, ensuring the proper routing and delivery of data across interconnected networks.


How network protocols work tcp udp

Internet Protocol (IP)

The Internet Protocol (IP) is a fundamental protocol responsible for routing and addressing data packets, ensuring their proper delivery across networks to their intended destinations. At the transport layer (Layer 4) of the TCP/IP protocol suite, two primary protocols exist: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). While TCP and UDP are not the only protocols operating on top of the Internet Protocol, they are the most commonly utilized ones. Both TCP and UDP are employed for transmitting data packets, referred to as packets, over the Internet. They rely on port (or socket) numbers to facilitate communication with higher layers of the protocol stack.

TCP

Transmission Control Protocol (TCP) stands as the preeminent protocol utilized across the Internet due to its remarkable error correction capabilities. TCP operates as a connection-oriented stream over an IP network, ensuring the precise and reliable delivery of data packets to their designated destinations in the correct sequence. This unparalleled reliability is largely attributed to the implementation of "flow control," a method that intelligently determines when data necessitates re-transmission and momentarily halts the data flow until previous packets have been successfully transferred. Consequently, this entails the utilization of acknowledgement packets sent back to the sender and automatic retransmission, albeit resulting in additional delays, and comparatively, a less optimally efficient transmission compared to the User Datagram Protocol (UDP).

Characteristics of TCP

  1. Connection-oriented.
  2. Reliable.
  3. Divides outgoing messages into segments.
  4. Reassembles messages at the destination station.
  5. Re-sends anything not received.
  6. Reassembles messages from incoming segments.

Examples of TCP in real life

  1. World Wide Web(HTTP)
  2. E-mail (SMTP TCP)
  3. File Transfer Protocol (FTP)
  4. Secure Shell (SSH)

UDP

The User Datagram Protocol (UDP) operates as a connection-less protocol, boasting faster data transmission compared to TCP but at the cost of reduced reliability. The guarantee of data integrity applies solely to individual datagrams, leading to the possibility of datagrams arriving out of order or not reaching their destination altogether. Unlike TCP, UDP sends packets directly to the target computer without establishing a prior connection, neglecting to indicate packet order or verify their successful delivery. Consequently, UDP finds limited use in scenarios where crucial data, such as webpages or database information, must be transmitted securely and accurately. Instead, it is more commonly employed for real-time communication, where a marginal percentage of packet loss is acceptable to avoid the overhead associated with TCP connections. Notably, UDP prioritizes speed over other considerations, hence impacting the quality of streaming media due to its propensity for potential packet loss.

Characteristics of UDP

  1. Connectionless.
  2. Unreliable.
  3. Transmit messages (called user datagrams).
  4. Provides no software checking for message delivery (unreliable).
  5. Does not reassemble incoming messages.
  6. Uses no acknowledgments.
  7. Provides no flow control.

Examples of UDP in real life

  1. Domain Name System (DNS)
  2. Streaming media applications such as movies
  3. Online multiplayer games
  4. Voice over IP (VoIP)
  5. Trivial File Transfer Protocol (TFTP)

Types Network protocols tcp udp

Summary: TCP Vs. UDP

  1. TCP is connection oriented and reliable where as UDP is connection less and unreliable.
  2. TCP is heavy-weight, and UDP is lightweight.
  3. Header size is 20 bytes while UDP header size is 8 bytes.
  4. The speed for TCP is slower while the speed of UDP is faster.
  5. TCP uses handshake protocol like SYN, SYN-ACK, ACK while UDP uses no handshake protocols.
  6. TCP does error checking and also makes error recovery, on the other hand, UDP performs error checking, but it discards erroneous packets.
  7. TCP reads data as streams of bytes, and the message is transmitted to segment boundaries while UDP messages contain packets that were sent one by one. It also checks for integrity at the arrival time.