Inter-board communication method, network device and electronic device

By using a zero-copy approach for message sending and receiving and fragment reassembly in user space, the copying problem between user space and kernel space is solved, enabling more efficient inter-board communication and reducing the consumption of CPU resources and memory bandwidth.

CN118819893BActive Publication Date: 2025-11-07NEW H3C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410853244.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2025-11-07
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

In existing technologies, communication between the main control board and the service board requires message copying between user mode and kernel mode, resulting in significant overhead in CPU resources and memory bandwidth.

Method used

Inter-board communication is performed using a zero-copy approach. By sending, receiving, and reassembling messages in user space, copying between kernel space and user space is avoided. Shared memory and forwarding processes are used for message transmission and fragmentation.

Benefits of technology

This reduces copy operations between kernel mode and user mode, lowers CPU resource and memory bandwidth consumption, and improves communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819893B_ABST
    Figure CN118819893B_ABST
Patent Text Reader

Abstract

The application provides an inter-board communication method, a network device and an electronic device. The inter-board communication in the application does not depend on a socket mechanism, but places message receiving and sending, message fragmentation and fragment recombination in a user state. In the user state, zero-copy can be used for inter-board communication, without the need for copy actions between a kernel state and the user state, thereby reducing CPU resource and memory bandwidth consumption caused by copy actions between the kernel state and the user state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to network communication, and more particularly to inter-board communication methods, network devices, and electronic devices. Background Technology

[0002] In network devices such as chassis-based devices (e.g., base stations), the main control board and the service boards communicate using a socket communication mechanism based on the TCP / IP protocol. This socket communication mechanism requires pre-assigning IP addresses to the communication ports of the main control board and the service boards, and assigning different port numbers to different processes and service modules.

[0003] like Figure 1 As shown, one of the main control board and the service board acts as the sender, and the other as the receiver. The service process in the sender is in user mode, while the socket process, which operates in kernel mode, copies the message from user mode to kernel mode and specifies the receiver's IP address and port number before writing the message to the socket's buffer. The forwarding process in the receiver reads the socket's buffer and copies any necessary messages from kernel mode to user mode. Ultimately, the receiver receives the message written to the socket and obtains the sender's IP address and port number.

[0004] However, both writing messages to and reading messages from the socket buffer require a message copy between user mode and kernel mode. This copy operation increases CPU resource and memory bandwidth overhead, and the larger the amount of data being copied, the greater the overhead. Summary of the Invention

[0005] This application provides inter-board communication methods, network devices, and electronic devices to avoid message copying between user mode and kernel mode during inter-board communication.

[0006] This application provides an inter-board communication method applied to a network device, the network device including a main control board and an interface board; service processes and forwarding processes belonging to the same CPU on the same main control board or interface board are associated with the same shared memory; a designated storage area of ​​the shared memory is divided and correspondingly allocated to each service process; the method includes:

[0007] The forwarding process receives a communication indication sent by a first service process having a data sending requirement; the communication indication is sent by the first service process after putting a message start address into a queue of the shared memory, and a storage area where the queue is located is different from the designated storage area; the message is stored into a storage area allocated to the first service process, and the message start address refers to a start address of the message to be sent in the storage area;

[0008] The forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated to the first service process by using the message start address;

[0009] The forwarding process fragments the message in sequence to obtain at least two fragments when the message meets the fragmentation requirement, and sends each fragment to form a corresponding Ethernet packet in a user mode; or the forwarding process sends the message to form a corresponding Ethernet packet in the user mode when the message does not meet the fragmentation requirement.

[0010] Embodiments of the present application provide a board-to-board communication method, which is applied to a network device, the network device comprising a master board and an interface board; each service process and a forwarding process belonging to a same CPU on a same master board or interface board are associated with a same shared memory; a designated storage area of the shared memory is divided and allocated to the service processes; the method comprises the following steps:

[0011] The forwarding process polls a local Ethernet port used for board-to-board communication to obtain an Ethernet packet;

[0012] The forwarding process finds a target Bucket from local Buckets for storing the Ethernet packet;

[0013] The forwarding process determines a target fragment table entry from the target Bucket;

[0014] The forwarding process records fragment data carried by the Ethernet packet in the target fragment table entry, and when it is determined that the recorded fragment data in the target fragment table entry is all fragment data of a same message, recombines all fragment data of the message to obtain a target packet, and writes the target packet into a storage area allocated to a target service process according to a destination address of the fragment data, puts a start address of the target packet in the storage area into a queue of the shared memory, and notifies the target service process to obtain the target packet from the storage area allocated to the target service process based on the start address in the queue.

[0015] The embodiment of the present application further provides a network device, the network device comprising a master board and an interface board; each service process and a forwarding process belonging to a same CPU on the same master board or interface board are associated with a same shared memory; a specified storage area of the shared memory is divided and correspondingly allocated to the service processes;

