How Data Travels β From Wires to APIs
"Every time you load a webpage, send a message, or stream a video β data travels across networks. But how does it actually move?"
To understand that, we use the OSI model β a layered framework that breaks down communication into 7 steps. Each layer has a job. Together, they make the internet work.
For system design, we focus mostly on Layer 3 (Network), Layer 4 (Transport), and Layer 7 (Application)
User-facing protocols (HTTP, etc.)
Data formatting and encryption
Start, manage, and end sessions
Reliable or fast delivery (TCP/UDP)
Routing and addressing (IP)
Frame transmission over local network
Electrical signals and hardware
The foundation β raw bits, cables, and electrical signals
Analogy: It's the roads and highways β the actual physical infrastructure that carries everything.
Local network traffic controller β manages frames within the same network
Analogy: It's the local postal service β handling delivery within your neighborhood using house addresses.
Connects different networks and ensures data reaches the correct destination
Analogy: It's the GPS system β figuring out how to get data from your device to a server across the world.
Decides how data is delivered β reliably or quickly β depending on the use case
Analogy: It's the delivery truck β deciding whether to guarantee delivery (TCP) or send it quickly without confirmation (UDP).
Connection manager β establishes, maintains, and terminates conversations
Analogy: It's the meeting coordinator β scheduling, managing, and ending conversations between apps.
Data translator and security guard β formats, encrypts, and compresses data
Analogy: It's the translator and security checkpoint β making sure data is in the right format and secure.
Where developers interact β designing APIs, sending requests, building user-facing systems
Analogy: It's the spoken language between apps β the actual content of the message.
Step-by-step journey from your chat app to your friend's phone
π¦ When you send a "Hi" message, it travels down the OSI layers on your device, across the network, and back up the layers on the receiver's device.
User clicks 'Send' on chat app
App creates HTTP/WebSocket request with 'Hi' message
Message encoded and encrypted
JSON formatting + TLS encryption applied
Session established
TLS handshake completed, conversation tracked
Message split into segments
TCP adds headers for sequencing and port numbers
Wrapped in IP packet
IP header with source/destination addresses added
Encapsulated in frame
MAC addresses and error detection codes added
Converted to signals
Electrical signals sent through cables/wireless
Signal received
Electrical/wireless signals converted back to data
Frame extracted
MAC addresses checked, error detection verified
IP packet read
Destination IP confirmed, packet forwarded up
Segments reassembled
TCP reorders segments, acknowledges receipt
Session resumed
Conversation state maintained
Message decrypted & decoded
TLS decryption, JSON parsing applied
Message delivered to app
'Hi' message appears in chat interface
The encapsulated message travels through routers, switches, and cables to reach the destination
Think of each layer as wrapping the message in a new box
The message itself
Format and lock the box
Track the delivery
Choose delivery method
Add address label
Add building routing
Send down the wire
Key Insight: Each layer adds a header β like a label or instruction β to help the message reach its destination and be understood.
"Understanding the OSI model helps you reason about every part of system communication β from physical cables to APIs."
And as we move forward in this course, we'll explore how these layers shape load balancing, transport protocols, and global delivery.