164 lines
3.4 KiB
Markdown
164 lines
3.4 KiB
Markdown
---
|
||
id: 1777801183-SYMV
|
||
aliases:
|
||
- The Life of a Packet
|
||
tags: []
|
||
---
|
||
|
||
# The Life of a Packet
|
||
|
||
## Network Topology
|
||
|
||

|
||
|
||
We will follow a packet traveling from **PC1** to **PC4** across multiple routers.
|
||
|
||
### Devices and MAC Addresses
|
||
|
||
| Device | Interface | MAC Address |
|
||
| ------ | --------- | ----------- |
|
||
| PC1 | - | 1111 |
|
||
| R1 | G0/2 | aaaa |
|
||
| | G0/0 | bbbb |
|
||
| R2 | G0/0 | cccc |
|
||
| | G0/1 | dddd |
|
||
| R4 | G0/0 | eeee |
|
||
| | G0/1 | ffee |
|
||
| PC4 | - | 4444 |
|
||
|
||
### IP Addresses
|
||
|
||
* **Source IP:** 192.168.1.1
|
||
* **Destination IP:** 192.168.4.1
|
||
|
||
---
|
||
|
||
## Step 1: PC1 Needs a Gateway
|
||
|
||
PC1 belongs to the **192.168.1.0/24** network, while the destination is in a different network. That means the packet must be sent to the **default gateway**.
|
||
|
||
Before sending anything, PC1 needs the MAC address of the gateway (192.168.1.254). It doesn’t have it yet, so it uses ARP.
|
||
|
||
### ARP Request (Broadcast)
|
||
|
||
* Source IP: 192.168.1.1
|
||
* Destination IP: 192.168.1.254
|
||
* Source MAC: 1111
|
||
* Destination MAC: ffff.ffff.ffff (broadcast)
|
||
|
||
> “Who has 192.168.1.254? Tell me!”
|
||
|
||
### ARP Reply (Unicast)
|
||
|
||
Router R1 responds:
|
||
|
||
* Source IP: 192.168.1.254
|
||
* Destination IP: 192.168.1.1
|
||
* Source MAC: aaaa
|
||
* Destination MAC: 1111
|
||
|
||
Now PC1 knows the MAC address of its gateway.
|
||
|
||
---
|
||
|
||
## Step 2: PC1 Sends the Packet to R1
|
||
|
||
PC1 builds the frame:
|
||
|
||
```
|
||
+-----------------+--------+
|
||
| SRC: 192.168.1.1 | DST: aaaa |
|
||
| DST: 192.168.4.1 | SRC: 1111 |
|
||
+-----------------+--------+
|
||
```
|
||
|
||
* The **IP header** stays constant end-to-end
|
||
* The **MAC addresses** are only for the local hop
|
||
|
||
The packet is sent to R1.
|
||
|
||
---
|
||
|
||
## Step 3: R1 Forwards to R2
|
||
|
||
R1 checks its routing table:
|
||
|
||
| Destination | Next Hop |
|
||
| -------------- | ------------ |
|
||
| 192.168.4.0/24 | 192.168.12.2 |
|
||
|
||
R1 must forward the packet to R2, but first it needs R2’s MAC address.
|
||
|
||
### ARP Process (again)
|
||
|
||
* R1 sends ARP request
|
||
* R2 replies with MAC **cccc**
|
||
|
||
### New Frame (re-encapsulation)
|
||
|
||
```
|
||
+-----------------+--------+
|
||
| SRC: 192.168.1.1 | DST: cccc |
|
||
| DST: 192.168.4.1 | SRC: bbbb |
|
||
+-----------------+--------+
|
||
```
|
||
|
||
Notice:
|
||
|
||
* IP addresses are unchanged
|
||
* MAC addresses are updated for the new hop
|
||
|
||
---
|
||
|
||
## Step 4: R2 Forwards to R4
|
||
|
||
R2 receives the packet, checks its routing table, and determines the next hop is R4.
|
||
|
||
Same process:
|
||
|
||
* ARP request
|
||
* ARP reply from R4 (MAC: eeee)
|
||
|
||
### New Frame
|
||
|
||
```
|
||
+-----------------+--------+
|
||
| SRC: 192.168.1.1 | DST: eeee |
|
||
| DST: 192.168.4.1 | SRC: dddd |
|
||
+-----------------+--------+
|
||
```
|
||
|
||
---
|
||
|
||
## Step 5: R4 Delivers to PC4
|
||
|
||
R4 sees that the destination network is directly connected.
|
||
|
||
It performs ARP to find PC4’s MAC:
|
||
|
||
* ARP request
|
||
* ARP reply from PC4 (MAC: 4444)
|
||
|
||
### Final Frame
|
||
|
||
```
|
||
+-----------------+--------+
|
||
| SRC: 192.168.1.1 | DST: 4444 |
|
||
| DST: 192.168.4.1 | SRC: ffee |
|
||
+-----------------+--------+
|
||
```
|
||
|
||
---
|
||
|
||
## Final Insight
|
||
|
||
This journey hides a simple but powerful rule:
|
||
|
||
* **IP addresses = end-to-end identity (never change)**
|
||
* **MAC addresses = hop-by-hop delivery (change every step)**
|
||
|
||
Each router peels off the old frame and wraps the packet in a new one, like a traveler switching taxis at every city while keeping the same passport.
|
||
|
||
And just like that, the packet arrives at PC4, having quietly crossed networks, routers, and multiple layers of logic without ever losing its sense of direction. 🚀
|
||
|