[0016] The forwarding process receives a communication indication sent by a first service process having a data sending requirement; the communication indication is sent by the first service process after a message start address is put into a queue of the shared memory, and a storage area where the queue is located is different from the specified storage area; the message is stored into a storage area allocated to the first service process, and the message start address refers to a start address of the message to be sent in the storage area;

[0017] The forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated to the first service process by using the message start address;

[0018] The forwarding process fragments the message according to an order when the message meets a fragmentation requirement, obtains at least two fragments, and sends each fragment in a user state to form a corresponding Ethernet message; the forwarding process organizes the message into a corresponding Ethernet message in a user state and sends the Ethernet message when the message does not meet the fragmentation requirement.

[0019] The embodiment of the present application further provides a network device, the network device comprising a master board and an interface board; each service process and a forwarding process belonging to a same CPU on the same master board or interface board are associated with a same shared memory; a specified storage area of the shared memory is divided and correspondingly allocated to the service processes;

[0020] The forwarding process polls a local Ethernet port used for inter-board communication to obtain an Ethernet message; the forwarding process finds a target Bucket from local Buckets for storing the Ethernet message; the forwarding process determines a target fragment table entry from the target Bucket; the forwarding process records fragment data carried by the Ethernet message in the target fragment table entry, and when it is determined that the fragment data recorded in the target fragment table entry is all fragment data of a same message, recombines all fragment data of the message to obtain a target message, writes the target message into a storage area allocated to a target service process corresponding to a destination address of the fragment data according to the destination address, puts a start address of the target message in the storage area into a queue of the shared memory, and notifies the target service process to obtain the target message from the storage area allocated to the target service process based on the start address in the queue.

[0021] The embodiment of the present application further provides an electronic device. The electronic device comprises a processor and a machine readable storage medium;

[0022] The machine readable storage medium stores machine executable instructions capable of being executed by the processor;

[0023] The processor is used to execute the machine executable instructions to realize the steps of the disclosed method.

[0024] From the above technical solution, it can be seen that the inter-board communication in the present application does not depend on the socket mechanism, but puts the message receiving and sending, message fragmentation and fragment recombination in the user mode. In the user mode, the zero-copy mode can be used for the inter-board communication, without the copy action between the kernel mode and the user mode, so that the CPU resource and the memory bandwidth consumption caused by the copy action between the kernel mode and the user mode are reduced. BRIEF DESCRIPTION OF DRAWINGS

[0025] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0026] Figure 1 It is a structural diagram of the existing inter-board communication;

[0027] Figure 2 It is a method flowchart provided by the embodiment of the present application;

[0028] Figure 3 It is a structural diagram of the inter-board communication provided by the embodiment of the present application;

[0029] Figure 4 It is a structural diagram of the message provided by the embodiment of the present application;

[0030] Figure 5 It is a fragment structure diagram provided by the embodiment of the present application;

[0031] Figure 6 It is a diagram showing the relationship between the fragment and the cache pair provided by the embodiment of the present application;

[0032] Figure 7 It is an Ethernet message structure diagram provided by the embodiment of the present application;

[0033] Figure 8 It is another method flowchart provided by the embodiment of the present application;

[0034] Figure 9 It is a structural diagram of the forwarding process local bucket provided by the embodiment of the present application;

[0035] Figure 10A structure diagram of a slice table item provided by an embodiment of the present application is shown in the following table.

[0036] Figure 11 A structure diagram of a target message provided by an embodiment of the present application is shown in the following table.

[0037] Figure 12 An electronic device structure diagram provided by an embodiment of the present application is shown in the following table. DETAILED DESCRIPTION

[0038] Unlike the traditional communication mechanism, the inter-board communication in the present application does not rely on the socket mechanism, but places the sending and receiving of messages, the slicing of messages, and the reassembly of slices in the user mode. In the user mode, the inter-board communication can be performed in the zero-copy mode, without the need for copying actions between the kernel mode and the user mode, thereby reducing the CPU resource and memory bandwidth consumption caused by the copying actions between the kernel mode and the user mode.

[0039] In order for those skilled in the art to better understand the technical solutions provided by the embodiments of the present application, and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more apparent and easy to understand, the technical solutions in the embodiments of the present application are further described in detail below with reference to the drawings.

[0040] Referring to Figure 2 , Figure 2 A method flowchart provided by an embodiment of the present application is shown in the following table. The method is applied to a network device such as a base station.

[0041] In the present embodiment, the network device includes a master board and an interface board; each service process and forwarding process belonging to the same CPU on the same master board or interface board is associated with the same memory (which can be a physical memory, referred to as a shared memory). Figure 3 An example is shown in the following table to illustrate the service process 1 and the service process 2, and the forwarding process. Among them, the service process 1 and the service process 2, and the forwarding process are all in the user mode.

[0042] In the present embodiment, a certain storage space (referred to as a designated storage area) in the shared memory associated with each service process belonging to the same CPU is pre-divided into different storage areas, so as to allocate a storage area as a message memory pool for each service process. In addition, the shared memory also has an area (referred to as a queue area) for storing a message queue, which is independent of the divided storage areas. The message queue will be described in detail below, and will not be described here.

