WO2018094743A1 - Method for processing packet, and computer device - Google Patents

Method for processing packet, and computer device Download PDF

Info

Publication number
WO2018094743A1
WO2018094743A1 PCT/CN2016/107521 CN2016107521W WO2018094743A1 WO 2018094743 A1 WO2018094743 A1 WO 2018094743A1 CN 2016107521 W CN2016107521 W CN 2016107521W WO 2018094743 A1 WO2018094743 A1 WO 2018094743A1
Authority
WO
WIPO (PCT)
Prior art keywords
port number
service
network card
processor core
mapping relationship
Prior art date
Application number
PCT/CN2016/107521
Other languages
French (fr)
Chinese (zh)
Inventor
张丰伟
徐君
戴芬
王元钢
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2016/107521 priority Critical patent/WO2018094743A1/en
Priority to CN201680004271.1A priority patent/CN108377671B/en
Publication of WO2018094743A1 publication Critical patent/WO2018094743A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/30Peripheral units, e.g. input or output ports
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/64Hybrid switching systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/25Routing or path finding in a switch fabric
    • H04L49/253Routing or path finding in a switch fabric using establishment or release of connections between ports

Definitions

  • the present invention relates to the field of information technology and, more particularly, to a method and computer apparatus for processing a message.
  • the NIC is moving toward intelligence, it has provided routing functions based on the specified field in the message network header, and has brought significant performance improvements.
  • the NIC When the NIC is initialized, it specifies the number of queues used by the NIC and gives each queue an index. When the NIC receives the packet, it forwards the packet to the queue of the specified index according to the forwarding flow table.
  • the field field of the general forwarding flow table includes the source Internet Protocol (IP) and destination IP, the source port number and the destination port number, and the mask and matching fields, and the action field after the hit.
  • IP Internet Protocol
  • the Action can be: "Direct to queue i", where i is the index of the queue queue.
  • the port number used can be any port number in the port range (for example, 0-65535).
  • the number of entries in the forwarding flow table is much smaller than the number of port numbers. Therefore, if any port number is used, the NIC may not be able to match the corresponding entry when forwarding the packet to the receiving queue, which may affect the forwarding efficiency of the packet.
  • the embodiment of the invention provides a method and a computer device for processing a message, which can improve the forwarding efficiency of the message.
  • a method for processing a message including:
  • mapping relationship information includes a mapping relationship between the processor core identifier and the port number
  • a method for processing a message according to an embodiment of the present invention by binding a service to a processor core identifier, and The port number corresponding to the service is determined according to the port number, and the to-be-sent packet of the service is processed according to the port number, so that the network card can forward the to-be-received packet of the service to the corresponding network card queue according to the port number, thereby improving the packet. Forwarding efficiency.
  • the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
  • the mapping relationship between the processor core identifier, the network card receiving queue, and the port number may be a mapping relationship between the processor core identifier and the network card receiving queue, and a mapping relationship between the network card receiving queue and the port number.
  • each processor core identifier corresponds to a plurality of port numbers.
  • one processor core identifier may correspond to multiple network card queues, and one network card queue may correspond to multiple port numbers.
  • determining the first local port number includes:
  • the first local port number is selected from a plurality of port numbers corresponding to the first processor core identifier.
  • the method further includes:
  • the method further includes:
  • the to-be-sent message includes a link request message of the client
  • the method further includes:
  • the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
  • the to-be-sent message includes a server-side link accepting message
  • the method further includes:
  • the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
  • the network card may forward the packet to the specified network card queue according to the forwarding flow table.
  • the forwarding flow table may be generated according to the mapping relationship information.
  • the network card may forward the to-be-received packet of the service to the corresponding receiving queue according to the first local port number, so that the packet can be effectively forwarded.
  • the port number includes a TCP or UDP port number.
  • a method for processing a message including:
  • mapping relationship information includes a mapping relationship between the processor core identifier and the port number
  • the method for processing a message in the embodiment of the present invention by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, Both the service and the protocol stack correspond to the same processor core, thereby improving the processing efficiency of the service packets.
  • the method further includes:
  • the listening port number is a UDP port number.
  • a host comprising a module that performs the method of the first aspect or any possible implementation of the first aspect, or the method of any of the possible implementations of the second aspect or the second aspect Module.
  • a host including a processor and a memory, the memory is for storing an instruction, the processor is configured to execute the instruction, and when the processor executes the instruction stored by the memory, the executing causes the processor Performing the first aspect or any possible implementation of the first aspect, or the method of the second aspect or any possible implementation of the second aspect.
  • a computer device including:
  • a host configured to obtain a first processor core identifier of the service binding, and determine, according to the first processor core identifier and the configured mapping relationship information, a first local port number corresponding to the service, where the mapping relationship information includes The mapping between the processor core identifier and the port number, the first local port number is written in the source port number field of the to-be-sent packet of the service, and the to-be-sent packet is sent to the network card sending queue;
  • the network card is configured to send the to-be-sent packet in the sending queue of the network card.
  • the computer device of the embodiment of the present invention binds the service to the processor core identifier, and determines the port number corresponding to the service according to the port number, and processes the to-be-sent packet of the service according to the port number, so that the network card can be made according to the port number.
  • the packets to be received of the service are forwarded to the corresponding network card queue, so that the forwarding efficiency of the packets can be improved.
  • the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
  • each processor core identifier corresponds to a plurality of port numbers.
  • the host is specifically configured to select the first local port number from the plurality of port numbers corresponding to the first processor core identifier.
  • the host is further configured to configure the mapping relationship information.
  • the network card is further configured to receive a to-be-received packet of the service, where the destination port number in the to-be-received packet is the first local port number, and the to-be-received according to the destination port number.
  • the packet is forwarded to the network card receiving queue corresponding to the first local port number;
  • the host is further configured to obtain the to-be-received packet from the network card receiving queue corresponding to the first local port number.
  • the computer device is a client device, and the to-be-sent message includes a link request message;
  • the host is further configured to bind the service to the first processor core identity.
  • the computer device is a server, and the to-be-sent message includes a link accept message;
  • the host is further configured to bind the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
  • the network card is further configured to receive a link request message of the service, where the destination port number in the link request message is the listening port number, and forward the to-be-received message to the corresponding listening port number according to the destination port number.
  • NIC receiving queue
  • the host is further configured to obtain the link request message from the network card receiving queue corresponding to the listening port number.
  • a computer device comprising:
  • the host is configured to bind the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number,
  • the first network card receiving queue obtains the to-be-received message of the service, where the first network card receiving queue is the network card receiving queue corresponding to the first processor core identifier;
  • the network card is configured to receive the to-be-received packet, and the destination port number in the to-be-received packet is the listening port number, and the to-be-received packet is forwarded to the first network card receiving queue according to the destination port number.
  • the computer device of the embodiment of the present invention by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, the service and the protocol can be implemented.
  • the stacks all correspond to the same processor core, thereby improving the processing efficiency of the service packets.
  • the host is further configured to: write the listening port number into a source port number field of the to-be-sent packet of the service, and send the to-be-sent packet to the network card sending queue;
  • the network card is further configured to send the to-be-sent packet in the network card sending queue.
  • the computer device is a server.
  • the listening port number is a UDP port number.
  • a computer apparatus comprising the host of the third aspect or the fourth aspect, and a network card.
  • a computer readable medium for storing a computer program, the computer program comprising any of the possible implementations of the first aspect or the first aspect, or the second or second aspect The instructions of the method in any of the possible implementations.
  • FIG. 1 is a schematic diagram of a computer device to which the technical solution of the embodiment of the present invention is applied.
  • FIG. 2 is a schematic diagram of a mapping relationship between a processor core identifier, a network card queue, and a port number according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a method for processing a message according to an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a method for processing a message according to another embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
  • FIG. 6 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
  • FIG. 7 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
  • FIG. 8 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
  • FIG. 9 is a schematic block diagram of a computer device in accordance with an embodiment of the present invention.
  • FIG. 1 is a schematic diagram of a computer device to which the technical solution of the embodiment of the present invention is applied.
  • computer device 100 can include a processor 111, a memory 112, and a network card 120.
  • Host 110 e.g., an application in host 110
  • Processor 111 can include multiple processor cores (Cores).
  • Memory 112 can include memory and other memory.
  • the network card 120 supports multiple network card queues, which may also be referred to as queues.
  • the queue includes a send queue and a receive queue.
  • the queue of network card 120 can be configured in memory 112, such as in memory.
  • the network card 120 can obtain the message to be sent from the sending queue or forward the message received by the network card to the receiving queue based on the address of the queue.
  • the network card 120 may forward the packet to the designated network card queue according to the destination IP and the mask and the matching domain of the packet in the packet network header.
  • the network card 120 can forward the message to the designated network card queue according to the forwarding flow table.
  • the forwarding flow table may be configured in the network card 120 or in a memory accessible by the network card 120.
  • a mapping relationship is configured between a processor core identifier (CoreID), a network card queue, and a port number.
  • the forwarding flow table can be generated according to the mapping relationship.
  • FIG. 2 shows a schematic diagram of a mapping relationship between a processor core identifier, a network card queue, and a port number.
  • each network card queue and processor core identifier correspond to multiple port numbers. These multiple port numbers can also be referred to as NIC queues or port resource pools identified by the processor core.
  • the correspondence between the network card queue and the processor core identifier may be one-to-one or not one-to-one, which is not limited by the embodiment of the present invention.
  • the embodiment of the present invention maps the processor core identifier, the network card queue, and the port number.
  • the specific form of the system is not limited. It can be expressed as a mapping relationship between the three, or a mapping relationship between the two. For example, the mapping between the processor core identifier and the NIC queue can be performed. And the mapping relationship between the NIC queue and the port number.
  • the service is bound to the CoreID, so that the port number corresponding to the service can be determined according to the binding relationship.
  • the port number determined in this way can be matched to a specific network card queue, so that the network card can forward packets, which can improve the forwarding efficiency of packets.
  • the service in the embodiment of the present invention may be a Transmission Control Protocol (TCP)/User Data Protocol (UDP) service, and the port number may be a TCP/UDP port number, but the present invention is implemented. This example is not limited to this.
  • FIG. 3 is a schematic flowchart of a method 300 for processing a message according to an embodiment of the present invention.
  • the method 300 can be performed by a host.
  • the host can be a host in the client device or a host in the server.
  • the to-be-sent message of the service may be a link request message and a data message after the link is established;
  • the service-to-send message may be a link-received message and a link-established data message.
  • the link request message may be a message sent by the client to the server for requesting to establish a communication connection with the server.
  • the connection accepting message may be a message sent by the server to the client for establishing a communication connection with the client.
  • the service is bound to the CoreID.
  • the subsequent port number of the service can be determined according to the bound CoreID, and then the packet of the service is processed.
  • the service can be bound to the CoreID before the link class socket (Socket) associated with the service is created; for the server, before or after the listener socket associated with the service is created This service is bundled with CoreID.
  • Socket link class socket
  • the local port number corresponding to the service (represented as the first local port number) may be selected.
  • the first local port number is also the port number of the Socket associated with the service, that is, subsequent packets of the Socket can be transmitted according to the first local port number.
  • the first local port number may be determined according to the first processor core identifier and the configured mapping relationship information.
  • the port number corresponding to the first processor core identifier may be selected as the first local port number according to the configured mapping relationship information.
  • mapping relationship information may be pre-configured in a memory.
  • the mapping relationship information can be obtained by an application in the host.
  • the mapping relationship information may include a mapping relationship between the processor core identifier and the port number.
  • the mapping relationship information may include a mapping relationship between the processor core identifier, the network card receiving queue, and the port number.
  • the mapping relationship information may include a mapping relationship between the processor core identifier and the network card receiving queue, and a mapping relationship between the network card receiving queue and the port number.
  • each processor core identifier can correspond to multiple port numbers.
  • the mapping relationship information may include a mapping relationship as shown in FIG. 2.
  • mapping relationship information does not limit the specific form and content of the mapping relationship information, that is, the mapping relationship information may also adopt other mapping relationships.
  • the first local port number may be selected from multiple port numbers corresponding to the first processor core identifier.
  • the first local port number is the source port number of the to-be-sent packet of the service, and is the destination port number of the to-be-received packet of the service.
  • the host may write the first local port number to the source port number field of the to-be-sent packet, and send the to-be-sent packet to the network card sending queue.
  • the network card sends the to-be-sent packet in the NIC sending queue.
  • the host may obtain the to-be-received packet of the service from the network card receiving queue corresponding to the first local port number, where the to-be-received packet is determined by the network card.
  • the destination port number in the to-be-received packet is forwarded to the network card receiving queue corresponding to the first local port number.
  • the source port number of the to-be-sent packet of the service is the first local port number
  • the destination port number in the to-be-received packet of the service is the first local port number.
  • the network card can forward the to-be-received packet to the network card receiving queue corresponding to the first local port number according to the destination port number in the to-be-received packet, and the host can receive the queue from the network card corresponding to the first local port number. Obtain the pending message of the service.
  • the forwarding flow table of the network card may be configured based on the mapping relationship information described above. For example, multiple port numbers correspond to one NIC queue. Based on the range of the port number, you can calculate the mask and matching field of the forwarding flow table entry. For example, if a port number range is: 1024-2047; then the segmentation The mask is: 0100-0000-0000(1024)->0111-1111-1111 (2047). Therefore, the matching field of the corresponding forwarding flow table entry can be calculated as 0100-0000-0000, and the mask is 0111-1111-1111.
  • the all-matching entry may also be set. When all the entries in the forwarding flow table do not match, the entry is finally matched.
  • the method for processing a message according to the embodiment of the present invention is to bind the service to the processor core identifier, and determine the port number corresponding to the service according to the port number, and process the to-be-sent packet of the service according to the port number, so that the network card can be
  • the port number forwards the to-be-received packet of the service to the corresponding network card queue, thereby improving the forwarding efficiency of the packet.
  • the to-be-sent message includes a link request message of the client.
  • the method 300 may further include:
  • the service is bound to a CoreID, ie, the service is bound to the processor core (Core) of the process running the service.
  • Core processor core
  • the local port number corresponding to the service that is, the Socket port number
  • the link request message is transmitted according to the local port number corresponding to the service.
  • the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
  • FIG. 5 is a schematic diagram of a processing flow of a client shown from the perspective of a software module.
  • the application creates a link class Socket.
  • An app can also be called an app.
  • the application in the client needs to create a link class Socket when it needs to obtain the service, that is, it needs to communicate with the application in the server.
  • the application calls the application programming interface (API) provided by the operating system to create a TCP-linked Socket.
  • API application programming interface
  • the TCP/UDP protocol stack module determines whether the service is bound to the Core.
  • the TCP/UDP protocol stack module is a module for processing TCP/UDP protocol stacks. It should be understood that since the application, the application's process, or the thread all correspond to the service, the service and Core binding may also be an application, an application's process, or a thread bound to the Core. For example, the TCP/UDP protocol stack module queries the CoreID of the service binding through an API provided by the operating system. If the corresponding CoreID is queried, step 505 is performed, otherwise step 503 is performed.
  • the TCP/UDP protocol stack module feeds back to the application and needs to bind the Core.
  • the TCP/UDP protocol stack module needs to bind a Core by feeding back error information to the application.
  • the application binds the service to a Core.
  • the TCP/UDP protocol stack module notifies the Flow-Director management module to obtain the port number.
  • the flow-director management module may be configured to configure a network card queue, mapping relationship information, and the like.
  • the TCP/UDP protocol stack module informs the Flow-Director management module of the CoreID of the service module binding, and notifies the Flow-Director management module to obtain the Socket port number, that is, the port number corresponding to the service.
  • the Flow-Director management module acquires a port number according to the bound CoreID and the mapping relationship information.
  • the Flow-Director management module obtains the Socket port number according to the binding CoreID and the mapping relationship between the preset CoreID, the NIC queue, and the port number.
  • the TCP/UDP protocol stack module processes the link request message according to the port number.
  • the TCP/UDP protocol stack module writes the port number to the source port number field of the link request message, and sends the link request message to the network card send queue.
  • the port number is used as the destination port number, so that the NIC of the client can forward the packet to the corresponding receiving queue according to the destination port number, so that the packet can be effectively forwarded.
  • the to-be-sent message includes a server-side link accept message.
  • the method 300 may further include:
  • the server side listens for the link request, it needs to create a listener class Socket associated with the service, where the listening port number is a port number known by the client. That is, the listening port number is the destination port number when the client sends the link request message.
  • the server binds the service to the CoreID according to the listening port number. For example, the service is bound to the CoreID according to the listening port number and the configured mapping relationship information.
  • the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
  • the server can also know the network card receiving queue corresponding to the link request message.
  • the network card of the server side forwards the link request message to the corresponding network card receiving queue according to the destination port number in the link request message, that is, the listening port number.
  • the host on the server side can obtain the link request message from the network card receiving queue corresponding to the listening port number.
  • the server end After obtaining the link request message and accepting the link request, the server end sends a link acceptance message and a data message to the client.
  • the server side needs to determine the next transmission port number, that is, the first local port number described above.
  • the server may determine the first local port number according to the CoreID bound to the service, and then transmit the link acceptance message and the subsequent data packet according to the first local port number.
  • Fig. 7 is a schematic diagram showing the processing flow of the server side from the perspective of a software module.
  • the application creates a listener class Socket.
  • the application calls the API provided by the operating system to create a listener class Socket.
  • the TCP/UDP protocol stack module obtains a CoreID that the service should be bound to the Flow-Director management module.
  • the TCP/UDP protocol stack module passes the listening port number to the Flow-Director management module to obtain the CoreID that the service should bind.
  • the Flow-Director management module acquires a corresponding CoreID according to the listening port number.
  • the Flow-Director management module obtains the corresponding CoreID according to the listening port number and the preset mapping relationship information, that is, the CoreID to which the service should be bound, and feeds back to the TCP/UDP protocol stack module.
  • the TCP/UDP protocol stack module determines whether the service is bound to the Core.
  • the TCP/UDP protocol stack module queries whether the CoreID of the service binding is empty (no binding) through the API provided by the operating system. If it is empty, execute 705, otherwise execute 706.
  • the TCP/UDP protocol stack module binds the service to the Core fed back by the Flow-Director management module.
  • the TCP/UDP protocol stack module feeds back the CoreID that should be bound to the application.
  • the application binds or exits the current process.
  • the TCP/UDP protocol stack module notifies the Flow-director management module to obtain a data transmission port number.
  • the TCP/UDP protocol stack module When a client actively links to the server, and the server accepts the link request, the TCP/UDP protocol stack module notifies the FlowID of the Flow-director management module service binding to obtain the data transmission port number.
  • the flow-director management module returns a port number corresponding to the CoreID according to the bound CoreID and the preset mapping relationship information.
  • the TCP/UDP protocol stack module processes the packet of the service according to the port number.
  • the TCP/UDP protocol stack module processes the link acceptance message and the subsequent data message according to the port number. For example, the TCP/UDP protocol stack module writes the port number to the source port number field of the message and sends the message to the network card send queue.
  • the port number is used as the destination port number, so that the network card of the server can forward the packet to the corresponding receiving queue according to the destination port number, so that the packet can be reported.
  • the effective forwarding of the text is used as the destination port number, so that the network card of the server can forward the packet to the corresponding receiving queue according to the destination port number, so that the packet can be reported.
  • the transmission port number that is, the first local port number described above, may be no longer selected, but the listening port number is always used. This case will be described below.
  • FIG. 8 is a schematic flowchart of a method 800 for processing a message according to another embodiment of the present invention.
  • the method 800 can be performed by a host.
  • This host can be a host in the server.
  • the listening port number is the port number known to the client.
  • the server can bind the service to the CoreID according to the listening port number.
  • the service may be bound to the first processor core identifier according to the listening port number and the configured mapping relationship information.
  • mapping relationship information refer to the foregoing embodiment, and for brevity, no further details are provided herein.
  • the server can obtain the to-be-received packet of the service, that is, the network card receiving queue corresponding to the request packet sent by the client.
  • the NIC of the server forwards the request packet to the corresponding network card receiving queue according to the destination port number in the request packet, that is, the listening port number, that is, the first network card receiving queue.
  • the host on the server side can obtain the to-be-received packet from the first NIC receiving queue.
  • the server may further send a to-be-sent packet of the service according to the listening port number, that is, send a response packet of the service to the client.
  • the host on the server side can write the listening port number to the source port number field of the to-be-sent packet of the service; and send the to-be-sent packet to the network card sending queue.
  • the network card sends the to-be-sent packet in the NIC sending queue.
  • the method for processing a message in the embodiment of the present invention by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, Both the service and the protocol stack correspond to the same processor core, thereby improving the processing efficiency of the service packets.
  • the size of the sequence numbers of the above processes does not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not be taken to the embodiments of the present invention.
  • the implementation process constitutes any limitation.
  • a method of processing a message according to an embodiment of the present invention is described in detail above, and a computer device according to an embodiment of the present invention will be described below.
  • FIG. 9 shows a schematic block diagram of a computer device 900 in accordance with an embodiment of the present invention.
  • the computer device 900 can include a host 910 and a network card 920.
  • the host 910 is configured to obtain a first processor core identifier of the service binding, and the configured mapping relationship information, and determine, according to the first processor core identifier, a first local port number corresponding to the service, where the mapping relationship information is The mapping between the processor core identifier and the port number is performed, and the first local port number is written into the source port number field of the to-be-sent packet of the service, and the to-be-sent packet is sent to the network card sending queue.
  • the network card 920 is configured to send the to-be-sent packet in the network card sending queue.
  • the computer device of the embodiment of the present invention binds the service to the processor core identifier, and accordingly The port number corresponding to the service is determined, and the to-be-sent packet of the service is processed according to the port number, so that the network card can forward the to-be-received packet of the service to the corresponding network card queue according to the port number, thereby improving the forwarding efficiency of the packet. .
  • the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
  • each processor core identifier corresponds to a plurality of port numbers.
  • the host 910 is specifically configured to select the first local port number from the plurality of port numbers corresponding to the first processor core identifier.
  • the host 910 is further configured to: configure the mapping relationship information.
  • the network card 920 is further configured to receive a to-be-received packet of the service, where the destination port number in the to-be-received packet is the first local port number, according to the destination port. No. forwarding the to-be-received packet to the network card receiving queue corresponding to the first local port number;
  • the host 910 is further configured to obtain the to-be-received packet from the network card receiving queue corresponding to the first local port number.
  • the computer device 900 is a client device, and the to-be-sent message includes a link request message;
  • the host 910 is further configured to bind the service to the first processor core identifier.
  • the computer device 900 is a server, and the to-be-sent message includes a link accepting message;
  • the host 910 is further configured to bind the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
  • the network card 920 is further configured to: receive a link request message of the service, where the destination port number in the link request message is the listening port number, and forward the to-be-received message to the listening port number according to the destination port number.
  • Network card receiving queue
  • the host 910 is further configured to obtain the link request message from the network card receiving queue corresponding to the listening port number.
  • the host 910 is configured to bind the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a processor.
  • the mapping between the core identifier and the port number, the packet to be received of the service is obtained from the first network card receiving queue, where the first network card receiving queue is the first processor core identifier pair The appropriate network card receiving queue;
  • the network card 920 is configured to receive the to-be-received packet, and the destination port number in the to-be-received packet is the listening port number, and forward the to-be-received packet to the first network card receiving queue according to the destination port number.
  • the computer device of the embodiment of the present invention by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, the service and the protocol can be implemented.
  • the stacks all correspond to the same processor core, thereby improving the processing efficiency of the service packets.
  • the host 910 is further configured to: write the listening port number to a source port number field of the to-be-sent packet of the service, and send the to-be-sent packet to the network card sending queue;
  • the network card 920 is further configured to send the to-be-sent packet in the network card sending queue.
  • host 910 can include a processor and a memory.
  • the memory is for storing a program
  • the processor is for executing a program for performing the method in the foregoing embodiments of the present invention.
  • the term "and/or” is merely an association relationship describing an associated object, indicating that there may be three relationships.
  • a and/or B may indicate that A exists separately, and A and B exist simultaneously, and B cases exist alone.
  • the character "/" in this article generally indicates that the contextual object is an "or" relationship.
  • the disclosed systems, devices, and methods may be implemented in other manners.
  • the device embodiments described above are merely illustrative
  • the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some features may be Ignore, or not execute.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, or an electrical, mechanical or other form of connection.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the technical solution of the present invention contributes in essence or to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

