To deal with the massive complexity of network communications, the network architecture is organized into layers. Each layer provides a specific service to the layer above it and relies on the services of the layer below it. This layered architecture allows hardware and software from vastly different vendors to communicate seamlessly.
There are two primary models used to describe network architecture: the OSI Reference Model (theoretical) and the TCP/IP Protocol Suite (practical, used by the modern Internet).
The Open Systems Interconnection (OSI) model was developed by the ISO in the late 1970s. It consists of 7 layers.
The application layer is responsible for providing services to the user. It enables the user (human or software) to access the network. Protocols: HTTP, FTP, SMTP, DNS.
The presentation layer is concerned with the syntax and semantics of the information exchanged between two systems. It handles data translation, encryption/decryption, and compression.
The session layer is the network dialog controller. It establishes, maintains, and synchronizes the interaction between communicating systems.
The transport layer is responsible for process-to-process delivery of the entire message. It ensures that the whole message arrives intact and in order, overseeing both error control and flow control at the source-to-destination level. Protocols: TCP, UDP.
The network layer is responsible for the source-to-destination delivery of a packet, possibly across multiple networks (links). If two systems are connected to the same link, there is usually no need for a network layer. However, if the two systems are attached to different networks with connecting devices (routers) between them, the network layer accomplishes logical addressing (IP addresses) and routing. Protocols: IPv4, IPv6, ICMP.
The data link layer transforms the physical layer (a raw transmission facility) into a reliable link. It makes the physical layer appear error-free to the upper layer. It frames data and provides physical addressing (MAC addresses). Protocols: Ethernet, Wi-Fi (802.11).
The physical layer coordinates the functions required to carry a bit stream over a physical medium. It deals with the mechanical and electrical specifications of the interface and transmission medium (voltage levels, cable types, fiber optics).
While the OSI model is a fantastic theoretical tool for learning, the actual Internet does not strictly follow it. Instead, the Internet runs on the TCP/IP Protocol Suite, which was developed prior to the OSI model by the Department of Defense (DoD).
The TCP/IP model condenses the 7 OSI layers into 4 simpler layers:
Encapsulation: When you send an email, the message travels down the TCP/IP stack. At each layer, the protocol adds its own "Header" to the data. By the time it reaches the physical layer, your email text is wrapped in an HTTP header, a TCP header, an IP header, and an Ethernet frame header!