[0043] Based on the above description, as shown in the following table, the flowchart can include the following steps: Figure 2

[0044] Step 201, the forwarding process receives a communication indication sent by a first service process having a data sending requirement.​

[0045] The first service process is named for convenience of description, and is not intended to limit.

[0046] In the embodiment, when the first service process has data to send, it first applies for a memory pool from the allocated message memory pool, and organizes the data to be sent into a message to be sent and fills it into the memory pool. Then, the start address of the message in the memory pool is written into the message queue (also called enqueued), and a communication indication is sent to the forwarding process to inform the forwarding process that there is a message to be sent. Finally, the forwarding process receives the communication indication.

[0047] In the embodiment, as shown in Figure 4 The message includes a message header and a message payload.

[0048] Optionally, the message header includes at least a destination address (dst_addr), a source address (src_addr), a message length (msg_len), and a message sequence ID (msg_id). As an embodiment, for convenience of data management, the message payload is located directly in the memory pool, and the message header can further include a start address of the message payload (msg_addr). As shown in Figure 4

[0049] Here, the destination address is the address of the second service process, the source address is the address of the first service process, and the first service process and the second service process are service processes supported by different boards or different CPUs; the message sequence ID is assigned according to a message sequence identification assignment principle, for example, each time a message is received, a set value such as 1 is added, and so on.

[0050] In the embodiment, the source address and the destination address have similar structures, and are generally represented by chassis, slot, CPU, and module.

[0051] Taking the destination address as an example, the chassis, slot, CPU, and module together represent the second service process. Among them, chassis represents the number of the frame where the second service process is located, slot represents the slot number of the board where the second service process is located, CPU represents the CPU to which the second service process belongs, and module represents the identification of the second service process. The source address is similar, and will not be described here.

[0052] In step 202, the forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated by the first service process using the message start address. ​

[0053] Step 203, the forwarding process fragments the message according to the order to obtain at least two fragments when the message meets the fragmentation requirement, and sends each fragment to the user state as a corresponding Ethernet packet; when the message does not meet the fragmentation requirement, the message is organized into a corresponding Ethernet packet in the user state and sent.

[0054] Here, the message meets the fragmentation requirement refers to that the length of the message is greater than the set maximum length, and it is determined that the message meets the fragmentation requirement; wherein the set maximum length is the difference between the maximum transmission unit (MTU) supported by the Ethernet card and the set fragmentation header length.

[0055] If the MTU of the Ethernet card is 1500 Bytes, then the set maximum length is the difference between 1500 Bytes and the set fragmentation header length. If the length of the message exceeds the set maximum length, it is considered that the message meets the fragmentation requirement, and if it does not exceed, it is considered that the message does not meet the fragmentation requirement.

[0056] In this embodiment, the message (including message header and message payload) is fragmented according to the set maximum length when the message meets the fragmentation requirement, and a plurality of different fragments are obtained. Figure 5 For example, it is divided into three fragments (frag_0, frag_1, frag_2).

[0057] In this embodiment, after the fragmentation is completed, in order to realize zero-copy when the forwarding process sends the fragments, the forwarding process will apply for an associated cache pair in the local cache for each fragment. Wherein the cache pair includes the following two caches (rte_mbuf): the first cache and the second cache. Here, the first cache is used to record the associated fragment corresponding to the Ethernet header (ether header) and the fragmentation header (scatter header). The second cache only has the rte_mbuf header, which points to the associated fragment and records at least the fragment length and the fragment start address of the associated fragment. Here, the start address of the fragment is the start address of the message plus the fragment offset of the fragment in the message. Figure 6 For example, the relationship between the fragment and the associated cache pair is shown.

[0058] Optionally, the forwarding process reads and splices the Ethernet header (ether header) and the fragmentation header (scatter header) recorded in the first cache of the cache pair associated with the fragment, and the fragment read based on the fragment start address and the fragment length recorded in the first cache, to organize a complete Ethernet packet and send it out from the Ethernet port.

[0059] In the embodiment, the fragment header at least includes: destination address, source address, fragment offset, packet length, packet sequence number, fragment continuation flag.

[0060] The destination address and the source address are similar to the destination address and the source address in the message header respectively. The fragment offset represents the offset of the current fragment in the message. The packet length is the sum of the fragment length and the length of the fragment header. The fragment length of the last fragment is the difference between the total length of the message and the offset of the current fragment in the message, and the fragment length of the rest fragments is the set maximum length. The packet sequence number is used to identify the sending of a message, and the packet sequence numbers in the fragment headers of all fragments in the same message are the same. The fragment continuation flag indicates that the current fragment is not the last fragment.

[0061] In the embodiment, the forwarding process organizes the fragments into a corresponding Ethernet packet and sends them in order when the sending time or other sending occasions arrive, based on the cache pair associated with each fragment. Any fragment is read based on the fragment length and the fragment start address recorded by the first cache in the cache pair associated with the fragment. The Ethernet packet corresponding to any fragment is obtained by combining the fragment with the Ethernet header and the fragment header recorded by the second cache in the cache pair associated with the fragment.