Disclosed in an embodiment of the present invention are a method for processing a packet, and a computer device. The method comprises: acquiring a first processor core identifier to which a service is bound; determining, according to the first processor core identifier and configured mapping relationship information, a first local port number corresponding to the service, wherein the mapping relationship information comprises a mapping relationship between the processor core identifier and the port number; writing the first local port number to a source port number segment in a packet of the service to be transmitted; and transmitting the packet to be transmitted to a transmit queue of a network card. The method for processing a packet and the computer device disclosed in the embodiment of the present invention can increase packet forwarding efficiency.

Description

处理报文的方法和计算机设备Method and computer device for processing messages 技术领域Technical field
本发明涉及信息技术领域,并且更具体地,涉及一种处理报文的方法和计算机设备。The present invention relates to the field of information technology and, more particularly, to a method and computer apparatus for processing a message.
背景技术Background technique
现在网卡朝着智能化发展,已经提供了基于报文网络头中指定字段域的路由功能,并带来了显著的性能提升。Now that the NIC is moving toward intelligence, it has provided routing functions based on the specified field in the message network header, and has brought significant performance improvements.
在网卡初始化时,会指定网卡使用的队列(queue)数目,并给每个队列一个索引。当网卡收到报文时,按照转发流表将报文转发到指定索引的队列。一般转发流表的字段域,包括源网际协议(Internet Protocol,IP)和目的IP,源端口号和目标端口号等掩码和匹配字段,以及命中后的动作(Action)字段。例如,Action可以为:“Direct to queue i”,其中i为队列queue的索引。When the NIC is initialized, it specifies the number of queues used by the NIC and gives each queue an index. When the NIC receives the packet, it forwards the packet to the queue of the specified index according to the forwarding flow table. The field field of the general forwarding flow table includes the source Internet Protocol (IP) and destination IP, the source port number and the destination port number, and the mask and matching fields, and the action field after the hit. For example, the Action can be: "Direct to queue i", where i is the index of the queue queue.
客户端和服务器端在发送报文时,采用的端口号可以是端口范围(例如,0-65535)中的任一端口号。然而,由于受限于介质和功耗,转发流表的项数远小于端口号数量。因此,若采用任一端口号,网卡在将报文转发到接收队列时,可能会无法匹配到相应表项,从而会导致影响报文的转发效率。When the client and server send a packet, the port number used can be any port number in the port range (for example, 0-65535). However, due to media and power consumption, the number of entries in the forwarding flow table is much smaller than the number of port numbers. Therefore, if any port number is used, the NIC may not be able to match the corresponding entry when forwarding the packet to the receiving queue, which may affect the forwarding efficiency of the packet.
发明内容Summary of the invention
本发明实施例提供了一种处理报文的方法和计算机设备,能够提高报文的转发效率。The embodiment of the invention provides a method and a computer device for processing a message, which can improve the forwarding efficiency of the message.
第一方面,提供了一种处理报文的方法,包括:In a first aspect, a method for processing a message is provided, including:
获取服务绑定的第一处理器核标识;Obtaining a first processor core identifier of the service binding;
根据该第一处理器核标识,以及配置的映射关系信息,确定该服务对应的第一本地端口号,其中,该映射关系信息包括处理器核标识和端口号的映射关系;Determining, according to the first processor core identifier, and the configured mapping relationship information, a first local port number corresponding to the service, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number;
将该第一本地端口号写入该服务的待发送报文的源端口号字段;Writing the first local port number to the source port number field of the to-be-sent packet of the service;
将该待发送报文发送到网卡发送队列。Send the to-be-sent message to the network card sending queue.
本发明实施例的处理报文的方法,通过将服务与处理器核标识绑定,并 依此确定该服务对应的端口号,根据该端口号处理该服务的待发送报文,可以使网卡根据该端口号转发该服务的待接收报文到相应的网卡队列,从而能够提高报文的转发效率。A method for processing a message according to an embodiment of the present invention, by binding a service to a processor core identifier, and The port number corresponding to the service is determined according to the port number, and the to-be-sent packet of the service is processed according to the port number, so that the network card can forward the to-be-received packet of the service to the corresponding network card queue according to the port number, thereby improving the packet. Forwarding efficiency.
在一些可能的实现方式中,该映射关系信息包括处理器核标识、网卡接收队列和端口号的映射关系。In some possible implementation manners, the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
在一些可能的实现方式中,处理器核标识、网卡接收队列和端口号的映射关系可以是处理器核标识和网卡接收队列的映射关系,以及网卡接收队列和端口号的映射关系。In some possible implementation manners, the mapping relationship between the processor core identifier, the network card receiving queue, and the port number may be a mapping relationship between the processor core identifier and the network card receiving queue, and a mapping relationship between the network card receiving queue and the port number.
在一些可能的实现方式中,每个处理器核标识对应多个端口号。In some possible implementations, each processor core identifier corresponds to a plurality of port numbers.
在一些可能的实现方式中,一个处理器核标识可以对应多个网卡队列,一个网卡队列可以对应多个端口号。In some possible implementations, one processor core identifier may correspond to multiple network card queues, and one network card queue may correspond to multiple port numbers.
在一些可能的实现方式中,确定该第一本地端口号,包括:In some possible implementations, determining the first local port number includes:
从该第一处理器核标识对应的多个端口号中,选择该第一本地端口号。The first local port number is selected from a plurality of port numbers corresponding to the first processor core identifier.
在一些可能的实现方式中,该方法还包括:In some possible implementations, the method further includes:
配置该映射关系信息。Configure the mapping relationship information.
在一些可能的实现方式中,该方法还包括:In some possible implementations, the method further includes:
从该第一本地端口号对应的网卡接收队列中获取该服务的待接收报文,其中,该待接收报文由网卡根据该待接收报文中的目的端口号转发到该第一本地端口号对应的网卡接收队列。Obtaining a to-be-received packet of the service from the network card receiving queue corresponding to the first local port number, wherein the to-be-received packet is forwarded by the network card to the first local port number according to the destination port number in the to-be-received packet The corresponding network card receiving queue.
在一些可能的实现方式中,该待发送报文包括客户端的链接请求报文;In some possible implementation manners, the to-be-sent message includes a link request message of the client;
在该获取服务绑定的第一处理器核标识之前,该方法还包括:Before the obtaining the first processor core identifier of the service binding, the method further includes:
将该服务与该第一处理器核标识绑定。Binding the service to the first processor core identity.
通过将服务与处理器核标识绑定,可以预先获知服务对应的处理器核,从而可以将服务和协议栈都对应到同一处理器核上,进而提高对服务的报文的处理效率。By binding the service to the processor core identifier, the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
在一些可能的实现方式中,该待发送报文包括服务器端的链接接受报文;In some possible implementation manners, the to-be-sent message includes a server-side link accepting message;
在该获取服务绑定的第一处理器核标识之前,该方法还包括:Before the obtaining the first processor core identifier of the service binding, the method further includes:
根据该服务的监听端口号,以及该映射关系信息,将该服务与该第一处理器核标识绑定;Binding the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
从该监听端口号对应的网卡接收队列中获取该服务的链接请求报文。 Obtaining a link request message of the service from the network card receiving queue corresponding to the listening port number.
通过将服务与处理器核标识绑定,可以预先获知服务对应的处理器核,从而可以将服务和协议栈都对应到同一处理器核上,进而提高对服务的报文的处理效率。By binding the service to the processor core identifier, the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
在一些可能的实现方式中,网卡可以根据转发流表转发报文到指定网卡队列。In some possible implementation manners, the network card may forward the packet to the specified network card queue according to the forwarding flow table.
在一些可能的实现方式中,转发流表可以根据该映射关系信息生成。In some possible implementation manners, the forwarding flow table may be generated according to the mapping relationship information.
在一些可能的实现方式中,网卡可以根据该第一本地端口号将该服务的待接收报文转发到相应的接收队列,从而能够实现对报文的有效转发。In some possible implementation manners, the network card may forward the to-be-received packet of the service to the corresponding receiving queue according to the first local port number, so that the packet can be effectively forwarded.
在一些可能的实现方式中,端口号包括TCP或者UDP端口号。In some possible implementations, the port number includes a TCP or UDP port number.
第二方面,提供了一种处理报文的方法,包括:In a second aspect, a method for processing a message is provided, including:
根据服务的监听端口号,以及配置的映射关系信息,将该服务与第一处理器核标识绑定,其中,该映射关系信息包括处理器核标识和端口号的映射关系;Binding the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number;
从第一网卡接收队列中获取该服务的待接收报文,其中,该第一网卡接收队列为第一处理器核标识对应的网卡接收队列。Obtaining a to-be-received message of the service from the first network card receiving queue, where the first network card receiving queue is a network card receiving queue corresponding to the first processor core identifier.
本发明实施例的处理报文的方法,通过将服务与处理器核标识绑定,一方面可以使网卡将报文转发到相应的网卡队列,从而提高报文的转发效率,另一方面可以将服务和协议栈都对应到同一处理器核上,从而提高对服务的报文的处理效率。The method for processing a message in the embodiment of the present invention, by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, Both the service and the protocol stack correspond to the same processor core, thereby improving the processing efficiency of the service packets.
在一些可能的实现方式中,该方法还包括:In some possible implementations, the method further includes:
将该监听端口号写入该服务的待发送报文的源端口号字段;Writing the listening port number to the source port number field of the to-be-sent packet of the service;
将该待发送报文发送到网卡发送队列。Send the to-be-sent message to the network card sending queue.
在一些可能的实现方式中,监听端口号为UDP端口号。In some possible implementations, the listening port number is a UDP port number.
第三方面,提供了一种主机,包括执行第一方面或第一方面的任意可能的实现方式中的方法的模块,或者,执行第二方面或第二方面的任意可能的实现方式中的方法的模块。In a third aspect, a host is provided, comprising a module that performs the method of the first aspect or any possible implementation of the first aspect, or the method of any of the possible implementations of the second aspect or the second aspect Module.
第四方面,提供了一种主机,该主机包括处理器和存储器,该存储器用于存储指令,该处理器用于执行该指令,该处理器执行该存储器存储的指令时,该执行使得该处理器执行第一方面或第一方面的任意可能的实现方式,或者,第二方面或第二方面的任意可能的实现方式中的方法。In a fourth aspect, a host is provided, the host including a processor and a memory, the memory is for storing an instruction, the processor is configured to execute the instruction, and when the processor executes the instruction stored by the memory, the executing causes the processor Performing the first aspect or any possible implementation of the first aspect, or the method of the second aspect or any possible implementation of the second aspect.
第五方面,提供了一种计算机设备,包括: In a fifth aspect, a computer device is provided, including:
主机,用于获取服务绑定的第一处理器核标识,根据该第一处理器核标识,以及配置的映射关系信息,确定该服务对应的第一本地端口号,其中,该映射关系信息包括处理器核标识和端口号的映射关系,将该第一本地端口号写入该服务的待发送报文的源端口号字段,将该待发送报文发送到网卡发送队列;以及a host, configured to obtain a first processor core identifier of the service binding, and determine, according to the first processor core identifier and the configured mapping relationship information, a first local port number corresponding to the service, where the mapping relationship information includes The mapping between the processor core identifier and the port number, the first local port number is written in the source port number field of the to-be-sent packet of the service, and the to-be-sent packet is sent to the network card sending queue;
网卡,用于发送该网卡发送队列中的该待发送报文。The network card is configured to send the to-be-sent packet in the sending queue of the network card.
本发明实施例的计算机设备,通过将服务与处理器核标识绑定,并依此确定该服务对应的端口号,根据该端口号处理该服务的待发送报文,可以使网卡根据该端口号转发该服务的待接收报文到相应的网卡队列,从而能够提高报文的转发效率。The computer device of the embodiment of the present invention binds the service to the processor core identifier, and determines the port number corresponding to the service according to the port number, and processes the to-be-sent packet of the service according to the port number, so that the network card can be made according to the port number. The packets to be received of the service are forwarded to the corresponding network card queue, so that the forwarding efficiency of the packets can be improved.
在一些可能的实现方式中,该映射关系信息包括处理器核标识、网卡接收队列和端口号的映射关系。In some possible implementation manners, the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
在一些可能的实现方式中,每个处理器核标识对应多个端口号。In some possible implementations, each processor core identifier corresponds to a plurality of port numbers.
在一些可能的实现方式中,该主机具体用于,从该第一处理器核标识对应的多个端口号中,选择该第一本地端口号。In some possible implementations, the host is specifically configured to select the first local port number from the plurality of port numbers corresponding to the first processor core identifier.
在一些可能的实现方式中,该主机还用于,配置该映射关系信息。In some possible implementations, the host is further configured to configure the mapping relationship information.
在一些可能的实现方式中,该网卡还用于,接收该服务的待接收报文,该待接收报文中的目的端口号为该第一本地端口号,根据该目的端口号将该待接收报文转发到该第一本地端口号对应的网卡接收队列;In some possible implementations, the network card is further configured to receive a to-be-received packet of the service, where the destination port number in the to-be-received packet is the first local port number, and the to-be-received according to the destination port number. The packet is forwarded to the network card receiving queue corresponding to the first local port number;
该主机还用于,从该第一本地端口号对应的网卡接收队列中获取该待接收报文。The host is further configured to obtain the to-be-received packet from the network card receiving queue corresponding to the first local port number.
在一些可能的实现方式中,该计算机设备为客户端设备,该待发送报文包括链接请求报文;In some possible implementations, the computer device is a client device, and the to-be-sent message includes a link request message;
该主机还用于,将该服务与该第一处理器核标识绑定。The host is further configured to bind the service to the first processor core identity.
在一些可能的实现方式中,该计算机设备为服务器,该待发送报文包括链接接受报文;In some possible implementations, the computer device is a server, and the to-be-sent message includes a link accept message;
该主机还用于,根据该服务的监听端口号,以及该映射关系信息,将该服务与该第一处理器核标识绑定;The host is further configured to bind the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
该网卡还用于,接收该服务的链接请求报文,该链接请求报文中的目的端口号为该监听端口号,根据该目的端口号将该待接收报文转发到该监听端口号对应的网卡接收队列; The network card is further configured to receive a link request message of the service, where the destination port number in the link request message is the listening port number, and forward the to-be-received message to the corresponding listening port number according to the destination port number. NIC receiving queue;
该主机还用于,从该监听端口号对应的网卡接收队列中获取该链接请求报文。The host is further configured to obtain the link request message from the network card receiving queue corresponding to the listening port number.
第六方面,提供了一种计算机设备,包括:In a sixth aspect, a computer device is provided, comprising:
主机,用于根据服务的监听端口号,以及配置的映射关系信息,将该服务与第一处理器核标识绑定,其中,该映射关系信息包括处理器核标识和端口号的映射关系,从第一网卡接收队列中获取该服务的待接收报文,其中,该第一网卡接收队列为第一处理器核标识对应的网卡接收队列;The host is configured to bind the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number, The first network card receiving queue obtains the to-be-received message of the service, where the first network card receiving queue is the network card receiving queue corresponding to the first processor core identifier;
网卡,用于接收该待接收报文,该待接收报文中的目的端口号为该监听端口号,根据该目的端口号将该待接收报文转发到该第一网卡接收队列。The network card is configured to receive the to-be-received packet, and the destination port number in the to-be-received packet is the listening port number, and the to-be-received packet is forwarded to the first network card receiving queue according to the destination port number.
本发明实施例的计算机设备,通过将服务与处理器核标识绑定,一方面可以使网卡将报文转发到相应的网卡队列,从而提高报文的转发效率,另一方面可以将服务和协议栈都对应到同一处理器核上,从而提高对服务的报文的处理效率。The computer device of the embodiment of the present invention, by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, the service and the protocol can be implemented. The stacks all correspond to the same processor core, thereby improving the processing efficiency of the service packets.
在一些可能的实现方式中,该主机还用于,将该监听端口号写入该服务的待发送报文的源端口号字段,将该待发送报文发送到网卡发送队列;In some possible implementation manners, the host is further configured to: write the listening port number into a source port number field of the to-be-sent packet of the service, and send the to-be-sent packet to the network card sending queue;
该网卡还用于,发送该网卡发送队列中的该待发送报文。The network card is further configured to send the to-be-sent packet in the network card sending queue.
在一些可能的实现方式中,该计算机设备为服务器。In some possible implementations, the computer device is a server.
在一些可能的实现方式中,监听端口号为UDP端口号。In some possible implementations, the listening port number is a UDP port number.
第七方面,提供了一种计算机设备,包括第三方面或第四方面的主机,以及网卡。In a seventh aspect, a computer apparatus is provided, comprising the host of the third aspect or the fourth aspect, and a network card.
第八方面,提供了一种计算机可读介质,用于存储计算机程序,该计算机程序包括用于执行第一方面或第一方面的任意可能的实现方式,或者,第二方面或第二方面的任意可能的实现方式中的方法的指令。In an eighth aspect, a computer readable medium is provided for storing a computer program, the computer program comprising any of the possible implementations of the first aspect or the first aspect, or the second or second aspect The instructions of the method in any of the possible implementations.
附图说明DRAWINGS
图1是本发明实施例的技术方案应用的计算机设备的示意图。FIG. 1 is a schematic diagram of a computer device to which the technical solution of the embodiment of the present invention is applied.
图2是本发明实施例的处理器核标识、网卡队列和端口号的映射关系的示意图。2 is a schematic diagram of a mapping relationship between a processor core identifier, a network card queue, and a port number according to an embodiment of the present invention.
图3是本发明一个实施例的处理报文的方法的示意性流程图。FIG. 3 is a schematic flowchart of a method for processing a message according to an embodiment of the present invention.
图4是本发明另一个实施例的处理报文的方法的示意性流程图。FIG. 4 is a schematic flowchart of a method for processing a message according to another embodiment of the present invention.
图5是本发明又一个实施例的处理报文的方法的示意性流程图。 FIG. 5 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
图6是本发明又一个实施例的处理报文的方法的示意性流程图。FIG. 6 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
图7是本发明又一个实施例的处理报文的方法的示意性流程图。FIG. 7 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
图8是本发明又一个实施例的处理报文的方法的示意性流程图。FIG. 8 is a schematic flowchart of a method for processing a message according to still another embodiment of the present invention.
图9是本发明实施例的计算机设备的示意性框图。9 is a schematic block diagram of a computer device in accordance with an embodiment of the present invention.
具体实施方式detailed description
图1是本发明实施例的技术方案应用的计算机设备的示意图。FIG. 1 is a schematic diagram of a computer device to which the technical solution of the embodiment of the present invention is applied.
如图1所示,计算机设备100可以包括处理器111、存储器112和网卡120。As shown in FIG. 1, computer device 100 can include a processor 111, a memory 112, and a network card 120.
处理器111和存储器112又可以统称为主机110。主机110(例如,主机110中的应用)可通过网卡120将报文发送给其他设备。 Processor 111 and memory 112 may in turn be collectively referred to as host 110. Host 110 (e.g., an application in host 110) can send messages to other devices via network card 120.
处理器111可以包括多个处理器核(Core)。存储器112可以包括内存和其他存储器。 Processor 111 can include multiple processor cores (Cores). Memory 112 can include memory and other memory.
网卡120支持多网卡队列,也可简称为队列。队列包括发送队列和接收队列。网卡120的队列可以配置于存储器112,例如内存中。网卡120可基于队列的地址从发送队列中获取待发送的报文或将网卡接收的报文转发到接收队列中。The network card 120 supports multiple network card queues, which may also be referred to as queues. The queue includes a send queue and a receive queue. The queue of network card 120 can be configured in memory 112, such as in memory. The network card 120 can obtain the message to be sent from the sending queue or forward the message received by the network card to the receiving queue based on the address of the queue.
在一些可能的实现方式中,网卡120可以根据报文网络包头中的目的IP和端口的掩码和匹配域,转发报文到指定网卡队列。In some possible implementation manners, the network card 120 may forward the packet to the designated network card queue according to the destination IP and the mask and the matching domain of the packet in the packet network header.
在一些可能的实现方式中,网卡120可以根据转发流表转发报文到指定网卡队列。转发流表可以配置于网卡120中,也可以配置于网卡120可以访问的存储器中。In some possible implementations, the network card 120 can forward the message to the designated network card queue according to the forwarding flow table. The forwarding flow table may be configured in the network card 120 or in a memory accessible by the network card 120.
在一些可能的实现方式中,处理器核标识(CoreID)、网卡队列和端口号之间配置有映射关系。转发流表可以根据该映射关系生成。In some possible implementations, a mapping relationship is configured between a processor core identifier (CoreID), a network card queue, and a port number. The forwarding flow table can be generated according to the mapping relationship.
图2示出了处理器核标识、网卡队列和端口号的映射关系的示意图。FIG. 2 shows a schematic diagram of a mapping relationship between a processor core identifier, a network card queue, and a port number.
如图2所示,由于端口号数量比较多,每个网卡队列和处理器核标识对应多个端口号。这多个端口号也可以称为网卡队列或处理器核标识的端口资源池。As shown in FIG. 2, since the number of port numbers is relatively large, each network card queue and processor core identifier correspond to multiple port numbers. These multiple port numbers can also be referred to as NIC queues or port resource pools identified by the processor core.
应理解,网卡队列和处理器核标识之间的对应关系可以是一对一也可以不是一对一,本发明实施例对此并不限定。It should be understood that the correspondence between the network card queue and the processor core identifier may be one-to-one or not one-to-one, which is not limited by the embodiment of the present invention.
还应理解,本发明实施例对处理器核标识、网卡队列和端口号的映射关 系的具体形式不做限定,其具体可以表现为一个三者在一起的映射关系,也可以表现为两个两者之间的映射关系,例如,可以为处理器核标识和网卡队列的映射关系,以及网卡队列和端口号的映射关系。It should also be understood that the embodiment of the present invention maps the processor core identifier, the network card queue, and the port number. The specific form of the system is not limited. It can be expressed as a mapping relationship between the three, or a mapping relationship between the two. For example, the mapping between the processor core identifier and the NIC queue can be performed. And the mapping relationship between the NIC queue and the port number.
在本发明实施例中,在上述映射关系的基础上,将服务与CoreID绑定,这样可以根据绑定关系确定服务对应的端口号。按照这种方式确定的端口号能够对应到特定的网卡队列,从而便于网卡转发报文,即能够提高报文的转发效率。In the embodiment of the present invention, on the basis of the foregoing mapping relationship, the service is bound to the CoreID, so that the port number corresponding to the service can be determined according to the binding relationship. The port number determined in this way can be matched to a specific network card queue, so that the network card can forward packets, which can improve the forwarding efficiency of packets.
应理解,本发明实施例中的服务可以为传输控制协议(Transmission Control Protocol,TCP)/用户数据报协议(User Data Protocol,UDP)服务,端口号可以为TCP/UDP端口号,但本发明实施例对此并不限定。It should be understood that the service in the embodiment of the present invention may be a Transmission Control Protocol (TCP)/User Data Protocol (UDP) service, and the port number may be a TCP/UDP port number, but the present invention is implemented. This example is not limited to this.
图3示出了本发明实施例的处理报文的方法300的示意性流程图。该方法300可以由主机执行。该主机可以是客户端设备中的主机,也可以是服务器中的主机。对于客户端,服务的待发送报文可以为链接请求报文和链接建立后的数据报文;对于服务器端,服务的待发送报文可以为链接接受报文和链接建立后的数据报文。其中,链接请求报文可以是客户端向服务器端发送的用于请求与服务器端建立通信连接的报文。连接接受报文可以是服务器端向客户端发送的用于与客户端建立通信连接的报文。FIG. 3 is a schematic flowchart of a method 300 for processing a message according to an embodiment of the present invention. The method 300 can be performed by a host. The host can be a host in the client device or a host in the server. For the client, the to-be-sent message of the service may be a link request message and a data message after the link is established; for the server, the service-to-send message may be a link-received message and a link-established data message. The link request message may be a message sent by the client to the server for requesting to establish a communication connection with the server. The connection accepting message may be a message sent by the server to the client for establishing a communication connection with the client.
310,获取服务绑定的第一处理器核标识。310: Obtain a first processor core identifier of the service binding.
在本发明实施例中,将服务与CoreID绑定。这样,后续可以根据绑定的CoreID确定服务对应的端口号,进而处理该服务的报文。In the embodiment of the invention, the service is bound to the CoreID. In this way, the subsequent port number of the service can be determined according to the bound CoreID, and then the packet of the service is processed.
可选地,对于客户端,可在创建服务关联的链接类套接字(Socket)前将该服务与CoreID绑定;对于服务器,可在创建该服务关联的监听类套接字前或后将该服务与CoreID绑定。Optionally, for the client, the service can be bound to the CoreID before the link class socket (Socket) associated with the service is created; for the server, before or after the listener socket associated with the service is created This service is bundled with CoreID.
320,根据该第一处理器核标识,确定该服务对应的第一本地端口号。320. Determine, according to the first processor core identifier, a first local port number corresponding to the service.
根据服务绑定的第一处理器核标识,可以选择该服务对应的本地端口号(表示为第一本地端口号)。该第一本地端口号也是该服务关联的Socket的端口号,即该Socket的后续报文都可以根据该第一本地端口号传输。According to the first processor core identifier of the service binding, the local port number corresponding to the service (represented as the first local port number) may be selected. The first local port number is also the port number of the Socket associated with the service, that is, subsequent packets of the Socket can be transmitted according to the first local port number.
可选地,在本发明一个实施例中,可以根据该第一处理器核标识,以及配置的映射关系信息,确定该第一本地端口号。Optionally, in an embodiment of the present invention, the first local port number may be determined according to the first processor core identifier and the configured mapping relationship information.
根据配置的映射关系信息,可以选择该第一处理器核标识对应的端口号,作为该第一本地端口号。 The port number corresponding to the first processor core identifier may be selected as the first local port number according to the configured mapping relationship information.
可选地,该映射关系信息可以预先配置在存储器中。该映射关系信息可以被主机中的应用获取。Optionally, the mapping relationship information may be pre-configured in a memory. The mapping relationship information can be obtained by an application in the host.
可选地,该映射关系信息可以包括处理器核标识和端口号的映射关系。Optionally, the mapping relationship information may include a mapping relationship between the processor core identifier and the port number.
可选地,该映射关系信息可以包括处理器核标识、网卡接收队列和端口号的映射关系。Optionally, the mapping relationship information may include a mapping relationship between the processor core identifier, the network card receiving queue, and the port number.
可选地,该映射关系信息可以包括处理器核标识和网卡接收队列的映射关系,以及网卡接收队列和端口号的映射关系。Optionally, the mapping relationship information may include a mapping relationship between the processor core identifier and the network card receiving queue, and a mapping relationship between the network card receiving queue and the port number.
可选地,每个处理器核标识可以对应多个端口号。Optionally, each processor core identifier can correspond to multiple port numbers.
例如,该映射关系信息可以包括如图2所示的映射关系。For example, the mapping relationship information may include a mapping relationship as shown in FIG. 2.
应理解,本发明实施例并不对该映射关系信息的具体形式和内容进行限定,也就是说,该映射关系信息还可以采用其他映射关系。It should be understood that the embodiment of the present invention does not limit the specific form and content of the mapping relationship information, that is, the mapping relationship information may also adopt other mapping relationships.
可选地,在每个处理器核标识对应多个端口号的情况下,可以从该第一处理器核标识对应的多个端口号中,选择该第一本地端口号。Optionally, in a case that each processor core identifier corresponds to multiple port numbers, the first local port number may be selected from multiple port numbers corresponding to the first processor core identifier.
330,根据该第一本地端口号处理该服务的待发送报文。330. Process the to-be-sent packet of the service according to the first local port number.
该第一本地端口号为该服务的待发送报文的源端口号,也是后续该服务的待接收报文的目的端口号。The first local port number is the source port number of the to-be-sent packet of the service, and is the destination port number of the to-be-received packet of the service.
具体地,在发送该待发送报文时,主机可以将该第一本地端口号写入该待发送报文的源端口号字段;并将该待发送报文发送到网卡发送队列。网卡再将该网卡发送队列中的该待发送报文发送出去。Specifically, when the to-be-sent packet is sent, the host may write the first local port number to the source port number field of the to-be-sent packet, and send the to-be-sent packet to the network card sending queue. The network card sends the to-be-sent packet in the NIC sending queue.
可选地,在后续接收该服务的待接收报文时,主机可以从该第一本地端口号对应的网卡接收队列中获取该服务的待接收报文,其中,该待接收报文由网卡根据该待接收报文中的目的端口号转发到该第一本地端口号对应的网卡接收队列。Optionally, the host may obtain the to-be-received packet of the service from the network card receiving queue corresponding to the first local port number, where the to-be-received packet is determined by the network card. The destination port number in the to-be-received packet is forwarded to the network card receiving queue corresponding to the first local port number.
具体而言,该服务的待发送报文的源端口号为该第一本地端口号,相应地,该服务的待接收报文中的目的端口号就为该第一本地端口号。这样,网卡可以根据该待接收报文中的目的端口号将该待接收报文转发到该第一本地端口号对应的网卡接收队列,主机可以从该第一本地端口号对应的网卡接收队列中获取该服务的待接收报文。Specifically, the source port number of the to-be-sent packet of the service is the first local port number, and correspondingly, the destination port number in the to-be-received packet of the service is the first local port number. In this way, the network card can forward the to-be-received packet to the network card receiving queue corresponding to the first local port number according to the destination port number in the to-be-received packet, and the host can receive the queue from the network card corresponding to the first local port number. Obtain the pending message of the service.
可选地,网卡的转发流表可以基于上述的映射关系信息而配置。例如,多个端口号对应一个网卡队列。根据端口号的范围,可以计算转发流表表项的掩码和匹配域。例如,如果某个端口号范围为:1024-2047;则其中分段 掩码为:0100-0000-0000(1024)->0111-1111-1111(2047)。因此可计算出相应的转发流表表项的匹配域为0100-0000-0000,掩码为0111-1111-1111。Optionally, the forwarding flow table of the network card may be configured based on the mapping relationship information described above. For example, multiple port numbers correspond to one NIC queue. Based on the range of the port number, you can calculate the mask and matching field of the forwarding flow table entry. For example, if a port number range is: 1024-2047; then the segmentation The mask is: 0100-0000-0000(1024)->0111-1111-1111 (2047). Therefore, the matching field of the corresponding forwarding flow table entry can be calculated as 0100-0000-0000, and the mask is 0111-1111-1111.
可选地,还可以设定全匹配的表项,当转发流表中所有表项都不匹配时,最终由这个表项匹配。Optionally, the all-matching entry may also be set. When all the entries in the forwarding flow table do not match, the entry is finally matched.
本发明实施例的处理报文的方法,通过将服务与处理器核标识绑定,并依此确定该服务对应的端口号,根据该端口号处理该服务的待发送报文,可以使网卡根据该端口号转发该服务的待接收报文到相应的网卡队列,从而能够提高报文的转发效率。The method for processing a message according to the embodiment of the present invention is to bind the service to the processor core identifier, and determine the port number corresponding to the service according to the port number, and process the to-be-sent packet of the service according to the port number, so that the network card can be The port number forwards the to-be-received packet of the service to the corresponding network card queue, thereby improving the forwarding efficiency of the packet.
下面分别对客户端和服务器端的处理流程进行详细描述。The processing flow of the client and server is described in detail below.
可选地,在本发明一个实施例中,对于客户端,该待发送报文包括客户端的链接请求报文。Optionally, in an embodiment of the present invention, for the client, the to-be-sent message includes a link request message of the client.
在这种情况下,如图4所示,在步骤310之前,该方法300还可以包括:In this case, as shown in FIG. 4, before step 310, the method 300 may further include:
302,将服务与该第一处理器核标识绑定。302. Bind the service to the first processor core identifier.
具体而言,客户端在需要链接服务时,要创建该服务关联的链接类套接字,需要选择一个端口号。在本发明实施例中,将该服务绑定一个CoreID,即,将该服务与运行该服务的进程的处理器核(Core)绑定。在客户端,在Core的选择上没有限定,即可以随机选择Core。然后,可以根据服务绑定的CoreID确定该服务对应的本地端口号,即Socket端口号,再根据该服务对应的本地端口号传输链接请求报文。Specifically, when the client needs to link the service, to create a link class socket associated with the service, you need to select a port number. In an embodiment of the invention, the service is bound to a CoreID, ie, the service is bound to the processor core (Core) of the process running the service. On the client side, there is no limit on the choice of the Core, that is, the Core can be randomly selected. Then, the local port number corresponding to the service, that is, the Socket port number, may be determined according to the CoreID of the service binding, and then the link request message is transmitted according to the local port number corresponding to the service.
通过将服务与处理器核标识绑定,可以预先获知服务对应的处理器核,从而可以将服务和协议栈都对应到同一处理器核上,进而提高对服务的报文的处理效率。By binding the service to the processor core identifier, the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
下面从软件模块的角度描述客户端的处理流程。应理解,软件模块的流程是逻辑上的流程,这些流程实际可以由主机中的处理器执行,从软件模块的角度描述只是为了便于理解本发明实施例的技术方案。The following describes the processing flow of the client from the perspective of the software module. It should be understood that the flow of the software module is a logical process, and the process may be performed by a processor in the host, and the description from the perspective of the software module is only for facilitating understanding of the technical solution of the embodiment of the present invention.
图5是从软件模块的角度示出的客户端的处理流程的示意图。FIG. 5 is a schematic diagram of a processing flow of a client shown from the perspective of a software module.
501,应用创建链接类Socket。501, the application creates a link class Socket.
应用也可以称为应用程序。客户端中的应用在需要获取服务,即需要与服务器中的应用通信时,需要创建链接类Socket。例如,应用调用操作系统提供的应用程序编程接口(Application Programming Interface,API),创建TCP链接的Socket。 An app can also be called an app. The application in the client needs to create a link class Socket when it needs to obtain the service, that is, it needs to communicate with the application in the server. For example, the application calls the application programming interface (API) provided by the operating system to create a TCP-linked Socket.
502,TCP/UDP协议栈模块判断服务是否绑定Core。502. The TCP/UDP protocol stack module determines whether the service is bound to the Core.
TCP/UDP协议栈模块为进行TCP/UDP协议栈处理的模块。应理解,由于应用、应用的进程或线程都与服务对应,因此,服务与Core绑定也可以是应用、应用的进程或线程与Core绑定。例如,TCP/UDP协议栈模块通过操作系统提供的API查询服务绑定的CoreID。如果查询到对应的CoreID,则执行步骤505,否则执行步骤503。The TCP/UDP protocol stack module is a module for processing TCP/UDP protocol stacks. It should be understood that since the application, the application's process, or the thread all correspond to the service, the service and Core binding may also be an application, an application's process, or a thread bound to the Core. For example, the TCP/UDP protocol stack module queries the CoreID of the service binding through an API provided by the operating system. If the corresponding CoreID is queried, step 505 is performed, otherwise step 503 is performed.
503,TCP/UDP协议栈模块反馈给应用需要绑定Core。503. The TCP/UDP protocol stack module feeds back to the application and needs to bind the Core.
例如,TCP/UDP协议栈模块,通过错误信息反馈给应用需要绑定一个Core。For example, the TCP/UDP protocol stack module needs to bind a Core by feeding back error information to the application.
504,应用将服务绑定一个Core。504, the application binds the service to a Core.
505,TCP/UDP协议栈模块,通知Flow-Director管理模块获取端口号。505. The TCP/UDP protocol stack module notifies the Flow-Director management module to obtain the port number.
在本发明实施例中,分流(Flow-Director)管理模块可以用于配置网卡队列,映射关系信息等。In the embodiment of the present invention, the flow-director management module may be configured to configure a network card queue, mapping relationship information, and the like.
例如,TCP/UDP协议栈模块告知Flow-Director管理模块服务绑定的CoreID,通知Flow-Director管理模块获取Socket端口号,即服务对应的端口号。For example, the TCP/UDP protocol stack module informs the Flow-Director management module of the CoreID of the service module binding, and notifies the Flow-Director management module to obtain the Socket port number, that is, the port number corresponding to the service.
506,Flow-Director管理模块根据该绑定CoreID,以及映射关系信息获取端口号。506. The Flow-Director management module acquires a port number according to the bound CoreID and the mapping relationship information.
例如,Flow-Director管理模块根据该绑定CoreID,以及预设的CoreID、网卡队列和端口号的映射关系,获取Socket端口号。For example, the Flow-Director management module obtains the Socket port number according to the binding CoreID and the mapping relationship between the preset CoreID, the NIC queue, and the port number.
507,TCP/UDP协议栈模块根据该端口号处理链接请求报文。507. The TCP/UDP protocol stack module processes the link request message according to the port number.
例如,TCP/UDP协议栈模块将该端口号写入该链接请求报文的源端口号字段,并将该链接请求报文发送到网卡发送队列。For example, the TCP/UDP protocol stack module writes the port number to the source port number field of the link request message, and sends the link request message to the network card send queue.
后续服务器在发送该服务的报文时,将该端口号作为目的端口号,这样,客户端的网卡可以根据该目的端口号将报文转发到相应的接收队列,从而能够实现对报文的有效转发。When the subsequent server sends the packet of the service, the port number is used as the destination port number, so that the NIC of the client can forward the packet to the corresponding receiving queue according to the destination port number, so that the packet can be effectively forwarded. .
可选地,在本发明另一个实施例中,对于服务器端,该待发送报文包括服务器端的链接接受报文。Optionally, in another embodiment of the present invention, for the server, the to-be-sent message includes a server-side link accept message.
在这种情况下,如图6所示,在步骤310之前,该方法300还可以包括:In this case, as shown in FIG. 6, before step 310, the method 300 may further include:
304,根据服务的监听端口号,将该服务与该第一处理器核标识绑定;304. Bind the service to the first processor core identifier according to the listening port number of the service.
305,从该监听端口号对应的网卡接收队列中获取该服务的链接请求报 文。305. Obtain a link request report of the service from a network card receiving queue corresponding to the listening port number. Text.
具体而言,服务器端在监听链接请求时,需要创建服务关联的监听类Socket,其中监听端口号为客户端已知的端口号。即,该监听端口号为客户端发送链接请求报文时的目的端口号。服务器端根据该监听端口号,将该服务与CoreID绑定。例如,根据该监听端口号以及配置的映射关系信息,将该服务与CoreID绑定。Specifically, when the server side listens for the link request, it needs to create a listener class Socket associated with the service, where the listening port number is a port number known by the client. That is, the listening port number is the destination port number when the client sends the link request message. The server binds the service to the CoreID according to the listening port number. For example, the service is bound to the CoreID according to the listening port number and the configured mapping relationship information.
通过将服务与处理器核标识绑定,可以预先获知服务对应的处理器核,从而可以将服务和协议栈都对应到同一处理器核上,进而提高对服务的报文的处理效率。By binding the service to the processor core identifier, the processor core corresponding to the service can be known in advance, so that both the service and the protocol stack can be mapped to the same processor core, thereby improving the processing efficiency of the service packet.
另外,根据该监听端口号,服务器端还可以获知链接请求报文对应的网卡接收队列。服务器端的网卡在接收到客户端的链接请求报文时,根据链接请求报文中的目的端口号,即该监听端口号,将链接请求报文转发到相应的网卡接收队列。服务器端的主机可以从该监听端口号对应的网卡接收队列中获取该链接请求报文。In addition, according to the listening port number, the server can also know the network card receiving queue corresponding to the link request message. When receiving the link request message of the client, the network card of the server side forwards the link request message to the corresponding network card receiving queue according to the destination port number in the link request message, that is, the listening port number. The host on the server side can obtain the link request message from the network card receiving queue corresponding to the listening port number.
在获取到该链接请求报文,接受链接请求后,服务器端接下来会向客户端发送链接接受报文以及数据报文。这时,服务器端需要确定接下来的传输端口号,即上述第一本地端口号。服务器端可以根据该服务绑定的CoreID确定该第一本地端口号,再根据该第一本地端口号传输链接接受报文以及后续的数据报文。After obtaining the link request message and accepting the link request, the server end sends a link acceptance message and a data message to the client. At this time, the server side needs to determine the next transmission port number, that is, the first local port number described above. The server may determine the first local port number according to the CoreID bound to the service, and then transmit the link acceptance message and the subsequent data packet according to the first local port number.
图7是从软件模块的角度示出的服务器端的处理流程的示意图。Fig. 7 is a schematic diagram showing the processing flow of the server side from the perspective of a software module.
701,应用创建监听类Socket。701, the application creates a listener class Socket.
应用调用操作系统提供的API,创建监听类Socket。The application calls the API provided by the operating system to create a listener class Socket.
702,TCP/UDP协议栈模块向Flow-Director管理模块获取服务应该绑定的CoreID。702. The TCP/UDP protocol stack module obtains a CoreID that the service should be bound to the Flow-Director management module.
TCP/UDP协议栈模块向Flow-Director管理模块传递监听端口号,获取该服务应该绑定的CoreID。The TCP/UDP protocol stack module passes the listening port number to the Flow-Director management module to obtain the CoreID that the service should bind.
703,Flow-Director管理模块根据监听端口号获取对应的CoreID。703. The Flow-Director management module acquires a corresponding CoreID according to the listening port number.
例如,Flow-Director管理模块根据监听端口号,以及预设的映射关系信息,获取对应的CoreID,即该服务应该绑定的CoreID,并反馈给TCP/UDP协议栈模块。For example, the Flow-Director management module obtains the corresponding CoreID according to the listening port number and the preset mapping relationship information, that is, the CoreID to which the service should be bound, and feeds back to the TCP/UDP protocol stack module.
704,TCP/UDP协议栈模块判断服务是否绑定Core。 704. The TCP/UDP protocol stack module determines whether the service is bound to the Core.
例如,TCP/UDP协议栈模块通过操作系统提供的API查询服务绑定的CoreID是否为空(没有绑定),如果为空,则执行705,否则执行706。For example, the TCP/UDP protocol stack module queries whether the CoreID of the service binding is empty (no binding) through the API provided by the operating system. If it is empty, execute 705, otherwise execute 706.
705,TCP/UDP协议栈模块将服务绑定到Flow-Director管理模块反馈的Core。705. The TCP/UDP protocol stack module binds the service to the Core fed back by the Flow-Director management module.
706,TCP/UDP协议栈模块将应该绑定的CoreID反馈给应用。706. The TCP/UDP protocol stack module feeds back the CoreID that should be bound to the application.
应用进行绑定或者退出当前进程。The application binds or exits the current process.
707,TCP/UDP协议栈模块通知Flow-director管理模块获取数据传输端口号。707. The TCP/UDP protocol stack module notifies the Flow-director management module to obtain a data transmission port number.
当有客户端主动链接服务器端,该服务器端接受链接请求后,TCP/UDP协议栈模块通知Flow-director管理模块服务绑定的CoreID,以获取数据传输端口号。When a client actively links to the server, and the server accepts the link request, the TCP/UDP protocol stack module notifies the FlowID of the Flow-director management module service binding to obtain the data transmission port number.
708,Flow-director管理模块根据绑定的CoreID和预设的映射关系信息,返回该CoreID对应的端口号。708. The flow-director management module returns a port number corresponding to the CoreID according to the bound CoreID and the preset mapping relationship information.
709,TCP/UDP协议栈模块根据该端口号处理该服务的报文。709. The TCP/UDP protocol stack module processes the packet of the service according to the port number.
TCP/UDP协议栈模块根据该端口号处理链接接受报文以及后续的数据报文。例如,TCP/UDP协议栈模块将该端口号写入报文的源端口号字段,并将报文发送到网卡发送队列。The TCP/UDP protocol stack module processes the link acceptance message and the subsequent data message according to the port number. For example, the TCP/UDP protocol stack module writes the port number to the source port number field of the message and sends the message to the network card send queue.
后续客户端在向服务器端发送该服务的报文时,将该端口号作为目的端口号,这样,服务器端的网卡可以根据该目的端口号将报文转发到相应的接收队列,从而能够实现对报文的有效转发。When the subsequent client sends the packet of the service to the server, the port number is used as the destination port number, so that the network card of the server can forward the packet to the corresponding receiving queue according to the destination port number, so that the packet can be reported. The effective forwarding of the text.
应理解,在服务器端,例如针对UDP协议,也可以不再选择传输端口号,即上述第一本地端口号,而是一直使用监听端口号。下面对这种情况进行描述。It should be understood that on the server side, for example, for the UDP protocol, the transmission port number, that is, the first local port number described above, may be no longer selected, but the listening port number is always used. This case will be described below.
图8示出了本发明另一实施例的处理报文的方法800的示意性流程图。该方法800可以由主机执行。该主机可以是服务器中的主机。FIG. 8 is a schematic flowchart of a method 800 for processing a message according to another embodiment of the present invention. The method 800 can be performed by a host. This host can be a host in the server.
810,根据服务的监听端口号,将该服务与第一处理器核标识绑定。810. Bind the service to the first processor core identifier according to the listening port number of the service.
监听端口号为客户端已知的端口号。服务器端可以根据该监听端口号,将该服务与CoreID绑定。The listening port number is the port number known to the client. The server can bind the service to the CoreID according to the listening port number.
可选地,可以根据该监听端口号,以及配置的映射关系信息,将该服务与该第一处理器核标识绑定。关于该映射关系信息的说明可以参见前述实施例,为了简洁,在此不再赘述。 Optionally, the service may be bound to the first processor core identifier according to the listening port number and the configured mapping relationship information. For the description of the mapping relationship information, refer to the foregoing embodiment, and for brevity, no further details are provided herein.
820,从第一网卡接收队列中获取该服务的待接收报文,其中,该第一网卡接收队列为第一处理器核标识对应的网卡接收队列。820. Obtain a to-be-received packet of the service from the first network card receiving queue, where the first network card receiving queue is a network card receiving queue corresponding to the first processor core identifier.
在将服务与处理器核标识绑定后,服务器端可以获知该服务的待接收报文,即客户端发送的请求报文对应的网卡接收队列。服务器端的网卡在接收到客户端的请求报文时,根据请求报文中的目的端口号,即该监听端口号,将请求报文转发到相应的网卡接收队列,即上述第一网卡接收队列。服务器端的主机可以从该第一网卡接收队列中获取该待接收报文。After the service is bound to the processor core identifier, the server can obtain the to-be-received packet of the service, that is, the network card receiving queue corresponding to the request packet sent by the client. When receiving the request packet from the client, the NIC of the server forwards the request packet to the corresponding network card receiving queue according to the destination port number in the request packet, that is, the listening port number, that is, the first network card receiving queue. The host on the server side can obtain the to-be-received packet from the first NIC receiving queue.
可选地,服务器端还可以根据该监听端口号发送该服务的待发送报文,即向客户端发送该服务的响应报文。具体地,服务器端的主机可以将该监听端口号写入该服务的待发送报文的源端口号字段;将该待发送报文发送到网卡发送队列。网卡再将该网卡发送队列中的该待发送报文发送出去。Optionally, the server may further send a to-be-sent packet of the service according to the listening port number, that is, send a response packet of the service to the client. Specifically, the host on the server side can write the listening port number to the source port number field of the to-be-sent packet of the service; and send the to-be-sent packet to the network card sending queue. The network card sends the to-be-sent packet in the NIC sending queue.
本发明实施例的处理报文的方法,通过将服务与处理器核标识绑定,一方面可以使网卡将报文转发到相应的网卡队列,从而提高报文的转发效率,另一方面可以将服务和协议栈都对应到同一处理器核上,从而提高对服务的报文的处理效率。The method for processing a message in the embodiment of the present invention, by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, Both the service and the protocol stack correspond to the same processor core, thereby improving the processing efficiency of the service packets.
应理解,在本发明的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。It should be understood that, in various embodiments of the present invention, the size of the sequence numbers of the above processes does not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not be taken to the embodiments of the present invention. The implementation process constitutes any limitation.
还应理解,本发明实施例中的具体的例子只是为了帮助本领域技术人员更好地理解本发明实施例,而非限制本发明实施例的范围。It should be understood that the specific examples of the embodiments of the present invention are only to be understood by those skilled in the art.
上文中详细描述了根据本发明实施例的处理报文的方法,下面将描述根据本发明实施例的计算机设备。A method of processing a message according to an embodiment of the present invention is described in detail above, and a computer device according to an embodiment of the present invention will be described below.
图9示出了本发明实施例的计算机设备900的示意性框图。FIG. 9 shows a schematic block diagram of a computer device 900 in accordance with an embodiment of the present invention.
如图9所示,该计算机设备900可以包括主机910和网卡920。As shown in FIG. 9, the computer device 900 can include a host 910 and a network card 920.
主机910,用于获取服务绑定的第一处理器核标识,以及配置的映射关系信息,根据该第一处理器核标识,确定该服务对应的第一本地端口号,其中,该映射关系信息包括处理器核标识和端口号的映射关系,将该第一本地端口号写入该服务的待发送报文的源端口号字段,将该待发送报文发送到网卡发送队列。The host 910 is configured to obtain a first processor core identifier of the service binding, and the configured mapping relationship information, and determine, according to the first processor core identifier, a first local port number corresponding to the service, where the mapping relationship information is The mapping between the processor core identifier and the port number is performed, and the first local port number is written into the source port number field of the to-be-sent packet of the service, and the to-be-sent packet is sent to the network card sending queue.
网卡920,用于发送该网卡发送队列中的该待发送报文。The network card 920 is configured to send the to-be-sent packet in the network card sending queue.
本发明实施例的计算机设备,通过将服务与处理器核标识绑定,并依此 确定该服务对应的端口号,根据该端口号处理该服务的待发送报文,可以使网卡根据该端口号转发该服务的待接收报文到相应的网卡队列,从而能够提高报文的转发效率。The computer device of the embodiment of the present invention binds the service to the processor core identifier, and accordingly The port number corresponding to the service is determined, and the to-be-sent packet of the service is processed according to the port number, so that the network card can forward the to-be-received packet of the service to the corresponding network card queue according to the port number, thereby improving the forwarding efficiency of the packet. .
可选地,在本发明一个实施例中,该映射关系信息包括处理器核标识、网卡接收队列和端口号的映射关系。Optionally, in an embodiment of the present invention, the mapping relationship information includes a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
可选地,在本发明一个实施例中,每个处理器核标识对应多个端口号。Optionally, in an embodiment of the invention, each processor core identifier corresponds to a plurality of port numbers.
可选地,在本发明一个实施例中,该主机910具体用于,从该第一处理器核标识对应的多个端口号中,选择该第一本地端口号。Optionally, in an embodiment of the present invention, the host 910 is specifically configured to select the first local port number from the plurality of port numbers corresponding to the first processor core identifier.
可选地,在本发明一个实施例中,该主机910还用于,配置该映射关系信息。Optionally, in an embodiment of the present invention, the host 910 is further configured to: configure the mapping relationship information.
可选地,在本发明一个实施例中,该网卡920还用于,接收该服务的待接收报文,该待接收报文中的目的端口号为该第一本地端口号,根据该目的端口号将该待接收报文转发到该第一本地端口号对应的网卡接收队列;Optionally, in an embodiment of the present invention, the network card 920 is further configured to receive a to-be-received packet of the service, where the destination port number in the to-be-received packet is the first local port number, according to the destination port. No. forwarding the to-be-received packet to the network card receiving queue corresponding to the first local port number;
该主机910还用于,从该第一本地端口号对应的网卡接收队列中获取该待接收报文。The host 910 is further configured to obtain the to-be-received packet from the network card receiving queue corresponding to the first local port number.
可选地,在本发明一个实施例中,该计算机设备900为客户端设备,该待发送报文包括链接请求报文;Optionally, in an embodiment of the present invention, the computer device 900 is a client device, and the to-be-sent message includes a link request message;
该主机910还用于,将该服务与该第一处理器核标识绑定。The host 910 is further configured to bind the service to the first processor core identifier.
可选地,在本发明一个实施例中,该计算机设备900为服务器,该待发送报文包括链接接受报文;Optionally, in an embodiment of the present invention, the computer device 900 is a server, and the to-be-sent message includes a link accepting message;
该主机910还用于,根据该服务的监听端口号,以及该映射关系信息,将该服务与该第一处理器核标识绑定;The host 910 is further configured to bind the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
该网卡920还用于,接收该服务的链接请求报文,该链接请求报文中的目的端口号为该监听端口号,根据该目的端口号将该待接收报文转发到该监听端口号对应的网卡接收队列;The network card 920 is further configured to: receive a link request message of the service, where the destination port number in the link request message is the listening port number, and forward the to-be-received message to the listening port number according to the destination port number. Network card receiving queue;
该主机910还用于,从该监听端口号对应的网卡接收队列中获取该链接请求报文。The host 910 is further configured to obtain the link request message from the network card receiving queue corresponding to the listening port number.
在本发明另一个实施例中,主机910,用于根据服务的监听端口号,以及配置的映射关系信息,将该服务与第一处理器核标识绑定,其中,该映射关系信息包括处理器核标识和端口号的映射关系,从第一网卡接收队列中获取该服务的待接收报文,其中,该第一网卡接收队列为第一处理器核标识对 应的网卡接收队列;In another embodiment of the present invention, the host 910 is configured to bind the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a processor. The mapping between the core identifier and the port number, the packet to be received of the service is obtained from the first network card receiving queue, where the first network card receiving queue is the first processor core identifier pair The appropriate network card receiving queue;
网卡920,用于接收该待接收报文,该待接收报文中的目的端口号为该监听端口号,根据该目的端口号将该待接收报文转发到该第一网卡接收队列。The network card 920 is configured to receive the to-be-received packet, and the destination port number in the to-be-received packet is the listening port number, and forward the to-be-received packet to the first network card receiving queue according to the destination port number.
本发明实施例的计算机设备,通过将服务与处理器核标识绑定,一方面可以使网卡将报文转发到相应的网卡队列,从而提高报文的转发效率,另一方面可以将服务和协议栈都对应到同一处理器核上,从而提高对服务的报文的处理效率。The computer device of the embodiment of the present invention, by binding the service to the processor core identifier, can enable the network card to forward the packet to the corresponding network card queue, thereby improving the forwarding efficiency of the packet, and on the other hand, the service and the protocol can be implemented. The stacks all correspond to the same processor core, thereby improving the processing efficiency of the service packets.
可选地,该主机910还用于,将该监听端口号写入该服务的待发送报文的源端口号字段,将该待发送报文发送到网卡发送队列;Optionally, the host 910 is further configured to: write the listening port number to a source port number field of the to-be-sent packet of the service, and send the to-be-sent packet to the network card sending queue;
该网卡920还用于,发送该网卡发送队列中的该待发送报文。The network card 920 is further configured to send the to-be-sent packet in the network card sending queue.
应理解,本发明实施例的计算机设备900、主机910和网卡920可以执行前述本发明方法实施例中的相应流程,为了简洁,在此不再赘述。It should be understood that the computer device 900, the host 910, and the network card 920 of the embodiments of the present invention may perform the corresponding processes in the foregoing method embodiments of the present invention. For brevity, no further details are provided herein.
应理解,主机910可以包括处理器和存储器。存储器用于存储程序,处理器用于执行程序,用于执行前述本发明实施例中的方法。It should be understood that host 910 can include a processor and a memory. The memory is for storing a program, and the processor is for executing a program for performing the method in the foregoing embodiments of the present invention.
应理解,在本发明实施例中,术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系。例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。It should be understood that in the embodiment of the present invention, the term "and/or" is merely an association relationship describing an associated object, indicating that there may be three relationships. For example, A and/or B may indicate that A exists separately, and A and B exist simultaneously, and B cases exist alone. In addition, the character "/" in this article generally indicates that the contextual object is an "or" relationship.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both, for clarity of hardware and software. Interchangeability, the composition and steps of the various examples have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示 意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口、装置或单元的间接耦合或通信连接,也可以是电的,机械的或其它的形式连接。In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the device embodiments described above are merely illustrative For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some features may be Ignore, or not execute. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, or an electrical, mechanical or other form of connection.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本发明实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention contributes in essence or to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此。 The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto.

