Skip to main content

Basics of OSI Model in networking

 The OSI (Open Systems Interconnection) model is a conceptual framework used to understand and standardize the functions of a telecommunication or computing system. It divides the process of networking into seven distinct layers, each responsible for specific tasks related to data transmission across a network. The OSI model was developed by the International Organization for Standardization (ISO) to help different networks and devices communicate with each other in a standardized way.




Here’s a brief overview:

Physical Layer: This is the foundation. It’s like the cables and the hardware that connect computers. Imagine the physical wires or the radio signals used for Wi-Fi.

Data Link Layer: This layer is responsible for making sure that the data gets from one point to another without errors. Think of it as the traffic cop that ensures data goes to the correct place on the same network.

Network Layer: This is where routing happens. It decides the best path for the data to travel from one device to another. Think of it as a map or GPS for your data.

Transport Layer: This layer ensures that the data is transferred completely and correctly. Imagine sending a long letter in several envelopes; this layer makes sure all the envelopes arrive and in the correct order.

Session Layer: This layer manages the sessions or connections between computers. It’s like a meeting coordinator who sets up, manages, and ends communication sessions.

Presentation Layer: This layer translates data between the application layer and the network. It’s like a translator that converts data into a format that the application layer can understand.

Application Layer: This is the layer you interact with directly. It’s like the software or application you use to send an email, browse the web, or stream a video.

Here's a table with an example for each OSI layer:

OSI LayerDescriptionExample
Physical LayerPhysical connection and transmission of raw dataEthernet cables, Wi-Fi signals
Data Link LayerError detection and correction, node-to-node data transferMAC addresses, Switches
Network LayerRouting of data packets, logical addressingIP addresses, Routers
Transport LayerEnsuring complete data transfer, flow controlTCP, UDP
Session LayerManaging sessions, establishing, and terminating connectionsSSL/TLS sessions, RPC (Remote Procedure Call)
Presentation LayerData translation, encryption, and compressionJPEG, MP3, encryption (e.g., SSL/TLS)
Application LayerEnd-user services, network process to applicationHTTP, FTP, Email clients (e.g., Gmail, Outlook)


Let's delve into what happens in each layer of the OSI model in terms of networking:

Physical Layer:

Function: Transmits raw bitstream over the physical medium (cables, radio frequencies, etc.).

Details: Converts digital data from the computer into electrical, radio, or optical signals. Determines the physical characteristics of the network (e.g., voltage levels, timing of voltage changes, physical data rates, maximum transmission distances, physical connectors, etc.).

Data Link Layer:

Function: Provides node-to-node data transfer and handles error detection and correction from the Physical Layer.

Details: Packages raw bits into frames (structured packets of data) and manages access to the physical medium. Uses MAC (Media Access Control) addresses to ensure data is sent to the correct device on the same local network. Implements error checking to ensure frames are transmitted and received without corruption.

Network Layer:

Function: Routes data packets between devices across different networks.

Details: Uses logical addressing (IP addresses) to identify devices on a network and determine the best path for data to travel across interconnected networks (routing). Handles packet forwarding, including routing through routers.

Transport Layer:

Function: Ensures complete and reliable data transfer between devices.

Details: Divides larger messages into smaller packets (segmentation) and ensures they are transferred reliably and in sequence using protocols like TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). Manages error detection and recovery, flow control, and data retransmission if necessary.

Session Layer:

Function: Manages and controls the connections between computers.

Details: Establishes, maintains, and terminates communication sessions between applications. Synchronizes data exchange by managing the flow of data and coordinating dialogue between the sending and receiving applications.

Presentation Layer:

Function: Translates data between the application layer and the network.

Details: Formats data to be presented to the Application Layer or to be sent over the network. Handles data encryption and decryption, data compression and decompression, and conversion of data formats (e.g., character encoding, data serialization).

Application Layer:

Function: Provides network services directly to end-user applications.