[0062] In the embodiment, the forwarding process uses the DPDK (Data Plane Development Kit) mechanism to combine each fragment with the Ethernet header and the fragment header recorded by the second cache associated with the fragment, based on the records of the two caches (the first cache and the second cache) in the cache pair associated with the same fragment, to obtain the Ethernet packet and send it. Figure 5 As shown in the fragments, the finally sent Ethernet packet is as shown in Figure 7 .

[0063] As can be seen, in the embodiment, the forwarding process does not need to copy the message when fragmenting, which can effectively improve the performance and save the memory bandwidth advantage.

[0064] The above describes the method flowchart provided by the embodiment of the application from the perspective of packet sending. The following describes the method flowchart provided by the embodiment of the application from the perspective of packet receiving:

[0065] Referring to Figure 8 , Figure 8 for another method flowchart provided by the embodiment of the application. As shown in Figure 8 , the flowchart can include the following steps:

[0066] Step 801: The forwarding process polls the local Ethernet port used for inter-board communication to obtain an Ethernet packet.

[0067] Step 802, the forwarding process finds a target Bucket from a local data Bucket for storing the Ethernet message.

[0068] In the embodiment, any forwarding process has a fragment table locally, which contains n Buckets, and each Bucket contains m fragment table entries, and n and m are both integer powers of 2. A schematic diagram of the n Buckets and m entries is shown in FIG. 1. Figure 9

[0069] In the embodiment, the target Bucket matching the source address, the destination address and the packet sequence number in the fragment header carried by the Ethernet message can be found from the local Bucket. For example, Hash operation is performed on the source address, the destination address and the packet sequence number in the fragment header to obtain a Hash value, and the Bucket numbered as the Hash value is taken as the target Bucket. The number of each Bucket can be set according to actual requirements, for example, starting from 0.

[0070] Step 803, the forwarding process records the fragment data to be reassembled carried by the Ethernet message in the target fragment table entry, and when it is determined that the fragment data recorded in the target fragment table entry is all the fragment data of the same message, reassembles all the fragment data of the message to obtain a target message, writes the target message into a storage area allocated to a target service process corresponding to the destination address according to the destination address of the fragment data, puts the start address of the target message in the storage area into a queue in a shared memory, and notifies the target service process to acquire the target message from the storage area allocated to the target service process based on the start address in the queue.

[0071] In the embodiment, the forwarding process determining the target fragment table entry from the target Bucket can include: checking whether there is a fragment table entry with a key matching the key information in the fragment header carried by the Ethernet message in the target Bucket, if yes, taking the fragment table entry as the target fragment table entry, and if no, taking an idle fragment table entry or a fragment table entry that has been used and meets the release requirement in the target Bucket as the target fragment table entry; the key information at least includes at least one of the source address, the destination address and the packet sequence number.

[0072] In the embodiment, after taking an idle fragment table entry or a fragment table entry that has been used and meets the release requirement in the target Bucket as the target fragment table entry, the Start time in the target fragment table entry can be updated to the current time.

[0073] ​In the embodiment, the fragment table entry that has been used and meets the release requirement refers to a fragment table entry whose time difference between the Start time and the current time is greater than the set time threshold.

[0074] Optionally, in the embodiment, the fragment data to be reassembled carried by the Ethernet message is the remaining data after the Ethernet header of the Ethernet message is stripped off; the remaining data is composed of a fragment header and a fragment.

[0075] In the embodiment, the determining, by the forwarding process, the target fragment table entry from the target Bucket further includes updating a fragment size (frag_size) recorded by the target fragment table entry; the frag_size is used to record the sum of lengths of the fragments belonging to the message that have been received.

[0076] In addition, the determining that the fragment data recorded by the target fragment table entry is all the fragment data of the same message includes: when the fragment carried by the Ethernet message is the last fragment of the message (determined based on a fragment continuation flag carried by the fragment header), updating a total size (total_size) recorded by the target fragment table entry; the total_size is the sum of a fragment length and a fragment offset; the fragment length is determined based on a difference between a packet length in the fragment header carried by the Ethernet message and a length of the set fragment header; the fragment offset is the fragment offset in the fragment header; and then checking whether the total_size matches (such as, is consistent with) the frag_size, and if so, reassembling all the fragment data of the message that have been received to obtain the target message.

[0077] Based on the above, Figure 9 Figure 10 An example is shown to illustrate the structure of each entry.

[0078] As Figure 10 shown, in the embodiment, each entry further includes a cache identifier, and a cache area associated with the cache identifier is used to store the fragment data to be reassembled of the same message as described above. Based on this, the reassembling all the fragment data of the message that have been received to obtain the target message includes concatenating all the fragment data of the message that have been received in sequence (such as, the order of the fragments in the message, i.e., the offset) to obtain the target message. Figure 11 An example is shown to illustrate the structure of the target message.

