Marking method and marking device of protocol message, electronic equipment and storage medium
By configuring access control list rules in the switching chip and re-marking the priority field of the virtual LAN label as the port identifier, the problem of the central processing unit being unable to recognize the protocol message input port is solved, ensuring the normal operation of network devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-17
AI Technical Summary
In traditional network devices, the central processing unit cannot determine which physical port of the switching chip the protocol message enters the device from, resulting in information gaps and potentially causing network device failure.
By configuring access control list rules in the switching chip, protocol packets are filtered, and the port identifier is re-marked using the priority field of the virtual LAN label, ensuring that the protocol packets contain physical port information.
Without increasing the protocol message length, the system effectively marks physical port information within the protocol message, preventing information gaps and ensuring the normal operation of network devices.
Smart Images

Figure CN121887350A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to a method for marking protocol messages, a device for marking protocol messages, an electronic device, and a computer-readable storage medium. Background Technology
[0002] In traditional network devices, when protocol messages need to be processed by the central processing unit (CPU), the CPU cannot directly determine which physical port of the switching chip the message entered the device from. The switching chip can forward and redirect messages, but the message itself does not record the source port information. When a message needs to be sent to the CPU for processing, the CPU cannot map the message to the local port of the switching chip, leading to information gaps and potentially causing network device failure. Summary of the Invention
[0003] This application provides a method, device, electronic device, and computer-readable storage medium for marking protocol messages. Without increasing the length of the protocol message, it ensures that the protocol message contains its corresponding physical port information, thereby avoiding information gaps and ensuring the normal operation of network devices.
[0004] This application provides a method for marking protocol messages. The marking method includes: configuring access control list rules for matching protocol messages; filtering all protocol messages according to the access control list rules to obtain messages to be processed; and remarking the priority field in the virtual local area network label of the messages to be processed with the corresponding port identifier according to a preset mapping relationship, wherein the mapping relationship is a mapping relationship between the priority field and the port identifier.
[0005] In some implementations, the step of remarking the priority field in the virtual LAN label of the packet to be processed with the corresponding port identifier according to a preset mapping relationship includes: when the number of physical ports is less than or equal to a preset number, mapping each number contained in the priority field to a different port identifier to obtain the preset mapping relationship; and remarking the priority field in the virtual LAN label of the packet to be processed with the corresponding port identifier according to the preset mapping relationship.
[0006] In some implementations, the step of remarking the priority field in the virtual LAN label of the message to be processed to the corresponding port identifier according to a preset mapping relationship further includes: when the number of physical ports is greater than a preset number, mapping multiple physical ports to the same priority field value to obtain the preset mapping relationship; and remarking the priority field in the virtual LAN label of the message to be processed to the corresponding port identifier according to the preset mapping relationship.
[0007] In some implementations, the messages to be processed include Spanning Tree Protocol (STP) and Internet Group Management Protocol (IGM) messages.
[0008] In some implementations, the marking method further includes: when the central processing unit receives the message to be processed, performing reverse mapping processing based on the priority field in the virtual local area network label of the message to be processed to obtain the port identifier corresponding to the message to be processed.
[0009] In some implementations, the reverse mapping process based on the priority field of the message to be processed includes: pre-storing a reverse mapping table between the priority field value and the port identifier in the central processing unit; when the central processing unit receives the message to be processed, parsing the virtual local area network tag of the message to be processed and extracting the priority field; and performing reverse mapping processing based on the reverse mapping table and the priority field to obtain the port identifier.
[0010] In some implementations, the configuration of access control list rules for matching protocol messages is performed in a switching chip having a preset number of physical ports, and the protocol messages are Layer 2 protocol messages.
[0011] This application also provides a protocol message marking device, which includes a configuration module, a preprocessing module, and a remarking module. The configuration module is used to configure access control list rules for matching protocol messages in a switching chip; the preprocessing module is used to filter all protocol messages according to the access control list rules to obtain messages to be processed; the remarking module is used to remark the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to a preset mapping relationship, wherein the mapping relationship is a mapping relationship between the priority field and the port identifier.
[0012] This application also provides an electronic device that includes a protocol message marking device as described in any of the above embodiments.
[0013] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the marking method described in any of the above embodiments.
[0014] In the protocol message marking method, device, electronic device, and computer-readable storage medium provided in this application, access control list rules for matching protocol messages are first configured in the switching chip. All protocol messages are then filtered according to these rules to obtain messages to be processed. Next, using a preset mapping relationship between priority fields and port identifiers, the priority field in the virtual LAN tag of the message to be processed is remarked with the corresponding port identifier. This application ensures that the protocol message contains its corresponding physical port information without increasing the message length by re-entering the port identifier into the priority field, thus avoiding information gaps and ensuring the normal operation of network devices.
[0015] Additional aspects and advantages of embodiments of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of embodiments of this application. Attached Figure Description
[0016] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, wherein:
[0017] Figure 1 This is a flowchart illustrating the method for marking protocol messages in some embodiments of this application; Figure 2 This is a schematic diagram of the structure of a protocol message marking device in some embodiments of this application; Figure 3 This is a schematic diagram illustrating the addition of a private header to a message in some implementations of this application; Figure 4 This is a schematic diagram illustrating message re-marking processing according to some embodiments of this application; Figure 5 This is a flowchart illustrating the process of remarking the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to a preset mapping relationship in the protocol message marking method of some embodiments of this application. Figure 6 This is a flowchart illustrating the process of remarking the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to a preset mapping relationship in the protocol message marking method of some embodiments of this application. Figure 7 This is a flowchart illustrating a method for marking protocol messages in other embodiments of this application; Figure 8This is a flowchart illustrating the process of a protocol message marking method in some embodiments of this application, in which the central processing unit receives a message to be processed and performs reverse mapping processing based on the priority field in the virtual local area network tag of the message to be processed to obtain the port identifier corresponding to the message to be processed. Figure 9 This is a schematic diagram illustrating the connection state of a computer-readable storage medium and a processor according to certain embodiments of this application.
[0018] Explanation of key component symbols: Protocol message marking device 10; Configuration module 11; Preprocessing module 12; Remarking module 13; Processor 20; 200 Computer-readable storage medium; 202 Computer program. Detailed Implementation
[0019] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of this application, and should not be construed as limiting the embodiments of this application.
[0020] In the traditional network equipment architecture using a central processing unit (CPU) + switch chip, when a Layer 2 (L2) protocol message requires control-level processing by the CPU, the CPU cannot directly determine which physical port of the switch chip the message initially entered the device from. This is because the switch chip is primarily responsible for high-speed packet forwarding on the data plane; its core task is to make efficient routing and forwarding decisions based on the message's destination address (such as a MAC address). During this process, the message's internal structure (such as the frame header) typically does not record or carry the specific information of the physical source port it initially passed through when entering the device. However, this gap in critical internal device information leads to serious consequences. For example, Spanning Tree Protocol (STP) messages require precise knowledge of the specific physical port where a loop occurs to prevent blocking, and Internet Group Management Protocol (IGMP) messages need to know the physical port accessed by multicast receivers to perform correct multicast forwarding. Without being able to trace the specific physical port, the normal operation of these protocol messages loses its foundation. Furthermore, if the protocol message indicates a network problem (such as topology changes, loops, or unauthorized access), the central processing unit (CPU) cannot accurately locate the physical access point where the problem occurs, which significantly increases the complexity and time required for troubleshooting. Information gaps can easily cause control plane failure, network configuration errors, or abnormal traffic forwarding; in severe cases, they can even paralyze the control logic of the entire network device or cause operational instability, thereby threatening the reliability and stability of the entire network. Therefore, how to avoid the loss of physical port-related information has become a pressing problem for those skilled in the art. To solve this problem, this application provides a method for marking protocol messages (such as...). Figure 1 (As shown).
[0021] Please see Figure 1 and Figure 2 In the protocol message marking method of the embodiments of this application, the protocol message marking method includes: 01: Configure access control list rules for matching protocol messages; 03: Filter all protocol messages according to the access control list rules to obtain the messages to be processed; 05: Based on the preset mapping relationship, the priority field in the virtual LAN label of the message to be processed is remarked with the corresponding port identifier. The mapping relationship is the mapping relationship between the priority field and the port identifier.
[0022] The above-described protocol message marking method can be applied to the protocol message marking device 10. The protocol message marking device 10 of this embodiment includes a configuration module 11, a preprocessing module 12, and a remarking module 13. The configuration module 11 is used to configure access control list rules for matching protocol messages. The preprocessing module 12 is used to filter all protocol messages according to the access control list rules to obtain messages to be processed. The remarking module 13 is used to remark the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to a preset mapping relationship, wherein the mapping relationship is a mapping relationship between the priority field and the port identifier.
[0023] Specifically, the protocol message marking device 10 can be a functional module integrated device deployed in the hardware of the switching chip, or it can be deployed in the central processing unit (CPU), or it can be deployed in any external device that can communicate with the CPU or the switching chip. The protocol message marking device 10 dynamically rewrites specific field values of the message, embedding the physical identification information of the switch's physical port into the internal logical flags of the protocol message to be processed without increasing the message length. This ultimately solves the technical problem that the CPU cannot identify the original input source of the protocol message. The protocol message marking device 10 can actively utilize the predefined priority field in the existing tag field of the message (such as the VLAN tag in L2 protocol messages) as the physical port identifier writing carrier without changing the original length and general structure of the standard protocol message, achieving logical encoding embedding of the physical port while maintaining compatibility with the IEEE 802.1Q standard.
[0024] More specifically, the protocol message marking device 10 includes a configuration module 11, a preprocessing module 12, and a remarking module 13. The configuration module 11 is a rule configuration module within the protocol message marking device 10 for configuring the underlying logical operations. The configuration module 11 is responsible for dynamically importing a set of feature matching instructions (i.e., access control list rules) for the target protocol messages into the internal hardware processing engine of the switching chip, used for preliminary feature pre-screening of all messages input to the switching chip. The function of the configuration module 11 is to pre-configure hardware-level access control list (ACL) rules in the switching chip. These ACL rules are designed to accurately identify specific types of protocol messages that require special marking, such as spanning tree protocol messages or multicast management protocol messages, thereby providing a logical matching basis for subsequent message filtering and remarking. The preprocessing module 12 is a message filtering module activated in the high-speed forwarding pipeline of the protocol message marking device 10. It performs real-time feature scanning of all input protocol messages, implements hardware-level filtering operations according to the access control list rules configured by the configuration module 11, and separates the subset of messages to be processed that require remarking. The preprocessing module 12 is used to complete the first diversion of the original message, ensuring that only the target message enters the subsequent remarking process. The remarking module 13 is the field rewriting unit in the switching chip message rewriting hardware logic of the protocol message marking device 10. Based on a preset static mapping table of "field value - port identifier", it dynamically overwrites the existing VLAN tag priority field value (originally used to identify service priority) in the message to be processed with the port identifier encoding value that represents the identity of the original receiving port. The remarking module 13 is used to convert the physical meaning of the priority field into the identifier of the port identifier through semantic reconstruction technology, adding physical port information without adding any new message data payload, and realizing the traceable marking of the physical entry location through the protocol message.
[0025] In existing technologies, switching chips are only responsible for high-speed packet forwarding, and physical port location information is stripped away during processing. This prevents the central processing unit (CPU), which requires in-depth protocol analysis, from determining which port identifier the protocol packet originated from. For example, Spanning Tree Protocol (STP) blocking decisions and Internet Group Management Protocol (IGMP) member management both rely on physical ports for operation. This information gap in existing technologies directly leads to protocol malfunctions.
[0026] Furthermore, in step 01, the switching chip is a dedicated integrated circuit hardware deployed inside the network device. The core function of the switching chip is to perform high-speed identification, classification, forwarding, or modification operations on transmitted network data packets (including protocol messages) according to preset rules. In this solution, the switching chip is the physical carrier that performs protocol message identification, filtering, and field rewriting operations, directly affecting the message transmission link. Access control list rules are a set of logical judgment instructions preset in the switching chip hardware. Each instruction includes matching conditions (such as message type, source address, and destination address) and execution actions (such as allowing, discarding, and marking). The role of access control list rules is to accurately filter target protocol messages from massive amounts of network packets.
[0027] Furthermore, in step 03, protocol messages refer to network data packets used to maintain or control the operational status of network devices, such as network device topology discovery messages and network device multicast membership management messages. These messages need to be parsed and processed by the central processing unit (rather than directly forwarded) to ensure the normal operation of network protocols. The messages to be processed are a subset of target protocol messages identified as requiring physical port marking operations after being filtered by access control list rules. After remarking, the messages to be processed can carry physical source port information to facilitate processing by the central processing unit.
[0028] Further, in step 05, the Virtual LAN tag (VLAN tag) is an identifier field (compliant with the IEEE 802.1Q standard) embedded in the frame header of a standard message. The VLAN tag is needed to identify the VLAN number to which the message belongs and its service priority. The remarking process in this application remarks the priority field of the VLAN tag, which identifies its service priority. A number representing port identification information is input into the priority field, overwriting the original number. This adds port identification information to the protocol message without increasing its length, thus avoiding the loss of port identification information. The priority field is a 3-bit segment located inside the VLAN tag. In traditional functions, the value of the priority field (0 being the lowest and 7 the highest) indicates the priority level of the switch for message transmission during congestion. The port identifier is a unique number of the physical interface on the network device (e.g., port 1, port 2 on the device panel). The port identifier is directly associated with the physical input location of the protocol message.
[0029] Further, please refer to Figure 3 , Figure 3This is a schematic diagram illustrating the addition of a private header to a message, as provided in this application. For example, both DSA_tag and 802.1BR technologies can implement this method of adding port identifiers. DSA_tag technology inserts a dedicated tag (e.g., a 4-8 byte DSA_tag) into the message. This dedicated tag carries relevant port identifier information for CPU parsing. However, DSA_tag technology increases the length of the protocol message by requiring an additional tag, thus wasting bandwidth. The extra tag consumes inline port bandwidth (e.g., inserting a tag in a 10Gbps link may reduce bandwidth utilization by more than 15%). DSA_tag technology also requires the switching chip to support the insertion / removal function of DSA_tag. Low-end switching chips generally do not support DSA_tag technology, which increases the manufacturing or purchase cost of the switching chip. 802.1BR technology achieves port expansion by extending the message header and marking the virtual port number or port identifier at the extended location. The 802.1BR technology also has similar problems to the DSA_tag technology. In addition, the 802.1BR technology requires that the interfaces of the switching chip and the central processing unit both support the 802.1BR protocol, otherwise it may lead to packet loss.
[0030] Further, please refer to Figure 4 The method for marking protocol messages provided in this application is to directly re-mark the priority field of the existing virtual LAN label in the protocol message, and overwrite the original priority field with the port identifier. This method does not increase the length of the protocol field, does not require special functional support, does not cause bandwidth waste, and can also be applied to low-end switching chips.
[0031] Understandably, this application provides a method for marking protocol packets. First, access control list rules for matching protocol packets are configured in the switching chip. All protocol packets are then filtered according to these rules to obtain packets to be processed. Next, using a preset mapping relationship between priority fields and port identifiers, the priority field in the virtual LAN tag of the packet to be processed is remarked with the corresponding port identifier. This application ensures that the protocol packet contains its corresponding physical port information without increasing the packet length by re-entering the port identifier into the priority field, thus avoiding information gaps and ensuring the normal operation of network devices.
[0032] In some implementations, access control list rules are configured within the switching chip. The matching dimensions of the access control list rules cover protocol type and physical port range, where the physical port range is a set of one or more physical ports. The protocol type identification layer accurately filters control traffic that requires central processing unit processing, such as Spanning Tree Protocol (STP) messages, Internet Group Management Protocol (IGM) messages, and Link Aggregation Control Protocol (LAC) messages, by parsing the feature codes of Layer 2 protocol messages. The physical port range layer supports defining matching fields by continuous port groups or discrete ports. For example, ports 1 to 8 on the front panel of the device can be classified as the first port group, and ports 9 to 16 as the second port group.
[0033] In some implementations, when a packet enters the physical port of the switching chip, the access control list rule engine simultaneously verifies the protocol type and port affiliation. If both matching conditions are met, a subsequent field remarking process is triggered; otherwise, a regular forwarding operation is performed.
[0034] In some implementations, please refer to Figure 2 and Figure 5 05: Based on the preset mapping relationship, remark the priority field in the virtual LAN label of the message to be processed with the corresponding port identifier, including: 051: When the number of physical ports of the switching chip is less than or equal to the preset number, each number contained in the priority field is mapped to a different port identifier to obtain the preset mapping relationship; 052: Based on the preset mapping relationship, remark the priority field in the virtual LAN label of the message to be processed to the corresponding port identifier.
[0035] The above-mentioned protocol message marking method can be applied to the protocol message marking device 10. The remarking module 13 of this application embodiment is used to map each number contained in the priority field to a different port identifier when the number of physical ports of the switching chip is less than or equal to a preset number, thereby obtaining a preset mapping relationship; according to the preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked to the corresponding port identifier.
[0036] Specifically, in step 051, the physical ports of the switching chip are the actual physical communication interfaces on the network device's hardware panel, each with a globally unique identifier (e.g., port 1, port 2). The function of the physical ports of the switching chip is to send and receive raw network data signals, forming the physical channel for packets to enter and exit the device. The preset number can be determined by the number of bits in the priority field. For example, if the priority field is a 3-bit segment, it can represent up to 8 values, so the preset number can be set to 8. When the number of physical ports of the switching chip is less than or equal to the preset number, each number contained in the priority field can be mapped to a different port identifier, thus obtaining the preset mapping relationship.
[0037] Further, in step 052, the remarking module 13 can remark the priority field in the virtual LAN label of the packet to be processed with the corresponding port identifier according to the mapping relationship between the port identifier and the priority field. For example, port identifier 1 can correspond to priority field value 1, and port identifier 2 can correspond to priority field value 2. When there are many port identifiers, group mapping can also be used, which will be further explained below. For example, port identifiers 1-3 can correspond to priority field value 1, and port identifiers 4-6 can correspond to priority field value 2.
[0038] Please see Figure 2 and Figure 6 In some implementations, 05: According to a preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked with the corresponding port identifier, which also includes: 053: When the number of physical ports of the switching chip is greater than the preset number, multiple physical ports are mapped to the same priority field value to obtain the preset mapping relationship; 054: Based on the preset mapping relationship, remark the priority field in the virtual LAN label of the message to be processed to the corresponding port identifier.
[0039] The above-mentioned protocol message marking method can be applied to the protocol message marking device 10. The remarking module 13 is used to map multiple physical ports to the same priority field value when the number of physical ports of the switching chip is greater than a preset number, so as to obtain a preset mapping relationship. According to the preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked to the corresponding port identifier.
[0040] Specifically, in step 053, the physical ports of the switching chip are the actual physical communication interfaces on the network device hardware panel, each with a globally unique identifier (e.g., port 1, port 2). The function of the physical ports of the switching chip is to send and receive raw network data signals, forming the physical channel for packets to enter and exit the device. The preset number can be determined by the number of bits in the priority field. For example, if the priority field is a 3-bit segment, it can represent a maximum of 8 values, so the preset number can be set to 8. When the number of physical ports of the switching chip is greater than the preset number, if the mapping is continued in a one-to-one correspondence manner, there will be redundant port identifiers. Therefore, when the number of physical ports of the switching chip is greater than the preset number, it is necessary to map each number contained in multiple priority fields to a port identifier to obtain the preset mapping relationship.
[0041] Furthermore, for example, port identifiers 1-3 can correspond to priority field value 1, and port identifiers 4-6 can correspond to priority field value 2.
[0042] In some implementations, the messages to be processed include Spanning Tree Protocol (STP) and Internet Group Management Protocol (IGM) messages.
[0043] Specifically, the Spanning Tree Protocol (STP) message is a dedicated control message used for network topology loop detection and congestion control. The function of the STP message is to enable network devices to dynamically discover the physical network connection structure and determine loop-free logical forwarding paths through cooperative algorithms, thus avoiding network paralysis caused by broadcast storms. When the central processing unit (CPU) receives and processes a STP message, it must accurately locate the specific physical port where the problem occurred and perform the blocking operation accordingly. If the CPU receives the message but cannot determine its originating physical port, it may result in incorrect port blocking or failure to perform blocking.
[0044] Specifically, the Internet Group Management Protocol (IGP) message is a communication message used to manage the multicast group membership of network devices. Its function is to allow devices to perceive which physical ports are connected to receivers of specific multicast streams, thus forwarding multicast data only to necessary ports and avoiding bandwidth waste. The central processing unit (CPU) needs to accurately identify which physical ports have multicast members in order to build the correct multicast forwarding tree. If the CPU cannot trace the original access port, multicast streams may flood to irrelevant ports.
[0045] Please see Figure 2 and Figure 7 In some implementations, the marking method further includes: 07: When the central processing unit receives a message to be processed, it performs reverse mapping processing based on the priority field in the virtual LAN tag of the message to obtain the port identifier corresponding to the message to be processed.
[0046] The above-mentioned protocol message marking method can be applied to the protocol message marking device 10. The preprocessing module 12 is used to perform reverse mapping processing based on the priority field in the virtual LAN tag of the message to be processed when the central processing unit receives the message to be processed, so as to obtain the port identifier corresponding to the message to be processed.
[0047] Specifically, the central processing unit (CPU) is the core logical control unit of a network device, responsible for parsing protocol message content and executing control commands, such as blocking decisions for the Spanning Tree Protocol (STP) and forwarding path calculations for the Multicast Protocol (MTP). In traditional architectures, the CPU cannot directly identify the original physical port location of a protocol message when processing it. However, this application ensures that the CPU can identify the original physical port location of a protocol message when processing it.
[0048] Furthermore, reverse mapping processing is the reverse parsing operation performed by the central processing unit (CPU) on the received packets to be processed. That is, based on a preset mapping relationship, the priority field value is reversed to restore the actual location information of the corresponding physical port (or port group). In this process, the CPU reads the priority field value from the virtual LAN tag, maps the value back to the port identifier according to the port number-field value correspondence rule of the same switching chip, and finally determines the original physical port or port group range from which the packet entered the device.
[0049] Understandably, the central processing unit (CPU) can pre-store a reverse mapping table, which strictly mirrors the mapping rules of the switching chip. When a packet to be processed is received, the CPU performs a process of parsing the virtual LAN tag, querying the reverse mapping table, and executing protocol control decisions. Specifically, the CPU first extracts the value of the priority field, then queries the reverse mapping table to convert the field value into a port identifier or port group range, and finally executes protocol control decisions, generating blocking instructions or forwarding paths based on the physical port location information. Furthermore, the port identifier restored by the CPU can be directly used as an interface parameter for the software-defined network controller (SDB), providing a location-aware foundation for network automation strategies. For example, in traffic engineering scenarios, the controller can dynamically adjust path calculation strategies based on port locations, improving resource scheduling accuracy.
[0050] Furthermore, for example, in a spanning tree protocol scenario, the central processing unit restores the actual port identifier where the loop occurred by using field values, and accurately blocks the port to eliminate broadcast storms.
[0051] Furthermore, for example, in the Internet Group Management Protocol (IGMP) scenario, the central processing unit (CPU) locates the multicast member access port based on field values and constructs a directed forwarding tree to avoid traffic flooding.
[0052] Please see Figure 2 and Figure 8 In some implementations, 07: Perform inverse mapping processing based on the priority field of the message to be processed, including: 071: A reverse mapping table between priority field values and port identifiers is pre-stored in the central processing unit; 072: When the central processing unit receives a message to be processed, it parses the virtual LAN tag of the message and extracts the priority field; 073: Perform reverse mapping based on the reverse mapping table and priority field to obtain the port identifier.
[0053] The above-mentioned protocol message marking method can be applied to the protocol message marking device 10. The preprocessing module 12 is used to pre-store a reverse mapping table between the priority field value and the port identifier in the central processing unit. When the central processing unit receives the message to be processed, it parses the virtual local area network label of the message to be processed and extracts the priority field. It performs reverse mapping processing according to the reverse mapping table and the priority field to obtain the port identifier.
[0054] Furthermore, the reverse mapping table is a port code reverse lookup rule table pre-stored within the central processing unit (CPU), whose contents strictly mirror the mapping rules of the switching chip. The process of extracting the priority field involves the CPU performing a tag parsing operation on the received packet to be processed, separating the 3-bit value of the priority field from the VLAN tag header, thereby obtaining the physical port code written by the switching chip.
[0055] In some implementations, the switching chip has a preset number of physical ports, and the protocol messages are Layer 2 protocol messages, including Spanning Tree Protocol and Internet Group Management Protocol messages.
[0056] Specifically, the physical ports of a switching chip are the actual communication access points of the switching chip on the physical hardware interface of the network device. Each port has a unique sequential number and constitutes the physical channel for protocol messages to enter and exit the device. The number of physical ports of a switching chip is determined by the device hardware specifications. When a protocol message enters the initial access position of the switching chip, the identity information of the physical port of the switching chip needs to be marked and transmitted to the central processing unit to support the protocol control logic.
[0057] Furthermore, Layer 2 protocol messages are control communication messages transmitted at the data link layer (Layer 2 of the network protocol stack). Layer 2 protocol messages are used to manage the connection status and forwarding rules between devices and are parsed and processed by the central processing unit (CPU). Spanning Tree Protocol (STP) messages are dedicated control messages used to implement network topology loop detection and congestion control. The function of STP messages is to allow network devices to dynamically discover the physical connection structure of the network and determine loop-free logical forwarding paths through cooperative algorithms, avoiding network paralysis caused by broadcast storms. When the CPU receives and processes a STP message, it must accurately locate the specific physical port where the problem occurred and perform blocking operations. If the CPU receives the message but cannot know its source physical port, it may cause incorrect port blocking or failure to perform blocking. Internet Group Management Protocol (IGMP) messages are communication messages used to manage the multicast group membership of network devices. Their function is to allow devices to perceive which physical ports are connected to receivers of specific multicast streams, thereby forwarding multicast data only to necessary ports and avoiding bandwidth waste. In order to build the correct multicast forwarding tree, the central processing unit (CPU) needs to accurately identify which physical ports have multicast members. If the CPU cannot trace the original access port, it may cause multicast flow to flood to irrelevant ports.
[0058] In summary, this application provides a method for marking protocol packets. First, access control list rules for matching protocol packets are configured in the switching chip. All protocol packets are then filtered according to these rules to obtain packets to be processed. Next, using a preset mapping relationship between priority fields and port identifiers, the priority field in the virtual LAN tag of the packet to be processed is remarked with the corresponding port identifier. This application ensures that the protocol packet contains its corresponding physical port information without increasing the packet length by re-entering the port identifier into the priority field, thus avoiding information gaps and ensuring the normal operation of network devices.
[0059] In some embodiments, this application also provides an electronic device, which includes the protocol message marking device 10 in any of the above embodiments.
[0060] Please see Figure 9 In some embodiments, this application also provides a computer-readable storage medium 200 having a computer program 202 stored thereon, which, when executed by a processor, implements the method in any of the above embodiments.
[0061] For example, when computer program 202 is executed by processor 20, the following method is implemented: 01: Configure access control list rules for matching protocol messages; 03: Filter all protocol messages according to the access control list rules to obtain the messages to be processed; 05: Based on the preset mapping relationship, the priority field in the virtual LAN label of the message to be processed is remarked with the corresponding port identifier. The mapping relationship is the mapping relationship between the priority field and the port identifier.
[0062] For example, when computer program 202 is executed by processor 20, the following method is implemented: 051: When the number of physical ports of the switching chip is less than or equal to the preset number, each number contained in the priority field is mapped to a different port identifier to obtain the preset mapping relationship; 052: Based on the preset mapping relationship, remark the priority field in the virtual LAN label of the message to be processed to the corresponding port identifier.
[0063] For example, when computer program 202 is executed by processor 20, it can also implement the methods in 053, 054, 07, 071, 072 and 073.
[0064] In the computer-readable storage medium 200 of this application, access control list rules for matching protocol packets are first configured in the switching chip. All protocol packets are then filtered and processed according to these rules to obtain packets to be processed. Next, using a preset mapping relationship between priority fields and port identifiers, the priority field in the virtual LAN label of the packets to be processed is remarked with the corresponding port identifier. This application ensures that the protocol packets contain their corresponding physical port information without increasing the packet length by re-entering the port identifier into the priority field, thus avoiding information gaps and ensuring the normal operation of network devices.
[0065] In the description of this specification, the references to terms such as "some embodiments," "in one example," "exemplarily," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0066] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.
[0067] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A method for marking protocol messages, characterized in that, include: Configure access control list rules for matching protocol messages; All protocol messages are filtered and processed according to the access control list rules to obtain the messages to be processed; According to the preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked with the corresponding port identifier, wherein the mapping relationship is the mapping relationship between the priority field and the port identifier.
2. The marking method according to claim 1, characterized in that, The step of remarking the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to the preset mapping relationship includes: When the number of physical ports is less than or equal to a preset number, each number contained in the priority field is mapped to a different port identifier to obtain the preset mapping relationship; According to the preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked with the corresponding port identifier.
3. The marking method according to claim 1, characterized in that, The step of remarking the priority field in the virtual LAN tag of the message to be processed with the corresponding port identifier according to the preset mapping relationship also includes: When the number of physical ports exceeds the preset number, multiple physical ports are mapped to the same priority field value to obtain the preset mapping relationship; According to the preset mapping relationship, the priority field in the virtual LAN tag of the message to be processed is remarked with the corresponding port identifier.
4. The marking method according to claim 1, characterized in that, The messages to be processed include Spanning Tree Protocol (STP) and Internet Group Management Protocol (IGN) messages.
5. The marking method according to claim 1, characterized in that, The marking method further includes: When the central processing unit receives the message to be processed, it performs reverse mapping processing based on the priority field in the virtual LAN tag of the message to be processed to obtain the port identifier corresponding to the message to be processed.
6. The marking method according to claim 5, characterized in that, The reverse mapping process based on the priority field of the message to be processed includes: The central processing unit pre-stores a reverse mapping table between priority field values and port identifiers; When the central processing unit receives the message to be processed, it parses the virtual local area network tag of the message to be processed and extracts the priority field; The port identifier is obtained by performing reverse mapping processing based on the reverse mapping table and the priority field.
7. The marking method according to claim 1, characterized in that, The configuration of the access control list rules for matching protocol messages is performed in the switching chip, which has a preset number of physical ports, and the protocol messages are Layer 2 protocol messages.
8. A protocol message marking device, characterized in that, include: The configuration module is used to configure access control list rules for matching protocol messages in the switching chip; The preprocessing module is used to filter all protocol messages according to the access control list rules to obtain messages to be processed; The remarking module is used to remark the priority field in the virtual local area network label of the message to be processed to the corresponding port identifier according to a preset mapping relationship, wherein the mapping relationship is the mapping relationship between the priority field and the port identifier.
9. An electronic device, characterized in that, The electronic device includes the tagging device for the protocol message as described in claim 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the marking method as described in any one of claims 1-7.