TCP Vs UDP PDF
TCP Vs UDP PDF
UDP
lifewire.com/tcp-headers-and-udp-headers-explained-817970
by Bradley Mitchell Writer An MIT graduate who brings years of technical experience to articles on SEO, computers,
and wireless networking. our editorial process LinkedIn Bradley Mitchell
Transmission Control Protocol and User Datagram Protocol are two transport layer
protocols that are widely used with Internet Protocol. A protocol is a set of procedures and
rules that two computers follow to understand each other and exchange data. Although TCP
is the most commonly used protocol of the two, UDP is more useful in some situations.
Overall Findings
TCP
UDP
No error-checking provided.
Both protocols send data over the internet in packets. Of the two, TCP is connection-
oriented. After a connection is made, data travels bidirectionally. UDP is a simpler protocol
that is connectionless.
TCP is more robust than UDP. It provides error-correction functions and high reliability. UDP
is faster than TCP, primarily because it doesn't provide error-correction. Additionally, TCP
handles flow control, whereas UDP does not have an option for flow control.
1/6
Best for Reliability: TCP
TCP
Flow control.
UDP
No guarantee of delivery.
No flow control.
TCP guarantees data delivery to the receiver. If any data is lost, TCP takes steps to recover
the lost data and resends it. To do this, TCP tracks packets of data, and it checks the packets
for errors.
UDP doesn't guarantee the delivery of data. In addition, UDP packets can be lost in transit or
become corrupt.
Both TCP and UDP use headers as part of packaging the message data for transfer over
network connections. Because TCP is the more robust of the two protocols, its header is
larger at 20 bytes with an option for additional data, while UDP headers are limited to 8
bytes in size.
UDP
2/6
Although TCP is reliable, it is slower than UDP, mainly because it carries out more functions.
End users who require the fastest speed possible, such as gamers and people who work
with video, benefit from UDP.
UDP
Best for VPNs, streaming video, VoIP, live broadcasts, and online gaming.
Because TCP is reliable, it is best in situations that require high reliability but don't demand
speed, such as the web, email, and FTP.
UDP's speed makes it most suitable for online gaming, live broadcasts, VPN tunneling, and
streaming videos.
3/6
Lifewire
TCP headers appear in the following sequence, beginning with the source and destination
communication endpoints:
Source TCP port number (2 bytes or 16 bits): The source TCP port number represents
the sending device.
Destination TCP port number (2 bytes or 16 bits): The destination TCP port number
is the communication endpoint for the receiving device.
Sequence number (4 bytes or 32 bits): Message senders use sequence numbers to
mark the ordering of a group of messages.
Acknowledgment number (4 bytes or 32 bits): Both senders and receivers use the
acknowledgmentnumbers field to communicate the sequence numbers of messages
that are either recently received or expected to be sent.
TCP data offset (4 bits): The data offset field stores the total size of a TCP header in
multiples of four bytes. A header not using the optional TCP field has a data offset of 5
(representing 20 bytes), while a header using the maximum-sized optional field has a
data offset of 15 (representing 60 bytes).
4/6
Reserved data (3 bits): Reserved data in TCP headers always has a value of zero. This
field aligns the total header size as a multiple of four bytes, which is important for the
efficiency of computer data processing.
Control flags (up to 9 bits): TCP uses a set of six standard and three extended control
flags—each an individual bit representing On or Off—to manage data flow in specific
situations.
Window size (2 bytes or 16 bits): TCP senders use a number, called window size, to
regulate how much data they send to a receiver before requiring an acknowledgment
in return. If the window size is too small, network data transfer is unnecessarily slow. If
the window size is too large, the network link may become saturated, or the receiver
may not be able to process incoming data quickly enough, resulting in slow
performance. Windowing algorithms built into the protocol dynamically calculate size
values and use this field of TCP headers to coordinate changes between senders and
receivers.
TCP checksum (2 bytes or 16 bits): The checksum value inside a TCP header is
generated by the protocol sender as a mathematical technique to help the receiver
detect messages that are corrupted or tampered with.
Urgent pointer (2 bytes or 16 bits): The urgent pointer field is often set to zero and
ignored, but in conjunction with one of the control flags, it can be used as a data
offset to mark a subset of a message as requiring priority processing.
TCP optional data (0 to 40 bytes): Usages of optional TCP data include support for
special acknowledgment and window scaling algorithms.
Source UDP port number (2 bytes): The source UDP port number represents the
sending device.
Destination UDP port number (2 bytes): The destination UDP port number is the
communication endpoint for the receiving device.
Length of data (2 bytes): The length field in UDP represents the total size of each
datagram, including both header and data. This field ranges in value from a minimum
of 8 bytes—the required header size—to sizes above 65,000 bytes.
UDP checksum (2 bytes): Similar to TCP, a UDP checksum allows receivers to cross-
check incoming data for any corrupted bits of the message.
Final Verdict
5/6
There's a reason TCP is the most commonly used protocol. It is robust and reliable, and it
guarantees data is received exactly as it was sent. Its error-checked stream of information
may slow it down slightly, but in most cases, the delay isn't a deal-breaker.
The time when UDP shines brighter than TCP is when speed is critically important such as in
the streaming of videos, VPNs, or online gaming.
6/6