[0079] In the embodiment, the first fragment data of the message that have been received includes a message header, and the message header carries a destination address; correspondingly, the destination address of the fragment data is the destination address carried by the message header.

[0080] Thus, the flow shown in Figure 8 is completed.​

[0081] The method provided by the embodiment of the application is described above, and the device provided by the embodiment of the application is described below.

[0082] The embodiment provides a network device, as shown in the figure, the network device comprises a main control board and an interface board; each service process and a forwarding process belonging to the same CPU on the same main control board or interface board are associated with the same shared memory; a specified storage area of the shared memory is divided and correspondingly allocated to the service processes; Figure 3

[0083] The forwarding process receives a communication indication sent by a first service process having a data sending requirement; the communication indication is sent by the first service process after a message start address is put into a queue of the shared memory, and a storage area where the queue is located is different from the specified storage area; the message is stored to a storage area allocated to the first service process, and the message start address refers to a start address of the message to be sent in the storage area;

[0084] The forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated to the first service process by using the message start address;

[0085] The forwarding process fragments the message according to an order when the message meets a fragmentation requirement, obtains at least two fragments, and sends each fragment in a user state to form a corresponding Ethernet message; the forwarding process sends the message in a user state to form a corresponding Ethernet message when the message does not meet the fragmentation requirement.

[0086] Optionally, the message comprises a message header and a message payload.

[0087] The message header comprises at least a destination address, a source address, a message length, and a message sequence ID; the destination address is an address of a second service process, the source address is an address of a first service process, the first service process and the second service process are located on different boards, and the message sequence ID is assigned according to a message sequence identification assignment principle.

[0088] The message payload carries data required to be sent to meet the data sending requirement.

[0089] Optionally, the message meets the fragmentation requirement refers to that a length of the message is greater than a set maximum length, and it is determined that the message meets the fragmentation requirement; the set maximum length is a difference between a maximum transmission unit MTU supported by an Ethernet network card and a set fragmentation header length.

[0090] ​Optionally, the sending each fragment into a corresponding Ethernet packet in the user mode comprises:

[0091] Before the sending each fragment into a corresponding Ethernet packet in the user mode, the method further comprises: for each fragment, applying a cache pair associated with the fragment in a local cache of the forwarding process; the cache pair comprises a first cache and a second cache; wherein the first cache records an Ethernet header and a fragment header of the fragment; the second cache records at least a fragment length and a fragment start address;

[0092] The sending each fragment into a corresponding Ethernet packet in the user mode comprises:

[0093] When the sending timing arrives, each fragment is organized into a corresponding Ethernet packet based on the cache pair associated with the fragment and is sent in sequence; wherein any fragment is read based on the fragment length and the fragment start address recorded in the second cache of the cache pair associated with the fragment; the Ethernet packet corresponding to any fragment is obtained by combining the fragment with the Ethernet header and the fragment header recorded in the first cache of the cache pair associated with the fragment.

[0094] Optionally, the fragment header comprises at least: a fragment offset, a packet length, a packet sequence number, and a fragment continuation flag;

[0095] The fragment offset represents an offset of the current fragment in the message.

[0096] The packet length is the sum of the fragment length and the length of the fragment header; wherein the fragment length of the last fragment is the difference between the total length of the message and the offset of the current fragment in the message, and the fragment length of the remaining fragments is the set maximum length.

[0097] The packet sequence number is used to identify the sending of the message, and the packet sequence numbers in the fragment headers of all fragments in the same message are the same; the fragment continuation flag indicates that the current fragment is not the last fragment.

[0098] The embodiment provides a network device, which comprises a master board and an interface board; each service process and forwarding process belonging to the same CPU on the same master board or interface board is associated with a same shared memory; and a specified storage area of the shared memory is divided and correspondingly allocated to the service processes.

[0099] As Figure 3As shown, the forwarding process polls a local Ethernet port used for inter-board communication to obtain an Ethernet message; the forwarding process finds a target Bucket from local Buckets for storing the Ethernet message; the forwarding process determines a target fragmentation table entry from the target Bucket; the forwarding process records fragmented data carried by the Ethernet message in the target fragmentation table entry, and when it is determined that the fragmented data recorded in the target fragmentation table entry is all fragmented data of a same message, reassembles all fragmented data of the message to obtain a target message, and writes the target message into a storage area allocated to a target service process corresponding to a destination address of the fragmented data according to the destination address, puts a start address of the target message in the storage area into a queue in the shared memory, and notifies the target service process to acquire the target message from the storage area allocated to the target service process based on the start address in the queue.

[0100] Optionally, the forwarding process finding a target Bucket from local Buckets for storing the Ethernet message comprises:

[0101] The forwarding process finds a target Bucket from local Buckets according to a source address, a destination address and a packet sequence number in a fragmentation header carried by the Ethernet message.

