Getting Started with Automotive Ethernet Switches (2) - Getting Started with VLAN

Publisher:EnigmaticCharmLatest update time:2024-09-13 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the book "Basic Skills of Switches - Part 1", it is mentioned that switches divide communication areas at the physical level and generate local area networks (LANs). A local area network has a characteristic: once the connection topology is determined, the communication area will not change for a certain period of time. In the actual communication process, broadcast messages and unicast messages with unknown destination addresses need to be notified to all devices. The size of the communication area affects the number of devices that need to be notified in this process. However, indiscriminate broadcasting of devices will cause broadcast flooding. The switch does not have the function of device selection at this time, and all devices in the communication area have no choice but to be constantly "disturbed" (the "i" device means: the "e-person" of the switch is so terrible, crying silently ㄒoㄒ~~). Moreover, this broadcast flooding will also occupy bandwidth, causing line conflicts and performance degradation, and may even cause network paralysis.


To solve this problem, a simple idea is: is it feasible to change the connection topology within the LAN? The answer is that it is useful, but not much. The reason is simple. If you only need to change the connection topology occasionally, and only change one or two devices each time, it is just a matter of plugging and unplugging a few network cables. But what if you need to change the communication area frequently, or there are multiple communication areas, and many devices are involved each time? Even Avalokitesvara would have to say: This job is too tiring...


Smart friends may think that if we do not change the physical connection, but limit the transmission path of the message so that they can only be forwarded within a specific range? That's right, there is always a way out. Since we can't change the physical world, we can show our skills in the virtual world. This is the origin of Virtual Local Area Network (VLAN)!

VLAN technology divides the LAN into multiple areas at the logical level. Each area is an independent broadcast domain. Broadcast communication can be carried out within the area, but direct communication cannot be carried out between areas. In this way, the broadcast domain can be quickly divided and modified without modifying the actual connection topology, which greatly enhances operability and adaptability. Imagine that you are discussing how to write group assignments in the group group while discussing what to eat in the dormitory group. If the information of the two groups can be seen by each other, wouldn’t it be a mess? ! The advantage of this group discussion method is that if a group member is temporarily added, you only need to pull this person into the group group to continue the discussion, and it will not affect the previous work. It is so convenient!

Then, friends may ask again: What kind of "magic" is used to achieve such a convenient VLAN?

The magic is: VLAN ID, or VID for short, which is the number of different VLANs. By adding an extra field in the message, the VID of the message is marked, indicating which VLAN the message will be transmitted under.

VLAN message structure

The message structure carrying VID follows the IEEE 802.1Q protocol. IEEE (Institute of Electrical and Electronics Engineers) has made outstanding contributions in the fields of electrical and electronic engineering, computers and other technologies, leading the development of new technologies and formulating international and industry standards. The 802.1Q protocol defines a standardized implementation of VLAN based on the MAC (Media Access Control) message.

First, let's introduce the MAC message without VLAN. There are two formats, one is the format promulgated by IEEE 802.3 in 1982, and the other is the format promulgated by Ethernet V2 in 1983. The two differ only in some fields. The formats are shown in Figure 2 and Figure 3:

wKgZomaV6S6AL2x1AABubwe4LoY096.png

Figure 2 IEEE 802.3 MAC message format

wKgZomaV6TSAXYT2AAB42kbRDUI329.png

Figure 3 Ethernet V2 MAC message format

The meaning of each field is as follows:

  • PRE: Preamble, 8 bytes long (one byte has 8 bits), used for time synchronization, usually a continuous value of "10".

  • DA: Destination Address, with a length of 6 bytes, indicating that the message is to be sent to a specific MAC address.

  • SA: Source Address, 6 bytes in length, indicating the MAC address that sends the message.

  • L/T: Length/Type, indicating the length/type of the message, with a length of 2 bytes; the L length field value is between 0 and 1500, and the T type field value is greater than 1536. The value between 1500 and 1536 is undefined. The T type field can indicate the protocol types such as IPv4, IPv6, and ARP.

  • DATA: data, with a length between 46 and 1500 bytes.

  • FCS: Frame Check Sequence uses the CRC (Cyclic Redundancy Check) algorithm to calculate the check value for the DA, SA, L/T, and DATA fields to ensure that the data has not been tampered with during transmission.

Furthermore, based on the above MAC message format, a VLAN description field is added. The specific format is shown in Figure 4:

wKgaomaV6USAcrWLAABYFVpra0A189.png

Figure 4 MAC message format carrying VLAN

The description field of VLAN is between SA and L/T, which is called Tag field. The Tag field is 4 bytes long and consists of two parts: TPID and TCI:

  • TPID: Tag Protocol Identifier, Tag protocol identification bit. The position of this field coincides with the L/T field of untagged messages and is used to distinguish whether a message carries a tag.

  • TCI: Tag Control Information, tag control information, including specific VLAN control information.

The TCI field can be divided into three parts:

  • PCP: Priority Code Point priority code bit, length is 3 bits, indicating the priority forwarding order of the message in the same VLAN, needs to be used in conjunction with the switch queue, which will be introduced later.

  • DEI: Drop Eligible Indicator, 1 bit in length, indicates whether to discard data if too much data affects the transmission efficiency. A value of 0 means no discard, and 1 means discard.

  • VLAN ID: VID for short, 12 bits in length, indicating the VLAN to which the message belongs. This is also the "magic" of arbitrarily dividing broadcast domains mentioned above!

In addition to adding a tag field to the message to indicate the VLAN to which the message belongs, the actual forwarding also requires the switch. Among them, the switch port attributes are very critical in the VLAN forwarding process. In "Switch Basics-3", we will introduce the switch port attributes and the specific forwarding process.


Reference address:Getting Started with Automotive Ethernet Switches (2) - Getting Started with VLAN

Previous article:CANXL Protocol Interpretation Series | (2) Understanding ISO 11898-2:2024 CANXL Physical Layer
Next article:Electric vehicle (EV) durability: Designing and testing SiC for millions of cycles

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号