Claims (18)

  1. 一种处理报文的方法,其特征在于,包括:A method for processing a message, comprising:
    获取服务绑定的第一处理器核标识;Obtaining a first processor core identifier of the service binding;
    根据所述第一处理器核标识,以及配置的映射关系信息,确定所述服务对应的第一本地端口号,其中,所述映射关系信息包括处理器核标识和端口号的映射关系;Determining, according to the first processor core identifier, and the configured mapping relationship information, a first local port number corresponding to the service, where the mapping relationship information includes a mapping relationship between a processor core identifier and a port number;
    将所述第一本地端口号写入所述服务的待发送报文的源端口号字段;Writing the first local port number into a source port number field of the to-be-sent packet of the service;
    将所述待发送报文发送到网卡发送队列。Sending the to-be-sent message to the network card sending queue.
  2. 根据权利要求1所述的方法,其特征在于,所述映射关系信息包括处理器核标识、网卡接收队列和端口号的映射关系。The method according to claim 1, wherein the mapping relationship information comprises a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
  3. 根据权利要求1或2所述的方法,其特征在于,每个处理器核标识对应多个端口号。The method of claim 1 or 2 wherein each processor core identifies a corresponding plurality of port numbers.
  4. 根据权利要求3所述的方法,其特征在于,所述确定所述第一本地端口号,包括:The method of claim 3, wherein the determining the first local port number comprises:
    从所述第一处理器核标识对应的多个端口号中,选择所述第一本地端口号。Selecting the first local port number from a plurality of port numbers corresponding to the first processor core identifier.
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, further comprising:
    从所述第一本地端口号对应的网卡接收队列中获取所述服务的待接收报文,其中,所述待接收报文由网卡根据所述待接收报文中的目的端口号转发到所述第一本地端口号对应的网卡接收队列。Obtaining a to-be-received packet of the service from the network card receiving queue corresponding to the first local port number, where the to-be-received packet is forwarded by the network card according to the destination port number in the to-be-received packet to the The NIC receiving queue corresponding to the first local port number.
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,所述待发送报文包括客户端的链接请求报文;The method according to any one of claims 1 to 5, wherein the to-be-sent message includes a link request message of the client;
    在所述获取服务绑定的第一处理器核标识之前,所述方法还包括:Before the obtaining the first processor core identifier of the service binding, the method further includes:
    将所述服务与所述第一处理器核标识绑定。Binding the service to the first processor core identity.
  7. 根据权利要求1至5中任一项所述的方法,其特征在于,所述待发送报文包括服务器端的链接接受报文;The method according to any one of claims 1 to 5, wherein the to-be-sent message includes a link accepting message on the server side;
    在所述获取服务绑定的第一处理器核标识之前,所述方法还包括:Before the obtaining the first processor core identifier of the service binding, the method further includes:
    根据所述服务的监听端口号,以及所述映射关系信息,将所述服务与所述第一处理器核标识绑定;And binding the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
    从所述监听端口号对应的网卡接收队列中获取所述服务的链接请求报 文。Obtaining a link request report of the service from a network card receiving queue corresponding to the listening port number Text.
  8. 一种处理报文的方法,其特征在于,包括:A method for processing a message, comprising:
    根据服务的监听端口号,以及配置的映射关系信息,将所述服务与第一处理器核标识绑定,其中,所述映射关系信息包括处理器核标识和端口号的映射关系;Binding the service to the first processor core identifier according to the listening port number of the service, and the configured mapping relationship information, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number;
    从第一网卡接收队列中获取所述服务的待接收报文,其中,所述第一网卡接收队列为第一处理器核标识对应的网卡接收队列。Obtaining a to-be-received message of the service from the first network card receiving queue, where the first network card receiving queue is a network card receiving queue corresponding to the first processor core identifier.
  9. 根据权利要求8所述的方法,其特征在于,所述方法还包括:The method of claim 8 further comprising:
    将所述监听端口号写入所述服务的待发送报文的源端口号字段;Writing the listening port number to a source port number field of the to-be-sent packet of the service;
    将所述待发送报文发送到网卡发送队列。Sending the to-be-sent message to the network card sending queue.
  10. 一种计算机设备,其特征在于,包括:A computer device, comprising:
    主机,用于获取服务绑定的第一处理器核标识,根据所述第一处理器核标识,以及配置的映射关系信息,确定所述服务对应的第一本地端口号,其中,所述映射关系信息包括处理器核标识和端口号的映射关系,将所述第一本地端口号写入所述服务的待发送报文的源端口号字段,将所述待发送报文发送到网卡发送队列;以及a host, configured to obtain a first processor core identifier of the service binding, and determine, according to the first processor core identifier and the configured mapping relationship information, a first local port number corresponding to the service, where the mapping The relationship information includes a mapping relationship between the processor core identifier and the port number, and the first local port number is written in the source port number field of the to-be-sent packet of the service, and the to-be-sent packet is sent to the network card sending queue. ;as well as
    网卡,用于发送所述网卡发送队列中的所述待发送报文。And a network card, configured to send the to-be-sent packet in the network card sending queue.
  11. 根据权利要求10所述的计算机设备,其特征在于,所述映射关系信息包括处理器核标识、网卡接收队列和端口号的映射关系。The computer device according to claim 10, wherein the mapping relationship information comprises a mapping relationship between a processor core identifier, a network card receiving queue, and a port number.
  12. 根据权利要求10或11所述的计算机设备,其特征在于,每个处理器核标识对应多个端口号。A computer apparatus according to claim 10 or 11, wherein each processor core identifier corresponds to a plurality of port numbers.
  13. 根据权利要求12所述的计算机设备,其特征在于,所述主机具体用于,从所述第一处理器核标识对应的多个端口号中,选择所述第一本地端口号。The computer device according to claim 12, wherein the host is specifically configured to select the first local port number from among a plurality of port numbers corresponding to the first processor core identifier.
  14. 根据权利要求10至13中任一项所述的计算机设备,其特征在于,所述网卡还用于,接收所述服务的待接收报文,所述待接收报文中的目的端口号为所述第一本地端口号,根据所述目的端口号将所述待接收报文转发到所述第一本地端口号对应的网卡接收队列;The computer device according to any one of claims 10 to 13, wherein the network card is further configured to receive a message to be received of the service, where a destination port number in the to-be-received message is Transmitting the to-be-received packet to the network card receiving queue corresponding to the first local port number according to the destination port number;
    所述主机还用于,从所述第一本地端口号对应的网卡接收队列中获取所述待接收报文。The host is further configured to obtain the to-be-received packet from a network card receiving queue corresponding to the first local port number.
  15. 根据权利要求10至14中任一项所述的计算机设备,其特征在于, 所述计算机设备为客户端设备,所述待发送报文包括链接请求报文;A computer apparatus according to any one of claims 10 to 14, wherein The computer device is a client device, and the to-be-sent message includes a link request message;
    所述主机还用于,将所述服务与所述第一处理器核标识绑定。The host is further configured to bind the service to the first processor core identifier.
  16. 根据权利要求10至14中任一项所述的计算机设备,其特征在于,所述计算机设备为服务器,所述待发送报文包括链接接受报文;The computer device according to any one of claims 10 to 14, wherein the computer device is a server, and the to-be-sent message includes a link acceptance message;
    所述主机还用于,根据所述服务的监听端口号,以及所述映射关系信息,将所述服务与所述第一处理器核标识绑定;The host is further configured to bind the service to the first processor core identifier according to the listening port number of the service and the mapping relationship information;
    所述网卡还用于,接收所述服务的链接请求报文,所述链接请求报文中的目的端口号为所述监听端口号,根据所述目的端口号将所述待接收报文转发到所述监听端口号对应的网卡接收队列;The network card is further configured to: receive a link request message of the service, where the destination port number in the link request message is the listening port number, and forward the to-be-received message to the destination port number to The network card receiving queue corresponding to the listening port number;
    所述主机还用于,从所述监听端口号对应的网卡接收队列中获取所述链接请求报文。The host is further configured to obtain the link request message from a network card receiving queue corresponding to the listening port number.
  17. 一种计算机设备,其特征在于,包括:A computer device, comprising:
    主机,用于根据服务的监听端口号,以及配置的映射关系信息,将所述服务与第一处理器核标识绑定,其中,所述映射关系信息包括处理器核标识和端口号的映射关系,从第一网卡接收队列中获取所述服务的待接收报文,其中,所述第一网卡接收队列为第一处理器核标识对应的网卡接收队列;The host is configured to bind the service to the first processor core identifier according to the listening port number of the service and the configured mapping relationship information, where the mapping relationship information includes a mapping relationship between the processor core identifier and the port number. Obtaining a to-be-received message of the service from the first network card receiving queue, where the first network card receiving queue is a network card receiving queue corresponding to the first processor core identifier;
    网卡,用于接收所述待接收报文,所述待接收报文中的目的端口号为所述监听端口号,根据所述目的端口号将所述待接收报文转发到所述第一网卡接收队列。a network card, configured to receive the to-be-received packet, where the destination port number in the to-be-received packet is the listening port number, and forward the to-be-received packet to the first network card according to the destination port number. Receive queue.
  18. 根据权利要求17所述的计算机设备,其特征在于,所述主机还用于,将所述监听端口号写入所述服务的待发送报文的源端口号字段,将所述待发送报文发送到网卡发送队列;The computer device according to claim 17, wherein the host is further configured to: write the listening port number into a source port number field of the to-be-sent packet of the service, and send the to-be-sent packet Send to the network card send queue;
    所述网卡还用于,发送所述网卡发送队列中的所述待发送报文。 The network card is further configured to send the to-be-sent packet in the network card sending queue.