[0102] Optionally, the forwarding process determining a target fragmentation table entry from the target Bucket comprises: checking whether a fragmentation table entry with a key matching key information in the fragmentation header carried by the Ethernet message exists in the target Bucket, and if so, determining the fragmentation table entry as the target fragmentation table entry, and if not, determining an idle fragmentation table entry in the target Bucket or a fragmentation table entry that has been used and meets a release requirement as the target fragmentation table entry; the key information at least includes at least one of the source address, the destination address and the packet sequence number.

[0103] Optionally, the forwarding process determining a target fragmentation table entry from the target Bucket further comprises: updating a fragmented size frag_size recorded in the target fragmentation table entry; the frag_size is used to record a sum of lengths of fragmented data belonging to the message that has been received;

[0104] The determining that the fragment data recorded in the target fragment table item is all fragment data of the same message comprises: when the fragment carried by the Ethernet message is the last fragment of the message, updating a total size total_size recorded in the target fragment table item; the total_size is a sum of a fragment length and a fragment offset; the fragment length is determined based on a difference between a packet length in a fragment header carried by the Ethernet message and a length of the set fragment header; the fragment offset is the fragment offset in the fragment header; checking whether the total_size matches the frag_size, and if yes, determining that the fragment data recorded in the target fragment table item is all fragment data of the same message.

[0105] Optionally, the recombining the received all fragment data of the message to obtain the target message comprises: concatenating the received all fragment data of the message in sequence to obtain the target message.

[0106] The first fragment data of the message received comprises a message header, and the message header carries a destination address; the destination address of the fragment data is the destination address carried by the message header.

[0107] Embodiments of the present application also provide a hardware structure. Referring to Figure 12 , Figure 12 An electronic device structure diagram is provided for the embodiments of the present application. As shown in Figure 12 , the hardware structure can comprise a processor and a machine readable storage medium, the machine readable storage medium storing machine executable instructions capable of being executed by the processor; the processor is configured to execute the machine executable instructions to implement the method disclosed in the above examples of the present application.

[0108] Based on the same application concept as the above method, the embodiments of the present application also provide a machine readable storage medium, the machine readable storage medium storing computer instructions, the computer instructions being executed by a processor to implement the method disclosed in the above examples of the present application.

[0109] For example, the machine readable storage medium can be a RAM (Random Access Memory), a volatile memory, a non-volatile memory, a flash memory, a storage drive (such as a hard disk drive), a solid state disk, any type of storage disk (such as an optical disk, a DVD, etc.), or similar storage medium, or a combination thereof.

[0110] The above merely provides an example of the present application, but is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the scope of claims of the present application.

Claims

1. An inter-board communication method characterized by, The method is applied to a network device, the network device comprising a main control board and an interface board; each service process and forwarding process belonging to a same CPU on a same main control board or interface board is associated with a same shared memory; a specified storage area of the shared memory is divided and correspondingly allocated to the service processes; the method comprises: The forwarding process receives a communication indication sent by a first service process having a data sending requirement; the communication indication is sent by the first service process after placing a message start address into a queue of the shared memory, and a storage area where the queue is located is different from the specified storage area; the message is stored into a storage area allocated to the first service process, and the message start address refers to a start address of a message to be sent in the storage area; The forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated to the first service process by using the message start address; The forwarding process fragments the message according to an order when the message meets a fragmentation requirement, obtains at least two fragments, and sends each fragment in a corresponding Ethernet packet in a user state; the forwarding process sends the message in a corresponding Ethernet packet in a user state when the message does not meet the fragmentation requirement.

2. The method of claim 1, wherein, The message comprises a message header and a message payload; The message header comprises at least a destination address, a source address, a message length, and a message sequence ID; the destination address is an address of a second service process, the source address is an address of the first service process, the first service process and the second service process are located on different boards, and the message sequence ID is assigned to the message according to a message sequence identification assignment principle; The message payload carries data required to be sent to meet the data sending requirement.

3. The method of claim 1, wherein, The message meets the fragmentation requirement when a length of the message is greater than a set maximum length, and it is determined that the message meets the fragmentation requirement; The set maximum length is a difference between a maximum transmission unit MTU supported by an Ethernet card and a set fragmentation header length.

4. The method of claim 3, wherein, Before sending each fragment in a corresponding Ethernet packet in a user state, the method further comprises: for each fragment, applying a cache pair associated with the fragment in a local cache of the forwarding process; the cache pair comprises a first cache and a second cache; the first cache records an Ethernet header and a fragment header of the fragment; and the second cache records at least a fragment length and a fragment start address; The sending of each fragment in a corresponding Ethernet packet in a user state comprises: When a sending opportunity arrives, each fragment is organized into a corresponding Ethernet packet based on the cache pair associated with the fragment and is sent in an order; any fragment is read based on the fragment length and the fragment start address recorded in the second cache of the cache pair associated with the fragment; and an Ethernet packet corresponding to any fragment is obtained by combining the fragment, the Ethernet header recorded in the first cache of the cache pair associated with the fragment, and the fragment header.

