Protocol stack packet forwarding method and device, electronic equipment and storage medium

By determining the type of the packet to be sent in the neighbor subsystem and directly obtaining the MAC address or querying the neighbor table entries, the problem of packet dropping when the neighbor table entries reach the limit is solved, thus improving the processing efficiency and performance of network devices.

CN116346718BActive Publication Date: 2026-05-19CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CORP LTD
Filing Date
2021-12-22
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In complex network environments, when the neighbor table reaches its limit, certain packets are dropped, leading to service interruptions for network devices.

Method used

In the neighbor subsystem, determine whether the packet to be sent is a specific packet. If it is, directly obtain the MAC address from the preset rule set; otherwise, query the neighbor table entry and obtain the MAC address if successful, and call the data link layer interface to forward the packet.

Benefits of technology

This avoids the dropping of specific messages, shortens the processing flow, reduces the number of neighbor entries maintained in the neighbor cache, and improves protocol stack performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116346718B_ABST
    Figure CN116346718B_ABST
Patent Text Reader

Abstract

The present disclosure provides a protocol stack packet forwarding method and device, electronic equipment and storage medium, wherein the method comprises: a neighbor subsystem first determines whether a to-be-sent packet is a specific packet, if the to-be-sent packet is the specific packet, a first MAC address corresponding to a destination IP address in the to-be-sent packet is obtained from a preset rule set; if the to-be-sent packet is not the specific packet, a first neighbor table entry in a neighbor table is queried according to the destination IP address contained in the to-be-sent packet, and a second MAC address corresponding to the destination IP address is obtained in the case of successful first neighbor table entry query; and the data link layer interface is called to forward the to-be-sent packet according to the first MAC address or the second MAC address. In this way, it is ensured that the specific packet will not be discarded by the neighbor subsystem, the processing flow of the specific packet is shortened, the number of neighbor table entries that need to be maintained in the neighbor cache is reduced, and the protocol stack performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of network communication technology, and in particular to a protocol stack message forwarding method, apparatus, electronic device, and storage medium. Background Technology

[0002] Currently, most network devices employ a control plane and forwarding plane separation technology. The forwarding plane uses ASIC chips to accelerate forwarding, while the control plane communicates with the outside world through a protocol stack. As network scale continues to increase, and with the advent of various attacks in the network environment, traditional protocol stacks are insufficient to handle complex network traffic, leading to the emergence of various optimization methods for protocol stacks.

[0003] The existing neighbor subsystem, during packet processing, queries the neighbor table using the target IP address contained in the packet. If the corresponding neighbor table entry does not exist and the number of neighbor table entries reaches the configured limit, the packet will be discarded because no neighbor table entry can be found. In complex network environments, when the number of neighbor table entries generated by network devices reaches the limit, control plane protocol packets may be discarded by the neighbor subsystem, causing service interruption.

[0004] Therefore, how to prevent certain packets from being dropped when the number of neighbor entries reaches the limit has become an urgent technical problem to be solved.

[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] This disclosure provides a protocol stack message forwarding method, apparatus, electronic device, and storage medium, which at least to some extent overcomes the problem of specific messages being discarded in related technologies.

[0007] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0008] According to one aspect of this disclosure, a protocol stack packet forwarding method is provided, comprising: determining whether a packet to be sent is a specific packet, wherein the specific packet is a packet that has a mapping relationship with a MAC (Media Access Control) address pre-stored in a preset rule set; if the packet to be sent is a specific packet, obtaining a first MAC address corresponding to the destination IP address from the preset rule set based on the destination IP (Internet Protocol) address contained in the packet to be sent; if the packet to be sent is not a specific packet, querying a first neighbor entry in a neighbor table based on the destination IP address contained in the packet to be sent, and obtaining a second MAC address corresponding to the destination IP address if the query of the first neighbor entry is successful; and forwarding the packet to be sent by calling a data link layer interface based on the first MAC address or the second MAC address.

[0009] In one embodiment of this disclosure, a receiving terminal sends a specific message, the specific message including multicast messages, broadcast messages and messages sent to the local machine; according to the address resolution protocol, the mapping relationship between the destination IP address and MAC address contained in the specific message is determined; the mapping relationship between the destination IP address and MAC address contained in the specific message is stored in the preset rule set to generate the preset rule set.

[0010] In one embodiment of this disclosure, the preset rule set also stores a mapping relationship between user-issued custom IP addresses and MAC addresses.

[0011] In one embodiment of this disclosure, the preset rule set is stored in memory.

[0012] In one embodiment of this disclosure, the step of querying the first neighbor entry in the neighbor table based on the destination IP address includes: if the query for the first neighbor entry fails, determining whether the number of neighbor entries in the current neighbor table is less than a preset number; if the number of neighbor entries is greater than or equal to the preset number, discarding the message to be sent; if the number of neighbor entries is less than the preset number, creating a second neighbor entry in the neighbor table.

[0013] In one embodiment of this disclosure, after creating a second neighbor entry in the neighbor table, the method further includes: updating the third MAC address of the second neighbor entry according to the destination IP address and the address resolution protocol; and forwarding the packet to be sent by calling a data link layer interface according to the third MAC address.

[0014] According to another aspect of this disclosure, a protocol stack packet forwarding apparatus is provided, comprising: a packet-to-be-sent judgment module, configured to determine whether a packet to be-sent is a specific packet, wherein the specific packet is a packet that has a mapping relationship with MAC addresses pre-stored in a preset rule set; a first address acquisition module, configured to, if the packet to be-sent is a specific packet, acquire a first MAC address corresponding to the destination IP address from the preset rule set based on the destination IP address contained in the packet to be-sent; a second address acquisition module, configured to, if the packet to be-sent is not a specific packet, query a first neighbor entry in a neighbor table based on the destination IP address contained in the packet to be-sent, and acquire a second MAC address corresponding to the destination IP address if the query of the first neighbor entry is successful; and a packet-to-be-sent forwarding module, configured to, based on the first MAC address or the second MAC address, call a data link layer interface to forward the packet to be-sent.

[0015] In one embodiment of this disclosure, the apparatus further includes a neighbor entry creation module; the neighbor entry creation module is used to determine whether the number of neighbor entries in the current neighbor table is less than a preset number when the first neighbor entry query fails; if the number of neighbor entries is greater than or equal to the preset number, the message to be sent is discarded; if the number of neighbor entries is less than the preset number, a second neighbor entry is created in the neighbor table.

[0016] In one embodiment of this disclosure, the apparatus further includes a third address update module; the third address update module is configured to update the third MAC address of the second neighbor entry according to the destination IP address and the address resolution protocol; the packet forwarding module is further configured to call a data link layer interface to forward the packet to be sent according to the third MAC address.

[0017] According to another aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above-described protocol stack message forwarding method by executing the executable instructions.

[0018] According to another aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described protocol stack message forwarding method.

[0019] This disclosure provides a protocol stack packet forwarding method, apparatus, electronic device, and storage medium. The protocol stack packet forwarding method includes: a neighbor subsystem first determines whether a packet to be sent is a specific packet; if the packet is a specific packet, it obtains a first MAC address corresponding to the destination IP address from a preset rule set based on the destination IP address contained in the packet; if the packet is not a specific packet, it queries a first neighbor entry in the neighbor table based on the destination IP address contained in the packet; if the query is successful, it obtains a second MAC address corresponding to the destination IP address; and it forwards the packet by calling a data link layer interface based on the first MAC address or the second MAC address. This ensures that these specific packets are not discarded by the neighbor subsystem, shortens the processing flow of these specific packets, reduces the number of neighbor entries that need to be maintained in the neighbor cache, and improves protocol stack performance.

[0020] Furthermore, the preset rule set in this disclosure can also store user-defined IP address and MAC address mapping rules, making the application of the preset rule set more flexible and improving the efficiency of physical address matching. This disclosure also improves the physical address matching speed by storing the preset rule set in memory.

[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0023] Figure 1 This diagram illustrates a flowchart of a protocol stack message forwarding method according to an embodiment of the present disclosure;

[0024] Figure 2 A flowchart illustrating another protocol stack packet forwarding method in an embodiment of this disclosure is shown.

[0025] Figure 3 A flowchart illustrating another protocol stack packet forwarding method in an embodiment of this disclosure is shown.

[0026] Figure 4 A flowchart illustrating another protocol stack packet forwarding method in an embodiment of this disclosure is shown.

[0027] Figure 5This diagram illustrates a flowchart of yet another protocol stack message forwarding method in an embodiment of this disclosure;