PCT/CN2016/107521 2016-11-28 2016-11-28 Method for processing packet, and computer device WO2018094743A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2016/107521 WO2018094743A1 (en) 2016-11-28 2016-11-28 Method for processing packet, and computer device
CN201680004271.1A CN108377671B (en) 2016-11-28 2016-11-28 Method and computer equipment for processing message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/107521 WO2018094743A1 (en) 2016-11-28 2016-11-28 Method for processing packet, and computer device

Publications (1)

Publication Number Publication Date
WO2018094743A1 true WO2018094743A1 (en) 2018-05-31

Family

ID=62194612

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/107521 WO2018094743A1 (en) 2016-11-28 2016-11-28 Method for processing packet, and computer device

Country Status (2)

Country Link
CN (1) CN108377671B (en)
WO (1) WO2018094743A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111049750A (en) * 2019-12-05 2020-04-21 东软集团股份有限公司 Message forwarding method, system and equipment
CN111756649A (en) * 2020-05-29 2020-10-09 浪潮电子信息产业股份有限公司 Data transmission method, device, equipment and computer readable storage medium
CN112162901A (en) * 2020-09-21 2021-01-01 东软集团股份有限公司 Method, system, storage medium and electronic device for determining CPU utilization rate
CN113938400A (en) * 2021-08-27 2022-01-14 曙光网络科技有限公司 Flow table management and maintenance method, device and storage medium
CN114205185A (en) * 2020-09-16 2022-03-18 厦门网宿有限公司 Proxy method and device for control message
CN114978953A (en) * 2022-07-27 2022-08-30 北京立华莱康平台科技有限公司 Network card identification method and device and computer readable medium

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110768999B (en) * 2019-10-31 2022-01-25 杭州迪普科技股份有限公司 Method and device for detecting illegal external connection of equipment
CN111917735A (en) * 2020-07-12 2020-11-10 中信银行股份有限公司 Communication message generation and processing method and device and electronic equipment
CN114448916A (en) * 2021-12-24 2022-05-06 锐捷网络股份有限公司 TIPC message processing method, device, equipment and storage medium
CN114979286B (en) * 2022-05-11 2023-09-19 咪咕文化科技有限公司 Access control method, device, equipment and computer storage medium for container service
CN115037708B (en) * 2022-08-10 2022-11-18 深圳星云智联科技有限公司 Message processing method, system, device and computer readable storage medium
CN116055586B (en) * 2022-08-15 2023-09-01 荣耀终端有限公司 Fragment message matching method, router and storage medium
CN115118685B (en) * 2022-08-30 2022-11-25 无锡沐创集成电路设计有限公司 Data packet processing method, device, system, electronic device and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101299773A (en) * 2008-06-02 2008-11-05 华为技术有限公司 Method, processor and system for implementing network address conversion
CN101822022A (en) * 2007-10-12 2010-09-01 爱立信电话股份有限公司 Support of triple play services in user devices
US20140204954A1 (en) * 2013-01-22 2014-07-24 Verax Technology Holdings, Inc. Communications gateway for transmitting and receiving information associated with at least one service class
CN105991473A (en) * 2015-03-30 2016-10-05 杭州迪普科技有限公司 Data stream forwarding method and data stream forwarding device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8009682B2 (en) * 2009-05-05 2011-08-30 Citrix Systems, Inc. Systems and methods for packet steering in a multi-core architecture
US8788570B2 (en) * 2009-06-22 2014-07-22 Citrix Systems, Inc. Systems and methods for retaining source IP in a load balancing multi-core environment
CN101626324B (en) * 2009-08-19 2011-12-07 杭州华三通信技术有限公司 Forwarding path detection method and forwarding path detection device
CN103841018B (en) * 2012-11-26 2017-04-19 华为技术有限公司 Content centric network multiport forwarding method and router

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101822022A (en) * 2007-10-12 2010-09-01 爱立信电话股份有限公司 Support of triple play services in user devices
CN101299773A (en) * 2008-06-02 2008-11-05 华为技术有限公司 Method, processor and system for implementing network address conversion
US20140204954A1 (en) * 2013-01-22 2014-07-24 Verax Technology Holdings, Inc. Communications gateway for transmitting and receiving information associated with at least one service class
CN105991473A (en) * 2015-03-30 2016-10-05 杭州迪普科技有限公司 Data stream forwarding method and data stream forwarding device

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111049750A (en) * 2019-12-05 2020-04-21 东软集团股份有限公司 Message forwarding method, system and equipment
CN111049750B (en) * 2019-12-05 2022-12-09 东软集团股份有限公司 Message forwarding method, system and equipment
CN111756649A (en) * 2020-05-29 2020-10-09 浪潮电子信息产业股份有限公司 Data transmission method, device, equipment and computer readable storage medium
CN114205185A (en) * 2020-09-16 2022-03-18 厦门网宿有限公司 Proxy method and device for control message
CN114205185B (en) * 2020-09-16 2023-03-24 厦门网宿有限公司 Proxy method and device for control message
CN112162901A (en) * 2020-09-21 2021-01-01 东软集团股份有限公司 Method, system, storage medium and electronic device for determining CPU utilization rate
CN113938400A (en) * 2021-08-27 2022-01-14 曙光网络科技有限公司 Flow table management and maintenance method, device and storage medium
CN113938400B (en) * 2021-08-27 2023-06-27 曙光网络科技有限公司 Method, apparatus and storage medium for managing and maintaining flow table
CN114978953A (en) * 2022-07-27 2022-08-30 北京立华莱康平台科技有限公司 Network card identification method and device and computer readable medium
CN114978953B (en) * 2022-07-27 2022-10-21 北京立华莱康平台科技有限公司 Network card identification method and device and computer readable medium

