Open Systems Interconnection Reference Model and Data Transmission

Open Systems Interconnection Reference Model (OSI)

The OSI model is a conceptual framework that standardizes how data is transmitted over a network. It divides networking into 7 layers, where each layer has a specific responsibility during the transmission of the message through network.

OSI LayerLayer NameFunction (Simple)Protocol Data Unit (PDU)
7ApplicationUser-level network services (HTTP, SSH)Data
6PresentationData formatting, encryption, compressionData
5SessionManages sessions/communication stateData
4TransportEnd-to-end delivery (TCP/UDP, ports)Segment (TCP) / Datagram (UDP)
3NetworkRouting between machines (IP)Packet
2Data LinkLocal delivery (MAC, Ethernet, Wi-Fi)Frame
1PhysicalRaw bit transmission over mediumBits

How data flows through OSI

When you send data (e.g., using curl):

Application (HTTP / HTTPS / SSH request)

    ├── Socket (IP + Port → identifies target application)

    ├── Application Protocol (HTTP structure, headers, methods)


Presentation Layer (data formatting / encryption / compression)

    ├── TLS encryption (for HTTPS)

    ├── Encoding (JSON, UTF-8, serialization)


Session Layer (manages communication state / dialogue)

    ├── Session establishment (login / session ID)
    ├── Session maintenance (keep-alive / continuity)
    ├── Session termination (logout / timeout)


Transport Layer (TCP / UDP → process-to-process delivery)

    ├── TCP/UDP headers (ports: source & destination)
    ├── Reliability (TCP: ordering, retransmission)
    ├── Unit: Segment / Datagram

    ├── Socket connection = (Src IP, Src Port, Dst IP, Dst Port)


Network Layer (IP → machine-to-machine routing)

    ├── IP addresses (source / destination)
    ├── Routing table (decides next hop)
    ├── Subnets (network segmentation)
    ├── Gateways (router entry/exit point)
    ├── Unit: Packet


Data Link Layer (MAC → local network delivery)

    ├── MAC addresses (device identity in LAN)
    ├── Ethernet / Wi-Fi frames (encapsulation unit)
    ├── ARP (IP → MAC resolution)
    ├── Switch forwarding (LAN delivery)
    ├── Unit: Frame


Physical Layer (raw transmission medium)

    ├── Electrical signals / radio waves / fiber optics
    ├── Bit transmission (0s and 1s)
    ├── Encoding into physical signals

At the receiver, the process is reversed.


Layer 7 — Application Layer

Defines how applications communicate over a network, including the structure and semantics of exchanged data. For example: HTTP / HTTPS (web communication), SSH (remote login), and DNS (name resolution).

Layer 6 — Presentation Layer

Responsible for data formatting, serialization, and encryption prior to transmission. For example, in HTTPS, data is encrypted using TLS, and application data is typically encoded or serialized (e.g., JSON, UTF-8) before being sent to lower layers.

Layer 5 — Session Layer

Session Layer is responsible for establishing, managing, and terminating sessions (dialogues) between applications. It handles the long-term interaction relationship between two applications, rather than single packet transmission. In modern application, it is often implemented in the application layer like HTTP session (JWT, cookie, session ID)

Layer 4 — Transport Layer (TCP / UDP)

Define how information through the network. Responsible for end-to-end transimission between processes. Uses source and destination ports to identify specific applications on a machine, enables multiple services to run on the same IP address simultaneously. The commonly used protocols are TCP and UDP.

Transmission Control Protocol (TCP)

TCP is a reliable, connection-oriented transport protocol used to ensure accurate and ordered delivery of data between applications. It establishes a connection before data transfer and maintains communication state throughout the session.

  • Key characteristics:
    • Connection-oriented (requires handshake before data transfer)
    • Reliable delivery (retransmits lost packets)
    • Ordered data stream (preserves sequence)
    • Flow control & congestion control
    • Uses source and destination ports for process-to-process communication
  • Typical use cases:
    • Web browsing (HTTP/HTTPS)
    • SSH remote login
    • File transfer (FTP, SCP)

User Datagram Protocol (UDP)

UDP is a lightweight, connectionless transport protocol designed for fast transmission with minimal overhead. It sends data without establishing a connection and does not guarantee delivery, ordering, or duplication protection.

  • Key characteristics:
    • Connectionless (no handshake)
    • No delivery guarantee
    • No ordering guarantee
    • Very low overhead (fast)
    • Uses source and destination ports
  • Typical use cases:
    • DNS queries
    • Video streaming
    • Online gaming
    • VoIP (voice calls)

Port

A Port is a logical number used to identify a specific service running on a machine. While an IP address identifies a device, a port identifies a process or application on that device.

Example:

192.168.1.10:80
  • 192.168.1.10 → IP Address (device)
  • 80 → Port (web server service)

Commonly Ports

ServicePort
HTTP80
HTTPS443
SSH22
DNS53
Node Dev3000
PostgreSQL5432
MongoDB27017
Redis6379
Ollama11434
vLLM8000

Socket

A Socket is the combination of IP Address, Port and Protocol. It represents a complete endpoint for communication.

Example Socket:

192.168.1.10:8080 (TCP)

Layer 3 — Network Layer (IP)

Defines how data is transmitted between machines across different networks. Responsible for routing and forwarding packets from source to destination by determining the best path through interconnected networks. It specifies:

  • IP addresses for identifying source and destination machines globally
  • Routing tables for deciding the next hop in packet forwarding
  • Subnets for dividing and organizing IP address spaces into network segments
  • Gateways (routers) as the entry/exit points between different networks

Packet

A Packet is the basic unit of data transmitted over a network. When data is sent across the Internet, it is split into small pieces (packets), sent individually, and reassembled at the destination. Each packet typically contains:

  • Header (metadata used for routing and delivery)
    • Source IP Address
    • Destination IP Address
    • Transportation Protocol (TCP/UDP)
    • Packet sequence number
    • Time To Live (TTL)
  • Payload (actual data)

Check the packet sent and received using tcpdump

sudo tcpdump -i eno1 -X -nnvv

One can use WireShark to monitor the packet sent.

Routing Table

A routing table is a set of rules that determines where network packets should be sent. In other words, it tells the system:If you want to reach this IP range, send traffic to this gateway or interface.”

View Routing Table in Linux

ip route

Example Output

default via 192.168.1.1 dev wlp2s0
192.168.1.0/24 dev wlp2s0 proto kernel
10.0.0.0/8 via 192.168.1.1

Interpretation

RuleMeaning
default via 192.168.1.1Send all unknown traffic to gateway
192.168.1.0/24Local subnet reachable directly
10.0.0.0/8 via …Route through gateway for private network

How Routing Works

When sending a packet:

Destination IP → Routing Table Lookup

        ├── Match subnet → direct send
        ├── No match → use default gateway

Network Address Translation (NAT)

When a packet leaves a private network, a router may perform Network Address Translation (NAT) by replacing the packet’s private IP address with its public IP address. In most home networks, the router also translates the source port (PAT), allowing multiple devices to share a single public IP address. NAT enables devices with private IP addresses to communicate with the Internet while conserving public IPv4 addresses.

  • Source NAT (SNAT/PAT): Home router, Cloud NAT, AWS NAT Gateway (outbound)
  • Destination NAT (DNAT): Router port forwarding, Kubernetes Services, Docker -p (inbound)

Examples

Internet router

Laptop
192.168.1.10

Phone
192.168.1.20



Home Router (NAT)
Public IP: 203.0.113.10


Internet

Port forwarding: allows external users to access services running inside a private network.

Internet
203.0.113.10:443


Home Router
Forward TCP 443


192.168.1.100:443
Web Server

Outbound HTTP Request through NAT

Suppose your laptop sends an HTTPS request to Google.

Application
curl https://google.com


TCP
Source Port      : 52344
Destination Port : 443


IP
Source IP        : 192.168.1.10
Destination IP   : 142.250.190.14


Home Router (NAT)

NAT Translation Table
──────────────────────────────────────────────
192.168.1.10:52344


203.0.113.10:61001
──────────────────────────────────────────────

Rewritten Packet

Source IP        : 203.0.113.10
Source Port      : 61001
Destination IP   : 142.250.190.14
Destination Port : 443


Internet


Google Server
142.250.190.14:443

Return Traffic

Google replies:

Source      : 142.250.190.14:443
Destination : 203.0.113.10:61001


Home Router


Lookup NAT Table

203.0.113.10:61001


192.168.1.10:52344


Laptop

Defines device-to-device communication within the same local network (LAN). Responsible for local delivery of data by using Layer 2 addressing and framing mechanisms. It works as follows:

  1. An IP packet (from Layer 3) is passed down to Layer 2
  2. The IP packet is encapsulated into an Ethernet or Wi-Fi frame, which will be used for local transmission.
  3. If the destination IP is in the same subnet, resolved the destination MAC using address resolution protocol (ARP), otherwise uses the gateway MAC (send the frame to the gateway, which will be/have been processed by Layer 3)
  4. The frame is sent using:
    • Source MAC address (your device)
    • Destination MAC address (resolved via ARP or gateway MAC)
    • Delivered directly over the local network (switch/Wi-Fi AP)

Layer 1 — Physical Layer

Responsible for raw bit transmission though changes of physical properties, such as electrical signals, Wi-Fi radio waves or fiber optics.

Related articles

Network Interfaces and IP Address Fundamentals

A Network Interface is the connection point between a computer and a network. It is the operating system's abstraction of a network adapter, allowing applications to send and receive network traffi…

Training

HTTP Protocol (HyperText Transfer Protocol)

Defines how clients (e.g., browsers) and servers communicate using a stateless request–response model. HTTP is an application-layer protocol that runs on top of TCP. HTTP follows a simple cycle: A …

Training

Transport Layer Security (TLS)

TLS is a cryptographic protocol used to secure communication over a network. It is most commonly used in HTTPS, where it encrypts data between a client (browser) and a server. TLS ensures that data…

Training

Secure Shell Protocol (SSH)

SSH is a cryptographic network protocol used to securely access and manage remote computers over an unsecured network. It is commonly used for remote server administration, file transfer, and secur…

Training