[0028] Figure 6 This diagram illustrates the structure of a protocol stack message forwarding device according to an embodiment of the present disclosure.

[0029] Figure 7 This diagram illustrates the structure of another protocol stack message forwarding device in an embodiment of this disclosure.

[0030] Figure 8 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0032] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0033] As mentioned in the background section, existing neighbor subsystems query neighbor entries using the target IP address contained in the packet during packet processing. If the corresponding neighbor entry does not exist and the number of neighbor entries reaches the configured limit, the packet will be discarded because no neighbor entry can be found. In complex network environments, when the number of neighbor entries generated by network devices reaches the limit, control plane protocol packets will be discarded by the neighbor subsystem, causing service interruption.

[0034] Based on this, this disclosure provides a protocol stack packet forwarding method, apparatus, electronic device, and storage medium. Before the neighbor subsystem queries the neighbor table entry through the target IP address in the packet, it first determines whether the packet is a specific packet. If it is a specific packet, it directly determines the corresponding MAC address in the preset rule set based on the target IP address and mapping relationship of the packet. In this way, it not only ensures that these specific packets are not discarded by the neighbor subsystem, but also shortens the processing flow of these specific packets. At the same time, it can also reduce the number of neighbor table entries that need to be maintained in the neighbor cache and improve the performance of the protocol stack.

[0035] To facilitate understanding, the following is an explanation of several terms used in this disclosure:

[0036] In the control plane of network devices, services communicate with the outside world by sending and receiving messages through the protocol stack. The neighbor subsystem is embedded between the network layer and the data link layer of the protocol stack. The network layer uses logical addresses (IP), and the data link layer uses physical addresses (MAC). The neighbor subsystem's job is to translate between these two addresses. Furthermore, the neighbor subsystem provides a general external service interface for the network layer to call, and internally calls the output interface of the data link layer, enabling transparent transmission of messages between different layers.

[0037] A protocol stack refers to the sum of all layers of protocols in a network. It vividly reflects the data transmission process in a network: from upper-layer protocols to lower-layer protocols, and then from lower-layer protocols to upper-layer protocols.

[0038] Physically, the neighbor subsystem refers to terminals within the same local area network (LAN). From a network topology perspective, it refers to hosts separated by only one hop, belonging to the same collision domain. The neighbor subsystem's role is to provide address mapping between Layer 3 and Layer 2 protocols, and to provide neighbor header caching to speed up packet transmission. When sending data, the neighbor subsystem first performs a route lookup on the local machine. If a path to the destination address is found, it checks the ARP (Address Resolution Protocol) cache for a corresponding mapping. If not, a new neighbor entry is created. It then checks if the neighbor entry is available. If unavailable, the socket buffer (SKB) is added to the neighbor send queue, and an ARP request is sent. If an ARP reply is received, the corresponding neighbor entry is made available. If no reply packet is received within a specified time, the corresponding neighbor entry is made invalid. If the neighbor entry becomes available again, the data packets in the corresponding SKB queue are sent.

[0039] The neighbor table exists in the EIGRP (Enhanced Interval Gateway Route Protocol). The neighbor routers, along with the links (interfaces) on which each neighbor router is located, and other necessary information for maintaining the neighbor routers are recorded in the neighbor table.

[0040] Address Resolution Protocol (ARP) is a TCP / IP protocol that retrieves the physical address from the IP address. When a host sends information, it broadcasts an ARP request containing the target IP address to all hosts on the local area network and receives a response message to determine the target's physical address. After receiving the response message, the host stores the IP address and physical address in its local ARP cache for a certain period of time. Subsequent requests directly query the ARP cache to save resources. ARP relies on mutual trust among hosts on the network. Hosts on the local area network can independently send ARP reply messages. Other hosts receiving these reply messages do not verify their authenticity but simply record them in their local ARP cache. This allows attackers to send fake ARP reply messages to a host, causing the message to fail to reach the intended host or reach the wrong host, thus constituting ARP spoofing. ARP commands can be used to query the mapping between IP addresses and MAC addresses in the local ARP cache, add or delete static mappings, etc.

[0041] The following detailed description of this exemplary implementation method is provided in conjunction with the accompanying drawings and embodiments.