Also Published As

Publication number Publication date
CN108377671B (en) 2020-11-20
CN108377671A (en) 2018-08-07

Similar Documents

Publication Publication Date Title
WO2018094743A1 (en) Method for processing packet, and computer device
US10666777B2 (en) Reducing network latency
WO2021135471A1 (en) Data transmission method and apparatus, network card and storage medium
CN105553977B (en) Processing, sending method and the device of request message
CN113326228B (en) Message forwarding method, device and equipment based on remote direct data storage
US11277350B2 (en) Communication of a large message using multiple network interface controllers
US20120331160A1 (en) Multi-path transmission control protocol proxy service
US20100027539A1 (en) Remote message routing device and methods thereof
JP2019134461A (en) System and method for preventing denial of service (dos) attack on system designed for middleware and application execution, and system and method for supporting reliable connection (rc) based on subnet administrator (sa) access in system designed for middleware and application execution
JP2017520214A (en) Method, apparatus and system for flow entry configuration
WO2015114473A1 (en) Method and apparatus for locality sensitive hash-based load balancing
CN105847142B (en) A kind of message transmitting method and device
CN106101007B (en) Handle the method and device of message
JP2016509822A (en) Ethernet packet forwarding
CN110417632B (en) Network communication method, system and server
CN107864101A (en) Load-balancing method and device
US8594113B2 (en) Transmit-side scaler and method for processing outgoing information packets using thread-based queues
WO2019033891A1 (en) Rdma-based network traffic determination method and device
US20200028779A1 (en) Packet processing method and apparatus
US10218820B2 (en) Method and apparatus for processing data packet based on parallel protocol stack instances
US20160099891A1 (en) Packet processing method, apparatus and system
WO2024037366A1 (en) Forwarding rule issuing method, and intelligent network interface card and storage medium
WO2020248906A1 (en) Secure data transmission method and apparatus for intelligent fusion identification network
CN112039712A (en) Method for unloading on cloud server, control device and storage medium
WO2014098185A1 (en) Controller, message delivery system, message delivery method, and program

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16922333

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16922333

Country of ref document: EP

Kind code of ref document: A1