Networking model
What is Network ?
A network is
2 or more devices connected together
to communicate
and share resources
(files, movies, songs, web pages, etc).
Some requirements when communicate between 2 computers
How a computer get IP address ?
Phase 1. When you connect your PC/ Laptop to Router
When you provide electricity to Router, mainboard will start a application at default IP, eg: 192.168.0.1 When you connect your PC to that Router via cable, Router will grant local IP to your PC.
In this case, Router is
DHCP
Server ~
Dynamic Host Configuration Protocol
To setup Router’s configuration, you can access default IP of Router: 192.168.0.1 in Browser.
Phase 2. When your Router connects to the internet
When your Router connects to the internet ( another router from
ISP
~
Internet Service Provider
), Router will get public IP, eg: 118.69.118.141
How network communication works ?
To understand communication process from sender to receiver, we use
OSI
model ~
Open Systems Interconnection
.
It's a
conceptual framework
or
reference model
OSI model has 7 layers.
Layer 7: Application
Layer 6: Presentation
Layer 5: Session
Layer 4: Transport
Layer 3: Networking
Layer 2: Data link
Layer 1: Physical
⇒ Each computer will apply 7 layers of OSI model
The other devices like Switch, Router have its own layers in OSI model.
Router: Layer 3 - 2 - 1
Switch: Layer 2 - 1
Scenario: when you use Browser to view website
http://udemynote.com/. It means your computer communicate to my blog ‘s server or computer which host udemynote.com website.
Layer 7: Application
Responsibility
: work with user to prepare data to ready for network
Each software applications require network will be treated as application in layer 7
Application layer is as interface to the network.
In here,
From your computer, Browser is layer 7. Layer 7 is visualized via browser to:
There are some common Web server applications: Node.js, Apache, Nginx, etc. But my website (udemynote) uses Vercel Edge Network ~ acts like CDN + Nginx.
Layer 6: Presentation
Responsibility
: format data
Key functions:
Layer 5: Session
Responsibility
: keeping connection is alive.
Key functions:
Layer 4: Transport
Responsibility
: delivery segments to right application/ service.
FYI, Client use applications ~ Server use services.
Client make request ~ Server fulfill the request.
Services are applications which are designed to run in the background.
Key functions:
Example:
src port: 49152 ← Chrome
des port: 443 ← Nginx Sometimes we see Nginx configuration like
server {
listen 443 ssl;
}What is segment ?
Segment is unit of data in Layer 4
Layer 4 takes data and break into Segment ( smaller pieces ) to delivery easily in the network.
So how to glue they back together to able to display at the Application layer ?
We need to control data flow via
ordered
protocol - TCP
From that, it guarantees the Application layer always gets data in the
correct order and complete
.
I will share detail in TCP in other article.
There are
2 main protocols
in Layer 4 — and a few others less commonly used:
Unreliable delivery like teacher talk (delivery data) & don’t care student understand or not.
Size of Datagram in UDP > size of Segment in TCP ⇒ allow to send more data ⇒ UDP is faster
Layer 3: Network
Responsibility
: route packet from source to destination
IP address identifies end device on a network.
Layer 2: Data link
Responsibility
: transfer frame between two directly connected devices on the same network
Mac address is
unique
and
can’t change
[?] How to get mac address of next device ? - ARP Resolution
Just when PC want to send data to the internet, it will get Mac address from connected Router.
Layer 1: Physical
Responsibility:
convert bits into electrical, light, or radio signals
How NIC know when the Frame begin/end ?
NIC ( Network Interface Card )
is hardware component which handles layer 1 & layer 2.
NIC is required to connect to the internet.
Frame is wrapped with a
header (prefix)
and a
trailer (suffix)
to mark its boundaries
Example: prefix - 10101011/ suffix - 10101010
When the NIC receives a signal (just bunch of 0 & 1), it scans for the
matching prefix pattern
to know where the frame begins, and the
suffix
to know where it ends — allowing it to
extract the actual frame data
in between.