5. The method of claim 4, wherein, The fragment header at least includes: a fragment offset, a packet length, a packet sequence number, and a fragment continuation flag; The fragment offset represents an offset of the current fragment in the message; The packet length is the sum of the fragment length and the length of the fragment header; the fragment length of the last fragment is the difference between the total length of the message and the offset of the current fragment in the message, and the fragment length of the remaining fragments is the set maximum length; The packet sequence number is used to identify the sending of the message, and the packet sequence numbers in the fragment headers of all fragments in the same message are the same; the fragment continuation flag indicates that the current fragment is not the last fragment.

6. An inter-board communication method characterized by comprising: The method is applied to a network device, the network device including a master board and an interface board; each service process and forwarding process belonging to the same CPU on the same master board or interface board is associated with a same shared memory; a specified storage area of the shared memory is divided and correspondingly allocated to the service processes; the method includes: The forwarding process polls a local Ethernet port used for inter-board communication to obtain an Ethernet message; The forwarding process finds a target Bucket from the local Buckets for storing the Ethernet message; The forwarding process determines a target fragment table entry from the target Bucket; The forwarding process records fragment data carried by the Ethernet message in the target fragment table entry, and when it is determined that the fragment data recorded in the target fragment table entry is all fragment data of a same message, the forwarding process reassembles all fragment data of the message to obtain a target message, writes the target message into a storage area allocated to a target service process according to a destination address of the fragment data, puts a start address of the target message in the storage area into a queue of the shared memory, and notifies the target service process to acquire the target message from the storage area allocated to the target service process based on the start address in the queue.

7. The method of claim 6, wherein, The forwarding process finds a target Bucket from the local Buckets for storing the Ethernet message includes: The forwarding process finds a target Bucket from the local Buckets for storing the Ethernet message according to a source address, a destination address, and a packet sequence number in a fragment header carried by the Ethernet message.

8. The method of claim 7, wherein, The forwarding process determines a target fragment table entry from the target Bucket includes: checking whether a fragment table entry with a key matching key information in the fragment header carried by the Ethernet message exists in the target Bucket, and if so, determining the fragment table entry as the target fragment table entry, and if not, determining an idle fragment table entry or a fragment table entry that has been used and meets a release requirement in the target Bucket as the target fragment table entry; the key information at least includes at least one of the source address, the destination address, and the packet sequence number.

9. The method of claim 6, wherein, The forwarding process further includes: updating a recorded fragment size frag_size of the target fragment table entry; the frag_size is used to record the sum of lengths of fragments belonging to the message that have been received; The determining that the recorded fragment data of the target fragment table entry is all fragment data of the same message includes: when the fragment carried by the Ethernet message is the last fragment of the message, updating a recorded total size total_size of the target fragment table entry; the total_size is the sum of a fragment length and a fragment offset; the fragment length is determined based on a difference between a packet length in a fragment header carried by the Ethernet message and a length of the fragment header; and the fragment offset is the fragment offset in the fragment header; The checking whether the total_size matches the frag_size, and if so, determining that the recorded fragment data of the target fragment table entry is all fragment data of the same message.

10. The method according to claim 6 or 9, characterized in that, The reorganizing the received all fragment data of the message to obtain the target message includes: concatenating the received all fragment data of the message in sequence to obtain the target message. The first fragment data belonging to the message that is received includes a message header; and the message header carries a destination address. The destination address of the fragment data is the destination address carried by the message header.

11. A network device, comprising: The network device includes a main control board and an interface board; each service process and forwarding process belonging to the same CPU on the same main control board or interface board is associated with a same shared memory; and a specified storage area of the shared memory is divided and correspondingly allocated to the service processes. The forwarding process receives a communication indication sent by a first service process having a data sending requirement; the communication indication is sent by the first service process after the first service process puts a message start address into a queue of the shared memory; the queue is located in a storage area different from the specified storage area; and the message is stored into a storage area allocated to the first service process, and the message start address is a start address of the message to be sent in the storage area. The forwarding process reads the message start address from the queue of the shared memory, and accesses the message from the storage area allocated to the first service process by using the message start address. The forwarding process fragments the message in sequence to obtain at least two fragments when the message meets a fragmentation requirement, and sends each fragment in a corresponding Ethernet message in a user mode; and the forwarding process sends the message in a corresponding Ethernet message in the user mode when the message does not meet the fragmentation requirement.

