CN107193673B - Message processing method and device - Google Patents

Message processing method and device Download PDF

Info

Publication number
CN107193673B
CN107193673B CN201710509548.2A CN201710509548A CN107193673B CN 107193673 B CN107193673 B CN 107193673B CN 201710509548 A CN201710509548 A CN 201710509548A CN 107193673 B CN107193673 B CN 107193673B
Authority
CN
China
Prior art keywords
message
shared memory
kernel
processing
user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710509548.2A
Other languages
Chinese (zh)
Other versions
CN107193673A (en
Inventor
黄墀晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ruijie Networks Co Ltd
Original Assignee
Ruijie Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ruijie Networks Co Ltd filed Critical Ruijie Networks Co Ltd
Priority to CN201710509548.2A priority Critical patent/CN107193673B/en
Publication of CN107193673A publication Critical patent/CN107193673A/en
Application granted granted Critical
Publication of CN107193673B publication Critical patent/CN107193673B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a message processing method and device, which are used for improving the domain name resolution speed of a DNS (domain name server) so as to improve the QPS (quick Path Server) of the DNS. The method comprises the following steps: the message processing equipment monitors a message through a first process in a kernel state; the message processing equipment receives a first message sent by user equipment through a message transceiving process and stores the first message into a shared memory; the shared memory can be accessed by a first process in a user mode; the message processing equipment switches the first process from a kernel mode to a user mode, and reads the first message from the shared memory through the first process; the message processing device processes the first message through the first process, generates a response message according to a processing result, and stores the response message to the shared memory through the first process.

Description

Message processing method and device
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for processing a packet.
Background
A Domain Name System (DNS) server is used to store Domain names of all hosts in a network and Internet Protocol (IP) addresses corresponding to the Domain names. When the user equipment accesses the domain name, the domain name is required to be resolved through the DNS and the IP address corresponding to the domain name is returned, so that the user equipment can access according to the IP address. The Query Per Second (QPS) of the DNS server domain name resolution guard refers to a threshold amount of domain name resolution of the DNS server, and if a domain name resolution request received by the DNS server at the same time exceeds the QPS of the DNS guard, the DNS server may have a case of domain name resolution timeout, so that the user equipment cannot normally perform domain name access. That is to say, if the QPS for domain name resolution protection is low, the success rate of the lawless person attacking the DNS server by sending a large number of domain name resolution requests is higher, so that the success rate of the DNS server failing to normally provide services for the user equipment is higher, which obviously affects the network use experience of the user. Therefore, QPS is an extremely important indicator of DNS servers.
And currently, the QPS of the DNS server is generally improved by improving the hardware processing capability of the DNS server. For example, by setting a plurality of DNS servers, different DNS servers provide domain name resolution services for user equipment in different ranges, so that the pressure of domain name resolution of each DNS server is lower, thereby ensuring that the domain name access of the user equipment is performed normally; alternatively, a DNS server with a larger memory or higher performance Central Processing Unit (CPU) is used. However, the two methods either need to modify the DNS server or need to set more DNS servers, which is a heavy workload and requires more manpower.
Disclosure of Invention
The embodiment of the invention provides a message processing method and device, which are used for improving the domain name resolution speed of a DNS (domain name server) so as to improve the QPS (quick Path Server) of the DNS.
In a first aspect, a method for processing a packet is provided, where the method includes:
the message processing equipment monitors a message received by a message receiving and sending process through a first process in a kernel state;
the message processing equipment receives a first message sent by user equipment through the message transceiving process and stores the first message into a shared memory; the shared memory can be accessed by a first process in a user mode;
when the message processing device monitors that the message transceiving process receives the first message through the first process in the kernel state, the message processing device switches the first process from the kernel state to the user state, and reads the first message from the shared memory through the first process;
the message processing device processes the first message through the first process, generates a response message according to a processing result, and stores the response message to the shared memory through the first process.
Optionally, when the first process in the kernel state detects that the message transceiving process has received the first message, the message processing device switches the first process from the kernel state to the user state, including:
the message processing device receives an indication message sent by the message transceiving process through the first process in the kernel state, wherein the indication message is used for indicating the first process, and the message transceiving process receives the first message;
and the message processing equipment switches the first process from a kernel mode to a user mode.
Optionally, after the message processing device stores the response message in the shared memory through the first process, the method further includes:
and the message processing equipment sends the response message to the user equipment through the message transceiving process.
Optionally, after the message processing device stores the response message in the shared memory through the first process, the method further includes:
the message processing equipment determines whether a second message to be processed exists in the shared memory through the first process;
if the second message to be processed exists in the shared memory, the message processing equipment reads and processes the second message from the shared memory through the first process; otherwise, the message processing device switches the first process from the user mode to the kernel mode, so as to continue to monitor the message through the first process in the kernel mode.
Optionally, the messages stored in the shared memory all adopt a lock-free data structure.
In a second aspect, a message processing device is provided, which includes:
the monitoring unit is used for monitoring the message received by the message receiving and sending process through the first process of the kernel state;
a receiving and sending unit, configured to receive a first packet sent by a user equipment through the packet receiving and sending process, and store the first packet in a shared memory; the shared memory can be accessed by a first process in a user mode;
a reading unit, configured to switch the first process from the kernel state to the user state when the interception unit intercepts, through the first process in the kernel state, that the message transceiving process has received the first message, and read the first message from the shared memory through the first process;
and the processing unit is used for processing the first message through the first process, generating a response message according to a processing result, and storing the response message to the shared memory through the first process.
Optionally, when the first process in the kernel state monitors that the message transceiving process has received the first message, the reading unit switches the first process from the kernel state to the user state, including:
when the first process in the kernel state receives an indication message sent by the message transceiving process, the indication message is used for indicating the first process, and the message transceiving process receives the first message; and the reading unit switches the first process from a kernel mode to a user mode.
Optionally, the transceiver unit is further configured to: and after the response message is stored in the shared memory through the first process, the response message is sent to the user equipment through the message transceiving process.
Optionally, the apparatus further comprises a determining unit,
the determination unit is configured to: after the processing unit stores the response message in the shared memory through the first process, determining whether a second message to be processed exists in the shared memory through the first process;
the processing unit is further to: if the determining unit determines that the shared memory has a second message to be processed, reading and processing the second message from the shared memory through the first process;
the interception unit is further configured to: if the determining unit determines that the second message to be processed does not exist in the shared memory, the first process is switched from the user mode to the kernel mode, so that the message is continuously intercepted through the first process in the kernel mode.
Optionally, the messages stored in the shared memory all adopt a lock-free data structure.
In a third aspect, a computer apparatus is provided, the apparatus comprising a processor configured to implement the steps of any one of the message processing methods provided in the first aspect when executing a computer program stored in a memory.
In a fourth aspect, there is provided a computer-readable storage medium having a computer program stored thereon, wherein: the computer program, when executed by a processor, implements the steps of any of the message processing methods provided in the first aspect.
In the embodiment of the present invention, after the message processing device receives the first message, the first message is stored in the shared memory accessible to the first process in the user mode, so that the first process can directly read the first message from the shared memory and perform message processing, and the first message does not need to be copied to the memory space accessible to the first process by the first process, thereby improving the processing efficiency. And after the first process finishes processing the first message, the response message is stored in the shared memory, so that the first process does not need to switch the state again to copy the response message, and the processing efficiency is also improved. Therefore, under the condition of not changing hardware resources of the DNS, the message processing speed of each time is increased, so that the number of messages which can be processed at the same time is increased, and the QPS of the DNS is correspondingly increased.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments of the present invention will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of domain name resolution performed by a DNS server in the prior art;
fig. 2 is a schematic flow chart of a message processing method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention.
The technical background of the embodiments of the present invention is described below.
Fig. 1 is a schematic diagram of domain name resolution performed by a DNS server in the prior art. Firstly, a DNS process in a DNS server needs to be switched from a user mode to a kernel mode, and a message is intercepted through an SOCKET interface provided by a system in the DNS server; when a DNS server receives a query message for requesting to query an IP address, the DNS process is awakened and switched from a kernel mode to a user mode; because the query message received by the DNS server is stored in the memory space that is only allowed to be accessed by the process in the kernel state, and the query message can only be processed by the DNS process in the user state, the DNS process needs to copy the query message to the memory space that is allowed to be accessed by the process in the user state through the SOCKET interface, and can process the query message. After the DNS process finishes processing the query message and generates a response message according to the processing result, the response message needs to be copied to a memory space that is allowed to be accessed by the process in the kernel state through the SOCKET interface, and then the response message can be sent to the corresponding user equipment. The DNS process needs to switch the state at least twice for each processing of the query packet, which is cumbersome, and time is consumed to copy the query packet and the response packet. The process is only a process of processing one DNS query message, and it is expected that when there are many DNS query messages, many DNS query messages to be processed will be likely to be accumulated, so that the domain name access speed of the user is slower, and the user experience of the user is affected. Obviously, the speed of processing one DNS query packet is slower, the QPS of the DNS server is also lower, and the possibility that the DNS server cannot normally provide the domain name resolution service is increased.
In view of this, an embodiment of the present invention provides a message processing method, in which after receiving a first message, a message processing device stores the first message in a shared memory accessible to a first process in a user state, so that the first process can directly read the first message from the shared memory and perform message processing, and the first process does not need to copy the first message to a memory space accessible to the first process, thereby improving processing efficiency. And after the first process finishes processing the first message, the response message is stored in the shared memory, so that the first process does not need to switch the state again to copy the response message, the processing efficiency is also improved, the domain name resolution speed can be increased, and the QPS of the DNS server is improved.
The technical scheme provided by the embodiment of the invention is described below by combining the accompanying drawings.
Referring to fig. 2, an embodiment of the present invention provides a message processing method, where a flow of the method is described as follows:
in the embodiment of the present invention, the message processing device may be any device capable of sending, receiving, and processing a message, for example, the message processing device may be a DNS server. The message processing device may include a first thread, a message transceiving thread, and a shared memory, and of course, the first thread, the message transceiving thread, and the shared memory may not be provided in the message processing device. The following description will take as an example that the message processing device may include a first thread, a messaging thread, and a shared memory.
Step S201: the message processing equipment monitors the message received by the message receiving and sending process through the first process in the kernel state.
In the embodiment of the invention, when the message processing equipment does not receive the message, the message processing equipment can intercept the message through the first process in the message processing equipment. The message received by the message processing device is stored in the memory space which can be accessed by the process in the kernel mode, so if the first process is in the user mode and cannot intercept the message, the message processing device switches the first process from the user mode to the kernel mode when no message to be processed exists. Specifically, the message processing device may call the kernel through an Application Programming Interface (API) provided by an operating system in the message processing device through the first process, so as to switch to the kernel mode. The API may be, for example, a NETLINK interface.
In the embodiment of the present invention, when the message processing device is a DNS server, the first process may be a DNS process in the DNS server.
Step S202: the user equipment sends a first message to the message processing equipment, and the message processing equipment receives the first message through a message receiving and sending process.
When the user equipment needs to process the first message, the user equipment sends the first message to the message processing equipment, for example, when the user equipment needs to access a domain name, the user equipment sends a DNS query message to a DNS server to request DNS to query an IP address corresponding to the domain name, and then the user equipment can access according to the IP address. Correspondingly, the message processing device can receive the first message sent by the user equipment through the message transceiving process.
Step S203: the message processing device stores the first message into the shared memory through a message transceiving process.
After the message processing device receives the first message through the message transceiving process, the message processing device may store the received first message in the shared memory through the message transceiving process. The message transceiving process is a process which is always in a kernel state, that is, the message transceiving process runs in a kernel space of the message processing device, so that the message transceiving process can directly receive the first message and can store the first message in the shared memory. The shared memory is a part of memory space which is drawn in the memory of the message processing device in the embodiment of the invention, and the part of memory space is set as the memory space which can be accessed by the user-mode process.
In the embodiment of the present invention, when the message processing device is a DNS server, the message transceiving process may be a fast forwarding DNS process in the DNS server. The fast forwarding DNS process is used for receiving the message and forwarding the processed response message to the corresponding user equipment.
Step S204: the message processing equipment sends an indication message to the first process through the message receiving and sending process, and the message processing equipment receives the indication message through the first process.
After the message processing device stores the first message in the shared memory through the message transceiving process, the message transceiving process may send an indication message to the first process to inform the first process that the message transceiving process has received and stored the first message. There may be multiple messages received by the messaging device, so that the messaging process may send an indication message to the first process after each message is stored. Of course, to reduce the amount of interaction between the messaging process and the first process, the messaging process may send an indication message to the first process after storing the first message received, and then send no indication message for consecutively received messages. Accordingly, the message processing device may receive the indication message through the first process.
Specifically, the message transceiving process may send an indication message to the first process through an API provided by the operating system, for example, the NETLINK interface described above.
Step S205: the message processing equipment reads a first message from the shared memory through a first process.
Specifically, since the first process in the kernel state cannot process the first packet, after the packet processing device receives the indication message through the first process, the packet processing device first switches the first process from the kernel state to the user state.
After the message processing device switches the first process from the kernel mode to the user mode, the message processing device may read the first message from the shared memory through the first process. Because the data stored in the shared memory can be accessed by the first process in the user mode, the first process can directly read the first message from the shared memory, and the first message does not need to be copied into the memory space accessible by the first process to continue the subsequent processing.
In the embodiment of the present invention, in order to ensure that the messages stored in the shared memory can be sequentially processed according to the sequence, the data structure used for storing the messages in the shared memory is a lock-free data structure. Of course, other possible data structures capable of implementing a function that messages can be sequentially processed according to a sequence may also be adopted, which is not limited in this embodiment of the present invention. The messages can be sequentially processed according to the sequence, that is, when a first process reads the messages, the messages are read from the first message in the message queue stored in the shared memory, and after the first message is processed, the next message becomes the first message, and so on, that is, the messages read by the first process are always the first message in the message queue. And storing the message in the message transceiving process, and storing the newly received message at the rearmost of the message queue. The method is similar when the message transceiving process sends the response message, namely the message transceiving process reads the first response message in the response message queue and sends the first response message to the corresponding user equipment, and the first process stores the response message at the last of the response message queue when storing the response message.
Specifically, the lock-free data structure of the embodiment of the present invention can implement the above functions, and also can enable the reading of the message and the storing of the response message to be performed simultaneously, and does not need to add a data lock for data protection, so that it can be prevented that a thread is suspended when the message is read or the response message is stored, and further, the next message reading or the next response message storing cannot be continued, and thus, the speed of reading the message or storing the response message can be increased by using the lock-free data structure.
Step S206: the message processing equipment processes the first message through the first process and generates a response message according to a processing result.
In the embodiment of the present invention, after the message processing device reads the first message through the first process, the message processing device processes the first message through the first process, and generates the response message according to the processing result. For example, when the message processing device is a DNS server, after a DNS process in the DNS server reads the first message, the corresponding IP address is queried according to information included in the first message, and a response message is generated according to a query result.
Step S207: the message processing equipment stores the response message into the shared memory through the first process.
In the embodiment of the present invention, after the message processing device stores the response message in the shared memory through the first process, the message processing device may further determine whether a second message to be processed exists in the shared memory through the first process. If the message processing equipment determines that the second message to be processed exists in the shared memory through the first process, the message processing equipment continues to read and process the second message from the shared memory through the first process; if the message processing equipment determines that the shared memory does not have any second message to be processed through the first process, the message processing equipment switches the first process from the user mode to the kernel mode so as to continue to monitor the message through the first process in the kernel mode. After the first process finishes processing the first message, the first process does not need to switch to a kernel mode to send a response message, but stores the response message in the shared memory, so that the first process can process other messages stored in the shared memory without frequently switching states, and obviously, the time is saved. For example, when the message processing device is a DNS server, the DNS process in the DNS server may continuously process the DNS query message without frequently switching the state of the DNS process, so the speed of domain name resolution is obviously increased more, and correspondingly, the QPS of the DNS server is also correspondingly increased. Meanwhile, the QPS of the DNS server is not required to be promoted by investing more hardware resources in the prior art, so that the cost is saved, and the labor is saved.
Step S208: the message processing equipment sends a response indication message to the message transceiving process through the first process, and the message processing equipment receives the response indication message through the message transceiving process.
The message processing device stores the response message into the shared memory through the first process, and in order to enable the message transceiving process to forward the response message to the user equipment in time, the message processing device may send a response indication message to the message transceiving process through the first process through an API provided by the operating system to notify the message transceiving process that the first message has been processed by the first process and has been stored into the shared memory. The API may be, for example, the NETLINK interface described above.
Step S209: the message processing equipment reads the response message from the shared memory through the message transceiving process.
Step S210: the message processing equipment sends the response message to the user equipment through a message receiving and sending process.
In the embodiment of the invention, the message processing device can directly read the response message from the shared memory through the message transceiving process and send the response message to the corresponding user equipment, and does not need to switch the user mode into the kernel mode through the first process and then send the response message to the corresponding user equipment like the prior art.
In the embodiment of the present invention, to achieve further beneficial effects, step 208 to step S210 are added, and although shown together in the figure, execution of step S207 may achieve the beneficial effects of the present application, that is, the QPS of the DNS server is promoted while the workload is reduced.
In summary, in the embodiment of the present invention, after receiving the first message, the message processing device stores the first message in the shared memory accessible to the first process in the user state, so that the first process can directly read the first message from the shared memory and process the message, and does not need to copy the first message to the memory space accessible to the first process by the first process, thereby improving the processing efficiency. And after the first process finishes processing the first message, the response message is stored in the shared memory, so that the first process does not need to switch the state again to copy the response message, the processing efficiency is also improved, the domain name resolution speed can be increased, and the QPS of the DNS server is improved.
The following describes the apparatus provided by the embodiment of the present invention with reference to the drawings.
Referring to fig. 3, based on the same inventive concept, an embodiment of the present invention provides a message processing apparatus 30, including:
the interception unit 301 is configured to intercept, through a first process in the kernel state, a message received by a transceiving process;
a transceiving unit 302, configured to receive a first packet sent by a user equipment through a packet transceiving process, and store the first packet in a shared memory; the shared memory can be accessed by a first process in a user mode;
a reading unit 303, configured to switch, when the interception unit detects, through the first process in the kernel state, that the message transceiving process has received the first message, the first process from the kernel state to the user state, and read the first message from the shared memory through the first process;
a processing unit 304, configured to process the first packet through the first process, generate a response packet according to a processing result, and store the response packet in the shared memory through the first process.
Optionally, when the first process in the kernel state detects that the message transceiving process has received the first message, the reading unit switches the first process from the kernel state to the user state, including:
when the first process in the kernel state receives an indication message sent by a message transceiving process, the indication message is used for indicating the first process, and the message transceiving process receives the first message; the reading unit switches the first process from a kernel mode to a user mode.
Optionally, the transceiver unit 302 is further configured to: and after the response message is stored in the shared memory through the first process, the response message is sent to the user equipment through the message transceiving process.
Optionally, the apparatus further comprises a determining unit 305,
the determining unit 305 is configured to: after the processing unit 304 stores the response packet in the shared memory through the first process, determining whether a second packet to be processed exists in the shared memory through the first process;
the processing unit 304 is further configured to: if the determining unit 305 determines that the second packet to be processed exists in the shared memory, the second packet is read from the shared memory through the first process and processed;
the listening unit 301 is further configured to: if the determining unit 305 determines that the second message to be processed does not exist in the shared memory, the first process is switched from the user mode to the kernel mode, so that the first process in the kernel mode continues to listen to the message.
Optionally, the messages stored in the shared memory all adopt a lock-free data structure.
The apparatus may be used to perform the method provided by the embodiment shown in fig. 2. Therefore, for functions and the like that can be realized by each functional module of the device, reference may be made to the description of the embodiment shown in fig. 2, which is not repeated. The determination unit 305 is not an optional functional module, and is shown by a dotted line in fig. 3.
Referring to fig. 4, an embodiment of the present invention further provides a computer apparatus, which includes a processor 401, and the processor 401 is configured to implement the steps of the method for calculating an asynchronous time difference between audio and video according to the embodiment of the present invention when executing a computer program stored in a memory.
Optionally, the processor 401 may be specifically a central processing unit, an Application Specific Integrated Circuit (ASIC), one or more Integrated circuits for controlling program execution, a hardware Circuit developed by using a Field Programmable Gate Array (FPGA), or a baseband processor.
Optionally, the processor 401 may include at least one processing core.
Optionally, the computer apparatus further includes a Memory 402, where the Memory 402 may include a Read Only Memory (ROM), a Random Access Memory (RAM), and a disk Memory. The memory 402 is used for storing data required by the processor 401 in operation. The number of the memories 402 is one or more. The memory 402 is also shown in fig. 4, but it should be understood that the memory 402 is not an optional functional block, and is shown in fig. 4 by a dotted line.
In the embodiments of the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the described unit or division of units is only one division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical or other form.
The functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be an independent physical module.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the technical solutions of the embodiments of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device, such as a personal computer, a server, or a network device, or a processor (processor) to execute all or part of the steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a Universal Serial Bus flash drive (usb flash drive), a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, and an optical disk.
The above embodiments are only used to describe the technical solutions of the present application in detail, but the above embodiments are only used to help understanding the method of the embodiments of the present invention, and should not be construed as limiting the embodiments of the present invention. Variations or substitutions that may be readily apparent to one skilled in the art are intended to be included within the scope of the embodiments of the present invention.

Claims (12)

1. A message processing method is characterized by comprising the following steps:
the message processing equipment monitors a message received by a message receiving and sending process through a first process in a kernel state;
the message processing equipment receives a first message sent by user equipment through the message transceiving process and stores the first message into a shared memory; the shared memory can be accessed by a first process in a user mode;
when the first process in the kernel state monitors that the message transceiving process receives the first message, the message processing equipment switches the first process from the kernel state to the user state, and reads the first message from the shared memory through the first process;
the message processing device processes the first message through the first process, generates a response message according to a processing result, and stores the response message to the shared memory through the first process.
2. The method according to claim 1, wherein when the first process in the kernel mode detects that the messaging process has received the first message, the message processing device switches the first process from the kernel mode to the user mode, including:
the message processing device receives an indication message sent by the message transceiving process through the first process in the kernel state, wherein the indication message is used for indicating the first process, and the message transceiving process receives the first message;
and the message processing equipment switches the first process from a kernel mode to a user mode.
3. The method according to claim 1, wherein after the message processing device stores the reply message to the shared memory through the first process, further comprising:
and the message processing equipment sends the response message to the user equipment through the message transceiving process.
4. The method according to any one of claims 1 to 3, wherein after the message processing device stores the response message in the shared memory through the first process, the method further comprises:
the message processing equipment determines whether a second message to be processed exists in the shared memory through the first process;
if the second message to be processed exists in the shared memory, the message processing equipment reads and processes the second message from the shared memory through the first process; otherwise, the message processing device switches the first process from the user mode to the kernel mode, so as to continue to monitor the message through the first process in the kernel mode.
5. The method of claim 4, wherein messages stored in the shared memory all use a lock-free data structure.
6. A message processing apparatus, comprising:
the monitoring unit is used for monitoring the message received by the message receiving and sending process through the first process in the kernel state;
a receiving and sending unit, configured to receive a first packet sent by a user equipment through the packet receiving and sending process, and store the first packet in a shared memory; the shared memory can be accessed by a first process in a user mode;
a reading unit, configured to switch the first process from the kernel state to the user state when the first process in the kernel state monitors that the message transceiving process has received the first message, and read the first message from the shared memory through the first process;
and the processing unit is used for processing the first message through the first process, generating a response message according to a processing result, and storing the response message to the shared memory through the first process.
7. The apparatus according to claim 6, wherein when the first process in the kernel mode detects that the messaging process has received the first message, the reading unit switches the first process from the kernel mode to the user mode, including:
when the first process in the kernel state receives an indication message sent by the message transceiving process, the indication message is used for indicating the first process, and the message transceiving process receives the first message; and the reading unit switches the first process from a kernel mode to a user mode.
8. The apparatus of claim 6,
the transceiver unit is further configured to: and after the response message is stored in the shared memory through the first process, the response message is sent to the user equipment through the message transceiving process.
9. The apparatus according to any of claims 6-8, wherein the apparatus further comprises a determining unit,
the determination unit is configured to: after the processing unit stores the response message in the shared memory through the first process, determining whether a second message to be processed exists in the shared memory through the first process;
the processing unit is further to: if the determining unit determines that the shared memory has a second message to be processed, reading and processing the second message from the shared memory through the first process;
the interception unit is further configured to: if the determining unit determines that the second message to be processed does not exist in the shared memory, the first process is switched from the user mode to the kernel mode, so that the message is continuously intercepted through the first process in the kernel mode.
10. The apparatus of claim 9, wherein messages stored in the shared memory each employ a lock-free data structure.
11. A computer arrangement, characterized in that the arrangement comprises a processor for implementing the steps of the method according to any of claims 1-5 when executing a computer program stored in a memory.
12. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program realizing the steps of the method according to any of claims 1-5 when executed by a processor.
CN201710509548.2A 2017-06-28 2017-06-28 Message processing method and device Active CN107193673B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710509548.2A CN107193673B (en) 2017-06-28 2017-06-28 Message processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710509548.2A CN107193673B (en) 2017-06-28 2017-06-28 Message processing method and device

Publications (2)

Publication Number Publication Date
CN107193673A CN107193673A (en) 2017-09-22
CN107193673B true CN107193673B (en) 2020-05-26

Family

ID=59881499

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710509548.2A Active CN107193673B (en) 2017-06-28 2017-06-28 Message processing method and device

Country Status (1)

Country Link
CN (1) CN107193673B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234481B (en) * 2017-12-29 2020-10-30 上海品顺信息科技有限公司 Method for controlling multi-machine distributed access to external system and distributed system
CN110149262B (en) * 2019-04-02 2021-03-12 视联动力信息技术股份有限公司 Method and device for processing signaling message and storage medium
CN110635569A (en) * 2019-09-24 2019-12-31 南京智联达科技有限公司 Power distribution terminal design architecture and method based on Linux
CN112995753B (en) * 2019-12-16 2024-03-22 中兴通讯股份有限公司 Media stream distribution method, CDN node server, CDN system and readable storage medium
CN113760560A (en) * 2020-06-05 2021-12-07 华为技术有限公司 Inter-process communication method and inter-process communication device
CN112104572B (en) * 2020-09-11 2023-02-07 北京天融信网络安全技术有限公司 Data processing method and device, electronic equipment and storage medium
CN113612773B (en) * 2021-08-03 2023-06-16 厦门至恒融兴信息技术股份有限公司 Intelligent message identification and analysis system and method realized by artificial intelligence
CN116414572A (en) * 2021-12-29 2023-07-11 华为技术有限公司 Flow management device, message caching method, chip and network equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103942149A (en) * 2014-03-27 2014-07-23 汉柏科技有限公司 User mode application and kernel message interaction method and system
CN104796337A (en) * 2015-04-10 2015-07-22 京信通信系统(广州)有限公司 Method and device for forwarding message
CN105656808A (en) * 2015-12-29 2016-06-08 京信通信技术(广州)有限公司 Message processing method and system thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103942149A (en) * 2014-03-27 2014-07-23 汉柏科技有限公司 User mode application and kernel message interaction method and system
CN104796337A (en) * 2015-04-10 2015-07-22 京信通信系统(广州)有限公司 Method and device for forwarding message
CN105656808A (en) * 2015-12-29 2016-06-08 京信通信技术(广州)有限公司 Message processing method and system thereof

Also Published As

Publication number Publication date
CN107193673A (en) 2017-09-22

Similar Documents

Publication Publication Date Title
CN107193673B (en) Message processing method and device
CN107678835B (en) Data transmission method and system
CN112333298B (en) Message transmission method and device, computer equipment and storage medium
CN108933829A (en) A kind of load-balancing method and device
US20200167186A1 (en) Container isolation method and apparatus for netlink resource
CN112087401B (en) Method and device for realizing service quality in distributed storage
CN111857992B (en) Method and device for allocating linear resources in Radosgw module
WO2023103419A1 (en) Message queue-based method and apparatus for sending 5g messages in batches, and electronic device
CN112311907A (en) ARP request response method, load balancing equipment and related device
WO2014183417A1 (en) Method, device, and system for memory management
CN105592134B (en) A kind of method and apparatus of load balancing
CN110399329B (en) RDMA data processing method and related device
WO2018000195A1 (en) Packet transmission method, virtual switch, and server
CN105635138B (en) A kind of method and apparatus for preventing ARP from attacking
US20220269411A1 (en) Systems and methods for scalable shared memory among networked devices comprising ip addressable memory blocks
CN114218317B (en) Progress information management and control method, micro-service device, electronic equipment and storage medium
CN112511440B (en) Message forwarding method, system, storage medium and electronic equipment
CN110046040B (en) Distributed task processing method and system and storage medium
CN107231339B (en) Method and device for detecting DDoS attack
US11271897B2 (en) Electronic apparatus for providing fast packet forwarding with reference to additional network address translation table
CN109391707B (en) Domain name resolution method, device, equipment and storage medium
CN105072047A (en) Message transmitting and processing method
CN112433820A (en) Method and system for acquiring IP (Internet protocol) of virtual machine host
CN110753043A (en) Communication method, device, server and medium
CN113114737B (en) Information sending method and device and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant