Learn this trick and you will never forget network layering again

When it comes to computer networks, we must understand the network layer model.

But to be honest, many people start to feel overwhelmed when they see a bunch of professional terms such as the seventh layer and the fourth layer: what is the physical layer and the data link layer? What does it have to do with sending a message?

Don't worry, today Shenchang will use a trick to help you thoroughly understand the network layer model. Remember it once and you will never forget it!


1. Why do we need network layering?
Let me explain the principle first: network layering is like building blocks, breaking down complex problems into smaller pieces, with each layer doing its own job.

If you want to send a WeChat message to a friend:

You write the content → the phone packages and sends → the network forwards → the other party receives and displays
In the middle, you have to go through signals, cables, IP addresses, TCP protocols, encryption, encoding...
With so many details, if there is no layering, engineers will go crazy.

Therefore, layering = dismantling complex communication processes to make protocols standardized, modular, and replaceable.
As a programmer, I understand it very well. The essence of network layering is like the architectural design of Java projects: high cohesion, low coupling, and clear definitions of each layer, which is convenient for development and maintenance, as well as for replacing protocols or components. If all your logic is written in one class, it will become an epic pile of shit that no one can maintain.

2. OSI seven-layer model
The classic OSI model has 7 layers, stacked like a hamburger:
Before the divine singing, I couldn't remember the order of their songs. In the end, I just remembered a paragraph and it would be enough to pass on the Internet. It's really useful and I can't forget it.

Simplified understanding:
3. TCP/IP model: representative of the practical school
To be honest, although the OSI model is clear in concept, the TCP/IP model, also known as the four-layer model, is more commonly used in our actual projects:
Mapping relationship list:

4. Reverse thinking of “packing and unpacking”
Remember a core concept: sender: packing from top to bottom → receiver: unpacking from bottom to top
Suppose you send an HTTP request in a browser:

Application layer: write the content and encapsulate it with HTTP
Transport layer: package it into a TCP segment
Network layer: add IP address and turn it into an IP packet
Data link layer: add MAC address and turn it into an Ethernet frame
Physical layer: turn it into an electrical signal and send it out!
Then at the receiving end:

Physical layer: receive electrical signals
Data link layer: remove MAC address
Network layer: remove IP packet
Transport layer: assemble TCP data
Application layer: restore it into a web page