12. The network device of claim 11, wherein, The message includes a message header and a message payload. The message header at least includes a destination address, a source address, a message length, and a message sequence ID; the destination address is an address of a second service process, the source address is an address of a first service process, the first service process and the second service process are on different boards; the message sequence ID is assigned to the message according to a message sequence identification assignment principle; The message payload carries data required to be sent to meet the data sending requirement; and / or The message meets the fragmentation requirement, which means that if the length of the message is greater than a set maximum length, it is determined that the message meets the fragmentation requirement; the set maximum length is a difference between a maximum transmission unit MTU supported by an Ethernet card and a set fragmentation header length; and / or The sending of each fragment as a corresponding Ethernet message in the user mode includes: For each fragment, a cache pair associated with the fragment is applied in a local cache of the current forwarding process; the cache pair includes a first cache and a second cache; the first cache records an Ethernet header and a fragmentation header of the fragment; the second cache records at least a fragment length and a fragment start address; When a sending opportunity arrives, each fragment is organized into a corresponding Ethernet message based on the cache pair associated with the fragment and is sent in sequence; any fragment is read based on the fragment length and the fragment start address recorded in the second cache of the cache pair associated with the fragment; the Ethernet message corresponding to any fragment is obtained by combining the fragment with the Ethernet header and the fragmentation header recorded in the first cache of the cache pair associated with the fragment; and / or The fragmentation header at least includes a fragment offset, a packet length, a packet sequence number, and a fragment continuation flag; The fragment offset represents an offset of the current fragment in the message; The packet length is a sum of the fragment length and the length of the fragmentation header; the fragment length of the last fragment is a difference between the total length of the message and the offset of the current fragment in the message, and the fragment length of the remaining fragments is the set maximum length; The packet sequence number is used to identify the sending of the message, and the packet sequence numbers in the fragmentation headers of all fragments in the same message are the same; the fragment continuation flag indicates that the current fragment is not the last fragment.

13. A network device, comprising: The network device includes a master board and an interface board; each service process and forwarding process belonging to the same CPU on the same master board or interface board is associated with a same shared memory; a designated storage area of the shared memory is divided and correspondingly allocated to the service processes; The forwarding process polls a local Ethernet port used for inter-board communication to obtain an Ethernet message; the forwarding process finds a target Bucket from the local Buckets to store the Ethernet message; The forwarding process determines a target fragment table entry from the target Bucket; and The forwarding process determines a target fragment table entry from the target Bucket. The forwarding process records the fragment data carried by the Ethernet message in the target fragment table entry, and when it is determined that the fragment data recorded in the target fragment table entry is all fragment data of the same message, reassembles all fragment data of the message recorded in the target fragment table entry to obtain a target message, writes the target message into a storage area allocated to the target service process corresponding to the destination address of the fragment data according to the destination address of the fragment data, puts the starting address of the target message in the storage area into a queue in the shared memory, and notifies the target service process to obtain the target message from the storage area allocated to the target service process based on the starting address in the queue.

14. The network device of claim 13, wherein, The forwarding process finds a target Bucket for storing the Ethernet message from a local Bucket, including: The forwarding process finds a target Bucket matching the source address, destination address and packet sequence number in the fragment header carried by the Ethernet message from a local Bucket according to the source address, destination address and packet sequence number in the fragment header carried by the Ethernet message; and / or, The forwarding process determines a target fragment table entry from the target Bucket, including: checking whether there is a fragment table entry in the target Bucket whose key matches the key information in the fragment header carried by the Ethernet message, if yes, determining the fragment table entry as the target fragment table entry, if not, determining an idle fragment table entry in the target Bucket or a fragment table entry that has been used and meets the release requirements as the target fragment table entry; the key information at least includes at least one of the source address, destination address and packet sequence number; and / or, The forwarding process further determines a target fragment table entry from the target Bucket, including: updating the fragment size frag_size recorded in the target fragment table entry; the frag_size is used to record the sum of the lengths of the fragments belonging to the message that have been received; The determination that the fragment data recorded in the target fragment table entry is all fragment data of the same message includes: when the fragment carried by the Ethernet message is the last fragment of the message, updating the total size total_size recorded in the target fragment table entry; the total_size is the sum of the fragment length and the fragment offset; the fragment length is determined based on the difference between the packet length in the fragment header carried by the Ethernet message and the length of the set fragment header; the fragment offset is the fragment offset in the fragment header; checking whether the total_size matches the frag_size, if yes, determining that the fragment data recorded in the target fragment table entry is all fragment data of the same message; and / or, The reassembly of all fragment data of the message that has been received to obtain a target message includes: concatenating all fragment data of the message that has been received in order to obtain the target message; and / or, The forwarding process further writes the target message into a storage area allocated to the target service process corresponding to the destination address of the fragment data according to the destination address of the fragment data, puts the starting address of the target message in the storage area into a queue in the shared memory, and notifies the target service process to obtain the target message from the storage area allocated to the target service process based on the starting address in the queue. The received first fragment data belonging to the message comprises a message header, and the message header carries a destination address; and the destination address of the fragment data is the destination address carried by the message header.

15. An electronic device, comprising: The electronic device includes a processor and a machine-readable storage medium; The machine-readable storage medium stores machine-executable instructions that can be executed by the processor; and the processor is configured to execute the machine-executable instructions to implement the method steps of any one of claims 1-10.

Citation Information

Patent Citations

  • High-speed network data transmission method

    CN106850565A

  • Inter-process communication method, device and system, medium and terminal

    CN110399229A