Updated on November 3, 2022
By Stelios Antoniou

Networking Basics: TCP vs UDP, TCP/IP vs OSI, and More

TCP is connection-oriented as end points must establish a connection prior to transmission. UDP is a connectionless protocol. Keep reading to learn more about TCP vs UDP and other basic networking concepts.

If you're preparing for your CCNA exam, or if you're just interested in networking, you probably want to learn about the differences between TCP and UDP as well as the origin of TCP/IP and OSI. This article explains the TCP and UDP protocols in computer networks so you can see the differences between the two. You will also find useful information concerning the protocol suite of the century: TCP/IP.

The TCP/IP model and OSI model

Both TCP/IP and OSI are suites of protocols that governs communication between applications on the internet. To understand UDP and TCP, let's start by comparing TCP/IP and the OSI Models. 

What is the TCP/IP model?

The Transmission Control Protocol/Internet Protocol (TCP/IP) suite was created by the U.S. Department of Defense (DoD) to ensure that communications could survive any conditions and that data integrity wouldn't be compromised under malicious attacks.

What is the OSI model?

The Open Systems Interconnection Basic Reference Model (OSI Model) is an abstract description for network protocol design, developed as an effort to standardize networking.

TCP/IP model vs. OSI model

The TCP/IP model is basically a shorter version of the OSI model. It consists of four instead of seven layers. Despite their architectural differences, both models have interchangeable transport and network layers and their operation is based upon packet-switched technology. The diagram below indicates the differences between the two models:

Layers in TCP/IP vs OSI models

Left: TCP/IP Model
Right: OSI Model

  • Application Layer: The Application layer deals with representation, encoding and dialog control issues. All these issues are combined together and form a single layer in the TCP/IP model whereas three distinctive layers are defined in the OSI model.
  • Host-to-Host: Host-to-Host protocol in the TCP/IP model provides more or less the same services with its equivalent Transport protocol in the OSI model. Its responsibilities include application data segmentation, transmission reliability, flow and error control.
  • Internet: Again Internet layer in TCP/IP model provides the same services as the OSIs Network layer. Their purpose is to route packets to their destination independent of the path taken.
  • Network Access: The network access layer deals with all the physical issues concerning data termination on network media. It includes all the concepts of the data link and physical layers of the OSI model for both LAN and WAN media.

TCP/IP Protocol Suite

Below is a diagram of the TCP/IP protocol suite. Note that in the Host-to-Host layer, Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are defined for transmitting datagrams. We will look at the details of both these protocols as well as their interaction with the upper layer.

Layers in the TCP/IP protocol including TCP and UDP

Differences Between TCP and UDP

Now that we understand that the TCP and UDP are protocols within the host-to-host layer of the TCP/IP, we can start to examine some of their differences more closely. 

What is TCP?

TCP is responsible for breaking down a stream of bytes into segments and reconnecting them at the other end, retransmitting whatever might be lost and also organizing the segments in the correct order. TCP is connection-oriented in the sense that end points need to establish a connection before transmission.

TCP protocol data units are called segments. The sending and receiving TCP entities exchange data in the form of segments, which consist of a fixed 20-byte header followed by a variable size data field. The segment size is restricted by the maximum transfer unit (MTU) of the underlying link layer technology (MTU is generally 1500 bytes which is the maximum payload size of the Ethernet).

The image below shows the TCP segment format. The most important fields are explained further on.

The TCP segment format
  • Source Port and Destination Port fields together identify the two local end points of the particular connection. A port plus its hosts' IP address forms a unique end point. Ports are used to communicate with the upper layer and distinguish different application sessions on the host.
  • The Sequence Number and Acknowledgment Number fields specify bytes in the byte stream. The sequence number is used for segment differentiation and is useful for reordering or retransmitting lost segments. The Acknowledgment number is set to the next segment expected.
  • Data offset or TCP header length indicates how many 4-byte words are contained in the TCP header.
  • The Window field indicates how many bytes can be transmitted before an acknowledgment is received.
  • The Checksum field is used to provide extra reliability and security to the TCP segment.
  • The actual user data appears after the end of the header.

What is UDP?

UDP (User Datagram Protocol) consists of fewer fields compared to TCP. The reason for that is because certain data types do not require reliable delivery and extra overhead. Real-time traffic for example, needs to be transported in an efficient way without error correction and retransmission mechanisms.

UDP is considered to be a connectionless protocol. It leaves reliability to be handled by the application layer. All it cares about is fast transmission. The UDP segment format is presented in the diagram below:

UPD Segment format

When should I use TCP vs. UDP?

Choosing the right transport protocol to use depends on the type of data to be transferred. For information that needs reliability, sequence transmission and data integrity -- TCP is the transport protocol to use. For data that require real-time transmission with low overhead and less processing -- transport protocol UDP is the right choice.

The following table summarizes the key-characteristics of each one of these protocols. Keep them in mind when choosing the transport protocol for your data.

Interested in tools for working with TCP and UDP protocols? Check out our list of Top 10 TCP/IP tools.

TCP

UDP

Reliable

Unreliable

Connection-oriented

Connectionless

Segment retransmission and flow control through windowing


No windowing or retransmission                                 

Segment sequencing

No sequencing

Acknowledge segments

No acknowledgment

Want to learn more about TCP and UDP? Try Pluralsight's TCP and UDP Operation course!

Stelios Antoniou

Stelios Antoniou holds a BSc in Electronic Engineering and an MSc in Communication Networks. He has over three years of experience in teaching MS Office applications, networking courses and GCE courses in Information Technology. Stelios is currently working as a VoIP Engineer in a Telecom company, where he uses his knowledge in practice. He has successfully completed training on CCNP topics, Linux and IMS. His enthusiasm, ambition and knowledge motivate him to offer his best. Stelios has written many articles covering Cisco CCENT, CCNA, and CCNP.