[0042] First, this disclosure provides a protocol stack message forwarding method, which can be executed by any electronic device with computing capabilities.

[0043] Figure 1 This diagram illustrates a flowchart of a protocol stack packet forwarding method according to an embodiment of the present disclosure, as follows: Figure 1 As shown, the protocol stack packet forwarding method provided in this embodiment includes the following steps:

[0044] S102, determine whether the message to be sent is a specific message. A specific message is a message that has a mapping relationship with the MAC address pre-stored in the preset rule set.

[0045] In this step, the neighbor subsystem provides an external service interface for collecting packets to be sent uploaded by the terminal. After receiving the packets to be sent collected by the external service interface, the neighbor subsystem determines whether the packet to be sent is a specific packet. It can check whether the destination IP address contained in the packet to be sent is the same as that in the specific packet. If the destination IP address is the same, the packet to be sent is a specific packet; otherwise, if the destination IP address is different, the packet to be sent is not a specific packet. A specific packet is a packet whose destination IP address meets certain conditions, such as a multicast IP address, a broadcast IP address, or a local IP address. Specific packets are pre-stored in a preset rule set. The preset rule set also stores the mapping relationship between the destination IP address and MAC address contained in the specific packet. The corresponding MAC address can be matched from the preset rule set according to the IP address and mapping relationship in the specific packet.

[0046] S104, If the message to be sent is a specific message, obtain the first MAC address corresponding to the destination IP address from the preset rule set according to the destination IP address contained in the message to be sent;

[0047] In this step, after determining that the packet to be sent is a specific packet, the neighbor subsystem obtains the first MAC address corresponding to the destination address from the preset rule set based on the destination IP address and mapping relationship contained in the packet. By using the mapping relationship of the destination IP address contained in the specific packet, the first MAC address can be directly obtained from the preset rule set. In this way, the specific packet can bypass the subsequent processing flow of the neighbor subsystem and directly obtain the MAC address from the preset rule set, thus slowing down the processing steps. At the same time, it avoids the problem of directly discarding specific packets when the number of neighbor table entries reaches the upper limit, as is the case in the prior art.

[0048] S106. If the message to be sent is not a specific message, then query the first neighbor table entry in the neighbor table based on the destination IP address contained in the message to be sent. If the query of the first neighbor table entry is successful, obtain the second MAC address corresponding to the destination IP address.

[0049] In this step, after the neighbor subsystem determines that the above-mentioned message to be sent is not a specific message, it queries the neighbor table to see if there is a corresponding neighbor table entry based on the destination IP address contained in the message to be sent. If a first neighbor table entry corresponding to the destination IP address is found, the second MAC address corresponding to the destination IP address is obtained from the first neighbor table entry.

[0050] S108: Based on the first MAC address or the second MAC address, call the data link layer interface to forward the message to be sent.

[0051] In this step, the neighbor subsystem can internally call the output interface of the data link layer to forward the message to be sent to the device with the first MAC address or the second MAC address.

[0052] The protocol stack packet forwarding method provided in this embodiment first determines whether the packet to be sent is a specific packet. If the packet is a specific packet, it obtains the first MAC address corresponding to the destination IP address from a preset rule set based on the destination IP address contained in the packet. If the packet is not a specific packet, it queries the first neighbor entry in the neighbor table based on the destination IP address contained in the packet. If the query is successful, it obtains the second MAC address corresponding to the destination IP address. Then, it calls the data link layer interface to forward the packet based on either the first or second MAC address. This ensures that these specific packets are not discarded by the neighbor subsystem, shortens the processing flow of these specific packets, reduces the number of neighbor entries that need to be maintained in the neighbor cache, and improves protocol stack performance.

[0053] In one embodiment of this disclosure, reference may be made to Figure 2 The steps shown complete the process of generating the above-mentioned preset rule set, as follows: Figure 2 The flowchart of another protocol stack message forwarding method shown may specifically include the following steps:

[0054] S202, Receive a specific message sent by the terminal. The specific message includes multicast messages, broadcast messages and messages sent to the local machine;

[0055] In this step, the terminal uploads specific messages to the neighboring subsystem through an external service interface. These specific messages can be multicast messages, broadcast messages, or messages destined for the local machine. Multicast messages are messages sent to specific recipients; broadcast messages are messages sent to all possible recipients on the network. In IPv4, each subnet has a local directed subnet broadcast address, which is formed by setting all host portions of the address to 1. The special address 255.255.255.255 corresponds to local network broadcast; messages destined for the local machine are messages whose destination IP address is the same as the local machine's IP address.

