Skip to main content

Ethernet Ⅱ以太帧

Ethernet Ⅱ帧,也称为Ethernet V2帧,是如今局域网里最常见的以太帧,是以太网事实标准。如今大多数的TCP/IP应用(如HTTP、FTP、SMTP、POP3等)都是采用Ethernet II帧承载。

帧格式

Ethernet Ⅱ帧格式
+-----------+-----------+-------------+--------------------+----------+
|   DMAC    |   SMAC    |     Type    |          Data      |   FCS    |
|  6 Bytes  |  6 Bytes  |   2 Bytes   |  Variable length   | 4 Bytes  |
+-----------+-----------+-------------+--------------------+----------+
|                                                                     |
        |                                                          |
                  |                                             |
                           |                                  |
                                   |                         |
                                          |                 |
+-------------+-----------+----------------+-----------------+
|   帧间隙     | 前同步码   |   帧开始定界符   |  Ethernet Frame  |
| 至少12Bytes  | 7 Bytes   |  1 Byte        | Variable length |
+-------------+-----------+----------------+-----------------+
Ethernet Ⅱ以太帧的链路层各字段含义
字段 长度 含义
DMAC 6B 目的MAC地址,IPv4为6字节,该字段标识帧的接收者。
SMAC 6B 源MAC地址,IPv4为6字节,该字段标识帧的发送者。
Type 2B 协议类型。 Ethernet Ⅱ以太帧的物理层各字段含义列出了链路直接封装的协议类型。
Data 46~1500B 数据字段,标识帧的负载(可能包含填充位)。数据字段的最小长度必须为46字节以保证帧长至少为64字节,这意味着传输1字节信息也必须使用46字节的数据字段。如果填入该字段的信息少于46字节,该字段的其余部分也必须进行填充。数据字段的最大长度为1500字节。以太帧的长度必须为整数字节,因此帧的负载长度不足整数字节,需插入填充字段以保证数据帧的长度为整数字节。
FCS 4B 帧校验序列FCS(Frame Check Sequence)是为接收者提供判断是否传输错误的一种方法,如果发现错误,丢弃此帧。FCS只是通用叫法,具体的FCS还可以细分多种校验方法。在以太帧中,FCS通常采用循环冗余码校验CRC(Cyclical Redundancy Check)。
Ethernet Ⅱ以太帧的物理层各字段含义
字段 长度 含义
帧间隙 至少12B 每个以太帧之间都要有帧间隙(Inter Frame Gap),即每发完一个帧后要等待一段时间才能再发另外一个帧,以便让帧接收者对接收的帧做必要的处理(如调整缓存的指针、更新计数、通知对报文进行处理等等)。在以太网标准中规定最小帧间隙是12个字节,其数据为全1。对于个别的接口,可减少到64(GE)或40比特(10GE),其他的接口都不应该小于12字节。
前同步码 7B 以太网标准中规定前导码为10101010 10101010 10101010 10101010 10101010 10101010 10101010(二进制),共7字节。
帧开始定界符 1B 以太网标准中规定帧开始定界符为10101011(二进制),共1字节。

常见Type值

常见Type值对应的协议
协议
0x0800 Internet Protocol Version 4 (IPv4)
0x0801 X.75 Internet
0x0805 X.25 Level 3
0x0806 Address Resolution Protocol (ARP)
0x0808 Frame Relay ARP
0x22F3 TRILL
0x22F4 L2-IS-IS
0x6558 Trans Ether Bridging
0x6559 Raw Frame Relay
0x8035 Reverse Address Resolution Protocol (RARP)
0x809b Appletalk
0x8100 IEEE Std 802.1Q - Customer VLAN Tag Type (C-Tag, formerly called the Q-Tag) (initially Wellfleet)
0x8137 Novell NetWare IPX/SPX (old)
0x8138 Novell, Inc.
0x8100 IEEE Std 802.1Q - Customer VLAN Tag Type
0x814C SNMP over Ethernet
0x86DD IP Protocol version 6 (IPv6)
0x876B TCP/IP Compression
0x876C IP Autonomous Systems
0x876D Secure Data
0x8808 IEEE Std 802.3 - Ethernet Passive Optical Network (EPON)
0x880B Point-to-Point Protocol (PPP)
0x880C General Switch Management Protocol (GSMP)
0x8847 MPLS (multiprotocol label switching)
0x8848 MPLS with upstream-assigned label
0x8863 PPP over Ethernet (PPPoE) Discovery Stage
0x8864 PPP over Ethernet (PPPoE) Session Stage
0x888E IEEE Std 802.1X - Port-based network access control
0x88A8 IEEE Std 802.1Q - Service VLAN tag identifier (S-Tag)
0x88B7 IEEE Std 802 - OUI Extended Ethertype
0x88C7 IEEE Std 802.11 - Pre-Authentication (802.11i)
0x88CC IEEE Std 802.1AB - Link Layer Discovery Protocol (LLDP)
0x88E5 IEEE Std 802.1AE - Media Access Control Security
0x88F5 IEEE Std 802.1Q - Multiple VLAN Registration Protocol (MVRP)
0x88F6 IEEE Std 802.1Q - Multiple Multicast Registration Protocol (MMRP)
0x893B TRILL Fine Grained Labeling (FGL)
0x8946 TRILL RBridge Channel

