Section 23.6
Protocol Stacks

Almost all protocol suites used in networking are layered, which means that the various protocols in the suite are built in top of each other. The OSI model has seven layers, so it is often referred to as the 7-layer model. TCP/IP is also layered, although there are fewer.

Fig. 23.6.1 shows the TCP/IP layers and how they would appear on two computers that are communicating using TCP/IP.


Fig. 23.6.1: TCP/IP layered architecture

At the top of the stack (the collection of layers) are the user programs which are generating and consuming the bit streams. For example, the UNIX mail program is such a user program. Some person wishing to send email to someone uses the program on a terminal. When the email is ready to be sent, the mail program encapsulates it in a packet format and uses SMTP to deliver it to the network for delivery. Only the computer doesn't directly send SMTP packets over the network. Instead it uses TCP to open up a reliable connection (see next section) with the destination computer.

However, TCP is actually using IP so the software takes the TCP packets (which encapsulate the SMTP packets which encapsulate the original email) and encapsulates them in IP format which it then supposedly delivers. However, most computers cannot use IP directly. They use instead a variety of data link protocols, Ethernet being probably the most popular in a local area network. Ethernet has its own packet format, so it takes the IP packet (which encapsulates the TCP packet, which encapsulates the SMTP packet, which encapsulates the original email) and encapsulates that in its own packet format and sends that on the wire.

The lowest level, the "bare wire," so to speak, is called the physical layer, and it is governed by rules as much as any other, although they are hardware and electrical rules.

Now the Ethernet packet finally travels over the wire to the destination, which snarfs it up and tries to decode it. The receiving computer's operating system spies that IP is being used so it sends the packet "up" through the IP layer, which decodes it and sends it "up" through the TCP layer, which further sends the constantly shrinking packet up to SMTP, which then delivers it to the receiving human who is reading her mail, unaware of the intricate complexity underneath the seemingly simple communication.

Layering costs time since all those packet headers have to be created at the sender and decoded at the receiver. However, they make it easy to mix and match different technologies and to keep track of where the packets are and where they are going. Not all computers use Ethernet, but may use token ring or several other technologies, but the IP packets are the same on all. Further, UDP is used for some applications instead of TCP. For instance, the Unix talk program, which is a primitive two-person chat facility or typewritten telephone, uses UDP because it is not imperative that every packet be delivered with 100% reliability.