Networking Explained, Second Edition

As promised, no more questions about HTTP or application-layer protocols. Let's now discuss the transport layer.
Okay, but it will be most helpful if you first go back to Chapter 2 and review Figures 2.15 and 2.16. As can be seen from these figures, the TCP/IP protocol suite defines two different transport layer protocols: the User Datagram Protocol (UDP) and the Transport Control Protocol (TCP). Additional information about UDP and TCP can also be found in the RFCs at http://www.rfceditor.org.
I went back to Chapter 2 and looked at Figures 2.15 and 2.16. I am little confused about TCP versus UDP and don't really understand when each one is used. How do you decide whether to use TCP or UDP?
You don't. This determination is made by the application program. For example, in Figure 2.16, examples of programs that use TCP include FTP, TELNET, FINGER, SMTP, and POP. Similarly, examples of programs that use UDP include SNMP, TFTP, NFS, DNS, and BOOTP. What is important to understand here is that TCP/IP has two different transport layer protocols TCP and UDP. TCP is connection-oriented and provides for reliable network transmission. UDP is connectionless and provides unreliable network transmission. This implies that UDP cannot recover from lost packets. Thus, the application must detect lost data and retransmit them. UDP also has no ability to perform error or flow control. This makes UDP faster than TCP in performance when the network is not congested because...