This tutorial explains what segmentation is, how segmentation works in the data communication process, what the TCP and UDP headers contain, and how the header is used to create a segment.
Both Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) work in the Transport layer. Both offer the same functionality in different ways. This functionality is the delivery of data to the correct destination. While providing this functionality, TCP focuses on precision while UDP pays attention to speed.
This tutorial is the first part of the article “Similarities and differences between TCP and UDP explained with functions” This tutorial explains the following CCNA topic.
Compare and contrast TCP and UDP protocols
Other parts of this article follow.
Connection multiplexing explained with examples
This tutorial is the second part of the article. It explains what connection multiplexing is and how the TCP and UDP protocols use it to connect to multiple applications simultaneously.
TCP features and functions explained with examples
This tutorial is the last part of the article. It explains how TCP provides guaranteed data delivery through its protocol-specific functionality.
The following five functions are used in the data delivery process: –
- Connection multiplexing
- Oriented connection or connection without delivery
- Reliability through recognition and sequencing
- Flow control by windowing
From these functions, to ensure the accuracy of the delivery process, TCP supports all functions, while to provide the highest possible speed, UDP supports only the second function.
Let’s understand each function in detail and compare how the two protocols provide it.
Segmentation is the process of dividing a large data stream into smaller pieces. This feature allows a host to send or receive a file of any size over any network size. For example, if the network bandwidth is 1 Mbps and the file size is 100 Mb, the host can split the file into 100 pieces or more. Once an item becomes less than or equal to the network bandwidth, it can be transferred easily. The destination host, after receiving all the documents, joins them to reproduce the original file.
TCP supports segmentation, unlike UDP. This means that if an application wants to use TCP to send its data, it can give the data to TCP in full size. Depending on several conditions such as data size and available network bandwidth, if segmentation is required, TCP does this itself before compressing the data for transmission.
But if an application wants to use UDP to send its data, it cannot give the data to UDP in full size. It must use its own mechanism to detect whether segmentation is required or not. And if segmentation is necessary, it must do it alone before giving data to UDP.
Packing data for transmission
The two protocols group data in a similar way. Both add a header to each data item. A header mainly contains two types of information;
- The information required to send the segment to the correct destination.
- The information required to support protocol-specific functionality.
TCP and UDP add the first type of information in the same way. Both use two fields for this information; source port and destination port. Information about the application that sends the data and information about the application that will receive the data is added to the source port field and the destination port field, respectively.
Protocols add a second type of information depending on the services they offer. TCP offers several protocol-specific services such as segmentation, windowing, flow control, etc. To provide these services, it adds the necessary information in the header.
The following figure shows a piece of data with the TCP header.
|Source port||Used to identify the application that sends data from the source host|
|The port of destination||Used to identify the application that will receive the data on the destination host|
|Sequence number||Used to identify lost segments and maintain sequencing in transmission.|
|Acknowledgment number||Allows you to send a verification of the segments received and to request the following segments|
|Header length||A number that indicates where the data begins in the segment|
|Reserve||Reserve for future use. Always set to zero.|
|Code bits||Used to define control functions such as configuration and end of session|
|Window size||Allows you to define the number of segments that can be sent before waiting for a confirmation of the destination.|
|Checksum||CRC (cyclic redundancy check) of the header and the data.|
|Urgent||Used to point to all urgent data in the segment.|
|The options||Used to set additional options such as maximum segment size|
|The data||Data produced from segmentation|
On the other hand, UDP does not provide any protocol-specific services, nor does it add additional information to the header.
The following figure shows the data with UDP header.
|Source port||Port number of the application that transmits the data from the source computer|
|The port of destination||Port number of the application that will receive the data at destination.|
|Length||Specifies the length of the UDP header and UDP data|
|Checksum||Full segment CRC|
|The data||Data received from the application|
Once a header is attached to the data item (generated from segmentation in TCP or received from the application in UDP), it is called a segment.
The following figure shows how segmentation works in the two protocols.
- TCP uses segmentation, unlike UDP.
- Both protocols use different types of headers to package the data to be transmitted.
- The UDP header contains only information about mandatory functions and its length is 8 bytes.
- The TCP header contains information about mandatory and optional functions. The TCP header is 20 bytes long and 24 bytes long without options and with options respectively.
That’s it for this part. In the next section, I will explain connection multiplexing in detail with examples. If you like this tutorial, don’t forget to share it with your friends.