Method and device for realizing accurate aging of MAC table entries
By increasing the number of aging status identification bits and timer scanning frequency, combined with traffic and timer trigger logic, the precise aging of the MAC table entries of the switching chip is achieved, solving the problem of large aging time error and improving the forwarding accuracy of the switch.
Patent Information
- Application Number
- CN202211714416.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-12-27
AI Technical Summary
The aging time accuracy of MAC table entries of existing switching chips has a large error in some application scenarios, which affects the accuracy of forwarding decisions of the switch.
By increasing the aging status identification bits of the MAC table entry and the timer scanning frequency, the aging time of the MAC table entry is accurately controlled by combining traffic triggering and timer triggering logic.
It improves the accuracy of the aging time of MAC table entries, shortens the aging time error, and ensures the accuracy of forwarding decisions of the switch.
Smart Images

Figure CN115987919B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic communications, and in particular to a method and device for realizing accurate aging of MAC table entries. Background Art
[0002] In modern networks, Ethernet switches need to learn and maintain a Layer 2 MAC address table to quickly and efficiently forward packets. The MAC address table contains the MAC address, forwarding instance FID, and egress port information. When a packet enters the switch, the MAC forwarding table is queried using the packet's destination MAC address and source MAC address. The MAC table is searched based on the destination MAC address and FID. If the packet is found, it is treated as a known unicast and forwarded through the found egress port. If the packet is not found, it is treated as an unknown unicast and flooded to all ports in the FID forwarding domain. The MAC table is searched based on the source MAC address and FID. If the packet is found, the MAC table is updated. If not, the source MAC address, FID, and egress port are learned and added to the MAC table.
[0003] For existing switching chips, the accuracy of their aging time is generally controlled between T and 2T. The existing aging mechanism uses a timer to periodically poll and scan each MAC in the MAC table. The configured aging time T corresponds to the time it takes for the timer to scan all MAC tables. Each MAC has an aging status flag, and the chip uses this aging status flag to determine whether to delete this MAC. This aging status flag will be modified by two logical points. The first logic is triggered by traffic. When a message enters the chip and finds the MAC table through the source MAC address, this flag will be set to 1. The second logic is triggered by the timer. Each time the timer scans this MAC table, if this flag is 1, it will be cleared to 0. If it is 0, the MAC will be aged out.
[0004] With the development of network technology, the requirements for various switch indicators are also increasing. The error of the aging time of T to 2T is too large in some application scenarios.
[0005] The information disclosed in this background technology section is only intended to enhance understanding of the overall background of the invention and should not be regarded as an admission or any form of suggestion that the information constitutes the prior art already known to a person skilled in the art. Summary of the Invention
[0006] The object of the present invention is to provide a method and apparatus for realizing accurate aging of MAC table entries, which can improve the accuracy of the aging time of the exchange chip flow table by increasing the number of bits of the aging status identifier and the scanning frequency of the timer.
[0007] To achieve the above objectives, an embodiment of the present invention provides a method for implementing accurate aging of MAC entries.
[0008] In one or more embodiments of the present invention, the method includes: setting an n-bit aging status flag on each MAC table entry in the MAC table and configuring an aging time of T; a timer within the switching chip performs n rounds of scanning on all MAC tables and modifies the aging status flag according to two logics; and when all bits of the aging status flag are set to 0, deleting the MAC table entry corresponding to the aging status flag.
[0009] In one or more embodiments of the present invention, the aging status flag is modified according to two logics, including: the first logic is traffic triggering, when the message enters the switching chip, the MAC table is queried by the source MAC address, and all n-bit aging status flags of the queried MAC table items are set to 1.
[0010] In one or more embodiments of the present invention, the modification of the aging status identifier according to two logics also includes: the second logic is triggered by a timer, and each time the timer scans a MAC table entry, it executes an operation of setting the first 1 from right to left of the n-bit aging status identifier to 0.
[0011] In one or more embodiments of the present invention, the aging time is controlled between T and (1+1 / n)T.
[0012] In one or more embodiments of the present invention, when the timer scans the aging status flag of a MAC table entry that has just been updated by a message and no message updates the MAC table entry again, the aging time is T.
[0013] In one or more embodiments of the present invention, when a message updates the aging status flag of a MAC entry that has just been cleared to 0 by a timer and no message updates the MAC entry again, the aging time is (1+1 / n)T.
[0014] In another aspect of the present invention, a device for implementing accurate aging of MAC table entries is provided, which includes a setting module, a scanning module and an aging module.
[0015] The setting module is used to set an n-bit aging status flag on each MAC table entry in the MAC table and configure the aging time to T.
[0016] The scanning module is used to perform n rounds of scanning on all MAC tables by using a timer in the switching chip, and to modify the aging status identifier according to two logics.
[0017] The aging module is configured to delete the MAC table entry corresponding to the aging status flag when all bits of the aging status flag are set to 0.
[0018] In one or more embodiments of the present invention, the scanning module is further used for: the first logic is traffic triggering, when the message enters the switching chip, the MAC table is queried by the source MAC address, and all n-bit aging status flags of the queried MAC table items are set to 1.
[0019] In one or more embodiments of the present invention, the scanning module is further configured to: the second logic is timer triggering, and each time the timer scans a MAC table entry, it executes an operation of setting the first 1 from right to left of the n-bit aging status identifier to 0.
[0020] In one or more embodiments of the present invention, the aging module is further configured to control the aging time to be between T and (1+1 / n)T.
[0021] In one or more embodiments of the present invention, the aging module is further configured to: when the timer scans the aging status identifier of a MAC table entry that has just been updated by a message and no message updates the MAC table entry again, the aging time is T.
[0022] In one or more embodiments of the present invention, the aging module is further configured to: when a message updates the aging status flag of a MAC table entry that has just been cleared to 0 by a timer and no message updates the MAC table entry again, the aging time is (1+1 / n)T.
[0023] In another aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory, wherein the memory stores instructions, which, when executed by the at least one processor, enable the at least one processor to execute the method for implementing accurate aging of MAC table entries as described above.
[0024] In another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for achieving accurate aging of MAC table entries are implemented.
[0025] Compared with the prior art, the method for realizing accurate aging of MAC table entries according to the embodiment of the present invention can solve the problem that the error of the aging time of the switching chip is too large in certain application scenarios. By increasing the number of bits of the aging status identifier and the scanning frequency of the timer, the error of the aging time of the switching chip flow table is effectively shortened without increasing the complexity and cost pressure of the chip design too much, and the accuracy of the aging time is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is a flow chart of a method for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0027] Figure 2 This is a flowchart of a specific solution of a method for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0028] Figure 3 This is a flowchart of a specific solution of a method for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0029] Figure 4 This is a flowchart of a specific solution of a method for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0030] Figure 5 This is a flowchart of a specific solution of a method for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0031] Figure 6 1 is a structural diagram of an apparatus for implementing accurate aging of MAC table entries according to an embodiment of the present invention;
[0032] Figure 7 4 is a hardware structure diagram of a computing device for implementing accurate aging of MAC table entries according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific embodiments.
[0034] Unless expressly stated otherwise, throughout the specification and claims, the term "comprise" or variations such as "include" or "comprising", etc., will be understood to include the stated elements or components but not to exclude other elements or other components.
[0035] The technical solutions provided by various embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0036] Example 1
[0037] like Figures 1 to 5 As shown, a method for implementing accurate aging of MAC table entries in an embodiment of the present invention is introduced, and the method includes the following steps.
[0038] In step S101, an n-bit aging status flag is set on each MAC table entry in the MAC table, and the aging time is configured as T.
[0039] The capacity of the MAC table is an important parameter indicator of the switch. In order to fully utilize the limited capacity of the MAC table, the MAC table introduces an aging mechanism. The aging mechanism means that if a MAC table entry is not updated within a specified time, the MAC will be aged and deleted. Aging is a basic attribute of the MAC table and an important function provided by the switching chip. If the aging time is too long, the MAC address table in the switch will expire, causing the switch to make some incorrect filtering or forwarding decisions. If the aging time is too short, the address table will be refreshed too quickly, and the destination addresses of a large number of received data packets cannot be found in the MAC address table. As a result, the switch can only broadcast these data packets to all ports, which greatly weakens the advantages of the switch.
[0040] In this embodiment, each MAC entry in the MAC table has an n-bit aging status flag, and the switching chip determines whether to delete the MAC entry based on the aging status flag.
[0041] In step S102, the timer in the switch chip performs n rounds of scanning on all MAC tables and modifies the aging status flag according to two logics.
[0042] Specifically, the first logic is traffic triggering. When a message enters the switching chip, the MAC table is queried by the source MAC address, and all n-bit aging status flags of the queried MAC table entries are set to 1. The second logic is timer triggering. Every time the timer scans a MAC table entry, it sets the first 1 of the n-bit aging status flag from right to left to 0.
[0043] In step S103, when all bits of the aging status flag are set to 0, the MAC table entry corresponding to the aging status flag is deleted.
[0044] In this embodiment, the aging time is controlled between T and (1+1 / n)T. When the timer scans the aging status flag of a MAC table entry that has just been updated by a message and no message updates the MAC table entry again, the aging time is T. When a message updates the aging status flag of a MAC table entry that has just been cleared to 0 by the timer and no message updates the MAC table entry again, the aging time is (1+1 / n)T.
[0045] Specifically, for different application scenarios, the aging time accuracy is effectively improved by increasing the number of bits in the aging status identifier and the scanning frequency of the timer. This can be applied not only to improving the aging time accuracy of the MAC table, but also to improving the aging time accuracy of other flow tables.
[0046] like Figure 2 and Figure 3As shown, the present invention is introduced by taking a two-digit aging status identifier in a switch chip design as an example.
[0047] Within the configured aging time T, the timer performs two rounds of scanning of all MAC table entries, with each round taking T / 2. The aging status flag is modified by two logic points. The first logic point is traffic-triggered. When a packet enters the switch chip and the MAC table is checked, the aging status flag is set to "11." The second logic point is timer-triggered. Each time the timer scans a MAC table entry, if the flag is "11," the aging status flag is set to "10." If it is "10," the flag is set to "00." If it is "00," the MAC table entry is aged out. The following example analyzes two critical scenarios.
[0048] refer to Figure 2 , introduces scenario 1. The aging status flag of a MAC table entry has just been updated to "11" by a message, and the timer immediately scans this MAC table entry, and the aging status flag is set to "10". Assuming that no message comes to update this MAC table entry, the starting state of the aging status flag of this MAC table entry is "10". After a period of T / 2, the timer scans this MAC table entry again and sets the aging status flag to "00". After another period of T / 2, the timer scans this MAC table entry again and finds that the aging status flag is "00", so this MAC table entry is deleted. In this scenario, the aging time of this MAC table entry is (T / 2+T / 2).
[0049] refer to Figure 3 , introduces scenario 2. Just as the timer clears the aging status flag of a MAC table entry to "00", a message arrives and sets the aging status flag of this MAC table entry to "11". Assuming that no message updates this MAC table entry, the initial state of the aging status flag of this MAC table entry is "11". After T / 2, the timer scans this MAC table entry again and finds that the aging status flag is "11", so it sets the aging status flag to "10". After another T / 2, the timer scans this MAC table entry again and sets the aging status flag to "00". After another T / 2, the timer scans this MAC table entry again and finds that the aging status flag is "00", so it deletes this MAC table entry. In this scenario, the aging time of this MAC table entry is (T / 2 + T / 2 + T / 2).
[0050] From the above, it can be seen that the accuracy of the aging time of the two-digit aging status identifier in the switch chip design is between T and (1+1 / 2)T.
[0051] like Figure 4 and Figure 5As shown, the present invention is introduced by taking the 4-digit aging status identifier in the switch chip design as an example.
[0052] The timer scans all MAC table entries four times within the configured aging time T, with each scan taking T / 4. The aging status flag is modified by two logic points. The first logic point is traffic-triggered. When a packet enters the chip and the MAC table is checked, the aging status flag is set to "1111." The second logic point is timer-triggered. Each time the timer scans a MAC table entry, if the flag is "1111," the aging status flag is set to "1110." If it is "1110," the aging status flag is set to "1100." If it is "1100," the aging status flag is set to "1000." If it is "1000," the aging status flag is set to "0000." If it is "0000," the MAC table entry is aged out. The following example analyzes two critical scenarios.
[0053] refer to Figure 4 Let's introduce scenario 1. A MAC entry's aging status flag has just been updated to "1111" by a message. Immediately afterward, the timer scans this MAC entry and clears the aging status flag to "1110." Assuming no further messages update this MAC entry, the aging status flag for this MAC entry starts at "1110." After a T / 4 interval, the timer scans this MAC entry again and sets the aging status flag to "1100." After another T / 4 interval, the timer scans this MAC entry again and finds the aging status flag is "1100." The timer then changes the aging status flag to "1000." After another T / 4 interval, the timer scans this MAC entry again and finds the aging status flag is "1000." The timer changes the aging status flag to "0000." After another T / 4 interval, the timer scans this MAC entry again and finds the aging status flag is "0000." The timer then deletes this MAC entry. In this scenario, the aging time of this MAC entry is (T / 4+T / 4+T / 4+T / 4).
[0054] refer to Figure 5, introduces scenario 2. Just as the timer clears the aging status flag of a MAC address entry to "0000", a message arrives and sets the aging status flag of this MAC address entry to "1111". Assuming that there is no message to update this MAC table entry next, the starting state of the aging status flag of this MAC table entry is "1111". After a T / 4 period, the timer scans this MAC table entry again and finds that the aging status flag is "1111", so the aging status flag is set to "1110"; after another T / 4 period, the timer scans this MAC table entry again and finds that the aging status flag is "1110", so the aging status flag is set to "1100"; after another T / 4 period, the timer scans this MAC table entry and finds that the aging status flag is "1100", so the aging status flag is changed to "1000"; after another T / 4 period, the timer scans this MAC table entry and finds that the aging status flag is "1000", so the aging status flag is changed to "0000"; after another T / 4 period, the timer scans this MAC table entry and finds that the aging status flag is "0000", so the MAC table entry is deleted. In this scenario, the aging time of this MAC entry is (T / 4+T / 4+T / 4+T / 4+T / 4).
[0055] From the above, it can be seen that the accuracy of the aging time of the 4-digit aging status identifier in the switch chip design is between T and (1+1 / 4)T.
[0056] According to the method for realizing accurate aging of MAC table entries in an embodiment of the present invention, it is possible to solve the problem that the error of the aging time of the switching chip is too large in certain application scenarios. By increasing the number of bits of the aging status identifier and the scanning frequency of the timer, the error of the aging time of the switching chip flow table is effectively shortened and the accuracy of the aging time is improved without excessively increasing the complexity and cost pressure of the chip design.
[0057] like Figure 6 As shown, a device for implementing accurate aging of MAC table entries according to a specific embodiment of the present invention is introduced.
[0058] In the embodiment of the present invention, the apparatus for implementing accurate aging of MAC entries includes a setting module 601 , a scanning module 602 and an aging module 603 .
[0059] The setting module 601 is configured to set an n-bit aging status flag on each MAC table entry in the MAC table and configure the aging time to T.
[0060] The scanning module 602 is configured to perform n rounds of scanning on all MAC tables using a timer in the switching chip, and to modify the aging status identifier according to two logics.
[0061] The aging module 603 is configured to delete the MAC entry corresponding to the aging status flag when all bits of the aging status flag are set to 0.
[0062] The scanning module 602 is further configured to: the first logic is traffic triggering, when a message enters the switching chip, query the MAC table by the source MAC address, and set all n-bit aging status flags of the queried MAC table entries to 1.
[0063] The scanning module 602 is further configured to: the second logic is timer triggering, and each time the timer scans a MAC table entry, it executes an operation of setting the first 1 from the right to the left of the n-bit aging status flag to 0.
[0064] The aging module 603 is further configured to control the aging time to be between T and (1+1 / n)T.
[0065] The aging module 603 is further configured to: when the timer scans the aging status flag of the MAC table entry that has just been updated by a message and no message updates the MAC table entry again, the aging time is T.
[0066] The aging module 603 is further configured to: when a message updates the aging status flag of a MAC entry that has just been cleared to 0 by the timer and no message updates the MAC entry again, the aging time is (1+1 / n)T.
[0067] Figure 7 FIG. 7 shows a hardware structure diagram of a computing device 70 for implementing accurate aging of MAC table entries according to an embodiment of the present specification. Figure 7 As shown, the computing device 70 may include at least one processor 701, a memory 702 (e.g., a non-volatile memory), a storage 703, and a communication interface 704, and the at least one processor 701, the memory 702, the storage 703, and the communication interface 704 are connected together via a bus 705. The at least one processor 701 executes at least one computer-readable instruction stored or encoded in the storage 702.
[0068] It should be understood that the computer executable instructions stored in the memory 702, when executed, cause the at least one processor 701 to perform the above combined operations in the various embodiments of this specification. Figure 1-7 Describes the various operations and functions.
[0069] In the embodiments of the present specification, the computing device 70 may include, but is not limited to, a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile computing device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable computing device, a consumer electronic device, and the like.
[0070] According to one embodiment, a program product such as a machine-readable medium is provided. The machine-readable medium may have instructions (i.e., the above-mentioned elements implemented in software form), which, when executed by a machine, causes the machine to perform the above-mentioned combined embodiments of the present specification. Figure 1-7 Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes for implementing the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can be enabled to read and execute the instructions stored in the readable storage medium.
[0071] According to the method for realizing accurate aging of MAC table entries in an embodiment of the present invention, it is possible to solve the problem that the error of the aging time of the switching chip is too large in certain application scenarios. By increasing the number of bits of the aging status identifier and the scanning frequency of the timer, the error of the aging time of the switching chip flow table is effectively shortened and the accuracy of the aging time is improved without excessively increasing the complexity and cost pressure of the chip design.
[0072] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0073] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0074] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0075] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0076] The foregoing descriptions of specific exemplary embodiments of the present invention are for purposes of illustration and description. These descriptions are not intended to limit the invention to the precise forms disclosed, and it is apparent that many variations and modifications are possible in light of the foregoing teachings. The exemplary embodiments have been selected and described for the purpose of explaining the specific principles of the invention and their practical application, thereby enabling those skilled in the art to realize and utilize a variety of exemplary embodiments of the invention and various options and modifications. The scope of the invention is intended to be defined by the claims and their equivalents.
Claims
1. A method for implementing accurate aging of MAC table entries, characterized in that: The method comprises: Set an n-bit aging status flag on each MAC table entry and set the aging time to T, where n ≥ 2. A timer in the switching chip performs n rounds of scanning of all MAC tables and modifies the aging status flag according to two logics, the two logics including traffic triggering and timer triggering. The traffic triggering includes querying the MAC table by the source MAC address when a message enters the switching chip and setting all n-bit aging status flags of the queried MAC table entries to 1. The timer triggering includes setting the first 1 in the n-bit aging status flag from the right to the left to 0 each time the timer scans a MAC table entry. When all bits of the aging status flag are set to 0, the MAC table entry corresponding to the aging status flag is deleted.
2. The method for implementing accurate aging of MAC table entries according to claim 1, wherein: The aging time is controlled between T and (1+1 / n)T.
3. The method for implementing accurate aging of MAC table entries according to claim 2, wherein: When the timer scans the aging status flag of the MAC table entry that has just been updated by a message and no message updates the MAC table entry again, the aging time is T.
4. The method for implementing accurate aging of MAC table entries according to claim 2, wherein: When a message updates the aging status flag of a MAC entry that has just been cleared to 0 by the timer and no message updates the MAC entry again, the aging time is (1+1 / n)T.
5. A device for realizing accurate aging of MAC table entries, characterized in that: The device comprises: A setting module is used to set an n-bit aging status flag on each MAC table entry in the MAC table and configure the aging time to be T, where n ≥ 2; a scanning module configured to scan all MAC tables n times using a timer within the switching chip, and modify the aging status flag according to two logics: traffic triggering and timer triggering. The traffic triggering includes querying the MAC table by source MAC address when a message enters the switching chip, and setting all n-bit aging status flags of the queried MAC table entries to 1. The timer triggering includes setting the first 1 in the n-bit aging status flag from right to left to 0 each time the timer scans a MAC table entry; and The aging module is configured to delete the MAC table entry corresponding to the aging status flag when all bits of the aging status flag are set to 0.
6. An electronic device, characterized in that: include: at least one processor; as well as A memory storing instructions, wherein when the instructions are executed by the at least one processor, the at least one processor executes the method for implementing accurate aging of MAC table entries according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for implementing accurate aging of MAC table entries according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method and system for realizing accurate aging of Ethernet two-layer forwarding table
CN114024919A