VLAN报文帧格式
IEEE 802.1Q标准对以太帧格式进行了修改,在源MAC地址字段和协议类型字段之间加入4字节的802.1Q Tag。802.1Q Tag也称为VLAN Tag,带有VLAN Tag的以太帧称为VLAN帧。
一、VLAN报文帧格式
+-----------+----------+--------+-----------+ | TPID | PRI | CFI | VID | | 2 Bytes | 3 Bits | 1 Bits | 12 Bits | +-----------+----------+--------+-----------+ | | | | | | | | +-----------+-----------+--------------+---------------+------+-----------+----------+ | DMAC | SMAC | 802.1Q Tag | Length/Type | Data | FCS | | 6 Bytes | 6 Bytes | 4 Bytes | 2 Bytes | Variable length | 4 Bytes | +-----------+-----------+--------------+---------------+------+-----------+----------+ | | | | | | | | +--------------------+-----------------+-------------+---------------------+ | 帧间隙 | 前同步码 |帧开始定界符 | Ethernet Frame | | 至少12Bytes | 7 Bytes | 1 Byte | Variable length | +--------------------+-----------------+-------------+---------------------+
字段 | 长度 | 含义 |
---|---|---|
DMAC | 6字节 | 目的MAC地址,该字段标识帧的接收者。 |
SMAC | 6字节 | 源MAC地址,该字段标识帧的发送者。 |
TPID | 2字节 | TPID(Tag Protocol Identifier,标签协议标识)表示帧类型。
说明:
根据IEEE 802.1Q标准的定义,取值为0x8100时表示802.1Q Tag(VLAN)帧。如果不支持802.1Q的设备收到这样的帧,会将其丢弃。 根据IEEE 802.1ad的定义,8021.Q Tag可分为S-Tag和C-Tag两种,S-Tag用于标识业务,C-Tag用于标识用户。区分这两种Tag的是TPID,S-Tag的TPID是0x88a8,C-Tag的TPID是0x8100。 MEF 26.1(ENNI Specification)标准中规定出ENNI端口的VLAN帧的Tag可以是S-Tag。可见,VLAN帧的TPID值可以是非0x8100。 |
PRI | 3比特 | PRI(Priority)表示帧的QoS优先级,取值范围为0~7,值越大优先级越高,该优先级主要为QoS差分服务提供参考依据。当阻塞时,优先发送优先级高的数据包。
如果设置用户优先级,但是没有VID(VLAN ID),则VLAN ID必须设置为0x000。 |
CFI | 1比特 |
CFI (Canonical Format Indicator,标准格式指示),长度为1比特,表示MAC地址是否是标准格式。CFI为0说明是标准格式(以太网帧的MAC地址采用低字节在前),CFI为1表示为非标准格式(以太网帧的MAC地址采用高字节在前)。CFI可用于区分以太网帧、FDDI(Fiber Distributed Digital Interface)帧和令牌环网帧。在以太网中,CFI的值为0。 DEI(Drop Eligible Indicator,丢弃优先级指示),配合PRI字段使用,共同指示帧的丢弃优先级,也就是系统发生了拥塞时,这些报文会被优先丢弃。 说明:
IEEE 802.1Q定义了CFI字段,而IEEE 802.1ad标准重新定义了CFI字段,规定S-Tag里面的是DEI,C-Tag里面的是CFI。 实际应用中,可以根据需要将此比特位用作CFI或者用作DEI。 |
VID | 12比特 | VID(VLAN ID),长度为12比特,表示该帧所属的VLAN。在VRP中,可配置的VLAN ID取值范围为1~4094。协议规定0和4095为保留的VLAN ID。
有三种VID类型:
三个特殊的VID:
|
Length/Type | 2字节 | 该字段有两种含义:
|
Data | 42~1500字节 |
负载(可能包含填充位)。 VLAN帧的长度必须为整数字节,因此帧的负载长度不足整数字节,需插入填充字段以保证数据帧的长度为整数字节。 说明:
IEEE 802.1Q和IEEE 802.1ad标准中并没有定义VLAN帧的最小长度和最大长度。
|
FCS | 4字节 |
帧校验序列FCS(Frame Check Sequence)是为接收网卡提供判断是否传输错误的一种方法,如果发现错误,丢弃此帧。 FCS只是通用叫法,具体的FCS还可以细分多种校验方法。在以太帧中,FCS通常采用循环冗余码校验CRC(Cyclical Redundancy Check)。 |
字段 | 长度 | 含义 |
---|---|---|
帧间隙 | 至少12字节 | 每个以太帧之间都要有帧间隙(Inter Frame Gap),即每发完一个帧后要等待一段时间才能再发另外一个帧,以便让帧接收者对接收的帧作必要的处理(如调整缓存的指针、更新计数、通知对报文进行处理等等)。在以太网标准中规定最小帧间隙是12个字节,其数据为全1。对于个别的接口,可减少到64(GE)或40比特(10GE),其他的接口都不应该小于12字节。 |
前同步码 | 7字节 | 以太网标准中规定前导码为10101010 10101010 10101010 10101010 10101010 10101010 10101010(二进制),共7字节。 |
帧开始定界符 | 1字节 | 以太网标准中规定帧开始定界符为10101011(二进制),共1字节。 |
2 、VLAN报文帧示例
Frame 1: 114 bytes on wire (912 bits), 114 bytes captured (912 bits) Arrival Time: Jan 1, 1970 08:00:00.083640000 Epoch Time: 0.083640000 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: 114 bytes (912 bits) Capture Length: 114 bytes (912 bits) [Frame is marked: False] [Frame is ignored: False] [Protocols in frame: eth:ip:udp:ptp] [Coloring Rule Name: UDP] [Coloring Rule String: udp] Ethernet II (VLAN tagged), Src: HuaweiTe_92:27:fe (28:6e:d4:92:27:fe), Dst: HuaweiTe_00:00:11 (00:18:82:00:00:11) Destination: HuaweiTe_00:00:11 (00:18:82:00:00:11) Address: HuaweiTe_00:00:11 (00:18:82:00:00:11) .... ...0 .... .... .... .... = IG bit: Individual address (unicast) .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default) Source: HuaweiTe_92:27:fe (28:6e:d4:92:27:fe) Address: HuaweiTe_92:27:fe (28:6e:d4:92:27:fe) .... ...0 .... .... .... .... = IG bit: Individual address (unicast) .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default) VLAN tag: VLAN=10, Priority=Best Effort (default) Identifier: 802.1Q Virtual LAN (0x8100) 000. .... .... .... = Priority: Best Effort (default) (0) ...0 .... .... .... = CFI: Canonical (0) .... 0000 0000 1010 = VLAN: 10 Type: IP (0x0800) Trailer: e614db8b Internet Protocol Version 4, Src: 10.0.1.50 (10.0.1.50), Dst: 10.0.1.2 (10.0.1.2) Version: 4 Header length: 20 bytes Differentiated Services Field: 0x10 (DSCP 0x04: Unknown DSCP; ECN: 0x00: Not-ECT (Not ECN-Capable Transport)) 0001 00.. = Differentiated Services Codepoint: Unknown (0x04) .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00) Total Length: 92 Identification: 0x0566 (1382) Flags: 0x00 0... .... = Reserved bit: Not set .0.. .... = Don't fragment: Not set ..0. .... = More fragments: Not set Fragment offset: 0 Time to live: 255 Protocol: UDP (17) Header checksum: 0x0fe7 [correct] [Good: True] [Bad: False] Source: 10.0.1.50 (10.0.1.50) Destination: 10.0.1.2 (10.0.1.2) User Datagram Protocol, Src Port: ptp-general (320), Dst Port: ptp-general (320) Source port: ptp-general (320) Destination port: ptp-general (320) Length: 72 Checksum: 0x82b8 [validation disabled] [Good Checksum: False] [Bad Checksum: False] Precision Time Protocol (IEEE1588) 0001 .... = transportSpecific: 0x01 ...1 .... = V1 Compatibility: True .... 1011 = messageId: Announce Message (0x0b) .... 0010 = versionPTP: 2 messageLength: 64 subdomainNumber: 0 flags: 0x040a 0... .... .... .... = PTP_SECURITY: False .0.. .... .... .... = PTP profile Specific 2: False ..0. .... .... .... = PTP profile Specific 1: False .... .1.. .... .... = PTP_UNICAST: True .... ..0. .... .... = PTP_TWO_STEP: False .... ...0 .... .... = PTP_ALTERNATE_MASTER: False .... .... ..0. .... = FREQUENCY_TRACEABLE: False .... .... ...0 .... = TIME_TRACEABLE: False .... .... .... 1... = PTP_TIMESCALE: True .... .... .... .0.. = PTP_UTC_REASONABLE: False .... .... .... ..1. = PTP_LI_59: True .... .... .... ...0 = PTP_LI_61: False correction: 0.000000 nanoseconds correction: Ns: 0 nanoseconds SubNs: 0.000000 nanoseconds ClockIdentity: 0x00188200000085ba SourcePortID: 1 sequenceId: 22 control: Other Message (5) logMessagePeriod: 1 originCurrentUTCOffset: 0 priority1: 128 grandmasterClockClass: 84 grandmasterClockAccuracy: The time is accurate to within 250 ns (0x22) grandmasterClockVariance: 0 priority2: 128 grandmasterClockIdentity: 0x00188200000085ba localStepsRemoved: 0 TimeSource: ATOMIC_CLOCK (0x10)
三、VLAN报文帧参考标准
标准 | 描述 |
---|---|
RFC 3069 | VLAN Aggregation for Efficient IP Address Allocation |
IEEE 802.1Q | IEEE Standards for Local and Metropolitan Area Networks : Virtual Bridged Local Area Networks |
IEEE 802.1ad | IEEE Standards for Local and Metropolitan Area Networks: Virtual Bridged Local Area Networks- Amendment 4 |
发表评论