Search The Hostwinds Guides Knowledge Base

TCP VS UDP

Share This Article

Without transport protocols such as TCP (Transmission Control Protocol) and UDP (User Datagram Protocol), data that is sent over the network with no regard for how a host handles the incoming data packets would be impossible to handle. That is where the Transport layer, (Layer 4 on the OSI Model) comes into play. It serves as the interface between the lower level Network layer (Layer 3 in the OSI Model) and the high level Application layer (Layer 7 in the OSI Model).

What is a transport protocol?

In the TCP/IP suite, there are a few protocols, including the titualr TCP and UDP protocols. At its core, the trasport protocol carries data between the network and specific ports. These ports are available for use to higher level applications.

TCP

TCP is the most used transport protocol for purposes such as email, web traffic, and file transfer applications such as FTP. The main advantages of TCP is that  it is :

  • Connection-oriented: TCP ensures a two-way connection between hosts, even if it is only for one-way data flow.
  • Reliable: TCP ensures that all data arrives at the intended target host. If any of the data does not arrive, TCP will handle the errors and attempt to resend.
  • Error correction: a TCP segment contains something called a checksum which is used for detecting discrepancies between the segments sent and the segments received. TCP will detect corrupt segments and attempt to resend them just like with missing segments.
  • Flow control: The receiving host can regulate the flow of data to keep slower hosts from getting bogged down by a host sending data much faster than it can receive.
  • Sequencing: TCP ensures that packets will be sent to higher layers in the correct order, even if they came across the network out of order.

UDP

While the features that TCP has makes it a good choice for network traffic, all of the extra error checking and handling makes the packets larger and increases the processing load to accomplish the task.

UDP is essentially the opposite of TCP in how it behaves. It is unreliable, connectionless, fast, and lightweight. The local host sends diagrams to the remote host and does not wait for any connection to be set up or any acknowledgement from the remote host. This makes it an unpopular choice compared to TCP, but in some cases UDP is the perfect protocol.

Streaming services and game servers are prime examples of times when a fast connection is essential and when error checking on each packet with TCP could cause more of a hang-up than a corrupt packet sent with UDP.

Related Articles