You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: notes/2025-03-22-network-layer-en.md
+18-18
Original file line number
Diff line number
Diff line change
@@ -11,37 +11,37 @@ Okay, let's dive into a detailed tutorial on the Network Layer, specifically tai
11
11
12
12
## Network Layer Tutorial
13
13
14
-
The Network Layer (网络层) is the third layer in the OSI model and the TCP/IP model. Its primary responsibility is to facilitate the movement of data packets from a source host to a destination host across one or more networks. Think of it as the postal service for the internet – it figures out the best route and ensures your "package" (data packet) gets to the correct address.
14
+
The Network Layer is the third layer in the OSI model and the TCP/IP model. Its primary responsibility is to facilitate the movement of data packets from a source host to a destination host across one or more networks. Think of it as the postal service for the internet – it figures out the best route and ensures your "package" (data packet) gets to the correct address.
15
15
16
16
Here's a breakdown of the key topics within this chapter:
17
17
18
-
### 1. Functions of the Network Layer (网络层的功能)
18
+
### 1. Functions of the Network Layer
19
19
20
20
The Network Layer performs three main functions:
21
21
22
-
#### a) Logical Addressing (逻辑寻址)
22
+
#### a) Logical Addressing
23
23
24
24
***Purpose:** To uniquely identify each host on a network. This is different from the physical address (MAC address) which identifies a device within a local network. Logical addresses are hierarchical and allow for efficient routing.
25
25
***Key Concept:** IP addresses (Internet Protocol addresses) are the primary form of logical addressing used in the Network Layer.
26
26
***Analogy:** Think of your home address. It's a logical address that helps the postal service find your specific house within a city and country, regardless of the physical location of the post office.
27
27
28
-
#### b) Routing (路由选择)
28
+
#### b) Routing
29
29
30
30
***Purpose:** To determine the best path for a data packet to travel from the source to the destination. This involves selecting a sequence of network devices (routers) that the packet will traverse.
31
31
***Key Concept:** Routing algorithms are used by routers to build and maintain routing tables, which contain information about the best paths to different networks.
32
32
***Analogy:** Imagine planning a road trip. You look at a map or use a GPS to figure out the best route to your destination, considering factors like distance and traffic. Routers do something similar for data packets.
33
33
34
-
#### c) Forwarding (转发)
34
+
#### c) Forwarding
35
35
36
36
***Purpose:** The actual process of moving a data packet from an input port of a router to the appropriate output port based on the routing decision.
37
37
***Key Concept:** When a router receives a packet, it examines the destination IP address and consults its routing table to determine the next hop (another router or the destination host).
38
38
***Analogy:** Once you've planned your route, forwarding is like actually driving your car along that route, moving from one point to the next.
39
39
40
-
### 2. IP Addressing (IP地址)
40
+
### 2. IP Addressing
41
41
42
42
IP addresses are fundamental to the Network Layer. There are two main versions: IPv4 and IPv6.
43
43
44
-
#### a) IPv4 Structure (IPv4结构)
44
+
#### a) IPv4 Structure
45
45
46
46
***Format:** A 32-bit numerical address written in dotted decimal notation (e.g., 192.168.1.10). It's divided into four 8-bit octets.
47
47
***Address Classes (Historically):** While largely obsolete now due to Classless Inter-Domain Routing (CIDR), understanding the historical classes (A, B, C, D, E) can be helpful for foundational knowledge.
@@ -57,7 +57,7 @@ IP addresses are fundamental to the Network Layer. There are two main versions:
57
57
***Private IP Addresses:** Ranges reserved for use within private networks (e.g., 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). These addresses are not routable on the public internet.
58
58
***Public IP Addresses:** Addresses that are routable on the public internet.
59
59
60
-
#### b) IPv6 Structure (IPv6结构)
60
+
#### b) IPv6 Structure
61
61
62
62
***Format:** A 128-bit numerical address written in hexadecimal format, grouped into eight 16-bit segments separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
63
63
***Advantages over IPv4:** Larger address space (solves IPv4 address exhaustion), improved security (IPsec is often integrated), simplified header format, better support for mobile devices.
@@ -71,7 +71,7 @@ IP addresses are fundamental to the Network Layer. There are two main versions:
71
71
***Link-Local Addresses (fe80::/10):** Used for communication within a single network link.
72
72
***Global Unicast Addresses:** Globally routable addresses on the internet.
73
73
74
-
#### c) Subnetting (子网划分)
74
+
#### c) Subnetting
75
75
76
76
***Purpose:** To divide a larger network into smaller, more manageable subnetworks (subnets). This helps in organizing networks, improving security, and optimizing network performance.
77
77
***Mechanism:** Subnetting is achieved by borrowing bits from the host portion of an IP address and using them to create subnet IDs. This is done using a **subnet mask**.
@@ -85,11 +85,11 @@ IP addresses are fundamental to the Network Layer. There are two main versions:
85
85
5. Identify the valid subnet addresses, broadcast addresses, and usable host ranges for each subnet.
86
86
***Subnetting in IPv6:** While the concept of subnetting exists in IPv6, the vast address space makes it less about conserving addresses and more about network organization. IPv6 subnets are typically a fixed size (/64).
87
87
88
-
### 3. Routing Algorithms (路由算法)
88
+
### 3. Routing Algorithms
89
89
90
90
Routing algorithms are used by routers to determine the best path for data packets. They can be broadly classified into:
91
91
92
-
#### a) Static vs. Dynamic Routing (静态路由 vs. 动态路由)
92
+
#### a) Static vs. Dynamic Routing
93
93
94
94
***Static Routing:**
95
95
* Routing tables are manually configured by the network administrator.
@@ -101,23 +101,23 @@ Routing algorithms are used by routers to determine the best path for data packe
101
101
* More complex to configure initially but highly adaptable to network changes and failures.
102
102
* Scalable for larger and more complex networks.
103
103
104
-
#### b) Distance Vector Routing (距离向量路由)
104
+
#### b) Distance Vector Routing
105
105
106
106
***Principle:** Each router maintains a routing table that lists the best known distance (e.g., number of hops) and the direction (next hop router) to each destination network.
107
107
***Information Exchange:** Routers periodically exchange their entire routing tables with their directly connected neighbors.
108
108
***Algorithm Example:** The **Bellman-Ford algorithm** is a common algorithm used in distance vector routing protocols.
109
109
***Protocols:** RIP (Routing Information Protocol) is a well-known example of a distance vector routing protocol.
110
110
***Limitations:** Can suffer from slow convergence (takes time for the network to adapt to changes) and the "count-to-infinity" problem (routing loops can occur).
111
111
112
-
#### c) Link State Routing (链路状态路由)
112
+
#### c) Link State Routing
113
113
114
114
***Principle:** Each router maintains a complete map of the network topology. It knows about all the routers and the links between them, along with the cost of each link.
115
115
***Information Exchange:** Routers exchange information about the state of their directly connected links with all other routers in the network. This information is called a Link State Advertisement (LSA).
116
116
***Algorithm Example:** The **Dijkstra's algorithm** (Shortest Path First - SPF) is used by each router to calculate the shortest path to all other destinations based on the collected link state information.
117
117
***Protocols:** OSPF (Open Shortest Path First) and IS-IS (Intermediate System to Intermediate System) are popular link state routing protocols.
118
118
***Advantages:** Faster convergence, less prone to routing loops compared to distance vector routing.
119
119
120
-
### 4. Protocols (协议)
120
+
### 4. Protocols
121
121
122
122
Several key protocols operate at the Network Layer:
123
123
@@ -139,11 +139,11 @@ Several key protocols operate at the Network Layer:
139
139
***Process:** When a host needs to send a packet to another host on the same network, it knows the destination IP address but needs the destination MAC address to frame the packet at the Data Link Layer. The sending host broadcasts an ARP request containing the destination IP address. The host with that IP address responds with an ARP reply containing its MAC address.
140
140
***ARP Cache:** Hosts maintain an ARP cache to store recently resolved IP-to-MAC address mappings to avoid sending ARP requests for every communication.
141
141
142
-
### 5. Network Devices (网络设备)
142
+
### 5. Network Devices
143
143
144
144
The Network Layer primarily involves two key types of network devices:
145
145
146
-
#### a) Routers (路由器)
146
+
#### a) Routers
147
147
148
148
***Primary Function:** To forward data packets between different networks based on their destination IP addresses.
149
149
***Key Features:**
@@ -152,7 +152,7 @@ The Network Layer primarily involves two key types of network devices:
152
152
* Perform packet forwarding based on routing decisions.
153
153
* Can implement security features like firewalls and access control lists (ACLs).
154
154
155
-
#### b) Gateways (网关)
155
+
#### b) Gateways
156
156
157
157
***Broader Term:** A gateway is a device that acts as an entry point to another network. It can be a router, firewall, or another type of device.
158
158
***Default Gateway:** In the context of IP networking, the default gateway is a router on the local network that a host uses to send traffic to destinations outside its own network.
@@ -173,4 +173,4 @@ The Network Layer primarily involves two key types of network devices:
173
173
***Relate to real-world scenarios:** Think about how these concepts apply to your own internet usage and network setups.
174
174
***Review past exam papers:** Understand the types of questions that are typically asked on this topic in the Chinese Self-Study Exam.
175
175
176
-
By thoroughly understanding these concepts, you will build a strong foundation in the Network Layer, which is essential for further studies in computer networking. Good luck with your studies!
176
+
By thoroughly understanding these concepts, you will build a strong foundation in the Network Layer, which is essential for further studies in computer networking. Good luck with your studies!
0 commit comments