Computer Networks Level 1 Fundamentals¶
Level 1 fundamentals for computer networks including the OSI model and TCP/IP.
1. OSI Model¶
1.1 Why Need Layers¶
Network communication involves many different responsibilities:
- Creating application data
- Representing/formatting data
- Managing communication sessions
- Providing reliable/end-to-end delivery
- Identifying destination networks
- Delivering data on a local network
- Physically transmitting bits
If one protocol handled everything, networking would become extremely complicated.
Therefore, networking is divided into layers, where each layer has a specific responsibility.
The OSI (Open Systems Interconnection) model is a 7-layer reference model used to understand these responsibilities.
2. The 7 OSI Layers¶
From top to bottom:
| Layer | Name | Main Responsibility | Data Unit |
|---|---|---|---|
| 7 | Application | Network services used by applications | Data |
| 6 | Presentation | Data representation, encryption, compression | Data |
| 5 | Session | Session/communication management | Data |
| 4 | Transport | End-to-end/process-to-process delivery | Segment / Datagram |
| 3 | Network | Logical addressing and routing | Packet |
| 2 | Data Link | Local/node-to-node delivery | Frame |
| 1 | Physical | Transmission of raw bits | Bits |
Mnemonic:
All People Seem To Need Data Processing
Bottom-up:
Please Do Not Throw Sausage Pizza Away
Understanding the responsibilities is more important than memorizing the mnemonic.
3. Physical Layer¶
Main responsibility:
The Physical layer handles the actual transmission of raw bits over a physical medium.
Example:
101101001010...
These bits are represented using physical signals.
Depending on the technology, these can be:
- Electrical signals
- Radio waves
- Light signals
Examples:
Ethernet:
Computer
↓
Electrical signals
↓
Ethernet cable
↓
Switch
Wi-Fi:
Computer
↓
Radio waves
↓
Wi-Fi Access Point
Things associated with Physical Layer:
- Cables
- Fiber optic
- Radio transmission
- Connectors
- Signal levels
- Bit transmission
- Physical transmission medium
- Data rate
The Physical layer does not understand:
- IP addresses
- MAC addresses
- TCP
- HTTP
It deals with the physical transmission of bits.
Data unit:
Bits
4. Data Link Layer¶
The Data Link layer handles node-to-node/local-network communication.
It provides structure to the raw bits received from the Physical layer.
Main responsibilities:
- Framing
- MAC addressing
- Local delivery
- Error detection
- Medium access control
Data unit:
Frame
Conceptually:
┌──────────────┬──────────────┬───────────┐
│ Frame Header │ Data │ Trailer │
└──────────────┴──────────────┴───────────┘
4.1 MAC Address¶
A MAC address identifies a network interface at the Data Link layer.
Example:
00:1A:2B:3C:4D:5E
4.2 Switch¶
A traditional Ethernet switch primarily operates at Layer 2.
It uses MAC addresses to determine where to forward frames.
PC A
↓
Switch
↓
PC B
Important:
Traditional switch → Layer 2
Layer 3 switch → can also perform Layer 3 routing
5. Network Layer¶
The Network layer handles communication between different networks.
Example:
Laptop
↓
Router
↓
Router
↓
Server
The Network layer is responsible for:
- Logical addressing
- Routing
- Packet forwarding between networks
The major protocol is:
IP — Internet Protocol
5.1 IP Address¶
Example:
192.168.1.10
Data unit:
Packet
5.2 Router¶
A router primarily operates at Layer 3.
It uses the destination IP address and its routing table to determine where the packet should be forwarded.
6. Transport Layer¶
The Transport layer provides end-to-end/process-to-process communication.
A computer can run many applications simultaneously:
Server
├── Web server
├── SSH
├── Database
└── Other applications
The Transport layer helps identify the correct application/process using port numbers.
Major protocols:
- TCP
- UDP
Responsibilities:
Depending on the protocol:
- End-to-end delivery
- Process-to-process communication
- Port numbers
- Reliability
- Ordering
- Flow control
- Congestion control
- Error recovery
Example:
Destination IP + Port
142.250.x.x : 443
The IP address identifies the destination machine/network interface, while the port identifies the destination service/process.
Data units:
TCP:
Segment
UDP:
Datagram
7. Session Layer¶
The Session layer deals with managing communication sessions/dialogues between applications.
Conceptually:
Establish session
↓
Communication
↓
Manage/synchronize session
↓
Terminate session
Responsibilities traditionally associated with this layer include:
- Session establishment
- Session management
- Session termination
- Synchronization/checkpoints
Important practical point:
Modern Internet protocols do not always map cleanly to a separate Session layer.
The OSI model is a reference/conceptual model, so don't assume every modern application literally has a separate Session-layer protocol.
For interviews:
Session layer = management of communication sessions/dialogues.
8. Presentation Layer¶
The Presentation layer deals with how data is represented.
Think:
"How should the data be represented so that communicating systems can understand it?"
Traditionally associated with:
1. Translation / encoding:
Converting between different data representations.
2. Encryption / decryption:
Plaintext
↓
Encryption
↓
Ciphertext
3. Compression / decompression:
Large data
↓
Compression
↓
Smaller data
Therefore:
Presentation = representation of data
Encryption and compression are traditionally associated with Layer 6 in the OSI model.
9. Application Layer¶
The Application layer is closest to applications and provides network services/protocols used by them.
Examples:
- HTTP
- DNS
- SMTP
- FTP
Example:
GET /index.html
HTTP is an Application-layer protocol.
Important distinction:
The application itself is not necessarily an "Application-layer protocol."
For example:
- Chrome = application
- HTTP = Application-layer protocol used by applications
10. Important Layer Identifiers¶
One of the most useful interview mappings:
MAC address → Layer 2
IP address → Layer 3
Port number → Layer 4
Think:
MAC → local delivery
IP → routing/destination network
Port → destination process/service
11. Devices And Layers¶
Switch:
Traditional Ethernet switch:
Layer 2 → uses MAC addresses
Router:
Router:
Layer 3 → uses IP addresses for routing
Layer 3 Switch:
Can perform both:
- Layer 2 switching
- Layer 3 routing
12. OSI Reference Model¶
Do not say:
"The Internet follows the OSI model exactly."
Instead:
OSI is a reference/conceptual model for understanding network communication.
The Internet primarily uses the TCP/IP protocol suite/architecture.
13. TCP IP Model¶
13.1 Why TCP IP¶
The Internet was developed around the TCP/IP protocol suite.
A commonly taught TCP/IP model has 4 layers:
4. Application
3. Transport
2. Internet
1. Network Access / Link
14. TCP IP Application Layer¶
The TCP/IP Application layer combines three OSI layers:
OSI:
Application
Presentation
Session
↓
TCP/IP:
Application
Protocols such as:
- HTTP
- DNS
- SMTP
- FTP
belong to the TCP/IP Application layer.
Important:
TCP/IP does not require the strict separation of Application, Presentation, and Session that OSI defines.
15. TCP IP Transport Layer¶
This corresponds directly to the OSI Transport layer.
Major protocols:
- TCP
- UDP
Responsibilities include:
- Process-to-process communication
- Port numbers
- Reliability
- Ordering
- Flow control
- Congestion control
16. TCP IP Internet Layer¶
This corresponds primarily to the OSI Network layer.
Major protocol:
IP
Responsibilities:
- Logical addressing
- Routing
- Packet forwarding
Source IP → Destination IP
A router primarily operates here for routing purposes.
OSI calls this:
Network layer
TCP/IP calls this:
Internet layer
17. TCP IP Link Layer¶
This layer combines the responsibilities represented by:
OSI Data Link
+
OSI Physical
It deals with:
- Frames
- MAC addresses
- Local delivery
- Physical transmission
- Network media/access
Examples:
- Ethernet
- Wi-Fi
Depending on the textbook, this layer may be called:
- Network Access layer
- Link layer
18. OSI TCP IP Mapping¶
OSI TCP/IP
────────────────────────────────────────
Application ┐
Presentation ├──────→ Application
Session ┘
Transport ───────→ Transport
Network ───────→ Internet
Data Link ┐
Physical ┴──────→ Network Access / Link
Important mapping:
| OSI | TCP/IP |
|---|---|
| Application | Application |
| Presentation | Application |
| Session | Application |
| Transport | Transport |
| Network | Internet |
| Data Link | Network Access / Link |
| Physical | Network Access / Link |
19. Why TCP IP Fewer Layers¶
TCP/IP doesn't require the same strict separation as OSI.
For example:
OSI:
Application
Presentation
Session
becomes:
TCP/IP:
Application
Similarly:
OSI:
Data Link
Physical
is commonly represented as:
TCP/IP:
Network Access / Link
The point is not that fewer layers automatically makes TCP/IP "better."
The two models simply use different abstractions.
20. TCP IP Scope¶
A common misconception:
TCP/IP = TCP + IP
This is incorrect.
TCP/IP refers broadly to the Internet protocol suite.
Examples:
Application:
- HTTP
- DNS
- SMTP
- FTP
Transport:
- TCP
- UDP
Internet:
- IP
- ICMP
Link:
- Ethernet
- Wi-Fi
TCP and IP are important protocols in the suite, but TCP/IP is not literally limited to those two protocols.
21. 4 Layer Vs 5 Layer¶
You may encounter two versions.
4-layer version:
Application
Transport
Internet
Network Access / Link
5-layer teaching model:
Application
Transport
Network
Data Link
Physical
The 5-layer version separates the TCP/IP Link/Network Access layer into:
Data Link
Physical
This is often done to make networking concepts easier to teach and to compare with OSI.
Don't get confused by the terminology.
Focus on the responsibilities and mapping.
22. Encapsulation¶
Encapsulation is the process in which data moves down the networking layers and each layer adds its own control information.
Suppose the application produces:
Hello
22.1 Application¶
Application Data
= "Hello"
22.2 Transport¶
Suppose TCP is being used.
TCP adds a TCP header:
┌──────────────┬──────────────┐
│ TCP Header │ Application │
│ │ Data │
└──────────────┴──────────────┘
This becomes a:
TCP Segment
22.3 Network¶
IP adds an IP header:
┌─────────────┬──────────────┬──────────────┐
│ IP Header │ TCP Header │ Application │
│ │ │ Data │
└─────────────┴──────────────┴──────────────┘
This becomes an:
IP Packet
22.4 Data Link¶
The Data Link layer adds a frame header and usually a trailer:
┌──────────────┬──────────────────┬─────────────┐
│ Frame Header │ IP Packet │ Trailer │
└──────────────┴──────────────────┴─────────────┘
This becomes a:
Frame
22.5 Physical¶
The frame is transmitted as physical signals representing bits:
Frame
↓
Bits
↓
Electrical / optical / radio signals
23. Encapsulation Chain¶
The fundamental chain is:
Application Data
↓
Segment
↓
Packet
↓
Frame
↓
Bits
Or:
Application
↓
Transport
↓
Network
↓
Data Link
↓
Physical
24. Nested Structure¶
The data units are not independent copies.
They are nested inside one another:
Frame
└── Packet
└── Segment
└── Application Data
More visually:
┌─────────────────────────────────────────────┐
│ Frame │
│ │
│ ┌───────────────────────────────────────┐ │
│ │ IP Packet │ │
│ │ │ │
│ │ ┌─────────────────────────────────┐ │ │
│ │ │ TCP Segment │ │ │
│ │ │ │ │ │
│ │ │ Application Data │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────┘ │ │
│ └───────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
Therefore:
A packet contains a segment.
A frame contains a packet.
25. Decapsulation¶
At the receiver, the reverse process occurs.
Bits
↓
Frame
↓
Packet
↓
Segment
↓
Application Data
This is called:
Decapsulation
26. Who Removes Which Header¶
A crucial rule:
Each layer processes the header/trailer belonging to its own protocol.
At the destination:
Data Link:
Processes:
Ethernet/Data Link header + trailer
Leaves:
IP Packet
Network:
Processes:
IP header
Leaves:
TCP Segment
Transport:
Processes:
TCP header
Leaves:
Application Data
So:
Data Link → handles Layer 2 information
Network → handles IP information
Transport → handles TCP/UDP information
Application → receives application data
The lower layer does not remove a higher layer's header.
For example:
The Data Link layer does not remove the TCP header.
The TCP layer processes the TCP header.
27. Router Processing¶
A router is particularly important because it does not normally decapsulate all the way up to TCP/Application.
Suppose:
PC → Router 1 → Router 2 → Server
At Router 1, conceptually:
Incoming signals
↓
Physical Layer
↓
Bits
↓
Data Link
↓
Frame
↓
IP Packet
↓
Routing decision
↓
New Layer-2 Frame
↓
Bits/signals
↓
Next hop
A router generally does:
Frame → Packet → Routing → New Frame
It does not normally do:
Frame
↓
Packet
↓
TCP Segment
↓
Application Data
because it does not need to inspect the application data or TCP payload to perform ordinary IP forwarding.
28. Router Lower Layers¶
Yes.
A router isn't simply a "Layer 3 object."
Its interfaces participate in lower-layer communication too.
Conceptually:
Router
┌─────────────────────┐
│ Layer 3 │ ← IP / Routing
├─────────────────────┤
│ Layer 2 │ ← Frames / MAC
├─────────────────────┤
│ Layer 1 │ ← Signals / Bits
└─────────────────────┘
Therefore, when a frame arrives at a router:
Signals
↓
Physical processing
↓
Bits / Frame
↓
Data Link processing
↓
IP Packet
↓
Layer 3 routing
The router then sends the packet through another interface:
IP Packet
↓
New Layer-2 Frame
↓
Physical signals
↓
Next hop
Real routers use specialized hardware and buffers, so don't imagine that they literally convert everything into a giant string of 0s in software. This is the conceptual networking model.
29. Frame Change Rationale¶
Consider:
PC ─── R1 ─── R2 ─── Server
There are multiple local links.
29.1 PC To R1¶
Source MAC = PC
Destination MAC = R1
29.2 R1 To R2¶
Source MAC = R1
Destination MAC = R2
29.3 R2 To Server¶
Source MAC = R2
Destination MAC = Server
Therefore:
The Layer-2 frame is recreated for every hop.
30. IP Vs MAC¶
This is one of the most important concepts in Level 1.
IP address:
Used for:
Layer-3 routing / determining where the packet ultimately needs to go
MAC address:
Used for:
Layer-2 delivery on the current local link
A useful mental model:
IP → "Which way should the packet go?"
MAC → "How do I deliver it to the next device on this particular link?"
31. Routing And MAC Coordination¶
Suppose:
PC → R1 → R2 → Server
PC wants to reach the server.
The PC knows the destination IP:
Destination IP = Server IP
It determines that the destination is not directly reachable on its local network, so the next hop is R1.
The Layer-2 frame is then addressed to R1:
Source MAC = PC
Destination MAC = R1
R1 receives the frame.
It processes the Layer-2 information and extracts the IP packet.
R1 looks at:
Destination IP = Server IP
It consults its routing table:
Destination Network → Next Hop / Interface
Suppose it determines:
Next hop = R2
Now R1 creates a new Layer-2 frame:
Source MAC = R1's outgoing interface
Destination MAC = R2's interface
The IP packet is carried inside this new frame.
This happens at every router.
32. Separate Decisions Rationale¶
Because there are two separate decisions.
32.1 Layer 3 Routing¶
Use the destination IP:
Destination IP
↓
Routing table
↓
Choose outgoing interface / next hop
32.2 Layer 2 Delivery¶
Once the outgoing interface/next hop is known:
Next-hop device
↓
Find its MAC
↓
Build Layer-2 frame
↓
Transmit
So:
IP → determines the route / next hop
MAC → performs delivery to that next hop on the selected link
This is why we say:
Routers route using IP addresses.
Even though the actual physical hop-by-hop transmission also involves MAC addresses.
33. Hop By Hop Delivery¶
For:
PC → R1 → R2 → R3 → Server
Think:
Layer 2:
PC → R1
R1 → R2
R2 → R3
R3 → Server
Each hop has a different frame.
Whereas:
Layer 3:
PC ─────────────────────────→ Server
Same IP destination
The IP packet is routed across multiple networks.
This distinction is fundamental:
Layer 2 = local/hop-by-hop delivery
Layer 3 = routing between networks
34. Destination IP Consistency¶
Suppose:
PC → R1 → R2 → R3 → Server
Normally:
Destination IP:
Server IP → Server IP → Server IP → Server IP
The Layer-2 destination MAC changes at each hop.
However, there are technologies such as NAT that can modify IP addresses. NAT will be studied later.
Therefore, in a normal routing scenario:
The destination IP remains the ultimate destination's IP while the packet is being routed.
35. Frame Packet Segment¶
Segment:
Transport-layer unit.
TCP Header + Application Data
→ TCP Segment
Packet:
Network-layer unit.
IP Header + TCP Segment
→ IP Packet
Frame:
Data Link-layer unit.
Data Link Header + Packet + Trailer
→ Frame
Therefore:
Segment → Transport
Packet → Network
Frame → Data Link
Bits → Physical
36. Complete Multi Hop Example¶
Consider:
PC → R1 → R2 → Server
Application creates:
HTTP Request
Transport:
TCP Header + HTTP
↓
TCP Segment
Network:
IP Header + TCP Segment
↓
IP Packet
Data Link:
Ethernet Header + IP Packet + Trailer
↓
Frame
Physical:
Frame
↓
Bits/signals
↓
R1
At R1:
Signals
↓
Frame
↓
Process Layer 2
↓
IP Packet
↓
Look at destination IP
↓
Routing table
↓
Select R2
↓
Create NEW Layer-2 frame
↓
Transmit
At R2:
New incoming frame
↓
Process Layer 2
↓
IP Packet
↓
Look at destination IP
↓
Routing table
↓
Select Server
↓
Create NEW Layer-2 frame
↓
Transmit
At Server:
Frame
↓
Data Link processing
↓
IP packet
↓
Network processing
↓
TCP segment
↓
Transport processing
↓
HTTP/application data
37. Important Interview Traps¶
Trap 1:
"A router uses MAC addresses to route packets."
❌ Incorrect.
Routing decisions are based primarily on the destination IP address.
MAC is used for local Layer-2 delivery.
Trap 2:
"A switch routes using IP."
❌ For a traditional Layer-2 switch.
It forwards frames using MAC addresses.
Layer-3 switches can perform routing.
Trap 3:
"The server's MAC address is placed in the first frame."
❌ Not necessarily.
The first frame is addressed to the next local-hop device, usually the default gateway/router when the destination is on another network.
Trap 4:
"The same Ethernet frame travels across the entire Internet."
❌ No.
A new Layer-2 frame is created for each hop/link.
Trap 5:
"The MAC address stays the same end-to-end."
❌ No.
The Layer-2 source/destination MAC addresses change from hop to hop.
Trap 6:
"The IP packet is completely removed and recreated from scratch at every router."
❌ Not in the same sense as Layer-2 framing.
The router processes and forwards the IP packet while creating a new Layer-2 frame for the outgoing link.
Some IP header fields can change during forwarding, such as TTL.
Trap 7:
"The Data Link layer removes the TCP header."
❌ No.
Each layer processes its own protocol information.
Data Link → Layer-2 header/trailer
Network → IP header
Transport → TCP/UDP header
38. End To End Mental Model¶
The entire Level 1 can be summarized as:
APPLICATION
│
│ HTTP / DNS / etc.
↓
TRANSPORT
│
│ TCP / UDP + ports
↓
NETWORK / INTERNET
│
│ IP + routing
↓
DATA LINK / LINK
│
│ MAC + frames
↓
PHYSICAL
│
│ Bits / signals
↓
NETWORK
During sending:
Data
↓
Segment
↓
Packet
↓
Frame
↓
Bits
During receiving:
Bits
↓
Frame
↓
Packet
↓
Segment
↓
Data
39. Placement Ready Answers¶
What is the OSI model?
The OSI model is a seven-layer reference model that divides network communication into separate responsibilities: Physical, Data Link, Network, Transport, Session, Presentation, and Application.
What is the TCP/IP model?
TCP/IP is the practical protocol architecture used by the Internet. It is commonly represented using four layers: Application, Transport, Internet, and Network Access/Link.
Difference between OSI and TCP/IP?
OSI is a seven-layer reference model with separate Session, Presentation, and Physical layers. TCP/IP is a practical Internet protocol architecture that commonly combines OSI Application, Presentation, and Session into Application, and Data Link and Physical into the Link/Network Access layer.
What is encapsulation?
Encapsulation is the process of adding protocol-specific control information as data moves down the networking layers. Application data becomes a segment, packet, frame, and finally bits/signals.
What is decapsulation?
Decapsulation is the reverse process at the receiver, where each layer processes the information belonging to its protocol and passes the remaining payload upward.
Why does a router use IP rather than MAC for routing?
IP is used for Layer-3 routing because the destination IP determines the destination network and the routing table determines the next hop/interface. MAC is then used for Layer-2 delivery over the selected local link.
Why does the MAC address change at every router?
Because the Layer-2 frame is hop-by-hop. Each router removes/processes the incoming Layer-2 frame and creates a new frame for the outgoing link with the appropriate source and destination MAC addresses.
40. Final Level 1 Mental Model¶
If you remember nothing else, remember this:
END-TO-END
│
Destination IP
│
▼
PC ─────── R1 ─────── R2 ─────── Server
│ │ │ │
│ │ │ │
Frame 1 Frame 2 Frame 3 Frame 4
│ │ │ │
└──────────── Layer 2 ────────────┘
HOP-BY-HOP
IP packet → routed across networks
Frame → changes at every hop
MAC → next-hop/local delivery
IP → network-level routing
Port → destination process
TCP → transport-level communication
HTTP → application-level communication
40.1 The Three Rules To Remember¶
1. IP decides where the packet should go.
2. MAC delivers the packet to the next hop on the current local link.
3. Each layer processes its own protocol's header.
And the fundamental data-unit chain:
Data → Segment → Packet → Frame → Bits
These concepts form the foundation for everything that follows in CN — especially switching, MAC addresses, ARP, IP addressing, routing, TCP, and the full browser-to-server request flow.