Ethernet Encapsulation
Ethernet 封装 (Ethernet Encapsulation)¶
Ethernet 帧结构 (Ethernet Frame Structure)¶
以太网帧的标准结构如下:
The standard structure of an Ethernet frame is as follows:
1. 前导码 (Preamble)¶
- 大小 (Size): 7 字节 (56 bits)
- 描述 (Description): 前导码是一段特定的比特序列(通常是 10101010 的重复),用于同步发送端和接收端的时钟信号,确保接收端能够正确识别即将到来的数据帧。
- The preamble is a specific bit sequence (usually a repetition of 10101010) used to synchronize the clock signals of the sender and receiver, ensuring that the receiver can correctly recognize the incoming data frame.
2. 帧起始定界符 (Start Frame Delimiter, SFD)¶
- 大小 (Size): 1 字节 (8 bits)
- 描述 (Description): SFD 是一个特殊的比特序列 (10101011),它紧跟在前导码之后,用于标识以太网帧的开始。
- The SFD is a special bit sequence (10101011) that immediately follows the preamble and indicates the start of the Ethernet frame.
3. 目标 MAC 地址 (Destination MAC Address)¶
- 大小 (Size): 6 字节 (48 bits)
- 描述 (Description): 目标设备的 MAC 地址,标识数据包的接收端。
- The MAC address of the destination device, indicating the recipient of the data packet.
4. 源 MAC 地址 (Source MAC Address)¶
- 大小 (Size): 6 字节 (48 bits)
- 描述 (Description): 发送设备的 MAC 地址,标识数据包的发送端。
- The MAC address of the sending device, identifying the sender of the data packet.
5. EtherType¶
- 大小 (Size): 2 字节 (16 bits)
- 描述 (Description): 用于标识上层协议类型(如 IPv4、IPv6、ARP 等),帮助以太网帧在到达目的地时由网络层正确处理。
- Used to indicate the type of upper-layer protocol (e.g., IPv4, IPv6, ARP) to help the Ethernet frame be correctly processed by the network layer upon reaching its destination.
6. 数据负载 (Payload)¶
- 大小 (Size): 46-1500 字节
- 描述 (Description): 传输的数据负载,包含上层协议的数据包(如 IP 数据包)。以太网帧的最小有效负载为 46 字节,最大为 1500 字节。
- The payload data being transmitted, containing the upper-layer protocol data (e.g., IP packets). The minimum valid payload for an Ethernet frame is 46 bytes, and the maximum is 1500 bytes.
- 填充 (Padding): 如果数据负载小于 46 字节,以太网帧会填充额外的数据以达到最小长度要求。
- If the payload is less than 46 bytes, the Ethernet frame adds padding to meet the minimum length requirement.
7. 帧校验序列 (Frame Check Sequence, FCS)¶
- 大小 (Size): 4 字节 (32 bits)
- 描述 (Description): FCS 使用循环冗余校验 (CRC) 计算出一个校验码,用于检测帧在传输过程中的错误。如果接收端计算出的 CRC 与 FCS 不匹配,则认为数据帧在传输过程中发生了错误。
- The FCS uses a Cyclic Redundancy Check (CRC) to calculate a checksum, which is used to detect errors in the frame during transmission. If the CRC calculated by the receiver does not match the FCS, it indicates that an error occurred during transmission.
Ethernet 封装过程 (Ethernet Encapsulation Process)¶
- 数据生成 (Data Generation): 上层协议生成数据包(如 IP 数据包)。
-
The upper-layer protocol generates a data packet (e.g., IP packet).
-
数据封装 (Data Encapsulation): 数据包通过 Ethernet 协议被封装成以太网帧,包括添加 MAC 地址、EtherType、Preamble 等头信息。
-
The data packet is encapsulated into an Ethernet frame by the Ethernet protocol, including adding MAC addresses, EtherType, Preamble, and other header information.
-
帧传输 (Frame Transmission): 以太网帧通过物理介质(如电缆、光纤、无线电波等)传输到目的地。
-
The Ethernet frame is transmitted to the destination through a physical medium (e.g., cable, fiber optics, radio waves).
-
帧解封装 (Frame Decapsulation): 接收端接收到帧后,检查 FCS 校验码,确保数据完整性。然后解封装帧,提取出上层协议的数据包,进行进一步处理。
- Upon receiving the frame, the receiver checks the FCS checksum to ensure data integrity. Then it decapsulates the frame, extracts the upper-layer protocol's data packet, and processes it further.
Ethernet 封装的用途 (Applications of Ethernet Encapsulation)¶
- 局域网通信 (LAN Communication): Ethernet Encapsulation 是局域网 (LAN) 中最常用的封装技术,几乎所有的 LAN 通信都依赖以太网帧。
-
Ethernet Encapsulation is the most commonly used encapsulation technology in Local Area Networks (LAN), with nearly all LAN communication relying on Ethernet frames.
-
错误检测 (Error Detection): 通过 FCS 和 CRC 算法,可以检测数据传输中的错误,确保数据的完整性。
-
Through FCS and CRC algorithms, errors in data transmission can be detected, ensuring data integrity.
-
多协议支持 (Multi-protocol Support): 通过 EtherType 字段,以太网能够支持多种上层协议,如 IPv4、IPv6、ARP 等。
- Through the EtherType field, Ethernet can support multiple upper-layer protocols such as IPv4, IPv6, ARP, and others.
重要性 (Importance)¶
Ethernet Encapsulation 是网络通信中的基础技术,它确保数据在局域网中的传输是可靠和高效的。理解以太网封装对于网络工程师、开发人员来说是至关重要的,尤其是在设计、调试和优化网络时。
Ethernet Encapsulation is a fundamental technology in network communication, ensuring that data transmission within a LAN is reliable and efficient. Understanding Ethernet encapsulation is crucial for network engineers and developers, especially in designing, debugging, and optimizing networks.
EtherType 表 (EtherType Table)¶
EtherType 值 (EtherType Value) | 协议 (Protocol) | 描述 (Description) |
---|---|---|
0x0800 | IPv4 | Internet Protocol version 4 (IPv4) |
0x0806 | ARP | Address Resolution Protocol (ARP) |
0x0842 | Wake-on-LAN | 用于远程唤醒设备的协议 (Protocol used for waking up a device remotely) |
0x86DD | IPv6 | Internet Protocol version 6 (IPv6) |
0x8100 | VLAN | IEEE 802.1Q VLAN Tagging |
0x88CC | LLDP | Link Layer Discovery Protocol (LLDP) |
0x8847 | MPLS Unicast | Multiprotocol Label Switching (MPLS) 单播 (Unicast) |
0x8848 | MPLS Multicast | Multiprotocol Label Switching (MPLS) 多播 (Multicast) |
0x8808 | Ethernet Flow Control | 以太网流量控制协议 (Ethernet Flow Control Protocol) |
0x88A8 | Provider Bridging (IEEE 802.1ad) | 服务提供商桥接协议 (Provider Bridging Protocol, also known as Q-in-Q) |
0x8863 | PPPoE Discovery | PPP over Ethernet (PPPoE) 探测阶段 (Discovery Stage) |
0x8864 | PPPoE Session | PPP over Ethernet (PPPoE) 会话阶段 (Session Stage) |
0x8870 | Jumbo Frames | 巨型帧协议 (Jumbo Frames Protocol) |
0x88E1 | HomePlug | HomePlug 1.0 |
0x88E5 | MAC Security (IEEE 802.1AE) | MAC 层安全协议 (Media Access Control Security Protocol) |
0x88F7 | Precision Time Protocol (PTP) | 精确时间协议 (Precision Time Protocol, IEEE 1588) |
0x8906 | Fibre Channel over Ethernet (FCoE) | 以太网上的光纤通道 (Fibre Channel over Ethernet) |
0x8914 | FCoE Initialization Protocol (FIP) | 光纤通道初始化协议 (Fibre Channel over Ethernet Initialization Protocol) |
0x9100 | Q-in-Q VLAN Tagging | VLAN stacking 标记 (Q-in-Q VLAN Tagging) |
0x9200 | Ethernet Configuration Testing Protocol (ECTP) | 以太网配置测试协议 (Ethernet Configuration Testing Protocol) |
0x88B5 | EAP over LAN (EAPOL) | 局域网上的扩展认证协议 (Extensible Authentication Protocol over LAN) |
说明 (Explanation)¶
- EtherType 值 (EtherType Value): 这是一个 16 位的值,用于标识以太网帧中携带的上层协议类型。
-
This is a 16-bit value used to identify the type of upper-layer protocol carried in the Ethernet frame.
-
协议 (Protocol): EtherType 值对应的协议名称。
-
The name of the protocol corresponding to the EtherType value.
-
描述 (Description): 简要描述协议的功能或用途。
- A brief description of the protocol's functionality or use.