Flashing method for forwarding table in automotive ethernet, electronic device, and medium
By performing segmented management of hardware forwarding tables, the problem of too long protection switching time in the on-board Ethernet switch system is solved, and the protection switching time requirements of less than 50ms are met in a hardware forwarding table system, which improves the reliability and real-timeness of the system.
Patent Information
- Application Number
- PCT/CN2024/143280
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-02
- Filing Date
- 2024-12-27
- Publication Date
- 2025-07-10
AI Technical Summary
In the process of recovering normal service data in the existing on-board Ethernet switch chips, the protection switching time cannot meet the requirements of less than 50ms, especially in on-board switch systems that use a hardware forwarding table. The traditional global traversal method causes too long.
By segmenting the hardware forwarding table in the initialization stage and managing the switch's hardware forwarding table according to the port at the software level, the traversal scope is narrowed and the addition, deletion and protection switching operations of forwarding table items are performed only within a specific range.
It effectively shortens the protection switching time, meets the industry requirements of less than 50ms, and improves the reliability and real-timeness of the on-board Ethernet system.
Smart Images

Figure CN2024143280_10072025_PF_FP_ABST
Abstract
Description
Vehicle Ethernet forwarding table flashing method, electronic device and medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on January 2, 2024, with application number 202410007001.2 and invention name “Method, electronic device and medium for flashing vehicle-mounted Ethernet forwarding table”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of in-vehicle Ethernet, and specifically to a method for flashing an in-vehicle Ethernet forwarding table, an electronic device, and a medium. Background Art
[0004] With the development of in-vehicle EE architecture, Ethernet has become the mainstream backbone network. To ensure the reliability and real-time performance of in-vehicle functional safety, automotive Ethernet design must protect service data to prevent interruption of critical data communications. The industry requires a protection switching time of less than 50ms, encompassing the total time from fault detection to service data restoration.
[0005] CN102368722A discloses a chip implementation method and system for fast switching in Ethernet ring network protection. When a primary port fails, the method can complete the switching between the working port and the backup port in hardware, without the need for software table flushing operations during the entire process. Although this greatly shortens the protection switching time, the method requires hardware support, which is not currently supported by switching chips provided by mainstream in-vehicle switching chip manufacturers such as NXP.
[0006] Current in-vehicle Ethernet ring systems mostly implement protection switching by refreshing the Ethernet forwarding table with software. If a backup forwarding table is used for protection switching, soft forwarding is required, with upper-layer software maintaining the primary and backup forwarding tables. While this theoretically allows for rapid protection switching in Ethernet rings, due to limited onboard MCU resources, the current approach primarily relies on hardware forwarding within the switch chip, which only has one hardware forwarding table. Traditional global traversal software refresh methods, when the switch chip forwarding table entries reach a certain specification, fail to meet the industry's requirement for a protection switching time of less than 50ms. Summary of the Invention
[0007] The purpose of this application is to provide a method, electronic device and medium for flashing an in-vehicle Ethernet forwarding table, so that the protection switching time of an in-vehicle Ethernet switch system using a hardware forwarding table meets the industry requirement of less than 50ms.
[0008] In a first aspect, the method for flashing an in-vehicle Ethernet forwarding table described in this application includes:
[0009] Step 1: Segment the hardware forwarding table during the initialization phase, and then proceed to step 2.
[0010] Step 2: Manage the forwarding table entries in the segmented segments, and then proceed to step 3.
[0011] Step 3: Determine whether the switching information is obtained. If yes, execute step 4; otherwise, return to step 2.
[0012] Step 4: Perform protection switching according to the segment information, and then return to step 2.
[0013] Optionally, in step 1, the method for segmenting the hardware forwarding table during the initialization phase includes:
[0014] During the initialization phase, based on the requirements of the Ethernet ring system, the hardware forwarding table is segmented based on ports, and the position range occupied by each port of the switch is divided.
[0015] Record the starting position S_x_START, ending position S_x_END, capacity S_x_max, and number of occupied slots S_x_num in the current segment S_x corresponding to port x in the hardware forwarding table after segmentation. Ports and segments are uniquely mapped, and x is an integer from 1 to n, where n represents the total number of ports on the switch. The initial value of S_x_num is 0. Segmenting the hardware forwarding table can narrow the traversal range and reduce traversal time when adding or deleting MAC address forwarding entries.
[0016] Optionally, after the hardware forwarding table is segmented in the initialization phase, the static MAC address forwarding table entry for port x required by the Ethernet ring system is written into the corresponding position in the segment S_x corresponding to port x in the hardware forwarding table, and S_x_num is updated (corresponding to accumulating S_x_num).
[0017] Optionally, in step 2, the method for managing forwarding entries in the segmented segments includes:
[0018] When a MAC address forwarding entry needs to be added after MAC address learning, the system first determines that the target location of the MAC address forwarding entry is within segment S_i based on the information that the outgoing port in the MAC address forwarding entry is port i. Next, the system traverses the range from S_i_START+S_i_num to S_i_END in segment S_i to obtain an empty location. The MAC address forwarding entry is then written into the empty location. Finally, S_i_num is updated (corresponding to incrementing S_i_num). Here, i is an integer with 1≤i≤n (i.e., i is any integer between 1 and n). When adding a MAC address forwarding entry, only the unoccupied locations within a segment need to be traversed, thereby reducing the traversal range and traversal time.
[0019] Optionally, in step 2, the method for managing forwarding entries in the segmented segments further includes:
[0020] When a MAC address forwarding entry needs to be deleted, first, based on the information that the outgoing port in the MAC address forwarding entry is port k, traverse the range from S_k_START to S_k_START+S_k_num-1 in segment S_k to find the location S_k_USE within segment S_k where the MAC address forwarding entry is located. Secondly, delete the MAC address forwarding entry within segment S_k. Then, flush the last MAC address forwarding entry in segment S_k to location S_k_USE (i.e., the original location of the deleted MAC address forwarding entry). Finally, update S_k_num (corresponding to decrementing S_k_num). Here, k is an integer, and 1≤k≤n (i.e., k is any integer between 1 and n). When deleting a MAC address forwarding entry, only the occupied location range within a segment needs to be traversed, thereby narrowing the traversal range and reducing the traversal time. After deleting a MAC address forwarding entry, flush the last MAC address forwarding entry to the deleted location. This prevents idle space in the middle of the segment and ensures that MAC address forwarding entries always remain in the range of S_k_START to S_k_START+S_k_num-1, preventing subsequent addition or deletion errors.
[0021] Optionally, when S_x_num=S_x_max (ie, when the position of the segment S_x is full), no MAC address forwarding entry is added, and only the message is forwarded.
[0022] Optionally, in step 4, the method for performing protection switching according to the segment information includes:
[0023] The first step is to obtain information of the segment S_h corresponding to the faulty port (i.e., the active port) based on the information that the faulty port (i.e., the active port) is port h; wherein h is an integer, and 1≤h≤n (i.e., h is any integer from 1 to n).
[0024] Step 2: Traverse the range from S_h_START to S_h_START+S_h_num-1 of segment S_h to obtain the MAC address forwarding entries in the range from S_h_START to S_h_START+S_h_num-1 (the outbound port of these MAC address forwarding entries is port h), which are recorded as forwarding table entries ZB.
[0025] Step 3: Delete the MAC address forwarding entries in the range from S_h_START to S_h_START+S_h_num-1 in the segment S_h, and update S_h_num (ie, S_h_num is decremented until S_h_num=0).
[0026] Step 4: Based on the information that the backup port is port m, obtain the information of the segment S_m corresponding to the backup port (ie, port m); wherein m is an integer, and 1≤m≤n (ie, m is any integer from 1 to n).
[0027] Step 5. Traverse the range from S_m_START to S_m_END of segment S_m to obtain the free position of segment S_m.
[0028] Step 6: Update the outgoing port of the forwarding table entry ZB to port m (ie, update it to a standby port), and obtain the forwarding table entry ZB'.
[0029] Step 7: Write the forwarding table entry ZB' (ie, the forwarding table entry whose egress port has been updated to port m) into the free position of segment S_m, and update S_m_num (ie, S_m_num is accumulated according to the number of forwarding table entries ZB').
[0030] During protection switching, traversal is performed only within the specific range of S_h_START to S_h_START+S_h_num-1 of segment S_h. This can shield invalid traversals within the segment, further reducing the number of traversals, thereby reducing the time consumption caused by invalid traversals during the protection switching process and effectively shortening the overall protection switching time.
[0031] In a second aspect, the electronic device described in the present application includes a processor and a memory connected to the processor, wherein the memory stores a computer-readable program, and when the computer-readable program is called by the processor, it can execute the above-mentioned method for flashing the in-vehicle Ethernet forwarding table.
[0032] In a third aspect, the medium described in the present application stores a computer-readable program therein, and when the computer-readable program is called, it can execute the above-mentioned method for flashing the in-vehicle Ethernet forwarding table.
[0033] This application segments the switch's hardware forwarding table by port at the software level. When a protection switch triggers a forwarding table refresh, the application deletes and relearns a specific range of forwarding table entries based on the segmentation information corresponding to the faulty port (i.e., a forwarding table refresh during protection switching). When the switch's hardware forwarding table reaches a certain capacity, or when a large number of forwarding table entries are occupied on non-protection ports, this application can narrow the traversal range and effectively reduce the time taken to refresh forwarding table entries during protection switching, thereby enabling automotive Ethernet switch systems using a hardware forwarding table to meet industry requirements for protection switching times of less than 50ms. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] FIG1 is a schematic diagram of an application scenario of the method for flashing the vehicle Ethernet forwarding table in an embodiment of the present application.
[0035] FIG2 is a flow chart of a method for flashing an in-vehicle Ethernet forwarding table in an embodiment of the present application.
[0036] FIG3 is a flow chart of a method for adding a MAC address forwarding entry in some embodiments.
[0037] FIG4 is a flow chart of a method for deleting a MAC address forwarding entry in some embodiments.
[0038] FIG5 is a flow chart of a method for performing protection switching based on segment information in some embodiments. DETAILED DESCRIPTION
[0039] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0040] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0041] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0042] It should also be pointed out that the terms "first\second\third" involved in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0043] The vehicle-mounted Ethernet forwarding table flushing method in the embodiment of the present application, the potential application scenario is shown in Figure 1. This vehicle-mounted Ethernet ring network system includes three terminal nodes (i.e., terminal node 1, terminal node 2, terminal node 3) and three switches (i.e., SWITCH1, SWITCH2, SWITCH3) that communicate with each other. An Ethernet ring is formed between switch SWITCH1, switch SWITCH2 and switch SWITCH3, wherein switch SWITCH1 is the OWNER node. Under normal circumstances, the RPL link is blocked. When a non-RPL link fails (i.e., the primary port fails), switch SWITCH1, switch SWITCH2 and switch SWITCH3 need to refresh the forwarding table of each faulty port to the backup port according to the APS message, thereby completing the protection switching. Because the processing logic of the forwarding table flushing of switch SWITCH1, switch SWITCH2 and switch SWITCH3 is consistent, switch SWITCH1 is taken as an example for explanation. Switch SWITCH1 has an MCU, and the upper-layer software is integrated in the MCU.
[0044] As shown in Figures 1 to 5, the method for flashing the vehicle Ethernet forwarding table in the embodiment of the present application includes the following steps:
[0045] Step 1: Segment the hardware forwarding table during the initialization phase, and then proceed to step 2.
[0046] In some embodiments, the specific method of segmenting the hardware forwarding table includes: in the initialization phase, according to the requirements of the Ethernet ring network system, the hardware forwarding table is segmented based on the port as the element, and the position range occupied by each port of the switch in the hardware forwarding table is divided. The starting position S_x_START, the ending position S_x_END, the capacity S_x_max and the number of occupied positions S_x_num in the current segment S_x of the segment S_x corresponding to the port x in the hardware forwarding table are recorded after the segmentation. Among them, there is a unique mapping relationship between the port and the segment (i.e., there are as many segments as there are ports), x takes all integers from 1 to n in sequence, and n represents the total number of ports of the switch. After the hardware forwarding table is segmented in the initialization phase, it is necessary to write the static MAC address forwarding table entry for port x required by the Ethernet ring network system into the corresponding position in the segment S_x corresponding to the port x in the hardware forwarding table, and update S_x_num (corresponding to accumulating S_x_num).
[0047] In the embodiment of the present application, switch SWITCH1 has three ports (i.e., n=3), namely PORT1 (i.e., port 1), PORT2 (i.e., port 2), and PORT3 (i.e., port 3). Port 1 is the active port, port 2 is the blocked port (i.e., backup port) on the RPL link, and port 3 is the port connected to terminal node 1. During the initialization phase, the hardware forwarding table is divided into three segments, namely segment S_1 corresponding to port 1, segment S_2 corresponding to port 2, and segment S_3 corresponding to port 3. The position range of segment S_1 in the hardware forwarding table is 0 to 99, the position range of segment S_2 in the hardware forwarding table is 100 to 199, and the position range of segment S_3 in the hardware forwarding table is 200 to 299. Therefore, the starting position S_1_START of segment S_1 is 0, the ending position S_1_END of segment S_1 is 99, the capacity S_1_max of segment S_1 is 100, and the initial value of the number of occupied positions S_1_num of segment S_1 is 0. Similarly, the starting position S_2_START of segment S_2 is 100, the ending position S_2_END of segment S_2 is 199, the capacity S_2_max of segment S_2 is 100, and the initial value of the number of occupied positions S_2_num of segment S_2 is 0; the starting position S_3_START of segment S_3 is 200, the ending position S_3_END of segment S_3 is 299, the capacity S_3_max of segment S_3 is 100, and the initial value of the number of occupied positions S_3_num of segment S_3 is 0.
[0048] Step 2: The upper-layer software manages the forwarding table entries within the segmented segments, and then executes step 3.
[0049] The management of the forwarding table entries within the segmented segments is performed by the upper-layer software. The management of the forwarding table entries mainly involves the addition and deletion of MAC address forwarding entries.
[0050] During system operation, MAC address learning is controlled by upper-layer software. As shown in Figure 3, in some embodiments, when a MAC address forwarding entry needs to be added after MAC address learning, the upper-layer software first determines that the target location of the MAC address forwarding entry is within segment S_1 based on the information that the egress port in the MAC address forwarding entry is port 1 (assuming i = 1 in this embodiment, i.e., the egress port in the MAC address forwarding entry to be added is port 1). The upper-layer software then traverses the range from S_1_START + S_1_num to S_1_END in segment S_1 to find an empty location. The upper-layer software then writes the MAC address forwarding entry into this empty location. Finally, the upper-layer software increments S_1_num by 1, completing the addition operation. When S_1_num = S_1_max (i.e., when the locations in segment S_1 are full), no further MAC address forwarding entries are added, and only packets are forwarded.
[0051] As shown in FIG4 , in some embodiments, when a MAC address forwarding entry needs to be deleted (e.g., due to MAC address aging), the upper-layer software first traverses the range from S_1_START to S_1_START+S_1_num-1 of segment S_1 based on the information that the outgoing port in the MAC address forwarding entry is port 1 (assuming k=1 in this embodiment, i.e., the outgoing port in the MAC address forwarding entry to be deleted is port 1), and searches for the location S_1_USE within segment S_1 where the MAC address forwarding entry is located. The upper-layer software then deletes the MAC address forwarding entry within segment S_1. The upper-layer software then flushes the last MAC address forwarding entry in segment S_1 to location S_1_USE (i.e., flushes the MAC address forwarding entry at location S_1_START+S_1_num-1 to location S_1_USE). Finally, the upper-layer software decrements S_1_num by 1, thereby completing the deletion operation.
[0052] In step 3, the upper-layer software determines whether the switching information has been obtained. If so, it proceeds to step 4; otherwise, it returns to step 2. When a fault occurs, each switch in the Ethernet ring system receives an APS message (i.e., an automatic protection switching message), which contains the switching information. Each switch then updates its MAC address forwarding table based on the APS message.
[0053] Step 4: The upper-layer software performs protection switching according to the segment information, and then returns to step 2.
[0054] As shown in FIG5 , in some embodiments, the method in which the upper layer software performs protection switching according to segment information includes:
[0055] In the first step, the upper layer software obtains information of segment S_1 corresponding to the faulty port (ie, port 1) based on the information that the faulty port is port 1 (in this embodiment, h=1, ie, the active port is faulty).
[0056] In the second step, the upper-layer software traverses the range from S_1_START to S_1_START+S_1_num-1 in segment S_1, obtains the MAC address forwarding entries in the range from S_1_START to S_1_START+S_1_num-1 (the outbound port of these MAC address forwarding entries is port 1), and records them as forwarding table entries ZB.
[0057] In the third step, the upper-layer software deletes the MAC address forwarding entries in the range from S_1_START to S_1_START+S_1_num-1 in segment S_1, and updates S_1_num (ie, S_1_num is decremented until S_1_num=0).
[0058] In the fourth step, the upper-layer software obtains information of the segment S_2 corresponding to the backup port (ie, port 2) based on the information that the backup port is port 2 (m=2 in this embodiment).
[0059] Step 5: The upper-layer software traverses the range from S_2_START to S_2_END of segment S_2 to obtain the free position of segment S_2.
[0060] Step 6: The upper layer software updates the outgoing port of the forwarding table entry ZB (ie, the MAC address forwarding entry in the range of S_1_START to S_1_START+S_1_num-1) to port 2, obtaining the forwarding table entry ZB'.
[0061] Step 7: The upper layer software writes the forwarding table entry ZB' (ie, the forwarding table entry with the egress port updated to port 2) into the free space of segment S_2 and updates S_2_num (ie, S_2_num is accumulated according to the number of forwarding table entries ZB').
[0062] During protection switching, traversal is performed only within the specific range of S_1_START to S_1_START+S_1_num-1 of segment S_1. This can shield invalid traversals within the segment, further reducing the number of traversals, thereby reducing the time consumption caused by invalid traversals during the protection switching process and effectively shortening the overall protection switching time.
[0063] An embodiment of the present application also provides an electronic device, which includes a processor and a memory connected to the processor, wherein a computer-readable program is stored in the memory. When the computer-readable program is called by the processor, it can execute the above-mentioned vehicle-mounted Ethernet forwarding table flashing method.
[0064] An embodiment of the present application also provides a medium storing a computer-readable program. When the computer-readable program is called, it can execute the above-mentioned vehicle-mounted Ethernet forwarding table flashing method.
Claims
1. A method for writing an in-vehicle Ethernet forwarding table, characterized in that, Including: Step 1: Segment the hardware forwarding table in the initialization stage, and then execute Step 2; Step 2: Manage the forwarding entries within the segmented segments, and then execute Step 3; Step 3: Determine whether switchover information is obtained. If so, execute Step 4; otherwise, return to execute Step 2; Step 4: Perform protection switchover according to the segmentation information, and then return to execute Step 2.
2. The method for writing the in-vehicle Ethernet forwarding table according to claim 1, wherein: In the above Step 1, the method for segmenting the hardware forwarding table in the initialization stage includes: In the initialization stage, according to the requirements of the Ethernet ring network system, segment the hardware forwarding table with ports as elements, and divide the position ranges occupied by the ports of the switch in the hardware forwarding table; Record the start position S_x_START, end position S_x_END, capacity S_x_max, and the number of occupied positions S_x_num in the current segment S_x corresponding to port x in the segmented hardware forwarding table; where there is a unique mapping relationship between the port and the segmentation, and x takes all integers from 1 to n in sequence, and n represents the total number of ports of the switch.
3. The method for writing the in-vehicle Ethernet forwarding table according to claim 2, wherein: After segmenting the hardware forwarding table in the initialization stage, write the static MAC address forwarding entries regarding port x required by the Ethernet ring network system to the corresponding positions in segment S_x, and update S_x_num.
4. The method for writing the in-vehicle Ethernet forwarding table according to claim 2, characterized in that: In the above Step 2, the method for managing the forwarding entries within the segmented segments includes: When a MAC address forwarding entry needs to be added after MAC address learning; first, determine that the target position of the MAC address forwarding entry is within segment S_i according to the information that the output port in the MAC address forwarding entry is port i; second, traverse the range from S_i_START + S_i_num to S_i_END in segment S_i to obtain an idle position; then, write the MAC address forwarding entry to the idle position; finally, update S_i_num; where i is an integer and 1 ≤ i ≤ n.
5. The method for writing the in-vehicle Ethernet forwarding table according to claim 4, wherein: In the above Step 2, the method for managing the forwarding entries within the segmented segments further includes: When a MAC address forwarding entry needs to be deleted; first, traverse the range from S_k_START to S_k_START + S_k_num - 1 in segment S_k according to the information that the output port in the MAC address forwarding entry is port k, and find the position S_k_USE of the MAC address forwarding entry within segment S_k; second, delete the MAC address forwarding entry within segment S_k; then, overwrite the last MAC address forwarding entry in segment S_k to position S_k_USE; finally, update S_k_num; where k is an integer and 1 ≤ k ≤ n.
6. The method for rewriting the in-vehicle Ethernet forwarding table according to claim 4, characterized in that: When S_x_num = S_x_max, no more MAC address forwarding entries are added, and only packets are forwarded.
7. The vehicle-mounted Ethernet forwarding table rewriting method according to any one of claims 2 to 6, characterized in that: In the above Step 4, the method for performing protection switchover according to the segmentation information includes: The first step: Obtain the information of segment S_h corresponding to the faulty port according to the information that the faulty port is port h; where h is an integer and 1 ≤ h ≤ n; Step 2: Traverse within the range from S_h_START to S_h_START + S_h_num - 1 of segment S_h to obtain the MAC address forwarding entries within the range from S_h_START to S_h_START + S_h_num - 1, denoted as forwarding table entry ZB; Step 3: Delete the MAC address forwarding entries within the range from S_h_START to S_h_START + S_h_num - 1 in segment S_h and update S_h_num; Step 4: Obtain the information of segment S_m corresponding to the standby port according to the information that the standby port is port m; where m is an integer and 1 ≤ m ≤ n; Step 5: Traverse within the range from S_m_START to S_m_END of segment S_m to obtain the free positions of segment S_m; Step 6: Update the output port of the forwarding table entry ZB to port m to obtain the forwarding table entry ZB'; Step 7: Write the forwarding table entry ZB' into the free position of segment S_m and update S_m_num.
8. An electronic device, comprising a processor and a memory connected to the processor; characterized in that: The memory stores a computer-readable program, which when called by a processor, can execute the in-vehicle Ethernet forwarding table rewriting method according to any one of claims 1 to 7.
9. A medium, characterized in that: It stores a computer-readable program, which when called, can execute the in-vehicle Ethernet forwarding table rewriting method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Main-standby clear network protection method
CN115190004A
Message processing method and device, equipment and storage medium
CN116761208A
Transmission path determination method and device
CN116938800A
Vehicle-mounted Ethernet forwarding table flashing method, electronic equipment and medium
CN117749738A
Apparatus and method for protection switching of transmitted packet to ethernet node
KR1020090062743A