# US 2024/0205170 A1 · Communication method based on user-mode protocol stack, and corresponding apparatus

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0205170 A1
- Document ID: US20240205170A1
- Status: Published application
- Kind: A1
- Application number: 18/589,783
- Filed: 2024-02-28
- Published: 2024-06-20
- Earliest claimed: 2021-08-31
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Zhihao LU; Liming HUANG; Changye WU
- Web page: https://patentgrep.com/patent/US20240205170A1

## CPC

- H04L 49/355: {Application aware switches, e.g. for HTTP}
- H04L 69/30: Definitions, standards or architectural aspects of layered protocol stacks
- G06F 9/54: Interprogram communication
- H04L 9/40: Network security protocols
- H04L 49/109: Integrated on microchip, e.g. switch-on-chip
- H04L 49/901: using storage descriptor, e.g. read or write pointers
- H04L 69/16: Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L 69/32: Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e.g. the interfaces between the data link level and the physical level
- H04L 69/321: Interlayer communication protocols or service data unit [SDU] definitions; Interfaces between layers
- H04L 43/10: Active monitoring, e.g. heartbeat, ping or trace-route
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Example communication methods and systems based on a user-mode protocol stack are provided. One example method is applied to a service side, where the service side includes an application layer, the user-mode protocol stack, and a hardware layer. A target application of the application layer corresponds to at least one W thread. The example method includes obtaining, by using a routing module, a first correspondence and a second correspondence, where the first correspondence includes a correspondence between a listen file descriptor (FD) of a first W thread and a plurality of shadow FDs, and the second correspondence includes a correspondence between a target N thread and a connection FD. Communication with a client is performed using the routing module based on the first correspondence and the second correspondence.

## Claims

### Claim 1

A communication method based on a user-mode protocol stack and applied to a service side, wherein the service side comprises an application layer, the user-mode protocol stack, and a hardware layer, wherein a target application of the application layer corresponds to at least one W thread, each of the at least one W thread is a thread for processing data of the target application, wherein the user-mode protocol stack comprises a plurality of N threads, a routing module, and transmission control protocol hash tables that are in a one-to-one correspondence with the plurality of N threads, wherein each of the plurality of N threads is a user-mode protocol stack thread, wherein the hardware layer comprises a plurality of non-uniform memory access (NUMA) nodes and a network adapter, and wherein the plurality of N threads are in a one-to-one correspondence with the plurality of NUMA nodes, and the method comprises:
obtaining a first correspondence by using the routing module, wherein the first correspondence comprises a correspondence between a listen file descriptor (FD) of a first W thread and a plurality of shadow FDs, the plurality of shadow FDs are generated in a one-to-one manner for the plurality of N threads, and the first W thread is one of the at least one W thread;
obtaining a second correspondence by using the routing module, wherein the second correspondence comprises a correspondence between a target N thread and a connection FD, and the target N thread is an N thread selected by the network adapter from the plurality of N threads when a communication connection to a client is established; and
communicating with the client by using the routing module based on the first correspondence and the second correspondence.

### Claim 2 (depends on 1)

The communication method according to claim 1, wherein the obtaining a first correspondence by using the routing module comprises:
receiving, by using the routing module, a listen operation initiated by the first W thread;
generating the listen FD for the first W thread;
initiating a listen operation to each of the plurality of N threads by using the routing module, to obtain the plurality of shadow FDs corresponding to the plurality of N threads, wherein the plurality of shadow FDs are in a one-to-one correspondence with the plurality of N threads; and
establishing the correspondence between the listen FD and the plurality of shadow FDs by using the routing module, to obtain the first correspondence.

### Claim 3 (depends on 1)

The communication method according to claim 1, wherein the network adapter comprises at least one network adapter queue, and the obtaining a second correspondence by using the routing module comprises:
obtaining, by using the routing module, the connection FD generated by the target N thread to establish the communication connection, wherein the communication connection is established based on a link establishment request that is sent by the client and that is received by a first network adapter queue, and the first network adapter queue is one of the at least one network adapter queue; and
establishing the correspondence between the target N thread and the connection FD by using the routing module, to obtain the second correspondence.

### Claim 4 (depends on 1)

The communication method according to claim 1, wherein the communicating with the client by using the routing module based on the first correspondence and the second correspondence comprises:
transferring, by using the routing module, the connection FD corresponding to the target N thread to the first W thread based on a correspondence that is in the first correspondence and that is between a shadow FD corresponding to the target N thread and the listen FD corresponding to the first W thread; and
communicating with the client by using the routing module based on the connection FD and the second correspondence.

### Claim 5 (depends on 4)

