Sub topic 2
Layers 3–6: Network, Transport, Session, and Presentation
Assume you know what IP addresses, web servers, and routers are. This chapter focuses on how the middle OSI layers move data, manage conversations, and represent information.
Layer 3: Network, IP addressing, and routing
The network layer moves packets between different networks. An IP address identifies a source or destination interface. A router reads the destination IP address and selects a path using its routing table.
An IP packet normally contains source and destination IP addresses. Layer 3 does not guarantee delivery, ordering, or duplicate protection. Those responsibilities may belong to Layer 4.
A subnet is a group of IP addresses treated as one network. The subnet mask tells a host which part of an address identifies the network. If the destination is outside the local subnet, the host sends the packet to its default gateway, usually a router.
Layer 4: Transport, TCP, UDP, and ports
The transport layer delivers data to the correct application on a host. A port is a numbered endpoint for a service.
- TCP is connection-oriented. It establishes a connection, acknowledges data, retransmits losses, and preserves order.
- UDP is connectionless. It adds little overhead and does not guarantee delivery or order.
For example, a web server commonly listens on TCP port 443 for HTTPS. IP identifies the host; the port identifies the service on that host.
Layer 5: Session, managing dialogues
The session layer manages a continuing dialogue between applications. It can establish, maintain, synchronize, and end a session. In modern networks, session functions are often combined with application protocols or libraries rather than implemented as a separate protocol.
Layer 6: Presentation, encoding, encryption, and compression
The presentation layer defines how data is represented. Encoding converts data into a shared format, such as UTF-8 text or JSON. Encryption protects confidentiality and integrity. Compression reduces size.
TLS is commonly described as providing presentation and session functions, although it does not map perfectly to one OSI layer.
Exercise
A host can reach an IP address, but a TCP connection to port 443 fails. Which layer should you investigate first?
Show answer
Layer 4. Check whether the service is listening, whether a firewall blocks TCP port 443, and whether the connection handshake succeeds.