TCP/IP Layered Protocol Model
There are different types of service that you can use when delivering a letter. You can use a best effort model. This means that you simply place a stamp on the letter and drop it in a mailbox. How do you know if the letter was delivered? You don't. Not unless the recipient somehow tells you they received the letter. If you want to ensure delivery, you could send a registered letter. After the letter has been delivered, you will receive an acknowledgment from the post office. The layered postal delivery model needs to be modified to include this feature. (See Figure 3-14.) Although IP is used to deliver packets, and TCP and UDP are transport level protocols, the layer model for the Internet is usually referred to as the TCP/IP model.
Figure 3-14 Post Office Layered Protocol Model
At the Addressing Person layer, two options have been added:
Normal deliveryThe sender will not receive any acknowledgment that the letter has been delivered.
Registered mail The sender will receive an acknowledgment after the letter has been delivered.
The Internet layered model has two additional protocols that are equivalent to normal and registered mail:
Transmission Control Protocol (TCP)The equivalent of a registered letter. When data is received at the destination host, an acknowledgment is sent back to the sender.
User Datagram Protocol (UDP)The equivalent of normal mail. An acknowledgment is not sent back to the sender.
Integrating TCP and UDP into the Internet model gives you the complete TCP/IP layered protocol model. (See Figure 3-15.)
Figure 3-15 TCP/IP Layered Model or Protocol Stack
The port information in the UDP header is used to identify the sending and receiving applications. (See Figure 3-16.)
Figure 3-16 UDP Header Format
The source port is equivalent to the person who is sending the letter. The destination port is equivalent to the person who is to receive the letter. Applications initially will use a well-known port number. For example, if you are using a web browser to contact the Cisco website, your application will send a message to port 80 at IP address 188.8.131.52. The source port is usually assigned dynamically for the application and is included in the UDP header. When the webserver for Cisco.com sends a reply, it will send it back to the dynamic port number that was assigned for the sender's application. The destination IP address is used to reach the host running the web server, and the destination port number is used to reach the proper application. The combination of a port number and an IP address is called a socket. A socket is sufficient to identify a particular application on a specific host.
The TCP header is similar to the UDP header with additional fields to enable acknowledgments. (See Figure 3-17.)
Figure 3-17 TCP Header Format
The source and destination port numbers serve the same function as they did in the UDP header. The remaining fields are used to send the equivalent of registered mail. The operation of the TCP protocol can be complex. If you are interested in learning more, consult the reference list at the end of the chapter.
Before moving on to the next exciting topic, let's trace the flow through the TCP/IP protocol stack. (See Figure 3-18.)
Figure 3-18 Data Flow Through the TCP/IP Protocol Stack
The application sends the data, such as the text of an e-mail, you are sending to UDP or TCP where the destination and source port numbers are recorded. The IP layer adds the source and destination IP addresses, and sets the protocol field to UDP or TCP depending on what is being used. The IP layer then hands the packet off to the network interface layer. This example uses Ethernet, so the network interface layer adds the source and destination Ethernet addresses. Finally, the entire thing is sent to the network to be sent to the destination.
Upon receipt of an IP packet by a host, the destination Ethernet address is first inspected. If it matches the host's Ethernet address, the Ethernet header is stripped off, and the remaining part of the packet is sent up the protocol stack to the IP layer. The IP layer looks at the destination IP address. If it is the correct IP address, the IP layer strips off the IP header, and sends what is left either to TCP or UDPdepending on the setting of the protocol field. UDP or TCP then uses the destination port number to send the data to the correct application.