Method and switch for transmitting an addressing request
Patent Information
- Application Number
- CN202610147775.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-02
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2046-02-02
AI Technical Summary
[0004]本申请提供了发送寻址请求的方法、装置、交换机、存储介质、程序产品,以解决相关技术通信效率较低的问题
[0011] This application first obtains the batch request quantity, cycle duration, and maintenance entry set for addressing requests, and pre-determines the cycle request quantity based on the batch request quantity and cycle duration. Then, during the processing of the target cycle, candidate maintenance entries can be extracted from the maintenance entry set based on the cycle request quantity. For any candidate maintenance entry in the target cycle, a corresponding addressing request can be generated, and all addressing requests generated in the target cycle are sent to the corresponding network devices in batches according to the batch request quantity. In this process, the switch can periodically send addressing requests to network devices, ensuring that all maintenance entries in the maintenance entry set can be used periodically. This allows the switch to detect that maintenance entries are continuously being used without deleting them. Furthermore, for any network device belonging to the same network as the switch, the switch can directly extract the corresponding maintenance entry from the maintenance entry set when communication is needed, without needing to rebroadcast to obtain the network device's physical address, thus improving communication efficiency.
Smart Images

Figure CN121644515B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a method for sending addressing requests and a switch. Background Technology
[0002] In the field of communication technology, switches can connect multiple network devices, such as computers, servers, and printers, and transmit data between these devices. Because switches need to know the communication addresses of each network device during data transmission, they maintain an Address Resolution Protocol (ARP) cache table. This cache table stores the mapping between the Internet Protocol (IP) addresses and physical addresses of the network devices. Generally, the cache table uses an aging mechanism; if a record in the cache table is not used within the aging period, that record is deleted.
[0003] However, within the aging period, information may remain unused because the network device has been removed from the network and no longer communicates, or because some network devices typically only support sending one addressing request, but subsequent network communication needs may still exist. If the information is deleted from the ARP cache table, the switch will need to re-obtain the network device's physical address by broadcasting the addressing request. This results in low communication efficiency. Summary of the Invention
[0004] This application provides a method, apparatus, switch, storage medium, and program product for sending addressing requests to solve the problem of low communication efficiency in related technologies.
[0005] This application provides a method for sending an addressing request, including:
[0006] Get the number of batch requests, the cycle duration, and the set of maintenance entries for addressing requests; The number of periodic requests is determined based on the batch request quantity and the period duration. In the processing of the target cycle, the number of cycle requests is used as the upper limit, and at least one candidate maintenance entry corresponding to the target cycle is extracted from the maintenance entry set. The number of candidate maintenance entries is less than or equal to the number of cycle requests. Based on the first maintenance entry, a first addressing request corresponding to the first maintenance entry is generated, wherein the first maintenance entry is any one of at least one candidate maintenance entry; Based on the number of batch requests, all addressing requests generated in the target period are sent to the network devices corresponding to the addressing requests in batches.
[0007] This application also provides an apparatus for sending an addressing request, comprising: The acquisition module is used to acquire the number of batch requests, the cycle duration, and the set of maintenance entries for addressing requests; The determination module is used to determine the number of periodic requests based on the batch request quantity and the period duration. The extraction module is used to extract at least one candidate maintenance entry corresponding to the target period from the maintenance entry set during the processing of the target period, based on the number of period requests, wherein the number of candidate maintenance entries is less than or equal to the number of period requests. The generation module is used to generate a first addressing request corresponding to the first maintenance entry based on the first maintenance entry, wherein the first maintenance entry is any one of at least one candidate maintenance entry; The sending module is used to send all addressing requests generated in the target period to the network devices corresponding to the addressing requests in batches according to the number of batch requests.
[0008] This application also provides a switch, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described methods for sending addressing requests.
[0009] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described methods for sending an addressing request.
[0010] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described methods for sending an addressing request.
[0011] This application first obtains the batch request quantity, cycle duration, and maintenance entry set for addressing requests, and pre-determines the cycle request quantity based on the batch request quantity and cycle duration. Then, during the processing of the target cycle, candidate maintenance entries can be extracted from the maintenance entry set based on the cycle request quantity. For any candidate maintenance entry in the target cycle, a corresponding addressing request can be generated, and all addressing requests generated in the target cycle are sent to the corresponding network devices in batches according to the batch request quantity. In this process, the switch can periodically send addressing requests to network devices, ensuring that all maintenance entries in the maintenance entry set can be used periodically. This allows the switch to detect that maintenance entries are continuously being used without deleting them. Furthermore, for any network device belonging to the same network as the switch, the switch can directly extract the corresponding maintenance entry from the maintenance entry set when communication is needed, without needing to rebroadcast to obtain the network device's physical address, thus improving communication efficiency. Attached Figure Description
[0012] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A schematic diagram of the architecture of a network system provided in an embodiment of this application; Figure 2 A flowchart illustrating a method for sending an addressing request provided in an embodiment of this application; Figure 3 A flowchart illustrating another method for sending an addressing request provided in an embodiment of this application; Figure 4 A flowchart illustrating another method for sending an addressing request provided in an embodiment of this application; Figure 5 This application provides a schematic diagram of the data flow of a switch. Figure 6 A schematic diagram of the structure of an apparatus for sending an addressing request, provided for an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a switch provided in an embodiment of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0015] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0016] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0017] The following is an explanation of the technical terms used in this application.
[0018] Networking Operating System (NOS): This is a dedicated system software that runs on network devices. It is primarily responsible for managing and abstracting underlying hardware resources, providing network protocol stacks, control plane functions, management interfaces, and programmability, thereby transforming general-purpose hardware into network devices that can intelligently forward and control data flows.
[0019] Internet Protocol (IP) is a protocol designed for communication between interconnected computer networks. In the Internet, the Internet Protocol specifies the rules that computers must follow when communicating, enabling all computer networks connected to the Internet to communicate with each other. Computer equipment from any manufacturer can interconnect with the Internet as long as it complies with IP.
[0020] Internet Protocol Address (IPA): Also commonly known as a network protocol address. An IPA is a standardized address format provided by the Internet Protocol (IP). Therefore, assigning a logical address to every network and every computer device on the Internet masks the differences in physical addresses.
[0021] Media Access Control (MAC) address: also commonly referred to as physical address, hardware address, network card address, etc. The MAC address is written into the hardware by the network device manufacturer during production. A physical address is typically 48 bits (6 bytes), usually represented as 12 hexadecimal numbers, separated by colons, for example, "08:00:20:0A:8C:6D".
[0022] Address Resolution Protocol (ARP) is a network transport protocol that resolves network layer addresses to find data link layer addresses. Network devices can store ARP cache tables, which contain the mappings between the Internet Protocol addresses (IPAs) and physical addresses of other network devices besides themselves. When a source network device sends information to a destination network device, it first searches its ARP cache table to find the physical address of the destination network device. If the address is not found, the source network device broadcasts an ARP request on its local network. The destination network device receives this request and responds with a unicast ARP reply, thus obtaining the physical address of the destination network device. The source network device can then communicate with the destination network device based on the obtained physical address and simultaneously updates its own ARP cache table.
[0023] A red-black tree is a self-balancing binary search tree data structure. It ensures that the tree maintains approximate balance during dynamic insertion and deletion operations by introducing a color attribute (red / black) into the nodes and following specific balancing rules. This guarantees search, insertion, and deletion performance with a worst-case time complexity of O(log n) (where n is the number of elements in the tree). It is one of the important foundational data structures in computer science for implementing efficient associative arrays (mappings, sets).
[0024] Control Plane Policing (COPP) is a critical security and Quality of Service (QoS) mechanism in network devices. It protects control plane resources from being overwhelmed by a large number of protocol packets caused by malicious attacks, network failures, or configuration errors by classifying, regulating, and rate-limiting traffic sent to the control plane, thereby ensuring the stable operation of network control and management functions.
[0025] The method for sending addressing requests provided in this application can be implemented by a network system, such as... Figure 1 As shown, a network system can include switches and multiple network devices. A switch can be a network device used for forwarding electrical or optical signals, and its main function is to provide a dedicated communication link for any two network devices connected to the switch. For example, a switch can be an Ethernet switch, a telephone voice switch, a fiber optic switch, etc. Network devices can be computers, servers, printers, etc.
[0026] A switch can include a switcher and a central processing unit (CPU). The switcher represents the data plane of the switch and is primarily used for forwarding data packets. The CPU represents the control plane of the switch and is primarily used for processing network protocols.
[0027] Embodiments of this application provide a method for sending an addressing request, which can be executed by a switch, such as... Figure 2 As shown, the specific processing steps of the method for sending an addressing request may include: Step S201: Obtain the batch request quantity, cycle duration, and maintenance entry set for addressing requests.
[0028] The batch request count indicates the maximum number of addressing requests a switch can send in a batch. For example, 1 second can be a batch. Addressing requests can be ARP requests. The maintenance entry set can include maintenance information about the communication addresses of various network devices belonging to the switch within the same network. The maintenance entry set can take the form of a red-black tree, where a node in the red-black tree represents a maintenance entry.
[0029] Specifically, when a switch is first put into operation, it can directly read the pre-set batch request quantity and cycle duration from its own memory. Additionally, the switch can obtain the communication address information of each network device within its network and, based on this address information, construct a set of maintenance entries for addressing requests.
[0030] Alternatively, when the switch is first put into operation, it can read configuration information related to the addressing request from its own memory. This configuration information may include the aging period and COPP value. Correspondingly, the switch can also obtain the cycle duration and batch request quantity as follows: First, obtain the cycle duration.
[0031] Obtain the aging duration of the maintenance entry for the addressing request. If the aging duration is determined to be greater than a preset duration threshold, determine the cycle duration based on the aging duration and a first preset value. Alternatively, if the aging duration is determined to be less than or equal to the preset duration threshold, directly determine the second preset value as the cycle duration.
[0032] Second, obtain the number of batch requests.
[0033] Obtain the architecture type of the switch's central processing unit (CPU) and the second largest number of addressing requests that the CPU can process per unit time. Determine the batch request count based on the architecture type, the second largest number, and the cycle duration.
[0034] The switch can retrieve the CPU architecture type by executing a preset architecture retrieval command. Furthermore, the switch can extract the aging time and COPP value from its own configuration information. For example, the architecture retrieval command can be "uname -m", the architecture type can be represented by "cpu_arch", the aging time can be represented by "arp_aging_time", and the COPP value can be represented by "max_arp_num". The COPP value is the second quantity.
[0035] Because longer aging times result in lower refresh requirements, while shorter aging times lead to higher refresh requirements, this solution sets a preset duration threshold to accommodate refresh demands under different aging times. Based on the comparison between the aging time and the preset duration threshold, a corresponding calculation method is used to determine the cycle duration. Specifically, when the aging time exceeds the preset duration threshold, the switch determines the cycle duration as the ratio of the aging time to a first preset value. When the aging time is less than or equal to the preset duration threshold, a second preset value is directly used as the cycle duration. For example, the preset duration threshold could be 300 seconds, the first preset value could be 10 seconds, and the second preset value could be 30 seconds. When the aging time exceeds 300 seconds, the cycle duration I = arp_aging_time / 10; when the aging time is less than or equal to 300 seconds, 30 seconds is directly used as the cycle duration.
[0036] Thus, with a long aging period, appropriately extending the cycle can avoid resource waste caused by excessive maintenance. With a short aging period, using a fixed cycle can prevent excessively short cycles due to extreme configurations, avoiding resource waste. For example, if the aging period is 10 seconds, using I=arp_aging_time / 10 to calculate the cycle length results in a cycle length of only 1 second, which is too short.
[0037] Because different CPU architectures have varying capabilities in processing protocol requests, this solution calculates the batch request quantity based on the COPP value, architecture type, and cycle duration to ensure the CPU can safely execute transmission operations every second. This guarantees that each batch within the cycle can send addressing requests according to the specified batch request quantity. This ensures that the determined batch request quantity satisfies both the switch's hardware capabilities and the aging time of maintenance entries. It guarantees that the necessary maintenance entries will not age out within the specified time and also ensures the stability of the entire process.
[0038] Optionally, determining the number of batch requests based on the architecture type, the second quantity, and the cycle duration may include the following specific steps: The switch can obtain an adjustment ratio coefficient corresponding to the architecture type. The product of the adjustment ratio coefficient and the second quantity is used to determine the third quantity. The ratio between the third quantity and the cycle duration is rounded down to obtain the batch request quantity.
[0039] For example, the architecture type can be "x86_64" or "arm". When the architecture type is "x86_64", the corresponding adjustment ratio can be 0.8, meaning the batch request quantity is... When the architecture type is "arm", the corresponding adjustment ratio can be 0.5, which means the batch request quantity is... .
[0040] In this way, since the adjustment ratio is less than 1, adjusting the second quantity by adjusting the ratio can reserve some processing resources to cope with sudden protocol messages, sudden operations in the control plane, and unknown background traffic, ensuring the security and stability of the switch. Furthermore, by rounding down during calculation, it can be ensured that the actual number of batch requests is strictly less than the theoretical calculated value, further eliminating the possibility of exceeding limits due to floating-point errors or rounding. Different utilization coefficients (such as 0.8 and 0.5) are set to address the performance differences between different architectures such as "x86_64" (high performance) and "arm" (low power), ensuring that the maintenance traffic load is precisely matched to the actual processing capacity of the switch's central processing unit.
[0041] Step S202: Determine the number of periodic requests based on the batch request quantity and the period duration.
[0042] Specifically, the batch request number can be the maximum number of addressing requests that the switch's central processing unit can process in 1 second. Therefore, the switch can directly determine the batch request number and the period duration as the period request number to represent the maximum number of addressing requests that the switch's central processing unit can process in one period.
[0043] Step S203: In the processing of the target cycle, the number of cycle requests is used as the upper limit, and at least one candidate maintenance entry corresponding to the target cycle is extracted from the maintenance entry set.
[0044] The number of candidate maintenance entries is less than or equal to the number of periodic requests.
[0045] Specifically, since the number of maintenance entries included in the maintenance entry set is constantly changing and requires processing in one or more cycles, and the number of maintenance entries that the switch must process in one cycle has been given in step S202 above, the switch can directly extract one or more candidate maintenance entries that need to be processed in the target cycle from the maintenance entry set based on the number of cycle requests in the target cycle.
[0046] For example, directly extract the same number of maintenance entries as the number of periodic requests as candidate maintenance entries.
[0047] Alternatively, the switch can define a round as completing one maintenance process for all maintenance items in the maintenance item set. A round can include at least one period. Accordingly, the switch can perform the extraction operation of candidate maintenance items for the target period in the following two ways: Method 1 Step 1: Identify the starting maintenance entry for the target cycle from the set of maintenance entries.
[0048] Step 2: Starting from the initial maintenance entry, traverse the maintenance entries in the set that have not been processed in the current round.
[0049] Step 3: For each item to be maintained encountered during traversal, extract the encountered item to be maintained from the set of items to be maintained as a candidate item to be maintained.
[0050] Step 4: Stop traversing when the number of items to be maintained is equal to the number of periodic requests, or when all items to be maintained in the maintenance item set have been traversed and the number of items to be maintained is less than the number of periodic requests, and obtain at least one candidate maintenance item.
[0051] The items to be maintained include at least the initial maintenance items, the current round includes at least one cycle, and the target cycle is any one of the at least one cycles.
[0052] Specifically, the candidate maintenance entries for each cycle can be extracted according to the order of the maintenance entries in the maintenance entry set. Accordingly, when the switch processes each cycle, it can determine the starting maintenance entry for the current cycle based on the last maintenance entry processed in the previous cycle.
[0053] Then, the switch can use the starting maintenance entry as a starting point to traverse the set of maintenance entries, including the starting maintenance entry. Each time a maintenance entry is encountered, the switch can extract that entry from the set of maintenance entries and use it as a candidate maintenance entry.
[0054] Furthermore, the switch can count the number of maintenance items being traversed. It can stop traversing when this number equals the number of periodic requests, or it can stop traversing if the count after traversing all maintenance items still does not reach the number of periodic requests. In this way, candidate maintenance items that are less than or equal to the number of periodic requests can be extracted.
[0055] Furthermore, if all maintenance entries in the maintenance entry set have been traversed and the number of maintenance entries traversed is less than the number of periodic requests, the switch, after sending all addressing requests for the target period, may not immediately enter the next period. Instead, it can wait for the target duration before proceeding to the next period. The target duration can be calculated as follows: The target duration is determined based on the number of candidate maintenance entries, the number of batch requests, and the cycle duration. This allows the system to wait for the target duration after completing the sending operation of the last batch of addressing requests in the target cycle before proceeding to the next cycle following the target cycle.
[0056] The switch can determine the first duration as the ratio between the number of candidate maintenance entries and the number of batch requests, which is the number of batches the switch needs to send to complete the addressing requests for the target period. One batch can be equal to 1 second. Correspondingly, the switch can determine the target duration as the difference between the period duration and the first duration. Then, after completing the sending operation of the last batch of the target period, the switch can wait for the target duration before entering the processing of the next period.
[0057] Method 2 Step 1: Identify the starting maintenance entry for the target cycle from the set of maintenance entries.
[0058] The current round includes at least one cycle, and the target cycle is any one of the at least one cycles.
[0059] Step 2: Identify the items to be maintained from the set of maintenance items that have not been processed in the current round, and count the first number of items to be maintained.
[0060] Step 3: Determine the number of maintenance entries corresponding to the target cycle based on the number of periodic requests and the first quantity.
[0061] Step 4: Starting from the initial maintenance entry, extract the same number of maintenance entries as the number of maintenance entries from the entries to be maintained as candidate maintenance entries.
[0062] Step one is similar to method one, so it will not be repeated here.
[0063] In step two, the switch can also identify the lock head maintenance items that have not been processed in the current round, and count the number of remaining maintenance items that have not yet been maintained in the current round, that is, count the first number of maintenance items.
[0064] In step three, the periodic request quantity specifies the maximum number of maintenance entries that can be processed in a period. Since a round requires processing all maintenance entries in the set of maintenance entries, the switch can determine the periodic request quantity as the number of maintenance entries corresponding to the target period if it determines that the first quantity is greater than or equal to the periodic request quantity. Alternatively, if it determines that the first quantity is less than the periodic request quantity, it can determine the first quantity as the number of maintenance entries corresponding to the target period.
[0065] In step four, the switch can directly extract the same number of maintenance entries as the number of maintenance entries from the maintenance entry set as candidate maintenance entries to be processed in the target cycle.
[0066] Optionally, in step one of both Method 1 and Method 2 above, the switch can determine the starting maintenance item for the target cycle according to the following specific steps: Retrieve the second maintenance entry indicated by the pre-built processing cursor. If the second maintenance entry is determined to be the last maintenance entry in the maintenance entry set, the first maintenance entry in the maintenance entry set is determined as the starting maintenance entry data. Alternatively, if the second maintenance entry is not determined to be the last maintenance entry in the maintenance entry set, the maintenance entry in the maintenance entry set that is ordered after the second maintenance entry is determined as the starting maintenance entry.
[0067] Specifically, when the switch completes processing of the previous cycle before the target cycle, it can set the processing cursor to the second maintenance entry (i.e., the last candidate maintenance entry in the previous cycle). During the processing of the target cycle, the switch can directly read the second maintenance entry indicated by the processing cursor and determine the starting maintenance entry for the target cycle based on the second maintenance entry. The second maintenance entry can be the last maintenance entry in the maintenance entry set, or it can be any other maintenance entry. In the former case, it means that when the previous cycle was completed, all maintenance entries in the maintenance entry set had undergone one round of maintenance operations, and the target cycle is the first cycle in the new round. Accordingly, the switch can determine the first maintenance entry in the maintenance entry set as the starting maintenance entry for the target cycle. In the latter case, it means that the maintenance operations of the current round have not yet been completed, and there are still maintenance entries in the maintenance entry set that have not undergone maintenance processing in the current round. In this case, maintenance entries after the second maintenance entry can be determined as the starting maintenance entry for the target cycle.
[0068] Step S204: Generate a first addressing request corresponding to the first maintenance entry based on the first maintenance entry.
[0069] The first maintenance entry can be any one of at least one candidate maintenance entry. Maintenance entries can include the Internet Protocol address and physical address of the source network device, the Internet Protocol address and physical address of the destination network device, etc.
[0070] Specifically, for each maintenance entry pre-determined in the target period, the switch can construct a corresponding addressing request based on the communication address information included in the maintenance entry. Taking the first maintenance entry as an example, the switch can call a pre-constructed addressing request sending function, inputting the Internet Protocol address and physical address of the source network device, and the Internet Protocol address and physical address of the destination network device included in the first maintenance entry into the addressing request sending function to obtain the first addressing request. For example, the addressing request sending function can be "send_arp_request", whose parameters include "src_ip", "src_mac", "dst_ip", and "dst_mac", representing the Internet Protocol address and physical address of the source network device, and the Internet Protocol address and physical address of the destination network device, respectively.
[0071] Step S205: According to the number of batch requests, send all addressing requests generated in the target period to the network devices corresponding to the addressing requests in batches.
[0072] Specifically, after generating a first addressing request by calling the addressing request sending function, the switch can determine the target communication interface bound to the source network device's Internet Protocol address (IPA address) from at least one of its communication interfaces. The first addressing request is then sent to the corresponding destination network device through the target IPA interface. During the addressing request sending process, the switch can use the batch request quantity as a reference, sending only addressing requests less than or equal to the batch request quantity in each batch. This allows the generated addressing requests to be sent to the corresponding network devices in batches within the target cycle. After completing the target cycle's processing, if the switch determines that there are still maintenance entries in the maintenance entry set that have not been processed in the current cycle, it can proceed to the next cycle's processing; or, if it determines that there are no maintenance entries in the maintenance entry set that have not been processed in the current cycle, it can proceed to the next cycle's processing, and so on, continuously looping.
[0073] The method for sending addressing requests according to embodiments of this application first obtains the batch request quantity, period duration, and maintenance entry set for the addressing requests, and pre-determines the period request quantity based on the batch request quantity and period duration. Then, during the processing of the target period, candidate maintenance entries can be extracted from the maintenance entry set based on the period request quantity. For any candidate maintenance entry in the target period, a corresponding addressing request can be generated, and all addressing requests generated in the target period are sent to the corresponding network devices in batches according to the batch request quantity. In the above process, the switch can periodically send addressing requests to network devices, ensuring that all maintenance entries in the maintenance entry set can be used periodically. This way, the switch can detect that maintenance entries are continuously being used without performing deletion operations. Furthermore, for any network device belonging to the same network as the switch, the switch can directly extract the corresponding maintenance entry from the maintenance entry set when communication is needed, without needing to rebroadcast to obtain the physical address of the network device, thus improving communication efficiency.
[0074] During the processing in steps S201 to S205, the switch can guarantee the validity of each maintenance entry in its own maintenance entry set. However, for network devices, the maintenance entry corresponding to the switch may still be deleted from the network device's maintenance entry set (e.g., ARP cache table). Therefore, to ensure that network devices can promptly find the physical address of the switch when they need to communicate with it, the switch can proactively send addressing requests for its various communication interfaces to the network devices. Accordingly, embodiments of this application also provide another method for sending addressing requests, which can be executed by the switch, such as... Figure 3 As shown, the specific processing steps of the method for sending an addressing request may include: Step S301: Obtain the batch request quantity, cycle duration, and maintenance entry set for addressing requests.
[0075] Step S302: Determine the number of periodic requests based on the batch request quantity and the period duration.
[0076] The specific processing of steps S301 to S302 can be referred to the specific processing of steps S201 to S202 above, and will not be repeated here.
[0077] Step S303: Obtain the communication address information corresponding to at least one communication interface of the switch.
[0078] Specifically, before each round of processing and maintaining a set of entries, that is, when the target period is the first period of at least one period included in the current round, the switch can obtain the communication address information of each communication interface it includes. For example, the communication address information may include the Internet Protocol address and physical address of the communication interface.
[0079] Step S304: Generate a second addressing request based on the first communication address information corresponding to the first communication interface, and broadcast it.
[0080] The first communication interface is any one of at least one communication interface.
[0081] Specifically, a switch can generate and broadcast corresponding addressing requests based on the communication address information of each communication interface. This operation is generally referred to as sending gratuitous ARP requests. Taking the first communication interface as an example, the switch can generate a second addressing request based on the Internet Protocol address and physical address in the first communication address information, and broadcast it through the first communication interface. In this way, network devices belonging to the same network as the switch can receive the switch's addressing requests and update their own maintenance entry sets based on the received addressing requests, ensuring that the maintenance entries related to the switch in the maintenance entry set can always be used.
[0082] Step S305: In the processing of the target cycle, at least one candidate maintenance entry corresponding to the target cycle is extracted from the maintenance entry set according to the number of cycle requests.
[0083] Step S306: Generate a first addressing request corresponding to the first maintenance entry based on the first maintenance entry data.
[0084] Step S307: According to the number of batch requests, send all addressing requests generated in the target period to the network devices corresponding to the addressing requests in batches.
[0085] The specific processing of steps S305 to S307 can be referred to the specific processing of steps S203 to S205 above, and will not be repeated here.
[0086] The method for sending addressing requests in embodiments of this application allows the switch to generate and broadcast corresponding addressing requests for each of its communication interfaces before processing its own stored set of maintenance entries. This enables network devices within the same network to receive the addressing requests and update their own set of maintenance entries based on the received requests, ensuring that maintenance entries related to the switch remain usable. In other words, the switch's maintenance entries do not age out. When a network device needs to communicate with the switch, it can directly extract the maintenance entry for the corresponding communication interface from its own set of maintenance entries, without needing to obtain the switch's physical address through broadcasting. This improves communication efficiency between the switch and network devices. Thus, communication efficiency is improved from both the switch and network device perspectives.
[0087] In some optional implementations, during the process of sending the addressing request described above, new network devices may be added to the network to which the switch belongs, or some network devices may disappear from the network (e.g., be shut down or removed). In order to ensure the validity of the maintenance entry set, the switch can update the maintenance entry set in real time. Accordingly, the switch can also perform the following specific steps: Step 1: After obtaining the new information of the maintenance entry, extract the identification information of the second communication interface, the Internet Protocol address and physical address of the destination network device from the new information.
[0088] Step 2: Based on the identification information of the second communication interface, determine the second communication address information corresponding to the second communication interface from the communication address information corresponding to at least one communication interface.
[0089] Step 3: Extract the Internet Protocol address and physical address of the second communication interface from the second communication address information.
[0090] Step 4: Generate a third maintenance entry based on the Internet Protocol address and physical address of the destination network device, as well as the Internet Protocol address and physical address of the second communication interface.
[0091] Step 5: Add the third maintenance entry to the maintenance entry set.
[0092] Specifically, the switch can listen to network link messages of a specified type in the kernel. For example, the specified type can be a message for adding a maintenance entry, a message for deleting a maintenance entry, etc. A message for adding a maintenance entry can generally be represented as "RTM_NEWNEIGH", and a message for deleting a maintenance entry can generally be represented as "RTM_DELNEIGH".
[0093] When a switch detects a new maintenance entry message, it can parse the message to extract the identifier of the second communication interface, the Internet Protocol address (IPA) of the destination network device, and its physical address. Then, based on the identifier, the switch can determine the second communication interface's second communication address from the communication address information of all its interfaces, and extract its IPA and physical address. Further, the switch can combine these multiple pieces of information—the destination network device's IPA and physical address, and the second communication interface's IPA and physical address—into a maintenance entry, also known as the third maintenance entry. Finally, the switch can add the third maintenance entry to the maintenance entry set. For example, if the maintenance entry set is a red-black tree, the third maintenance entry can be added as a new node to the red-black tree.
[0094] When a switch detects a deletion message for a maintenance entry, it can parse the message to extract the identifier of the third communication interface, the Internet Protocol address (IPA) of the destination network device communicating with the third communication interface, and its physical address. Then, based on the identifier, the switch can determine the third communication interface's address from the address information of all its communication interfaces, and extract its IPA and physical address. Finally, based on the IPA and physical addresses of the third communication interface and the destination network device communicating with it, the switch can determine the corresponding fourth maintenance entry in the maintenance entry set and delete it. For example, if the maintenance entry set is a red-black tree, the node corresponding to the fourth maintenance entry can be deleted from the red-black tree.
[0095] In this way, by monitoring messages in real time, it can be ensured that the maintenance entries included in the maintenance entry set match the actual requests of network devices in the network to which the switch belongs. When a new network device is added, the maintenance entry set can be updated promptly, ensuring that the maintenance entries for the new network device can be maintained in a timely manner, further improving the communication efficiency between the new network device and the switch. When a network device disappears, messages can be deleted promptly, reducing the size of the maintenance entry set and avoiding the need to traverse invalid maintenance entries when querying related maintenance entries, thus saving resources.
[0096] Furthermore, when the set of items to be maintained is a red-black tree, the addition or deletion operations can still guarantee the balance of the tree. Thus, in the worst case, the search, insertion and deletion performance can still be guaranteed to have a time complexity of O(log n), which can improve the efficiency of querying and maintaining items, and thus improve communication efficiency.
[0097] In some optional implementations, the switch can monitor the utilization of the central processing unit (CPU). During each processing cycle, it can first obtain the latest CPU utilization and adjust the batch request quantity based on this latest utilization. Specifically, if the latest utilization is determined to be greater than a first utilization threshold, the batch request quantity can be reduced by a first preset value; if the latest utilization is determined to be less than a second utilization threshold, the batch request quantity can be increased by a first preset value. The first utilization threshold is greater than the second utilization threshold; for example, the second utilization threshold could be 0.6 or 0.2.
[0098] In this way, when the CPU utilization is low, maintenance operations can be performed by fully utilizing CPU resources, thereby improving the efficiency of maintenance operations and avoiding the problem of insufficient maintenance operations to complete the corresponding maintenance items within a cycle when the utilization is high in subsequent stages. When the CPU utilization is high, some CPU resources can be freed up by reducing the number of batch requests, thus avoiding CPU overload and failure.
[0099] The following is a detailed explanation of the execution process of the above-mentioned method for sending addressing requests, using a specific example. The process can be described as follows: Figure 4 As shown, it supports the use of Python programming language to implement relevant code on switches running NOS.
[0100] First, when the switch is first put into operation, the cycle duration and batch request quantity can be generated. Then, based on the real-time acquired information, the switch can create two dictionaries and a red-black tree. The two dictionaries represent the mapping between the switch's communication interfaces and physical addresses, and the mapping between the switch's communication interfaces and Internet Protocol (IP) addresses, respectively. For the first dictionary, the communication interface is the key and the physical address is the value; for the second dictionary, the communication interface is the key and the IP address is the value. The red-black tree includes at least one node, and each node represents an entry from the aforementioned set of maintained entries.
[0101] Then, as Figure 5As shown, a switch can create a data update thread and a main thread. The switch can use the data update thread to monitor various network connection messages in the kernel, including "RTM_NEWLINK", "RTM_DELLINK", "RTM_NEWADDR", "RTM_DELADDR", "RTM_NEWNEIGH", and "RTM_DELNEIGH". Specifically, listening to "RTM_NEWLINK" and "RTM_DELLINK" network connection messages can be used to maintain the mapping between the switch's communication interfaces and physical addresses; listening to "RTM_NEWADDR" and "RTM_DELADDR" network connection messages can be used to maintain the mapping between the switch's communication interfaces and Internet Protocol (IP) addresses; and listening to "RTM_NEWNEIGH" and "RTM_DELNEIGH" network connection messages can be used to maintain red-black trees.
[0102] A switch can pre-create functions for sending addressing requests, a main function, and functions for obtaining the period duration and batch request count. The obtaining function can typically be represented as "generate_send_interval_and_number". After running the main function on the main thread, the main function will first call the obtaining function to obtain the period duration and batch request count returned by the obtaining function.
[0103] Furthermore, in the current round, the switch can generate corresponding addressing requests based on the two dictionaries mentioned above, according to the Internet Protocol addresses and physical addresses of each communication interface included therein, and then broadcast them.
[0104] In the first cycle of the current round, the switch updates its processing cursor to the first node of the red-black tree, i.e., the root node. Accordingly, the switch can begin traversing the red-black tree from the root node. If the number of nodes in the red-black tree is less than the number of cycle requests, all nodes in the red-black tree can be extracted. If the number of nodes in the red-black tree is greater than or equal to the number of cycle requests, the same number of nodes as the number of cycle requests can be extracted. At this point, the switch can determine whether it has traversed all nodes in the red-black tree.
[0105] If not all nodes of the red-black tree have been traversed, the first untraversed node can be designated as the starting point of the next cycle. Furthermore, after extracting the nodes corresponding to the current cycle, the switch can call the addressing request sending function to generate multiple addressing requests corresponding to each node based on the data extracted from the multiple nodes in the current cycle, and send the same number of addressing requests per second as the batch request count. After completing the sending operation of each batch, the switch can determine whether all addressing requests for the current cycle have been sent. If all have been sent, the switch can proceed to the next cycle in the current round. If not all have been sent, the switch will proceed to the next batch until the addressing requests for the current cycle have been sent.
[0106] If all nodes of the red-black tree have been traversed, the root node is determined as the starting point of the next cycle, and the red-black tree is traversed again at the trigger time of the next round, which means entering the next round of processing.
[0107] Alternatively, the switch can also be handled in the following way: The switch can first define the processing cursor as the root node of a red-black tree. Starting from the root node, it traverses the red-black tree, obtaining multiple nodes equal to the number of batch requests. The processing cursor is then updated to the last node among these nodes, and a pre-built batch count counter is incremented. The switch can then call an address request sending function. Using this function, based on the data included in the multiple nodes, it generates multiple address requests corresponding to each node and sends them to the appropriate network devices.
[0108] The switch can redetermine the starting node for the next batch based on the processing cursor. Using this starting node as a reference, it extracts multiple nodes from the red-black tree, equal to the number of batch requests. The processing cursor is then updated to the last node extracted in this batch, and the pre-built batch counter is incremented. Similarly, the switch can call the address request sending function to generate multiple address requests corresponding to each node based on the data included in the multiple nodes, and send them to the corresponding network devices. This process continues until the batch counter equals the aforementioned cycle duration, completing the operation of the current cycle. At this point, the batch counter value can be updated to 0, and the operation of the next cycle can begin.
[0109] After confirming that the entire red-black tree traversal operation has been completed, if the count value of the batch counter (i.e. the first duration) is less than the cycle duration, the difference between the cycle duration and the count value can be determined as the target duration. Within the target duration, the switch does not need to perform maintenance operations. After the waiting time, the traversal operation can be restarted from the root node of the red-black tree to continue the processing of the next round.
[0110] The method for sending addressing requests in the embodiments of this application employs sequential loop traversal, continuing from the position where the last iteration ended each time. In the long run, all data will be processed in a round-robin fashion, avoiding frequent processing or long-term omission of certain data. Furthermore, when the subscribed data (nodes) changes, new nodes can be inserted into the red-black tree in real time (inserted in order of key value). Since the red-black tree is balanced, the order is maintained after insertion, ensuring that the newly added node will be naturally included in the traversal scope during the next processing.
[0111] In some optional implementations, if the CPU architecture type is determined to be the target architecture type, the switch can create multiple threads to execute the above-described method of sending address requests in parallel. Accordingly, the switch can set a processing cursor as a global variable and set a mutex lock on the processing cursor. After each thread acquires the mutex lock on the processing cursor, it can then perform the operation of reading the node. After completing the read operation and updating the processing cursor, it can release the mutex lock. Each thread can execute the corresponding address request sending operation in parallel based on the read node. The target architecture type can be used to indicate that the CPU's performance indicators are greater than a preset performance indicator threshold. For example, the performance indicator can be the clock speed, operating frequency, or the number of cores included in the CPU.
[0112] In this way, the above-mentioned operations of sending addressing requests can be performed in parallel, improving the efficiency of sending addressing requests.
[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0114] Embodiments of this application also provide an apparatus for sending an addressing request, such as... Figure 6 As shown, it includes: The acquisition module 610 is used to acquire the batch request quantity, cycle duration, and the maintenance entry set of the addressing request; The determination module 620 is used to determine the number of periodic requests based on the batch request quantity and the period duration; The extraction module 630 is used to extract at least one candidate maintenance entry corresponding to the target period from the maintenance entry set during the processing of the target period, with the number of period requests as the upper limit, wherein the number of candidate maintenance entries is less than or equal to the number of period requests. The generation module 640 is used to generate a first addressing request corresponding to the first maintenance entry based on the first maintenance entry, wherein the first maintenance entry is any one of at least one candidate maintenance entry; The sending module 650 is used to send all addressing requests generated in the target period to the network devices corresponding to the addressing requests in batches according to the number of batch requests.
[0115] In some alternative implementations, the extraction module 630 is specifically used for: The starting maintenance entry for the target cycle is determined from the set of maintenance entries; Starting from the initial maintenance entry, the maintenance entry set that has not been processed in the current round is traversed. The maintenance entry includes at least the initial maintenance entry, the current round includes at least one cycle, and the target cycle is any one of the at least one cycle. For each of the items to be maintained encountered during traversal, the encountered item to be maintained is extracted from the set of maintenance items as a candidate maintenance item; If the number of maintenance entries being traversed is equal to the number of periodic requests, or if all maintenance entries in the maintenance entry set have been traversed and the number of maintenance entries being traversed is less than the number of periodic requests, then traversal stops and at least one candidate maintenance entry is obtained.
[0116] In some alternative implementations, the extraction module 630 is further configured to: If all maintenance entries in the maintenance entry set have been traversed and the number of maintenance entries traversed is less than the number of periodic requests, a target duration is determined based on the number of candidate maintenance entries, the number of batch requests, and the period duration. This allows the system to wait for the target duration after the last batch of addressing requests in the target period is sent before proceeding to the next period following the target period.
[0117] In some alternative implementations, the extraction module 630 is specifically used for: Retrieve the second maintenance entry indicated by the pre-built processing cursor; If the second maintenance entry is determined to be the last maintenance entry in the maintenance entry set, the first maintenance entry in the maintenance entry set will be determined as the starting maintenance entry data. Alternatively, if it is determined that the second maintenance entry is not the last maintenance entry in the set of maintenance entries, the maintenance entry that is ranked after the second maintenance entry in the set of maintenance entries is determined as the starting maintenance entry.
[0118] In some optional implementations, when the target period is the first period of at least one period included in the current round, before extracting at least one candidate maintenance entry corresponding to the target period from the maintenance entry set according to the number of period requests during the processing of the target period, the apparatus further includes a broadcast module 660, configured to: Obtain the communication address information corresponding to at least one communication interface of the switch; A second addressing request is generated based on the first communication address information corresponding to the first communication interface and broadcast, wherein the first communication interface is any one of at least one communication interface.
[0119] In some alternative embodiments, the device further includes an update module 670 for: After obtaining the new information of the maintenance entry, extract the identification information of the second communication interface, the Internet Protocol address and physical address of the destination network device from the new information; Based on the identification information of the second communication interface, the second communication address information corresponding to the second communication interface is determined from the communication address information corresponding to at least one communication interface. Extract the Internet Protocol address and physical address of the second communication interface from the second communication address information; A third maintenance entry is generated based on the Internet Protocol address and physical address of the target network device, as well as the Internet Protocol address and physical address of the second communication interface. Add the third maintenance entry to the maintenance entry set.
[0120] In some optional implementations, the acquisition module 610 is specifically used for: Get the aging time of the maintenance entry for the addressing request; If the aging time is determined to be greater than the preset time threshold, the cycle time is determined based on the aging time and the first preset value. Alternatively, if the aging time is determined to be less than or equal to the preset time threshold, the second preset value can be directly determined as the cycle time.
[0121] In some optional implementations, the acquisition module 610 is specifically used for: Obtain the architecture type of the switch's central processing unit and the second largest number of addressing requests that the central processing unit can process per unit time; The number of batch requests is determined based on the architecture type, the second quantity, and the cycle duration.
[0122] In some optional implementations, the acquisition module 610 is specifically used for: Based on the architecture type, obtain the adjustment ratio coefficient corresponding to the architecture type; The product of the adjustment ratio coefficient and the second quantity is determined as the third quantity; The ratio between the third quantity and the cycle duration is rounded down to obtain the batch request quantity.
[0123] For a description of the features in the embodiment corresponding to the device for sending an addressing request, please refer to the relevant description in the embodiment corresponding to the method for sending an addressing request, which will not be repeated here.
[0124] Embodiments of this application also provide a switch, such as Figure 7 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in any of the above-described embodiments of the method for sending an addressing request.
[0125] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described method embodiments for sending an addressing request when it is run.
[0126] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0127] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described methods for sending addressing requests.
[0128] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above-described methods for sending an addressing request.
[0129] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0130] The foregoing has provided a detailed description of the method, apparatus, switch, storage medium, and program product for sending addressing requests provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for sending an addressing request, characterized in that, include: The aging time of the maintenance entry for the addressing request, the set of maintenance entries for the addressing request, the architecture type of the central processing unit of the switch, and the second number of addressing requests that the central processing unit can process at most per unit time are obtained. The set of maintenance entries is in the form of a red-black tree, and one node in the red-black tree corresponds to one maintenance entry. If the aging time is determined to be greater than a preset time threshold, the ratio between the aging time and a first preset value is determined as the cycle time; or, if the aging time is determined to be less than or equal to the preset time threshold, a second preset value is directly determined as the cycle time. Based on the architecture type, obtain the adjustment ratio coefficient corresponding to the architecture type, wherein the adjustment ratio coefficient is less than 1; determine the third quantity by multiplying the adjustment ratio coefficient and the second quantity; round down the ratio between the third quantity and the cycle duration to obtain the batch request quantity; If the architecture type is determined to be the target architecture type, multiple threads are created, wherein the target architecture type is used to indicate that the performance index of the central processing unit is greater than a preset performance index threshold, and the performance index is one of the main frequency, working frequency, and number of cores. The multiple threads are used to execute the operation of sending addressing requests in parallel. The number of periodic requests is determined based on the batch request quantity and the period duration; In the processing of the target period, when the target period is the first period of at least one period included in the current round, the communication address information corresponding to at least one communication interface included in the switch is obtained; according to the first communication address information corresponding to the first communication interface, a second addressing request is generated and broadcast, wherein the first communication interface is any one of at least one of the communication interfaces. And, when the target period is any one of at least one of the periods, the number of period requests is used as an upper limit to extract at least one candidate maintenance entry corresponding to the target period from the set of maintenance entries, wherein the number of candidate maintenance entries is less than or equal to the number of period requests; Based on the first maintenance entry, a first addressing request corresponding to the first maintenance entry is generated, wherein the first maintenance entry is any one of the at least one candidate maintenance entry; According to the batch request quantity, all addressing requests generated in the target period are sent to the network devices corresponding to the addressing requests in batches; the latest utilization rate of the central processing unit is obtained. When the latest utilization rate is determined to be greater than a first utilization rate threshold, the number of batch requests is reduced by a first preset value; when the latest utilization rate is determined to be less than a second utilization rate threshold, the number of batch requests is increased by the first preset value.
2. The method for sending an addressing request according to claim 1, characterized in that, When the target period is any one of at least one of the periods, the number of period requests is used as an upper limit to extract at least one candidate maintenance entry corresponding to the target period from the maintenance entry set, including: The starting maintenance entry for the target cycle is determined from the set of maintenance entries; Starting from the initial maintenance entry, the maintenance entry set that has not been processed in the current round is traversed, wherein the maintenance entry includes at least the initial maintenance entry. For each of the items to be maintained encountered during traversal, the encountered item to be maintained is extracted from the set of maintenance items as a candidate maintenance item; If the number of maintenance entries being traversed is equal to the number of periodic requests, or if all maintenance entries in the maintenance entry set have been traversed and the number of maintenance entries being traversed is less than the number of periodic requests, then traversal stops and at least one candidate maintenance entry is obtained.
3. The method for sending an addressing request according to claim 2, characterized in that, If all maintenance entries in the maintenance entry set have been traversed and the number of maintenance entries traversed is less than the number of periodic requests, the method further includes: Based on the number of candidate maintenance entries, the number of batch requests, and the cycle duration, a target duration is determined so that when the sending operation of the last batch of addressing requests in the target cycle is completed, the processing of the next cycle after the target cycle will proceed after the target duration.
4. The method for sending an addressing request according to claim 2, characterized in that, The step of determining the starting maintenance entry for the target cycle from the set of maintenance entries includes: Retrieve the second maintenance entry indicated by the pre-built processing cursor; If the second maintenance entry is determined to be the last maintenance entry in the set of maintenance entries, the first maintenance entry in the set of maintenance entries is determined as the starting maintenance entry data; Alternatively, if it is determined that the second maintenance entry is not the last maintenance entry in the set of maintenance entries, the maintenance entry in the set of maintenance entries that is ordered after the second maintenance entry is determined as the starting maintenance entry.
5. The method for sending an addressing request according to any one of claims 1 to 4, characterized in that, The method further includes: After obtaining the new information of the maintenance entry, the identification information of the second communication interface, the Internet Protocol address and physical address of the destination network device are extracted from the new information; Based on the identification information of the second communication interface, the second communication address information corresponding to the second communication interface is determined from the communication address information corresponding to at least one of the communication interfaces respectively; Extract the Internet Protocol address and physical address of the second communication interface from the second communication address information; A third maintenance entry is generated based on the Internet Protocol address and physical address of the target network device, and the Internet Protocol address and physical address of the second communication interface; Add the third maintenance entry to the set of maintenance entries.
6. A switch, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the method for sending an addressing request as described in any one of claims 1 to 5 when executing the computer program.
Citation Information
Patent Citations
Method for renewing address analysis protocol rapidly
CN1764193A