Details: Facilitates user interaction with the network by providing services such as email, file transfer, and web browsing. Implements protocols like HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol), and SMTP (Simple Mail Transfer Protocol).


OSI LayerDescriptionTroubleshooting Tools
Physical Layer
Transmission of raw bitstream over the physical medium
- Cable Testers (e.g., Fluke Networks Cable Tester)
- Multimeters
- Spectrum Analyzers
- NIC Diagnostics
Data Link Layer
Node-to-node data transfer, error detection and correction
- Network Analyzers/Packet Sniffers (e.g., Wireshark)
- Switch Port Analyzers
- MAC Address Tables
- Error Counters
Network Layer
Routing of data packets between devices
- Ping
- Traceroute/Tracert
- IP Address Management (IPAM) Tools
- Routing Tables
- Route Analyzers (e.g., netstat, route)
Transport Layer
Ensuring complete and reliable data transfer
- Port Scanners (e.g., Nmap)
- Connection Monitors (e.g., netstat, Wireshark)
- Bandwidth Testers (e.g., iPerf)
- Protocol Analyzers
Session Layer
Managing and controlling the connections
- Session Monitors (e.g., Wireshark session features)
- Session Logging Tools
- Session Management Software (e.g., Citrix Session Monitor)
Presentation Layer
Data translation, encryption, and compression
- Encryption/Decryption Tools (e.g., OpenSSL)
- Data Format Analyzers (e.g., JSON/XML validators)
- Compression Tools (e.g., gzip, WinRAR)
Application Layer
Network services to end-user applications
- Web Browsers
- API Testing Tools (e.g., Postman)
- Email Clients (e.g., Outlook)
- File Transfer Tools (e.g., FileZilla)
- Application Logs


Let's add more specific details like IP addresses, MAC addresses, and port numbers to the example of a browser accessing google.com, illustrating how each layer of the OSI model is involved:

  1. Application Layer:

    • Action: You type "google.com" into your web browser (e.g., Chrome, Firefox).
    • Details: The browser sends an HTTP/HTTPS request to Google's web server. This request includes the URL, headers, and possibly a message body if you are submitting a form.
  2. Presentation Layer:

    • Action: The data is prepared for transmission.
    • Details: The browser encrypts the data using SSL/TLS if HTTPS is used, ensuring secure communication. The encrypted request is now ready for transmission.
  3. Session Layer:

    • Action: Establishing and managing the session.
    • Details: The browser establishes a session with Google's server. This session might involve setting up SSL/TLS parameters if HTTPS is used.
  4. Transport Layer:

    • Action: Ensuring reliable data transmission.
    • Details: The data is segmented into TCP segments. Each segment includes a source port number (e.g., 54321) and a destination port number (e.g., 443 for HTTPS). TCP ensures that all segments arrive correctly and in order.
  5. Network Layer:

    • Action: Routing the data packets to the destination.
    • Details: The browser performs a DNS lookup to translate "google.com" to an IP address, for example, 142.250.190.14. Each TCP segment is encapsulated into an IP packet with your computer's IP address (e.g., 192.168.1.2) as the source and Google's IP address (142.250.190.14) as the destination.
  6. Data Link Layer:

    • Action: Framing the packets for physical transmission.
    • Details: Each IP packet is encapsulated into an Ethernet frame. The frame includes your computer's MAC address (e.g., 00:14:22:01:23:45) as the source and your router's MAC address (e.g., 00:1A:2B:3C:4D:5E) as the destination. If the packet traverses multiple network segments, each segment's Data Link Layer will update the frame's source and destination MAC addresses.
  7. Physical Layer:

    • Action: Transmitting the raw data over the physical medium.
    • Details: The Ethernet frames are converted into electrical signals (or radio waves for Wi-Fi) and transmitted over the network medium (e.g., Ethernet cable, fiber optics, Wi-Fi). These signals travel from your computer's NIC to your router, through various intermediate devices, and eventually reach Google's server.