[0056] S204, According to the Address Resolution Protocol, determine the mapping relationship between the destination IP address and MAC address contained in a specific message;

[0057] In this step, the Address Resolution Protocol (ARP) can obtain the MAC address based on the destination IP address contained in a specific message. The process involves the host needing to obtain the physical address broadcasting an ARP request containing the target IP address to all hosts on the local network. If a host finds that the target IP address in the ARP request does not match its own IP address, it discards the ARP request. If the host's IP address matches the destination IP address in the ARP request, it directly returns an ARP reply message containing the MAC address to the host needing to obtain the physical address. The host receiving the ARP reply message obtains the destination host's MAC address from it. After obtaining the MAC address, the mapping relationship between the destination IP address and the MAC address is then determined.

[0058] S206 stores the mapping relationship between the destination IP address and MAC address contained in a specific message in a preset rule set, and generates a preset rule set.

[0059] In this step, the mapping relationship between the destination IP address and MAC address contained in all specific packets is stored in a preset rule set, and a preset rule set is generated so that when it is determined that the packet to be sent is a specific packet, the MAC address can be directly obtained from the preset rule set to determine the target host to which the packet needs to be sent. This simplifies the processing flow of specific packets and improves the forwarding efficiency of the packets to be sent.

[0060] In one embodiment of this disclosure, the preset rule set also stores the mapping relationship between user-defined IP addresses and MAC addresses. Besides storing the mapping relationship between destination IP addresses and MAC addresses in specific packets, the preset rule set can also store the mapping relationship between user-defined IP addresses and MAC addresses. When it is determined that the IP address in the packet to be sent is the same as the user-defined IP address, the corresponding MAC address can be directly obtained from the preset rule set, making the application of the preset rule set more flexible and efficient.

[0061] In one embodiment of this disclosure, a preset rule set is stored in memory. This makes it faster and more efficient for the neighbor subsystem to look up the MAC address corresponding to the destination IP address from the preset rule set.

[0062] In one embodiment of this disclosure, after querying the first neighbor entry in the neighbor table based on the destination IP address, it may further include... Figure 3 For the steps to create a second neighbor entry, see [link to documentation]. Figure 3 The flowchart of another protocol stack message forwarding method shown may specifically include the following steps:

[0063] S302, if the query for the first neighbor table fails, determine whether the number of neighbor table entries in the current neighbor table is less than the preset number;

[0064] In this step, if no corresponding first neighbor table entry is found in the neighbor table based on the destination IP address of the message to be sent, the system continues to determine whether the number of neighbor table entries in the neighbor table has reached the upper limit. To improve the accuracy of the determination, a preset number can be set to represent the upper limit. This preset number can be the maximum number of neighbor table entries stored in the neighbor table.

[0065] S304, If the number of neighbor entries is greater than or equal to the preset number, discard the message to be sent;

[0066] In this step, when the number of neighbor entries is greater than or equal to the preset number, it means that the number of neighbor entries in the neighbor table has reached the limit and no more new neighbor entries can be created. Therefore, the message to be sent is discarded.

[0067] S306. If the number of neighbor entries is less than the preset number, then create a second neighbor entry in the neighbor table.

[0068] In this step, when the number of neighbor entries is less than the preset number, it means that the number of neighbor entries in the neighbor table has not yet reached the upper limit, and a second neighbor entry corresponding to the message to be sent can be created.

[0069] In one embodiment of this disclosure, after creating the second neighbor table entry in the neighbor table, the process may further include... Figure 4 For the steps of obtaining the third MAC address and forwarding the packet to be sent based on the third MAC address, please refer to [link to documentation]. Figure 4 Another protocol stack message forwarding method shown may specifically include the following steps:

[0070] S402, Update the third MAC address of the second neighbor entry based on the destination IP address and the address resolution protocol;

[0071] In this step, based on the destination IP address and the Address Resolution Protocol (ARP), a third MAC address matching the IP address is determined, and the MAC address in the second neighbor table entry is updated to the third MAC address.

[0072] S404, based on the third MAC address, calls the data link layer interface to forward the message to be sent.

