CodewCaro.

The OSI Model: 7 Layers of Networking - How to 'Internet'

Caroline Cah
Caroline Cah

The OSI (Open System Interconnection) model is a framework that standardizes the functions of a telecommunication or computing system into seven layers. This model helps network engineers and, others curious, understand how data travels across networks and how different network protocols interact. In this article, we will learn about the 7 layers of the OSI model.


Why would I care about some really oooold technology?


Well without it, we would still be talking through tin cans and a string.


And also, it's easy to fall into the "of course I know about basic communication of the internet. I have that in the back of my mind.. somewhere..". That was me up until recently when I started a new role where networking actually is a core in the product teams deliverable. As a smart dude in Greece once said "the true wisdom is knowing you know nothing".


Layer 1: The Physical Layer


The physical layer is the first and lowest layer in the OSI model. It is responsible for the physical transmission of raw data across a communication channel, which could be a wire, cable, or wireless signal. Essentially, this layer defines the hardware elements of the network, including voltage levels, cable types, and signaling methods. The main objective of the Physical Layer is to ensure that data is transmitted accurately and reliably between hardware devices.


In practical terms, this layer deals with everything from the actual physical connection (like Ethernet cables or fiber optics) to the electrical impulses or radio signals that represent data. The Physical Layer is where the raw data is transformed into signals that can be transmitted over the medium, whether it's a stream of light pulses, electrical signals, or radio waves.


Layer 2: The Data Link Layer


Moving up from the physical layer, we reach the data link layer, which is responsible for ensuring reliable data transfer between two nodes on the same network segment. This layer establishes and terminates connections between devices, handles error detection and correction, and manages how data is framed and transmitted.


In a local network (such as a home or office network), Ethernet is a common protocol used at this layer. The data link layer introduces a unique hardware address known as the MAC (Media Access Control) address. A MAC address is a 48-bit identifier assigned to a network interface card (NIC) by the manufacturer, making it globally unique. This address is crucial for directing data to the correct device on a local network.


At this layer, data is encapsulated into frames. A frame is like a container for data, including several components:


Preamble: Indicates the start of the frame.


Destination and Source MAC Addresses: Directs the data to its intended recipient and identifies the sender.


Ethertype: Specifies the protocol used in the next layer (Layer 3).


Payload: The actual data being transmitted, ranging from 46 to 1500 bytes.


Frame Check Sequence (FCS): A CRC check to ensure data integrity.


The Data Link Layer's primary function is to facilitate communication between devices on the same network segment, ensuring data is correctly packaged, addressed, and sent to the appropriate location.


Layer 3: The Network Layer


The network layer is where the magic of routing and addressing happens. While Layer 2 deals with local network communication, the network layer is responsible for moving data between different networks, which is essential for communication over larger distances, such as across cities, countries, or even continents.


One of the primary protocols operating at this layer is the Internet Protocol (IP), which assigns IP addresses to devices on a network. IP addresses are crucial for routing data across multiple networks. When data is sent from one device to another, it's encapsulated in an IP packet, which contains the source and destination IP addresses, among other information.


Why is layer 3 important?


Imagine you have two separate Local Area Networks (LANs)— one on the east coast of Sweden and another on the west coast. Devices on each LAN can communicate within their own network, but not with devices on the other network. To connect these two LANs, you could set up a dedicated point-to-point link, but this would be expensive and impractical, especially over long distances.


This is where the network layer and IP come into play. By using IP, data can be routed across multiple networks, allowing devices on one LAN to communicate with devices on another LAN, even if they're far apart. Routers, which operate at Layer 3, play a crucial role in this process. They remove the frame encapsulation from the data, inspect the IP packet, and then encapsulate it in a new frame appropriate for the next network segment.


In conclusion, the network layer enables the creation of large, interconnected networks (like the internet) by allowing data to be transmitted across different network segments and technologies, ensuring that it reaches its final destination, no matter where that might be geographically.


IP Packet Structure


IP packets are the units of data transfer at the network layer. An IP packet is structured of:


Version: Indicates the IP version (IPv4 or IPv6).


Header Length: Specifies the length of the header.


Type of Service (ToS): Indicates how the packet should be handled (i.e, prioritization).