The communication method according to claim 4, wherein when there are a plurality of W threads corresponding to the target application, the communicating with the client by using the routing module based on the connection FD and the second correspondence comprises:
receiving, by using the routing module, a poll/extended poll (epoll) event initiated by a second W thread, wherein the poll/epoll event comprises the connection FD, the connection FD is transferred by the first W thread to the second W thread, the second W thread enters a sleep state after initiating the poll/epoll event, and the second W thread is one of the plurality of W threads corresponding to the target application;
determining, by using the routing module based on the second correspondence, that the connection FD corresponds to the target N thread, to wait for a wake-up event related to the target N thread; and
after the second W thread is woken up, performing, by using the routing module based on the second correspondence, a read operation or a write operation related to the target N thread.

### Claim 6 (depends on 5)

The communication method according to claim 5, wherein the method further comprises:
waking up the second W thread by using a wake-up proxy thread associated with the target N thread.

### Claim 7 (depends on 5)

The communication method according to claim 5, wherein after the determining, by using the routing module based on the second correspondence, that the connection FD corresponds to the target N thread, the method further comprises:
allocating a receive queue and a transmit queue to the connection FD in a memory of a NUMA node corresponding to the target N thread, wherein the receive queue is used to record a memory address of data related to the read operation, and the transmit queue is used to record a memory address of data related to the write operation.

### Claim 8 (depends on 7)

The communication method according to claim 7, wherein the performing, by using the routing module based on the second correspondence, a read operation related to the target N thread comprises:
receiving, by using the routing module, a read operation initiated by the second W thread or a third W thread, wherein the received read operation carries the connection FD, the third W thread is one of the plurality of W threads corresponding to the target application, and when the third W thread initiates the received read operation, the connection FD is transferred by the second W thread to the third W thread;
obtaining, by using the routing module based on the connection FD, a memory address of first data from the receive queue associated with the connection FD, wherein the first data is data received from the client by a first network adapter queue associated with the target N thread, and the first network adapter queue is a network adapter queue that receives a link establishment request sent by the client;
obtaining the first data based on the memory address of the first data; and
transferring the first data to the second W thread or the third W thread for processing.

### Claim 9 (depends on 7)

The communication method according to claim 7, wherein the performing, by using the routing module based on the second correspondence, a write operation related to the target N thread comprises:
receiving, by using the routing module, a write operation initiated by the second W thread or a third W thread, wherein the received write operation carries the connection FD and second data, the third W thread is one of the plurality of W threads corresponding to the target application, and when the third W thread initiates the received write operation, the connection FD is transferred by the second W thread to the third W thread;
writing, by using the routing module based on the connection FD, the second data into the memory corresponding to the target N thread;
writing a memory address of the second data in the memory into the transmit queue corresponding to the connection FD; and
when the target N thread obtains the memory address of the second data in the transmit queue through polling, sending the second data in the memory to the network adapter.

### Claim 10 (depends on 8)

The communication method according to claim 8, wherein before the performing a read operation or a write operation, the method further comprises:
binding the second W thread or the third W thread to a processing core in the NUMA node on which the target N thread is located.

### Claim 11

A communication method based on a user-mode protocol stack and applied to a client, wherein the client comprises an application layer, the user-mode protocol stack, and a hardware layer, wherein a target application of the application layer corresponds to at least one W thread, each of the at least one W thread is a thread for processing data of the target application, wherein the user-mode protocol stack comprises a plurality of N threads, a routing module, and transmission control protocol hash tables that are in a one-to-one correspondence with the plurality of N threads, wherein each of the plurality of N threads is a user-mode protocol stack thread, wherein the hardware layer comprises a plurality of non-uniform memory access (NUMA) nodes, and wherein the plurality of N threads are in a one-to-one correspondence with the plurality of NUMA nodes, and the method comprises:
obtaining a target correspondence by using the routing module, wherein the target correspondence comprises a correspondence between a connection file descriptor (FD) and a target N thread, the target N thread is an N thread selected by the routing module for a first W thread that initiates a connection operation, the first W thread is one of the at least one W thread, and the target N thread is one of the plurality of N threads; and
communicating with a service side by using the routing module based on the target correspondence.

### Claim 12 (depends on 11)

The communication method according to claim 11, wherein the obtaining a target correspondence by using the routing module comprises:
receiving, by using the routing module, the connection operation initiated by the first W thread;
selecting the target N thread from the plurality of N threads for the connection operation,
generating the connection FD for the first W thread; and
establishing the correspondence between the target N thread and the connection FD by using the routing module, to obtain the target correspondence.

### Claim 13 (depends on 11)

The communication method according to claim 11, wherein the communicating with a service side by using the routing module based on the target correspondence comprises:
determining, by using the routing module based on the connection FD, a network adapter queue and a NUMA node that corresponds to the target N thread; and
sending a link establishment request and first data to the service side by using the network adapter queue and the NUMA node that corresponds to the target N thread.

### Claim 14 (depends on 13)