[0073] In this step, after obtaining the physical address of the destination host to which the message to be sent is to be sent, the data link layer output interface forwards the message to be sent to the destination host based on the physical address of the destination host, which is also the third MAC address.

[0074] In one embodiment of this disclosure, another protocol stack message forwarding method is also provided, see [link to relevant documentation]. Figure 5 The flowchart shown represents another protocol stack message forwarding method, which may include the following steps:

[0075] Step 1: Determine if the message to be sent is a specific message. If it is a specific message, proceed to Step 2; otherwise, proceed to Step 3.

[0076] Step 2: Based on the destination IP address in the message to be sent, obtain the MAC address that has a mapping relationship with the destination IP address from the preset rule set, and continue to execute Step 7;

[0077] Step 3: Search the neighbor table for the first neighbor entry that corresponds to the destination IP address contained in the message to be sent. If the search is successful, proceed to step 4; otherwise, proceed to step 5.

[0078] Step 4: Directly obtain the MAC address corresponding to the destination IP address from the first neighbor table entry, and continue to step 7;

[0079] Step 5: Continue to check if the number of neighbor entries in the neighbor table has reached the upper limit. If so, discard the message to be sent directly; otherwise, proceed to step 6.

[0080] Step 6: Create a second neighbor entry, update the MAC address of the second neighbor entry according to the Address Resolution Protocol and the destination IP address in the packet to be sent, and continue to step 7;

[0081] Step 7: Call the data link layer interface to forward the message.

[0082] The protocol stack packet forwarding method in this embodiment solves the same technical problem as the protocol stack packet forwarding method in the above embodiments, and achieves the same technical effect, so it will not be described in detail here.

[0083] Based on the same inventive concept, this disclosure also provides a protocol stack message forwarding device, as shown in the following embodiment. Since the principle by which this device embodiment solves the problem is similar to that of the above method embodiment, the implementation of this device embodiment can refer to the implementation of the above method embodiment, and repeated details will not be elaborated further.

[0084] Figure 6 This diagram illustrates the structure of a protocol stack packet forwarding device according to an embodiment of the present disclosure, as shown below. Figure 6 As shown, the device includes:

[0085] The message to be sent judgment module 610 is used to determine whether the message to be sent is a specific message. A specific message is a message that has a mapping relationship with a MAC address pre-stored in a preset rule set.

[0086] The first address acquisition module 620 is used to obtain the first MAC address corresponding to the destination IP address from a preset rule set if the message to be sent is a specific message.

[0087] The second address acquisition module 630 is used to, if the packet to be sent is not a specific packet, query the first neighbor table entry in the neighbor table based on the destination IP address contained in the packet to be sent; and if the query of the first neighbor table entry is successful, obtain the second MAC address corresponding to the destination IP address; and

[0088] The message forwarding module 640 is used to forward messages to be sent by calling the data link layer interface based on the first MAC address or the second MAC address.

[0089] In one embodiment of this disclosure, the above-described apparatus may further include a neighbor entry creation module, which is used to determine whether the number of neighbor entries in the current neighbor table is less than a preset number when the first neighbor entry query fails; if the number of neighbor entries is greater than or equal to the preset number, the message to be sent is discarded; if the number of neighbor entries is less than the preset number, a second neighbor entry is created in the neighbor table.

[0090] In one embodiment of this disclosure, see Figure 7 The diagram shows another protocol stack message forwarding method. The above device may also include a third address update module.

[0091] The third address update module 650 is used to update the third MAC address of the second neighbor table entry based on the destination IP address and address resolution protocol.

[0092] In one embodiment of this disclosure, the message forwarding module 640 is further configured to call a data link layer interface to forward the message to be sent based on a third MAC address.

[0093] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0094] The following reference Figure 8 To describe an electronic device 800 according to such an embodiment of the present disclosure. Figure 8 The electronic device 800 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0095] like Figure 8As shown, the electronic device 800 is manifested in the form of a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including storage unit 820 and processing unit 810).