Total Length: Specifies the entire packet size, including header and data.


Identification, Flags, Fragment Offset: Used for fragmenting and reassembling packets.


Time to Live (TTL): Limits the packet's lifespan to prevent it from circulating indefinitely.


Protocol: Indicates the protocol used in the data portion of the packet (i .e, TCP or UDP).


Header Checksum: Ensures the header's integrity.


Source IP Address: Identifies the sender.


Destination IP Address: Identifies the recipient.


Options: Optional fields for additional functionality.


Layer 4: The Transport Layer


This layer is like that reliable friend who ensures your important messages get through, even when the path is bumpy. It’s all about making sure data is transferred efficiently, accurately, and in the right order, so you don’t end up with scrambled or missing information.


Components of layer 4


Segmentation:


When data is sent across a network, it’s often too large to be transmitted in one go. The Transport Layer breaks this data into smaller segments, each of which can be transmitted individually. Upon reaching the destination, these segments are reassembled into the original data, ensuring that the application receives the information in its entirety.


Flow control:


The Transport Layer manages the rate at which data is sent. This prevents a fast sender from overwhelming a slower receiver, ensuring that data transmission is smooth and consistent.


Error detection and correction


The Transport Layer adds a checksum to each segment of data, allowing the receiving device to detect any errors that may have occurred during transmission. If errors are detected, this layer can request the retransmission of faulty segments, ensuring data integrity.


Connection


Protocols like TCP (Transmission Control Protocol) establish and maintain connections between devices. TCP ensures that data is reliably transferred between devices, managing the connection setup, data transfer, and connection termination processes.


TCP and UDP protocols


TCP: A reliable, connection-oriented protocol that guarantees the delivery of data in the correct order, without any loss or duplication.


UDP (User Datagram Protocol): A connectionless protocol that does not guarantee delivery or order, but offers faster transmission, making it ideal for applications like streaming or online gaming, where speed is more critical than reliability.


Layer 5: The Session Layer


The session layer could be resembled as a host or event manager, it ensures that communication sessions between devices or applications are established, maintained, and properly exited when no longer needed. This layer is particularly important for managing multiple communication streams, ensuring that they don’t interfere with each other.


Layer 6: The Presentation Layer


The presentation layer acts as the translator of the OSI model, converting data from one format to another so that it can be correctly understood by different systems and applications. This layer is crucial for ensuring that data is presented in a usable format, regardless of differences in data representation between the sending and receiving systems.


Functions of the Presentation Layer


Data translation: The Presentation Layer converts data into a format that the application layer of the receiving system can understand. For example, it might translate between different character encoding systems, such as converting text from ASCII to EBCDIC.


Data encryption and decryption: the presentation layer can encrypt data before it’s sent over the network and decrypt it upon arrival, ensuring that the information remains secure and private during transmission.


Data compression: to optimize bandwidth and reduce transmission times, the presentation layer can compress data before it’s sent. This layer also decompresses data on the receiving end, restoring it to its original format.


Protocol examples


SSL/TLS: Secure Sockets Layer and Transport Layer Security are protocols that provide encrypted communication, often used in secure web browsing (HTTPS).


Layer 7: The Application Layer


The application layer is what is the closest layer of us users in the OSI model. It provides fancy frontend interfaces through applications can access network services. Important though to say is that this layer doesn’t refer to the applications themselves but rather the protocols and services that enable communication between software applications across a network.


Protocol examples

HTTP (HyperText Transfer Protocol): The foundation of data communication for the World Wide Web.


FTP (File Transfer Protocol): Used for transferring files between a client and server on a network.


SMTP (Simple Mail Transfer Protocol): Used for sending emails.


DNS (Domain Name System): Translates domain names (like ) into IP addresses that computers can understand.


Summary


So, there you have it, the seven layers of the OSI model, from the physical cables and bits all the way up to the applications we use every day. Each layer plays a crucial role in ensuring data moves smoothly and securely from one point to another, whether it’s across the room or across the globe. Understanding these layers isn’t just for networking pros; it’s essential knowledge for anyone who wants to get a brief understanding of the inner workings of the internet and modern communication. Sort of like to know your future you must know your past.

More posts