A message distribution method, device, apparatus and storage medium
By using an FPGA chip to poll the server's network card memory and allocate target servers based on IP addresses in high-concurrency scenarios, data frames can be sent directly, solving the problem of excessive hardware pressure in traditional microservice architectures and achieving efficient data frame allocation and processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2026-03-24
AI Technical Summary
In high-concurrency scenarios, the server's network ports are under tremendous pressure. Traditional microservice architectures distribute traffic through software-level gateways, which exacerbates the pressure on hardware devices and cannot solve the problem of network card memory being filled up.
The FPGA chip polls the remaining memory of the server's network card, allocates target servers based on the IP address of the network data frame, and sends data frames directly when the network card has enough remaining memory, avoiding distribution through an intermediate network card and using the local memory queue to buffer data frames when they are insufficient.
It reduces the network burden in high-concurrency scenarios, improves processing efficiency, avoids network card memory overflow, and enhances the reliability of data frame allocation.
Smart Images

Figure CN116319592B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of hardware acceleration technology, and in particular to a message distribution method and device, equipment and storage medium. BACKGROUND
[0002] FPGA (Field Programmable Gate Array, field programmable gate array) is widely used in communication systems, and many functional modules usually require a large number of filtering operations, and these filtering functions often require a large number of multiplication and accumulation operations. By using FPGA to realize a distributed arithmetic structure, the multiplication and accumulation operations can be effectively realized.
[0003] In the prior art, in a high concurrency scenario, the network port of the server often needs to withstand a lot of pressure, and the traditional micro-service architecture attempts to solve the problem from the software level, and introduces a software-level gateway for distributing traffic, but this aggravates the pressure on the hardware device, and cannot solve the problem of the network card memory being filled up. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a message distribution method, device, equipment and storage medium, which can directly send the received data frame message to the server through FPGA, avoid distributing the message through the intermediate network card, reduce the network burden in a high concurrency scenario, and improve the processing efficiency. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a message distribution method applied to FPGA, comprising:
[0006] Polling the remaining memory of the network card of each server and determining whether a network data frame is received;
[0007] If the network data frame is received, a first target server with a corresponding server number is assigned to the network data frame based on the IP address of the network data frame;
[0008] Determining whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame;
[0009] If not, the network data frame is sent to the first target server, and if yes, the network data frame is stored in a local memory queue, and when the polling finds that the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server.
[0010] Optionally, polling the remaining memory of the network card of each server and determining whether a network data frame is received comprises:
[0011] polling the memory occupation of the network card of each server after the FPGA chip is started;
[0012] record the current remaining memory of the network card of each server determined based on the memory occupation of the network card by using a preset record list, and determine whether a network data frame is received.
[0013] Optionally, before the first target server with the server number corresponding to the network data frame is assigned to the network data frame based on the IP address of the network data frame, the method can further include:
[0014] determining whether there is an unassigned network data frame in the local memory queue;
[0015] if there is, determining a second target server corresponding to the unassigned network data frame, and determining whether the remaining memory of the current second target server is less than the memory occupation of the unassigned network data frame;
[0016] if not, sending the unassigned network data frame to the second target server.
[0017] Optionally, the message assignment method can further include:
[0018] record the assignment state of the network data frame by using the preset record list.
[0019] Optionally, before the memory occupation of the network card of each server is polled and it is determined whether a network data frame is received, the method can further include:
[0020] determining the number of servers, and creating a corresponding server number for each server based on the number of servers.
[0021] Optionally, the first target server with the server number corresponding to the network data frame is assigned to the network data frame based on the IP address of the network data frame, and the method can include:
[0022] determining the IP address of the network data frame, and converting the IP address of the network data frame into an unsigned 32-bit integer to obtain a target code corresponding to the network data frame;
[0023] performing a remainder operation on a value corresponding to the number of servers based on the target code to obtain a remainder corresponding to the network data frame;
[0024] a server with a server number consistent with the remainder is taken as the first target server, and the first target server is assigned to the network data frame.
[0025] Optionally, the message assignment method can further include:
[0026] determining whether the network data frame is a disassembled data frame;
[0027] if yes, after obtaining other data frames belonging to the same data packet as the network data frame, sending the other data frames to the first target server.
[0028] In a second aspect, the present application discloses a message distribution device, comprising:
[0029] a data frame receiving and determining module, configured to poll the remaining memory of the network card of each server and determine whether a network data frame is received;
[0030] a server distribution module, configured to, if the network data frame is received, distribute the network data frame to a first target server with a corresponding server number based on the IP address of the network data frame;
[0031] a memory determining module, configured to determine whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame;
[0032] a data frame processing module, configured to, if no, send the network data frame to the first target server, and if yes, store the network data frame in a local memory queue and send the network data frame in the local memory queue to the first target server when the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame.
[0033] In a third aspect, the present application discloses an electronic device, comprising:
[0034] a memory, configured to save a computer program;
[0035] a processor, configured to execute the computer program to realize the message distribution method as described above.
[0036] In a fourth aspect, the present application discloses a computer readable storage medium, configured to save a computer program, and the computer program is executed by a processor to realize the message distribution method as described above.
[0037] In the present application, first, poll the remaining memory of the network card of each server, and determine whether the network data frame is received; if the network data frame is received, assign the network data frame to the first target server with the corresponding server number based on the IP address of the network data frame; determine whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame; if not, send the network data frame to the first target server, if yes, store the network data frame in the local memory queue, and when the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, send the network data frame in the local memory queue to the first target server. As can be seen, through the message distribution method in the present application, after the FPGA chip is started and the network data frame is received, the server with the corresponding server number is assigned to the network data frame based on the IP address of the network data frame, and when the remaining memory of the server network card is greater than the memory occupation of the network data frame, the network data frame is directly sent to the server. In this way, the received data frame message can be sent to the server through the FPGA, avoiding the distribution of messages through the intermediate network card, reducing the network burden in the high concurrency scenario, and improving the processing efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the provided drawings.
[0039] Figure 1 A message distribution method flow chart is provided for the present application;
[0040] Figure 2 A network data frame distribution timing diagram in a high concurrency scenario is provided for the present application;
[0041] Figure 3 A specific message distribution method flow chart is provided for the present application;
[0042] Figure 4 A message distribution device structure schematic diagram is provided for the present application;
[0043] Figure 5 An electronic equipment structure diagram is provided for the present application. DETAILED DESCRIPTION
[0044] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be clearly and completely described below, obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0045] In the prior art, in a high concurrency scenario, the network port of the server often needs to bear a great pressure, and the traditional micro-service architecture attempts to solve the problem from the software level, and introduces a software level gateway for distributing traffic, but this aggravates the pressure of the hardware device, and cannot solve the situation that the network card memory is full.
[0046] In order to overcome the above technical problems, the present application provides a message distribution method, device, equipment and storage medium, which can distribute the network data frame to the server with the corresponding server number based on the IP address of the network data frame after the FPGA chip is started and the network data frame is received, and directly send the network data frame to the server when the remaining memory of the server network card is greater than the network data frame memory occupation. In this way, the received data frame message can be directly sent to the server through the FPGA, avoiding distributing the message through the intermediate network card, reducing the network burden in the high concurrency scenario, and improving the processing efficiency.
[0047] Referring to Figure 1 The embodiment of the present application discloses a message distribution method applied to FPGA, comprising:
[0048] Step S11, polling the remaining memory of the network card of each server, and judging whether a network data frame is received.
[0049] In the embodiment, after the FPGA chip is started, the remaining memory of the network card of each server connected with the FPGA chip needs to be polled first, and the network card memory occupation of each server polled is recorded in a preset record list, and then it is judged whether a network data frame is received.
[0050] It should be noted that before polling the network card memory occupation of each server and judging whether a network data frame is received, it further comprises: determining the number of servers, and creating a corresponding server number for each server based on the number of servers. That is, before polling the remaining memory of the network card of each server, each server needs to be numbered based on the number of servers connected with the FPGA chip, for example, if the number of servers connected with the FPGA chip is 5, the servers are numbered from 0 to 4, and each server is assigned a corresponding server number.
[0051] Step S12, if the network data frame is received, a first target server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame.
[0052] In the embodiment, if the FPGA chip receives the network data frame, the IP address of the received network data frame needs to be determined, and the IP address of the network data frame is converted into an unsigned 32-bit integer. Then, the unsigned 32-bit integer obtained after the conversion is taken modulo the number of servers to obtain a remainder corresponding to the network data frame. The server with the server number consistent with the remainder is taken as the first target server receiving the network data frame.
[0053] It needs to be noted that before the first target server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame, it further includes: judging whether there is an uncompleted allocation network data frame in the current local memory queue; if there is, determining a second target server corresponding to the uncompleted allocation network data frame, and judging whether the remaining memory of the network card of the current second target server is less than the memory occupation of the uncompleted allocation network data frame; if not, the uncompleted allocation network data frame is sent to the second target server. That is, after the FPGA chip is started and the occupation of the server network card is polled, it needs to be judged whether there is a network data frame that has not been sent to the server in the FPGA memory queue. If there is, it needs to be determined whether the network card memory of the second target server corresponding to the uncompleted allocation network data frame is sufficient to receive the uncompleted allocation network data frame. If the network card memory of the second target server is not less than the memory occupation of the uncompleted allocation network data frame, the uncompleted allocation network data frame is directly sent to the second target server. If it is less than the memory occupation of the uncompleted allocation network data frame, the uncompleted allocation network data frame is continuously saved to the memory queue of the FPGA, and after the network card memory of the second target server is polled and is not less than the memory occupation of the uncompleted allocation network data frame, the uncompleted allocation network data frame is sent to the second target server.
[0054] Step S13, judging whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame.
[0055] In this embodiment, after receiving the network data frame, it is necessary to determine the memory occupation of the network data frame, and determine the remaining memory size of the network card of the first target server receiving the network data frame, and compare whether the remaining memory size of the network card of the first target server is less than the memory occupation of the network data frame, so as to determine whether the first target server can receive the network data frame through the comparison result.
[0056] Step S14, if not, the network data frame is sent to the first target server, if yes, the network data frame is stored in the local memory queue, and when the polling to the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server.
[0057] In this embodiment, as shown in Figure 2 The allocation timing diagram of the network data frame in the high concurrency scenario is shown in the figure. If the remaining memory of the network card of the first target server is not less than the memory occupation of the network data frame, the network data frame can be directly sent to the first target server. If the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame, it indicates that the remaining memory of the network card of the first target server is not enough to receive the network data frame, so the network data frame needs to be stored in the memory queue of the FPGA, and when the FPGA loops to the first target server and the remaining memory of the network card is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server.
[0058] It should be noted that the message allocation method further comprises: judging whether the network data frame is a data frame after unpacking; if yes, after obtaining other data frames belonging to the same data packet as the network data frame, the other data frames are sent to the first target server. That is, if the network data frame received by the FPGA is a data frame after TPC (Transmission Control Protocol, Transmission Control Protocol) unpacking, the server is locked by the server number after determining the server receiving the network data frame, and after receiving other data frames belonging to the same data packet, the other data frames are sent to the server with the same server number. In this way, the message request sent by the same client can be ensured to be processed by the same server through the server number, so that the same server can get all the data packets sent by the same client to complete data packet sticking, thereby effectively improving the reliability of the message allocation method.
[0059] It can be seen that in the embodiment, the remaining memory of the network card of each server is polled first, and it is determined whether a network data frame is received; if the network data frame is received, a first target server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame; it is determined whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame; if not, the network data frame is sent to the first target server, and if yes, the network data frame is stored in a local memory queue, and when the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server. It can be seen that by using the packet allocation method in the application, after the FPGA chip is started and a network data frame is received, a server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame, and when the remaining memory of the server network card is greater than the memory occupation of the network data frame, the network data frame is directly sent to the server. In this way, the received data frame packet can be directly sent to the server by the FPGA, the packet is avoided to be distributed through an intermediate network card, the network burden in a high-concurrency scenario is reduced, and the processing efficiency is improved.
[0060] Based on the foregoing embodiment, it is necessary to allocate a corresponding server to the network data frame based on the IP address of the network data frame in the application. For this purpose, the embodiment details how to allocate a corresponding server to the network data frame, as shown in Figure 3 The packet allocation method disclosed by the embodiment is applied to an FPGA and includes the following steps.
[0061] In step S21, the remaining memory of the network card of each server is polled, and it is determined whether a network data frame is received.
[0062] In step S22, if the network data frame is received, the IP address of the network data frame is determined, and the IP address of the network data frame is converted into an unsigned 32-bit integer to obtain a target code corresponding to the network data frame.
[0063] In the embodiment, if the FPGA chip receives a new network data frame after starting, the IP address of the network data frame needs to be determined first, so as to convert the IP address of the network data frame into an unsigned 32-bit integer. For example, a new network data frame is received, and the dotted decimal client IP corresponding to the network data frame is 63.74.28.1. The client IP is converted into an unsigned 32-bit integer, which is represented as 1049445616. After obtaining the unsigned 32-bit integer corresponding to the IP address of the network data frame, the unsigned 32-bit integer is determined as the target code corresponding to the network data frame.
[0064] Step S23, the number corresponding to the server number is processed by remainder based on the target code to obtain the remainder corresponding to the network data frame.
[0065] In the embodiment, after obtaining the target code corresponding to the received network data frame, the number corresponding to the server number needs to be processed by remainder based on the target code, wherein the numerator is the target code, and the denominator is the number corresponding to the server number. For example, as shown in the foregoing embodiment, the obtained target code is 1049445616, and the number of servers connected to the FPGA is 5. After the remainder processing, the remainder is 1, and the server with the server number 1 is used to receive the network data frame corresponding to the target code.
[0066] Step S24, the server with the server number consistent with the remainder is taken as the first target server, and the first target server is allocated to the network data frame.
[0067] In the embodiment, as shown in the foregoing embodiment, the number of servers connected to the FPGA is 5, and each server is numbered in sequence from 0 to 4, and the remainder obtained after the remainder processing is 1. The server with the server number 1 is used to receive the network data frame corresponding to the target code, that is, the server with the server number 1 is taken as the first target server. In this way, if the network data frame is a data frame after unpacking, the subsequent data of the network data frame can be received based on the server with the same server number, the continuous reception of the unpacked data is realized, so as to complete the data packeting, and the reliability of the message allocation method in the application is effectively improved.
[0068] Step S25, it is judged whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame.
[0069] If no, the network data frame is sent to the first target server; if yes, the network data frame is stored in a local memory queue, and when it is polled that the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server.
[0070] It should be noted that more specific descriptions about steps S21, S25 and S26 can refer to the foregoing embodiments, which will not be repeated here.
[0071] As can be seen, in the embodiment, after receiving the network data frame, the IP address of the network data frame is determined, and the IP address of the network data frame is converted into an unsigned 32-bit integer to obtain a target code corresponding to the network data frame, then the value corresponding to the number of servers is processed by taking the remainder based on the target code to obtain a remainder corresponding to the network data frame, and finally the server whose server number is consistent with the remainder is taken as the first target server, and the first target server is allocated to the network data frame. In this way, the corresponding receiving server can be directly allocated to the network data frame through the IP address of the network data frame, avoiding processing through the intermediate network card, and effectively relieving the network burden.
[0072] Referring to Figure 4 The embodiment of the application discloses a message allocation device applied to FPGA, comprising:
[0073] The data frame receiving and judging module 11 is used for polling the remaining memory of the network card of each server and judging whether a network data frame is received or not.
[0074] The server allocation module 12 is used for, if the network data frame is received, allocating a first target server with a corresponding server number to the network data frame based on the IP address of the network data frame.
[0075] The memory judging module 13 is used for judging whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame or not.
[0076] The data frame processing module 14 is used for, if no, sending the network data frame to the first target server; if yes, storing the network data frame in a local memory queue, and when it is polled that the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, sending the network data frame in the local memory queue to the first target server.
[0077] In the present application, first, the remaining memory of the network card of each server is polled, and it is judged whether a network data frame is received; if the network data frame is received, a first target server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame; it is judged whether the remaining memory of the network card of the first target server is less than the memory occupation of the network data frame; if not, the network data frame is sent to the first target server, and if yes, the network data frame is stored in a local memory queue, and when the remaining memory of the network card of the first target server is greater than the memory occupation of the network data frame, the network data frame in the local memory queue is sent to the first target server. As can be seen, through the message allocation method in the present application, after the FPGA chip is started and the network data frame is received, a server with a corresponding server number is allocated to the network data frame based on the IP address of the network data frame, and when the remaining memory of the server network card is greater than the memory occupation of the network data frame, the network data frame is directly sent to the server. In this way, the received data frame message can be directly sent to the server through the FPGA, the message is avoided to be distributed through the intermediate network card, the network burden in the high-concurrency scenario is reduced, and the processing efficiency is improved.
[0078] In some embodiments, the data frame receiving judgment module 11 can specifically include:
[0079] The network card polling unit is configured to poll the memory occupation of the network card of each server after the FPGA chip is started.
[0080] The data frame receiving judgment unit is configured to record the current remaining memory of the network card of each server determined based on the memory occupation of the network card by using a preset record list, and judge whether a network data frame is received.
[0081] In some embodiments, the message allocation device can further include:
[0082] The data frame allocation judgment module is configured to judge whether there is an uncompleted allocation network data frame in the local memory queue.
[0083] The memory comparison module is configured to, if there is, determine a second target server corresponding to the uncompleted allocation network data frame, and judge whether the remaining memory of the network card of the second target server is less than the memory occupation of the uncompleted allocation network data frame.
[0084] The first data frame sending module is configured to, if not less than, send the uncompleted allocation network data frame to the second target server.
[0085] In some embodiments, the message allocation device can further include:
[0086] The allocation state recording module is configured to record the allocation state of the network data frame by using the preset recording list.
[0087] In some embodiments, the message allocation device can further include:
[0088] The number creating module is configured to determine the number of servers and create a corresponding server number for each server based on the number of servers.
[0089] In some embodiments, the server allocation module 12 can specifically include:
[0090] The address conversion unit is configured to determine the IP address of the network data frame and convert the IP address of the network data frame into an unsigned 32-bit integer to obtain a target code corresponding to the network data frame.
[0091] The data processing unit is configured to perform a remainder processing on a value corresponding to the number of servers based on the target code to obtain a remainder corresponding to the network data frame.
[0092] The server allocation unit is configured to take a server whose number is consistent with the remainder as a first target server and allocate the first target server to the network data frame.
[0093] In some embodiments, the message allocation device can further include:
[0094] The unpacked data frame judging module is configured to judge whether the network data frame is an unpacked data frame.
[0095] The second data frame sending module is configured to, if yes, send other data frames belonging to a same data packet as the network data frame to the first target server after obtaining the other data frames.
[0096] Further, the embodiments of the present application also disclose an electronic device, Figure 5 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the figure cannot be considered as any limitation on the use range of the present application.
[0097] Figure 5A structural schematic diagram of an electronic device 20 is provided in the embodiments of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26. The memory 22 is configured to store a computer program, and the processor 21 is configured to load and execute the computer program to implement the related steps in the packet distribution method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the embodiments of the present application can be specifically an electronic computer.
[0098] In the embodiments of the present application, the power supply 23 is configured to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 is capable of creating a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which is not limited specifically herein; the input / output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which is not limited specifically herein.
[0099] In addition, the memory 22 as a carrier for resource storage can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.
[0100] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the packet distribution method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include a computer program capable of completing other specific work.
[0101] Further, the present application further discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the packet distribution method disclosed above. For the specific steps of the method, refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0102] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. For the same or similar parts between the embodiments, refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts refer to the method part.
[0103] Those skilled in the art will further appreciate that the units and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various examples have been described herein in terms of their functionality, which has been described generally and symbolically in flow charts. Having thus described the functionality of the examples, a person of ordinary skill in the art will be able to implement such functionality in hardware and / or software, and will recognize that the bounds of the examples are not limited by one approach or the other. The various examples can be realized in a centralized fashion in one computer system or network, or in a distributed fashion where different elements are spread across several computer systems or sub-networks. Any kind of computer system or other apparatus adapted for carrying out the methods described herein is suited. A typical combination of hardware and software could be a general purpose computer system with a computer program that, when being loaded and executed, carries out the methods described herein.
[0104] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in random access memory (RAM), flash memory, read-only memory (ROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, hard disk can be used as a storage medium.
[0105] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and are not otherwise intended to refer to the sequence, quantity, or importance of the elements. Also, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0106] The above detailed description of the technical solutions provided by the present application has been described in detail, and the principles and implementation modes of the present application have been described in the text. The above description of the examples is only to help understand the method and core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed; in view of the above, the content of the specification should not be understood as limiting the present application.
Claims
1. A message allocation method, characterized in that, Applied to FPGAs, including: Poll the remaining memory of each server's network card and determine whether a network data frame has been received; If the network data frame is received, a first target server with a corresponding server number is assigned to the network data frame based on the IP address of the network data frame; Determine whether the remaining memory of the network card of the first target server is less than the memory usage of the network data frame; If not, the network data frame is sent to the first target server; if yes, the network data frame is stored in a local memory queue, and when it is found that the remaining memory of the network card of the first target server is greater than the memory usage of the network data frame, the network data frame in the local memory queue is sent to the first target server. Before polling the network card memory usage of each server and determining whether a network data frame has been received, the process further includes: Determine the number of servers, and create a corresponding server number for each server based on the number of servers; The step of allocating a first target server with a corresponding server number to the network data frame based on the IP address of the network data frame includes: The IP address of the network data frame is determined, and the IP address of the network data frame is converted into an unsigned 32-bit integer to obtain the target encoding corresponding to the network data frame; Based on the target encoding, the value corresponding to the number of servers is processed by taking the remainder to obtain the remainder corresponding to the network data frame; The server whose server number matches the remainder is designated as the first target server, and the first target server is assigned to the network data frame.
2. The message allocation method according to claim 1, characterized in that, The step of polling each server's network card remaining memory and determining whether a network data frame has been received includes: After the FPGA chip starts up, it polls the network card memory usage of each server. The system uses a preset record list to record the remaining memory of each server's network card, which is determined based on the network card's memory usage, and then determines whether a network data frame has been received.
3. The message allocation method according to claim 2, characterized in that, Before assigning a first target server with a corresponding server number to the network data frame based on its IP address, the method further includes: Determine whether there are any unallocated network data frames in the current local memory queue; If it exists, then determine the second target server corresponding to the unallocated network data frame, and determine whether the remaining memory of the network card of the second target server is less than the memory usage of the unallocated network data frame; If the value is not less than the specified value, the unallocated network data frame will be sent to the second target server.
4. The message allocation method according to claim 2, characterized in that, Also includes: The allocation status of the network data frames is recorded using the preset record list.
5. The message allocation method according to any one of claims 1 to 4, characterized in that, Also includes: Determine whether the network data frame is a data frame that has been unpacked; If so, after obtaining other data frames belonging to the same data packet as the network data frame, the other data frames are sent to the first target server.
6. A message distribution device, characterized in that, Applied to FPGAs, including: The data frame reception and judgment module is used to poll the remaining memory of each server's network card and determine whether a network data frame has been received. The server allocation module is used to allocate a first target server with a corresponding server number to the network data frame based on the IP address of the network data frame if the network data frame is received. The memory determination module is used to determine whether the remaining memory of the network card of the first target server is less than the memory usage of the network data frame; The data frame processing module is configured to send the network data frame to the first target server if no, and store the network data frame in a local memory queue if yes, and send the network data frame in the local memory queue to the first target server when it is found that the remaining memory of the network card of the first target server is greater than the memory usage of the network data frame. The message distribution device also includes: The number creation module is used to determine the number of servers and create a corresponding server number for each server based on the number of servers. The server allocation module includes: The address translation unit is used to determine the IP address of the network data frame and convert the IP address of the network data frame into an unsigned 32-bit integer to obtain the target encoding corresponding to the network data frame. The data processing unit is used to perform remainder processing on the value corresponding to the number of servers based on the target encoding, so as to obtain the remainder corresponding to the network data frame; The server allocation unit is used to designate the server whose server number matches the remainder as the first target server and to allocate the first target server to the network data frame.
7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the message allocation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the message allocation method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Distributed system and unmanned equipment with same
CN110022356A
Memory management method and related equipment
CN110209490A