[0096] The storage unit stores program code, which can be executed by the processing unit 810, causing the processing unit 810 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 810 can perform the following steps of the above method embodiment: determining whether the message to be sent is a specific message, wherein the specific message is a message that has a mapping relationship with MAC addresses pre-stored in a preset rule set; if the message to be sent is a specific message, obtaining a first MAC address corresponding to the destination IP address from the preset rule set based on the destination IP address contained in the message to be sent; if the message to be sent is not a specific message, querying a first neighbor entry in the neighbor table based on the destination IP address contained in the message to be sent, and obtaining a second MAC address corresponding to the destination IP address if the query of the first neighbor entry is successful; and forwarding the message to be sent by calling the data link layer interface based on the first MAC address or the second MAC address.

[0097] In some embodiments, in the electronic device provided in this disclosure, the processing unit 810 is further configured to: receive a specific message sent by a terminal, the specific message including multicast messages, broadcast messages, and messages sent to the local machine; determine the mapping relationship between the destination IP address and MAC address contained in the specific message according to the address resolution protocol; and store the mapping relationship between the destination IP address and MAC address contained in the specific message in a preset rule set to generate a preset rule set. The preset rule set also stores the mapping relationship between user-issued custom IP addresses and MAC addresses, and the preset rule set is stored in memory.

[0098] In some embodiments of the electronic device provided in this disclosure, the processing unit 810 is further configured to: determine whether the number of neighbor entries in the current neighbor table is less than a preset number if the query for the first neighbor entry fails; if the number of neighbor entries is greater than or equal to the preset number, discard the message to be sent; if the number of neighbor entries is less than the preset number, create a second neighbor entry in the neighbor table.

[0099] In some embodiments of the electronic device provided in this disclosure, the processing unit 810 is further configured to: update the third MAC address of the second neighbor entry according to the destination IP address and the address resolution protocol; and call the data link layer interface to forward the message to be sent according to the third MAC address.

[0100] Storage unit 820 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 8201 and / or cache memory 8202, and may further include a read-only memory (ROM) 8203.

[0101] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0102] Bus 830 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0103] Electronic device 800 can also communicate with one or more external devices 840 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 800, and / or with any device that enables electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. As shown, network adapter 860 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0104] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0105] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the methods described above is stored thereon. In some possible implementations, various aspects of this disclosure may also be implemented as a program product including program code, which, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.

[0106] More specific examples of computer-readable storage media in this disclosure may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0107] In this disclosure, a computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution system, apparatus, or device.

[0108] Optionally, the program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0109] In practical implementation, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0110] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0111] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0112] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure. For example, when a computer program stored on a computer-readable storage medium in an embodiment of this disclosure is executed by a processor, the following steps of the following method can be implemented: determining whether the message to be sent is a specific message, wherein a specific message is a message that has a mapping relationship with a MAC address pre-stored in a preset rule set; if the message to be sent is a specific message, obtaining a first MAC address corresponding to the destination IP address from the preset rule set based on the destination IP address contained in the message to be sent; if the message to be sent is not a specific message, querying a first neighbor entry in the neighbor table based on the destination IP address contained in the message to be sent, and obtaining a second MAC address corresponding to the destination IP address if the query of the first neighbor entry is successful; and forwarding the message to be sent by calling a data link layer interface based on the first MAC address or the second MAC address.

[0113] In some embodiments of this disclosure, when a computer program stored on a computer-readable storage medium is executed by a processor, it can further implement the following steps of the following method: receiving a specific message sent by a terminal, the specific message including multicast messages, broadcast messages, and messages sent to the local machine; determining the mapping relationship between the destination IP address and MAC address contained in the specific message according to an address resolution protocol; storing the mapping relationship between the destination IP address and MAC address contained in the specific message in a preset rule set, thereby generating a preset rule set. The preset rule set also stores the mapping relationship between user-defined IP addresses and MAC addresses, and the preset rule set is stored in memory.

[0114] In some embodiments of the present disclosure, when a computer program stored on a computer-readable storage medium is executed by a processor, the following steps of the following method can also be implemented: if the query for the first neighbor entry fails, determine whether the number of neighbor entries in the current neighbor table is less than a preset number; if the number of neighbor entries is greater than or equal to the preset number, discard the message to be sent; if the number of neighbor entries is less than the preset number, create a second neighbor entry in the neighbor table.

[0115] In some embodiments of this disclosure, when a computer program stored on a computer-readable storage medium is executed by a processor, it may also implement the following steps of the following method: updating the third MAC address of the second neighbor entry according to the destination IP address and the address resolution protocol; and forwarding the packet to be sent by calling the data link layer interface according to the third MAC address.

