Network Daemons  «Prev  Next»

Lesson 3 TCP and UDP
Objective Define the two transport-layer protocols provided in TCP/IP that allow client/server transactions.

TCP, UDP and Transport-layer Protocols

Question: What is the difference between the TCP and UDP Protocols?
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two core transport layer protocols in the Internet Protocol (IP) suite. They are responsible for transmitting data between applications running on different devices in a network. Although both protocols serve the same purpose, they differ significantly in their design and operation:
  1. Connection-oriented vs. connectionless: TCP is a connection-oriented protocol, meaning it establishes a reliable, virtual connection between two devices before transmitting data. This connection is maintained throughout the data exchange, ensuring that data packets arrive in the correct order and without errors. In contrast, UDP is a connectionless protocol, which means it does not establish a connection before transmitting data. Instead, it sends data packets independently without any guarantee of their arrival or order.
  2. Reliability: TCP provides reliable data transmission by employing error checking, acknowledgements, and retransmission mechanisms. If a packet is lost or arrives out of order, the receiving end will request retransmission, ensuring that the data is received correctly. UDP, on the other hand, does not guarantee reliable data transmission. It lacks error checking, acknowledgements, and retransmission mechanisms, so lost or out-of-order packets are not retransmitted or reordered.
  3. Flow control and congestion control: TCP includes flow control and congestion control mechanisms to manage the rate of data transmission and prevent network congestion. It adjusts the transmission rate based on the available bandwidth and the receiver's ability to process incoming data. UDP does not have built-in flow control or congestion control mechanisms, making it potentially less efficient in congested networks or when dealing with varying bandwidth availability.
  4. Speed: Since UDP does not involve connection establishment, error checking, or flow control, it typically offers faster data transmission than TCP. Applications that prioritize speed and can tolerate data loss or out-of-order delivery often use UDP. TCP, with its additional overhead for reliability and congestion control, is generally slower than UDP but ensures the accurate and complete delivery of data.
  5. Use cases: TCP is used by applications that require reliable and ordered data transmission, such as web browsing (HTTP/HTTPS), file transfer (FTP), and email (SMTP/POP3/IMAP). UDP is used by applications that prioritize speed and can tolerate some data loss or out-of-order delivery, such as video streaming, online gaming, Voice over IP (VoIP), and Domain Name System (DNS) resolution.

In summary, TCP is a connection-oriented, reliable, and slower protocol suitable for applications that require accurate and complete data transmission. In contrast, UDP is a connectionless, unreliable, and faster protocol suitable for applications that prioritize speed over reliability and can tolerate some data loss or out-of-order delivery.

TCP and UDP

Under TCP/IP[1], client/server transactions come in two different kinds.
  1. The first kind of transaction: The first kind is a simple request-reply form. For example, machine A may query the time on machine B, and machine B replies with its idea of the current time. If, for some reason, machine B fails to respond, or its response is lost, machine A may simply repeat its request after a suitable timeout.
  2. The second kind of transaction: The second kind of client/server transaction requires an ongoing reliable data transfer. For example, a telnet connection requires a reliable stream of data to pass back and forth between the client and the server. An FTP[2] transaction, used to transfer bulk data files between machines, could not succeed without some way to ensure that the file sent in pieces from machine B to machine A can be reassembled completely at machine A.

Networking Computers enhances ability to communicate

Networking your computers dramatically enhances their ability to communicate and most computers (desktops, laptops, servers) are used for communication rather than computation. Many mainframes and supercomputers are busy crunching the numbers for business and science, but the number of these systems in use pales in comparison to the millions of systems busy moving mail to a remote associate or retrieving information from a remote repository. When you think of the hundreds of millions of desktop systems that are used primarily for preparing documents to communicate ideas from one person to another, it is easy to see why most computers can be viewed as communications devices. The positive impact of computer communications increases with the number and type of computers that participate in the network. One of the great benefits of TCP/IP is that it provides interoperable communications between all types of hardware and all kinds of operating systems. The name "TCP/IP" refers to an entire suite of data communications protocols.
The suite gets its name from two of the protocols that belong to it:
  1. the Transmission Control Protocol (TCP) and
  2. the Internet Protocol (IP).
TCP/IP is the traditional name for this protocol suite and it is the name used in this course. The TCP/IP protocol suite is also called the Internet Protocol Suite (IPS) and both names are acceptable.

Two transport-layer Protocols

TCP/IP provides two transport-layer protocols to allow for the two different types of client/server transactions. The simple reply-request transactions (such as those required for a DNS[3] server) use the User Datagram Protocol (UDP)[4], which provides no guarantee of reliability but which is simple and efficient. Those transactions requiring ongoing reliable data transfer use the (TCP) Transmission Control Protocol, which guarantees that a stream of data sent from one end of a connection to the other can be completely reconstructed in proper order. A Web server, for example, would require this level of reliability.

[1] TCP/IP: TCP/IP is the network protocol suite used by the Internet and most local area networks.
[2]File Transfer Protocol (FTP): Protocol used to transfer data over a network.
[3] DNS: Domain Name Service: resolves domain names to IP addresses
[4] UDP: User Datagram Protocol: A connectionless datagram service in the Transport layer used by applications that typically transmit small quantities of data.