The communication method according to claim 13, wherein after the determining, by using the routing module based on the connection FD, a network adapter queue and a NUMA node that corresponds to the target N thread, the method further comprises:
allocating a transmit queue to the connection FD in a memory of the NUMA node corresponding to the target N thread, wherein the transmit queue is used to record a memory address of data related to a write operation.

### Claim 15 (depends on 14)

The communication method according to claim 14, wherein the sending a link establishment request and first data to the service side by using the network adapter queue and the NUMA node that corresponds to the target N thread comprises:
receiving, by using the routing module, a write operation initiated by a second W thread, wherein the received write operation carries the connection FD and the first data, the second W thread is one of a plurality of W threads corresponding to the target application, and when the second W thread initiates the received write operation, the connection FD is transferred by the first W thread to the second W thread;
writing, by using the routing module based on the connection FD, the first data into the memory corresponding to the target N thread;
writing a memory address of the first data in the memory into the transmit queue corresponding to the connection FD; and
when the target N thread obtains the memory address of the first data in the transmit queue through polling, sending the first data in the memory to a network adapter.

### Claim 16

A computing device, comprising one or more processors and a non-transitory computer-readable storage medium storing a computer program
to be executed by the one or more processors, wherein the computer program comprises instructions that when executed, cause the one or more processors to perform operations based on a user-mode protocol stack and applied to a service side, wherein the service side comprises an application layer, the user-mode protocol stack, and a hardware layer, wherein a target application of the application layer corresponds to at least one W thread, each of the at least one W thread is a thread for processing data of the target application, wherein the user-mode protocol stack comprises a plurality of N threads, a routing module, and transmission control protocol hash tables that are in a one-to-one correspondence with the plurality of N threads, wherein each of the plurality of N threads is a user-mode protocol stack thread, wherein the hardware layer comprises a plurality of non-uniform memory access (NUMA) nodes and a network adapter, and wherein the plurality of N threads are in a one-to-one correspondence with the plurality of NUMA nodes, and the operations comprise:
obtaining a first correspondence by using the routing module, wherein the first correspondence comprises a correspondence between a listen file descriptor (FD) of a first W thread and a plurality of shadow FDs, the plurality of shadow FDs are generated in a one-to-one manner for the plurality of N threads, and the first W thread is one of the at least one W thread;
obtaining a second correspondence by using the routing module, wherein the second correspondence comprises a correspondence between a target N thread and a connection FD, and the target N thread is an N thread selected by the network adapter from the plurality of N threads when a communication connection to a client is established; and
communicating with the client by using the routing module based on the first correspondence and the second correspondence.

### Claim 17 (depends on 16)

The computing device according to claim 16, wherein the obtaining a first correspondence by using the routing module comprises:
receiving, by using the routing module, a listen operation initiated by the first W thread;
generating the listen FD for the first W thread;
initiating a listen operation to each of the plurality of N threads by using the routing module, to obtain the plurality of shadow FDs corresponding to the plurality of N threads, wherein the plurality of shadow FDs are in a one-to-one correspondence with the plurality of N threads; and
establishing the correspondence between the listen FD and the plurality of shadow FDs by using the routing module, to obtain the first correspondence.

### Claim 18

(canceled)

### Claim 19

(canceled)

### Claim 20

(canceled)

### Claim 21 (depends on 16)

The computing device according to claim 16, wherein the network adapter comprises at least one network adapter queue, and the obtaining a second correspondence by using the routing module comprises:
obtaining, by using the routing module, the connection FD generated by the target N thread to establish the communication connection, wherein the communication connection is established based on a link establishment request that is sent by the client and that is received by a first network adapter queue, and the first network adapter queue is one of the at least one network adapter queue; and
establishing the correspondence between the target N thread and the connection FD by using the routing module, to obtain the second correspondence.

### Claim 22 (depends on 16)

The computing device according to claim 16, wherein the communicating with the client by using the routing module based on the first correspondence and the second correspondence comprises:
transferring, by using the routing module, the connection FD corresponding to the target N thread to the first W thread based on a correspondence that is in the first correspondence and that is between a shadow FD corresponding to the target N thread and the listen FD corresponding to the first W thread; and
communicating with the client by using the routing module based on the connection FD and the second correspondence.

### Claim 23 (depends on 22)

The computing device according to claim 22, wherein when there are a plurality of W threads corresponding to the target application, the communicating with the client by using the routing module based on the connection FD and the second correspondence comprises:
receiving, by using the routing module, a poll/extended poll (epoll) event initiated by a second W thread, wherein the poll/epoll event comprises the connection FD, the connection FD is transferred by the first W thread to the second W thread, the second W thread enters a sleep state after initiating the poll/epoll event, and the second W thread is one of the plurality of W threads corresponding to the target application;
determining, by using the routing module based on the second correspondence, that the connection FD corresponds to the target N thread, to wait for a wake-up event related to the target N thread; and
after the second W thread is woken up, performing, by using the routing module based on the second correspondence, a read operation or a write operation related to the target N thread.