Response from Google:

  1. Physical Layer: Google's server sends the response back as electrical signals (or light pulses, radio waves) over the network medium.
  2. Data Link Layer: The server frames the response data with its MAC address (e.g., 00:25:96:FF:FE:12) as the source and the next hop’s MAC address as the destination.
  3. Network Layer: The server sends the IP packets back with its IP address (e.g., 142.250.190.14) as the source and your IP address (e.g., 192.168.1.2) as the destination.
  4. Transport Layer: The server uses the source port 443 and the destination port that your browser used (e.g., 54321) to send the TCP segments.
  5. Session Layer: The server maintains the session to manage the data exchange.
  6. Presentation Layer: The server encrypts the response data using SSL/TLS if HTTPS is used.
  7. Application Layer: The server sends an HTTP/HTTPS response, including the requested webpage or data.

Summary:

  • Application Layer: Browser sends HTTP/HTTPS request to google.com.
  • Presentation Layer: Data is encrypted using SSL/TLS.
  • Session Layer: Session is established and managed.
  • Transport Layer: Data segmented into TCP segments with source port 54321 and destination port 443.
  • Network Layer: IP packets routed with source IP 192.168.1.2 and destination IP 142.250.190.14.
  • Data Link Layer: Ethernet frames created with source MAC 00:14:22:01:23:45 and destination MAC 00:1A:2B:3C:4D:5E.
  • Physical Layer: Frames transmitted as electrical signals over the network.

Comments

Popular posts from this blog

Ansible script to stop iptables

 Ansible script to stop iptables and disable during boot Step 1. [root@cluster playbooks]# pwd /root/playbooks [root@cluster playbooks]# cat hosts [webservers] 169.254.41.221 169.254.41.222 Step2. [root@cluster playbooks]# cat iptables.yml --- - name: stop ipatbles and disable   hosts: webservers   tasks:   - name: stop iptables     service: name=iptables state=stopped   - name: disbale on iptable on boot     service: name=iptables enabled=no Step3: [root@cluster playbooks]# ansible-playbook iptables.yml PLAY [stop ipatbles and disable] *********************************************** TASK [setup] ******************************************************************* ok: [169.254.41.222] ok: [169.254.41.221] ok: [localhost] TASK [stop iptables] *********************************************************** changed: [localhost] ok: [169.254.41.221] ok: [169.254.41.222] TASK [disbale on iptable on boot] ********************************************** ok: [169.254.41.222] changed: [localhost

Get information about remote hosts using Ansible

Get information about remote hosts using Ansible setup command Below command gives all the information of client hosts which includes memory, server architecture, IP adresses etc. [root@ansible mywork]# ansible all -i hosts -m setup If you need just memory information of remote node then for the above command need to add filter as shown below [root@ansible mywork]# ansible all -i hosts -m setup -a "filter=ansible_*_mb" node01 | SUCCESS => {     "ansible_facts": {         "ansible_memfree_mb": 873,         "ansible_memory_mb": {             "nocache": {                 "free": 919,                 "used": 77             },             "real": {                 "free": 873,                 "total": 996,                 "used": 123             },             "swap": {                 "cached": 0,                 "free": 15

connect: Network is unreachable

connect: Network is unreachable If you are getting below error, then probably you have not added gateway address or you have incorrect gateway in config file. [root@cluster ~]# ping google.com connect: Network is unreachable Before: [root@cluster ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3 DEVICE=eth3 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.174.130 NETMASK=255.255.255.0 After: [root@cluster ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3 DEVICE=eth3 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.174.130 NETMASK=255.255.255.0 GATEWAY=192.168.174.2 [root@cluster ~]# ifdown eth3 [root@cluster ~]# ifup eth3 Determining if ip address 192.168.174.130 is already in use for device eth3... [root@cluster ~]# ping google.com PING google.com (216.58.218.174) 56(84) bytes of data. 64 bytes from dfw06s46-in-f14.1e100.net (216.58.218.174): icmp_seq=1 ttl=128 time=261 ms 6