Frames & Packets

Also available in 40 other languages

Ethernet Frames

Ethernet Frames 位於 OSI 7 層模型中的資料連結層。它們是現代 IP 網路的基礎網路區塊。當系統從實體線路上取出資料時,Ethernet Frame 是必須在讀取資訊之前先移除或解封的第一層。

Ethernet Frame

8 Bytes 1 Byte 6 Bytes 6 Bytes 4 Bytes 2 Bytes 9000 Bytes (Jumbo Frames) 4 Bytes
Preamble SFD (Start Frame Delimeter) Destination Address Source Address VLAN TAG Type / Length DATA Frame Check Sequence (CRC)

IPv4 and IPv6

IPv4 和 IPv6 都位於 OSI 7 層模型中的網路層。它們為系統在本地子網外部通訊提供了位址。一旦系統解封了 Ethernet Frame,它就會評估所呈現的 IP 資訊。IPv4 於 1981 年作為 IETF RFC 791 的一部分創建,但首次部署於 1983年。然而,隨著網際網路的增長,人們發現公共 IPv4 空間將會被完全耗盡,這促成了 IPv6 的創建。IPv4 位址空間已於 2015年9月24日 正式枯竭。因此,現在只能從 ARIN 購買 IPv6,而 ARIN 是美國網際網路號碼註冊機構。 IANA 是網際網路位址空間的全球組織者,還有其他區域。

IPv4 Header

IPv4 Header (32 bits)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Version IHL (header Len) Type Of Service (TOS) Total Length
4 Identification IP Flag Fragment Offset
8 Time To Live (TTL) Protocol Header Checksum
12 Source Address
16 Destination Address
20 IP Option (Variable Length, Optional, not common)

IPv6 Header

IPv6 Header (128 bits)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Version Traffic Class Flow Label
4 Payload Length Next Header Hop Limit
8-20 Source Address
24 - 36 Destination Address

TCP Header

TCP 是在進入操作系統之前的最後一個封裝層之一。伺服器通常會在特定的連接埠上監聽某個協議以實現功能。例如,未加密的網站伺服器通常在 TCP 連接埠 80 上監聽。

TCP Header (60 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Source Port # (16 bits) Destination Port # (16 bits)
4 Sequence Number (32 bits)
8 Acknowledgement Number (32 bits)
12 Header Length (4) Reserved (6) URG ACK PSH RST SYN FIN Window Size (16 bits)
16 TCP Checksum (16 bits) Urgent Pointer (16 bit)
20 Options (if any, variable length, padded with 0's)
24 Actual Data Payload

UDP Header

UDP 與 TCP 處於相同的層級,都是在進入操作系統之前的最後一個封裝層之一。伺服器通常會在特定的連接埠上監聽某個協議以實現功能。例如,DHCP 伺服器會針對 DHCP 請求在 UDP 連接埠 67 和 68 上監聽。

UDP Header (8 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Source Port # (16 bits) Destination Port # (16 bits)
4 Length (16 bits) Checksum (16 bits)

ICMP Header

ICMP 與 TCP 和 UDP 同級,但用於網路控制,需搭配 ARP 和 ping。

ICMP Header (8 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Type (8 bits) Code (8 bits) Checksum (16 bits)
4 Other Message Specific Information (32 bits)

IGMP Header

IGMP 與 TCP 和 UDP 以及 ICMP 同級,但用於多播通訊。以下是 IGMPv1 的 Header

IGMP Header Version 1

IGMP Header Version1 (8 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Version (4 bits) Type (4 bits) Unused (8 bits) Checksum (16 bits)
4 Group Address (32 bits)

IGMP Header Version 2

IGMP Header Version2 (8 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Type (8 bits) Max Response Time (8 bits) Checksum (16 bits)
4 Group Address (32 bits)

Internet Protocol Security (IPSEC) Header

IPSEC 是一種為 IP 通訊建置的安全協定套件。每個封包在傳輸前都會經過驗證和加密。

IPSEC Authentication Header

IPSEC Authentication Header (12 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Next Header (8 bits) Payload Length (8 bits) Reserved (16 bits)
4 Security Parameters Index (SPI) (32 bits)
8 Sequence Number (32 bits)
16 Integrity Check Value (ICV) (32 bits or more as required)

IPSEC ESP Header

IPSEC Encapsulating Security Payload (ESP) Header
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Security Parameter Index (SPI) (32 bits)
4 Sequence Number (32 bits)
8 Payload Data (32 bits or more)
... Padding (0 - 255 Bytes)
... Padding Length (8 Bytes) Next Header (8 Bytes) Integrity Check Value (ICV) (4 bytes or more)

Generic Routing Encapsulation (GRE) Header

GRE 是一種封裝其他資料的隧道協定。一旦資料被封裝,對終端用戶看起來就像是點對點的連線,即使隧道實際穿過了多個路由連線。如果不需要加密,它可以用於將一種網路流量(例如訪客流量)傳輸到另一種網路(例如公司網路)。

Generic Routing Encapsulation Header (16 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Checksum Present (1 bits) Reserved (12 bits) Version Number (3 bits) Protocol Type (16 bits)
4 Checksum (optional) (16 bits) Reserved (optional) (16 bits)

Generic Routing Encapsulation (GRE) Header - Extended

2000 年 9 月,IETF 在 RFC 2890 中為 GRE header 增加了擴展。

Generic Routing Encapsulation Header (32 Bytes)
Starting Byte Byte Byte Byte Byte
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 Checksum Present (1 bits) Key Present (1 bits) Sequence Number Present (1 bits) Reserved (12 bits) Version Number (3 bits) Protocol Type (16 bits)
4 Checksum (optional) (16 bits) Reserved (optional) (16 bits)
8 Key (optional) (32 bits)
12 Sequence Number (optional) (32 bits)

OSI 7 Layer Model

本篇文章引用了 OSI 7 層模型,故作為參考資料包含如下:

Presentation (表示層)
Session (會話層)
Transport (傳輸層)
Network (網路層)
Data Link (資料連結層)
Physical (實體層)