👉 说明 更详细的信息请参见IEEE 802 Numbers

帧示例

Ethernet II以太帧
Frame 1: 54 bytes on wire (432 bits), 54 bytes captured (432 bits)
  Arrival Time: May 4, 2008 18:15:17.630001000
  Epoch Time: 1209896117.630001000 seconds
  [Time delta from previous captured frame: 0.000000000 seconds]
  [Time delta from previous displayed frame: 0.000000000 seconds]
  [Time since reference or first frame: 0.000000000 seconds]
  Frame Number: 1
  Frame Length: 54 bytes (432 bits)
  Capture Length: 54 bytes (432 bits)
  [Frame is marked: False]
  [Frame is ignored: False]
  [Protocols in frame: eth:ip:tcp]
  [Coloring Rule Name: TCP]
  [Coloring Rule String: tcp]
Ethernet II, Src: CompalEl_df:d0:05 (00:0f:b0:df:d0:05), Dst: HughesNe_a9:4f:87 (00:80:ae:a9:4f:87)
  Destination: HughesNe_a9:4f:87 (00:80:ae:a9:4f:87)
      Address: HughesNe_a9:4f:87 (00:80:ae:a9:4f:87)
      .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
      .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  Source: CompalEl_df:d0:05 (00:0f:b0:df:d0:05)
      Address: CompalEl_df:d0:05 (00:0f:b0:df:d0:05)
      .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
      .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  Type: IP (0x0800)
Internet Protocol Version 4, Src: 192.168.128.101 (192.168.128.101), Dst: 172.25.4.24 (172.25.4.24)
  Version: 4
  Header length: 20 bytes
  Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
      0000 00.. = Differentiated Services Codepoint: Default (0x00)
      .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
  Total Length: 40
  Identification: 0xc17e (49534)
  Flags: 0x02 (Don't Fragment)
      0... .... = Reserved bit: Not set
      .1.. .... = Don't fragment: Set
      ..0. .... = More fragments: Not set
  Fragment offset: 0
  Time to live: 128
  Protocol: TCP (6)
  Header checksum: 0x4812 [correct]
      [Good: True]
      [Bad: False]
  Source: 192.168.128.101 (192.168.128.101)
  Destination: 172.25.4.24 (172.25.4.24)
Transmission Control Protocol, Src Port: tht-treasure (1832), Dst Port: icon-discover (2799), Seq: 1, Ack: 1, Len: 0
  Source port: tht-treasure (1832)
  Destination port: icon-discover (2799)
  [Stream index: 0]
  Sequence number: 1   (relative sequence number)
  Acknowledgement number: 1   (relative ack number)
  Header length: 20 bytes
  Flags: 0x10 (ACK)
      000. .... .... = Reserved: Not set
      ...0 .... .... = Nonce: Not set
      .... 0... .... = Congestion Window Reduced (CWR): Not set
      .... .0.. .... = ECN-Echo: Not set
      .... ..0. .... = Urgent: Not set
      .... ...1 .... = Acknowledgement: Set
      .... .... 0... = Push: Not set
      .... .... .0.. = Reset: Not set
      .... .... ..0. = Syn: Not set
      .... .... ...0 = Fin: Not set
  Window size value: 17520
  [Calculated window size: 17520]
  [Window size scaling factor: -1 (unknown)]
  Checksum: 0xf893 [validation disabled]
      [Good Checksum: False]
      [Bad Checksum: False]

参考标准

Ethernet II参考标准
标准 描述
IEEE 802.3 Carrier sense multiple access with collision detection (CSMA/CD) access method and physical layer specifications
IEEE 802.3ae Media Access Control (MAC) Parameters, Physical Layers, and Management parameters for 10Gb/s Operation
RFC 894 A Standard for the Transmission of IP Datagrams over Ethernet Networks
RFC 1042 A Standard for the Transmission of IP Datagrams over IEEE 802 Networks