# Network models

The OSI model divides networking responsibilities into seven conceptual layers. It helps explain how an application message becomes signals on a network and how the receiver reconstructs it. The Internet is commonly described with the smaller TCP/IP model, so the correspondence is useful but not perfectly one-to-one.

OSI Reference Model and TCP/IP Conceptual Layers Seven numbered OSI layers are shown beside four grouped TCP/IP conceptual layers. OSI Model TCP/IP Model 7 Application HTTP, DNS, SMTP 6 Presentation TLS, JSON, XML, UTF-8 5 Session RPC, NetBIOS, SIP 4 Transport TCP, UDP, QUIC 3 Network IPv4, IPv6, ICMP 2 Data Link Ethernet, Wi-Fi, ARP 1 Physical Ethernet signals, radio Application HTTP, DNS, TLS Transport TCP, UDP, QUIC Network IPv4, IPv6, ICMP Network Interface Ethernet, Wi-Fi, radio

# 7. Application

The Application layer describes network services used directly by applications. HTTP/HTTPS serve web resources, DNS resolves names, SMTP transfers mail, and WebSocket provides a long-lived bidirectional channel. HTTP, introduced in the next section, is an Application-layer protocol.

# 6. Presentation

The Presentation layer concerns how data is represented, encoded, compressed, or encrypted. TLS, JSON, XML, UTF-8, JPEG, and PNG are commonly associated with these concerns. In real Internet stacks, one protocol can cover responsibilities from more than one OSI layer.

# 5. Session

The Session layer manages conversations: establishing, maintaining, and ending a logical communication session. RPC, NetBIOS, and SIP provide examples of session-oriented concerns, while TLS also has session-management concepts. Modern web development does not always expose a separate Session-layer protocol, so this layer is mainly a useful model.

# 4. Transport

The Transport layer provides communication between processes and uses ports to identify services. TCP provides ordered, reliable delivery; UDP is connectionless and has lower overhead; QUIC is a modern transport built on UDP and is used by HTTP/3. It can also provide flow control and congestion control.

# 3. Network

The Network layer moves packets between networks using logical addresses and routing. IPv4 and IPv6 provide addressing, while ICMP supports diagnostic and control messages. Routers primarily operate at this layer.

The Data Link layer moves frames between devices on the same local network. Ethernet and Wi-Fi (IEEE 802.11) are common examples, and MAC addresses identify network interfaces locally. ARP helps map IPv4 addresses to local MAC addresses.

# 1. Physical

The Physical layer transmits bit patterns as electrical signals in copper, optical signals in fiber, or modulated electromagnetic waves in radio communication. Wireless technologies use carrier frequencies and encode data by changing properties such as amplitude, phase, or frequency. Copper and fiber cables, Wi-Fi radio waves, connectors, and network hardware are examples of physical-layer concerns; this layer does not interpret HTTP or IP data.

# Encapsulation and decapsulation

When a sender transmits an HTTP request, data moves down the protocol stack. Each layer receives the payload from the layer above and adds information needed for its own job; this process is called encapsulation.

For a simplified GET /articles/42 request:

  1. The Application layer creates the HTTP request.
  2. Presentation concerns represent, encode, compress, or encrypt the data when applicable.
  3. The Session layer manages the logical conversation where session behavior exists.
  4. Transport adds ports and delivery information, producing a TCP segment or a UDP/QUIC datagram.
  5. Network adds source and destination IP addresses, producing a packet.
  6. Data Link adds local MAC addresses and frame-delivery/error-detection information, producing a frame.
  7. Physical transmits the frame as electrical, optical, or radio signals.

The nesting is often illustrated like this:

Data Link frame
└─ Network packet
   └─ Transport segment/datagram
      └─ Application data: HTTP request

The names are useful but not universal: a TCP protocol data unit is commonly called a segment, UDP and QUIC units are commonly called datagrams, and exact headers/trailers depend on the protocol. Presentation and Session concerns may be implemented inside libraries or application protocols rather than as separate network packets.

At the receiver, the reverse process is decapsulation. The Physical layer reconstructs bits, Data Link checks and removes its frame information, Network processes the IP information, and Transport delivers the payload to the correct port. The upper layers then decode, decrypt, and process the payload until the HTTP server receives GET /articles/42.

Routers primarily use Network-layer information to forward packets, while local switches use Data Link information to forward frames. Neither device needs to interpret the complete HTTP body to perform its basic forwarding task.

# OSI and TCP/IP mapping

TCP/IP groups several OSI responsibilities:

OSI model TCP/IP model Examples
Application, Presentation, Session Application HTTP, DNS, TLS, JSON
Transport Transport TCP, UDP, QUIC
Network Internet IPv4, IPv6, ICMP
Data Link, Physical Link / Network access Ethernet, Wi-Fi, cables, radio

These labels are educational mappings rather than strict protocol boundaries. A protocol such as TLS can be discussed using Presentation and Session concepts, while the TCP/IP stack does not require separate implementations for those OSI layers.

# From a URL to a response

For https://example.com/articles?id=42, DNS resolves example.com, the lower layers establish a route and connection, TLS protects the HTTPS communication, and HTTP carries the request and response. The receiver processes the data in the reverse direction, from physical signals up to the application that handles HTTP.

Each lower layer wraps the data received from the layer above with its own information. The result is a nested protocol data unit: the original HTTP message remains inside the larger transport, network, data-link, and physical-layer representation.

Protocol encapsulation Each row adds layer-specific rectangles to the left and right of the existing payload. Protocol encapsulation Application HTTP data Presentation encoding HTTP data Session session encoding HTTP data Transport T header session encoding HTTP data T trailer Network IP header HTTP data IP trailer Data Link DL header HTTP data DL trailer Physical HTTP data Each layer adds a header and, when applicable, a trailer around the existing payload. The receiver removes these additions in reverse order during decapsulation.