[0116] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A protocol stack message forwarding method, characterized in that, Applied to a neighbor subsystem, which is embedded between the network layer and data link layer of the protocol stack, including: Determine whether the message to be sent is a specific message. The specific message includes multicast messages, broadcast messages, and messages sent to the local machine. The specific message is a message that has a mapping relationship with MAC addresses pre-stored in a preset rule set. The preset rule set stores the mapping relationship between the destination IP address and MAC address contained in the specific message. If the message to be sent is a specific message, the first MAC address corresponding to the destination IP address is obtained from the preset rule set according to the destination IP address contained in the message to be sent; If the message to be sent is not a specific message, then the first neighbor table entry in the neighbor table is queried based on the destination IP address contained in the message to be sent. If the query of the first neighbor table entry is successful, the second MAC address corresponding to the destination IP address is obtained. Based on the first MAC address or the second MAC address, the data link layer interface is invoked to forward the message to be sent.

2. The protocol stack message forwarding method according to claim 1, characterized in that, The method further includes: The specific message sent by the receiving terminal; According to the Address Resolution Protocol, the mapping relationship between the destination IP address and MAC address contained in the specific message is determined; The mapping relationship between the destination IP address and MAC address contained in the specific message is stored in the preset rule set to generate the preset rule set.

3. The protocol stack message forwarding method according to claim 2, characterized in that, The preset rule set also stores the mapping relationship between user-issued custom IP addresses and MAC addresses.

4. The protocol stack message forwarding method according to claim 1, characterized in that, The preset rule set is stored in memory.

5. The protocol stack message forwarding method according to claim 1, characterized in that, The step of querying the first neighbor entry in the neighbor table based on the destination IP address includes: If the query for the first neighbor table entry fails, determine whether the number of neighbor entries in the current neighbor table is less than a preset number; If the number of neighbor entries is greater than or equal to a preset number, the message to be sent is discarded. If the number of neighbor entries is less than the preset number, a second neighbor entry is created in the neighbor table.

6. The protocol stack message forwarding method according to claim 5, characterized in that, After creating a second neighbor table entry in the neighbor table, the method further includes: Update the third MAC address of the second neighbor table entry according to the destination IP address and address resolution protocol; Based on the third MAC address, the data link layer interface is invoked to forward the message to be sent.

7. A protocol stack message forwarding device, characterized in that, Applied to a neighbor subsystem, which is embedded between the network layer and data link layer of the protocol stack, including: The message to be sent judgment module is used to determine whether the message to be sent is a specific message. The specific message includes multicast messages, broadcast messages and messages sent to the local machine. The specific message is a message that has a mapping relationship with MAC addresses pre-stored in a preset rule set. The preset rule set stores the mapping relationship between the destination IP address and MAC address contained in the specific message. The first address acquisition module is used to, if the message to be sent is a specific message, acquire the first MAC address corresponding to the destination IP address from the preset rule set according to the destination IP address contained in the message to be sent; The second address acquisition module is used to, if the packet to be sent is not a specific packet, query the first neighbor table entry in the neighbor table based on the destination IP address contained in the packet to be sent, and if the query of the first neighbor table entry is successful, obtain the second MAC address corresponding to the destination IP address; and The message forwarding module is used to forward the message to be sent by calling the data link layer interface according to the first MAC address or the second MAC address.

8. The protocol stack message forwarding device according to claim 7, characterized in that, The device also includes a neighbor entry creation module; The neighbor entry creation module is used to determine whether the number of neighbor entries in the current neighbor table is less than a preset number when the first neighbor entry query fails. If the number of neighbor entries is greater than or equal to a preset number, the message to be sent is discarded. If the number of neighbor entries is less than the preset number, a second neighbor entry is created in the neighbor table.

9. The protocol stack message forwarding device according to claim 8, characterized in that, The device also includes a third address update module; The third address update module is used to update the third MAC address of the second neighbor table entry according to the destination IP address and the address resolution protocol; The message forwarding module is also used to forward the message to be sent by calling the data link layer interface according to the third MAC address.

10. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the protocol stack message forwarding method of any one of claims 1 to 6 by executing the executable instructions.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the protocol stack message forwarding method according to any one of claims 1 to 6.