TCP and UDP

The Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are the two most popular transport layer protocols in the TCP/IP suite. UDP consumes fewer bytes of overhead and requires less processing. TCP requires more overhead and more processing, but offers many useful functions, including error recovery. Table 6-2 summarizes the key comparisons between the two protocols.

Table 6-2 TCP and UDP Functional Comparison

KEY POINT

Table 6-2 TCP and UDP Functional Comparison

KEY POINT

Function

TCP

UDP

Multiplexing using ports

Yes; port numbers uniquely identify the processes (socket programs) on the computers sending and receiving the data.

Same as TCP.

Ordered data transfer

Yes; TCP reorders any data that is received out of order.

No; UDP has no concept of ordering of data.

Reliable transfer

Yes; TCP acknowledges data, resending lost segments, using the Sequence and Acknowledgment fields in the TCP header.

Not supported by UDP.

Flow control

Yes; TCP uses a granted (advertised) window, as well as a congestion window, to control each TCP sender's dynamic window.

Not supported by UDP.

Connections

Yes; the three-message TCP connection setup process initializes the port numbers.

UDP is connectionless.

IP protocol type

6

17

Base RFC

793

768

The TCP and UDP headers differ in length (20 and 8 bytes, respectively), mainly because TCP has more functions to support. Figure 6-1 shows the TCP and UDP header formats. Note that the TCP header shows the Options field, which extends the length of the TCP header past 20 bytes, but always to some multiple of 4 bytes.

Figure 6-1 TCP and UDP Headers

TCP Header

KEY POINT

Bit 0

Source Port 16

Destination Port 16

Sequence Number 32

Acknowledgement Number 32

HLen 4

Code Bits 6

Header Checksum 16

Window 16

Urgent Pointer 16

Options and Padding (Multiple of 32)

Data (Variable)

Bit 31

UDP Header

Bit 0

Bit 31

UDP Header

Bit 0

Source Port 16

Destination Port 16

Message Length 16

Header Checksum 16

Note that UDP operates identically to TCP in regard to the Port Number fields and the Header Checksum field. The UDP Length field identifies the length of the UDP message, including the UDP header and data. The fields inside the TCP header are explained in the next few sections of this chapter.

Continue reading here: TCP Connections and Port Numbers

Was this article helpful?

0 0