Communication methods and apparatus, electronic devices and storage media

By introducing a combination of fake and real connections into the HTTP/2 protocol, the problem of multiplexing multiple data streams using a single connection in existing technologies is solved, realizing the multi-stream multiplexing feature of the HTTP/2 protocol and improving communication efficiency and stability.

CN116828020BActive Publication Date: 2026-03-13BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-22
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing HTTP/2.0 origin pull solutions cannot support multiple data streams sharing a single connection, thus failing to fully utilize the multiple data stream sharing feature of the HTTP/2.0 protocol.

Method used

By establishing a false connection between the first node and the second node, and using a combination of real and false connections, data transmission for the target application is achieved, ensuring that the target application perceives it as a single connection, while actually realizing the reuse of multiple data streams.

Benefits of technology

Without modifying the target application, this method enables communication of multiple data streams within a single TCP connection, improving communication efficiency and stability, and adapting to dynamic business scenarios and high-concurrency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116828020B_ABST
    Figure CN116828020B_ABST
Patent Text Reader

Abstract

This application provides a communication method, apparatus, electronic device, and storage medium. The method includes: acquiring request data from a first node; encapsulating the request data into target data of a target protocol, wherein the target protocol is a protocol that supports multiple data streams simultaneously within a single TCP connection; establishing a unique pseudo-connection corresponding to a target application, wherein the pseudo-connection is used to transmit data of the target application to a real connection corresponding to the target application, the real connection being a TCP connection between the first node and a second node that supports the target protocol; and forwarding the target data to the second node through the real connection and the pseudo-connection. This application establishes a unique pseudo-connection corresponding to the target application, thereby ensuring that each request data has a dedicated connection for the target application. This allows the target application to support the target protocol and communicate through the target protocol without rewriting the target application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a communication method and apparatus, electronic device and storage medium. Background Technology

[0002] Currently, with the increasing popularity of the HTTP / 2.0 protocol in network applications, CDN customers are no longer satisfied with CDN platforms only supporting the HTTP / 2.0 protocol at the user access end. Some customers with high requirements for security and transmission performance require CDN platforms to support the HTTP / 2.0 protocol across the entire chain, that is, the CDN access end, the CDN internal network, and the CDN to the customer's origin server. At the same time, in dynamic business and some high-concurrency, high-connection scenarios, the multiplexing and data compression features of the HTTP / 2.0 protocol can save equipment resources well. CDN platforms supporting the HTTP / 2.0 protocol across the entire chain can better cope with business pressure.

[0003] In related technologies, although an important feature of the HTTP / 2 protocol is that multiple data streams can reuse a single connection, existing solutions for implementing HTTP / 2 origin pull do not support this important feature of the HTTP / 2 protocol.

[0004] Therefore, there is a problem in the relevant technologies that make it impossible to reuse a single connection for multiple data streams as provided by the HTTP / 2.0 protocol. Summary of the Invention

[0005] This application provides a communication method and apparatus, an electronic device and a storage medium to at least solve the problem in the related art that it is impossible to realize the multiplexing of multiple data streams using a single connection as provided by the HTTP / 2.0 protocol.

[0006] According to one aspect of the embodiments of this application, a communication method is provided, including:

[0007] Obtain request data from the first node, wherein the request data originates from the target application on the first node;

[0008] The request data is encapsulated into target data of the target protocol, wherein the target protocol is a protocol that supports multiple data streams in a single TCP connection.

[0009] Establish a unique pseudo connection corresponding to the target application, wherein the pseudo connection is used to transmit the data of the target application to the real connection corresponding to the target application, and the real connection is a TCP connection between the first node and the second node that supports the target protocol;

[0010] The target data is forwarded to the second node through the real connection and the fake connection.

[0011] Optionally, as described above, establishing a unique pseudo-connection corresponding to the target application includes:

[0012] Determine the flow number of the target flow corresponding to the target application in the true connection, and create the false connection;

[0013] Establish the correspondence between the pseudo-connection and the stream number.

[0014] Optionally, as described above, forwarding the target data to the second node via the real connection and the fake connection includes:

[0015] If the network conditions between the first node and the second node do not meet the preset requirements, the target data is sent to the target sending queue through the fake connection, wherein the target sending queue is a sending queue used to cache the data to be sent by the real connection;

[0016] If the network conditions meet the preset requirements, the target data in the target sending queue is sent to the second node through the true connection.

[0017] Optionally, as described above, before forwarding the target data to the second node via the true connection and the false connection, the method further includes:

[0018] If the resource utilization rate of the first node reaches the preset upper limit, the fake connection is sent to the queue to be processed.

[0019] Optionally, as described above, forwarding the target data to the second node via the real connection and the fake connection includes:

[0020] If it is determined that the real connection can be used for data transmission, the write callback of the fake connection on the pending queue is called back;

[0021] According to the write callback, the target application is woken up to send the target data to the fake connection;

[0022] The target data from the fake connection is forwarded to the second node through the real connection.

[0023] Optionally, as described above, encapsulating the request data into target data of the target protocol includes:

[0024] The request data is encapsulated into initial data for the target protocol;

[0025] If the true connection corresponding to the initial data is determined, the initial flow number in the initial data is modified according to the number of current flows already existing in the true connection to obtain the target data; and / or, the flow control window of the target flow corresponding to the request data is determined; the initial data is encapsulated according to the flow control window to obtain the target data, wherein the data volume of each frame in the target data is less than or equal to the flow size of the flow control window.

[0026] Optionally, as described above, after forwarding the target data to the second node via the true connection and the false connection, the method further includes:

[0027] Obtain the response headers from the second node;

[0028] By parsing the response header, the client corresponding to the response header is determined, wherein the target data is sent by the client to the first node;

[0029] Read the response data corresponding to the response header;

[0030] The response data is encapsulated according to the data types supported by the client to obtain encapsulated data;

[0031] The encapsulated data is sent to the client.

[0032] Optionally, as described above, after obtaining the request data from the first node, the method further includes:

[0033] Obtain confirmation information indicating whether the second node supports the target protocol;

[0034] If the confirmation information indicates that the second node supports the target protocol, a jump operation is performed to jump to the step of encapsulating the request data into target data of the target protocol.

[0035] If the confirmation information indicates that the second node does not support the target protocol, the request data is sent to the second node according to a candidate protocol jointly supported by the second node and the first node.

[0036] According to another aspect of the embodiments of this application, a communication device is also provided, comprising:

[0037] The acquisition module is used to acquire request data from the first node, wherein the request data comes from the target application on the first node;

[0038] An encapsulation module is used to encapsulate the request data into target data of a target protocol, wherein the target protocol is a protocol that supports multiple data streams in a single TCP connection.

[0039] A module is established to establish a unique fake connection corresponding to the target application, wherein the fake connection is used to transmit the data of the target application to the real connection corresponding to the target application, and the real connection is a TCP connection between the first node and the second node that supports the target protocol;

[0040] The sending module is used to forward the target data to the second node through the real connection and the fake connection.

[0041] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used to store a computer program; and the processor is used to execute the method steps of any of the above embodiments by running the computer program stored in the memory.

[0042] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the method steps of any of the above embodiments when running.

[0043] In this embodiment, the method involves acquiring request data from a first node, wherein the request data originates from a target application on the first node; encapsulating the request data into target data of a target protocol, wherein the target protocol is a protocol that supports multiple data streams simultaneously within a single TCP connection; establishing a unique pseudo-connection corresponding to the target application, wherein the pseudo-connection is used to transmit the data of the target application to a real connection corresponding to the target application, the real connection being a TCP connection between the first node and the second node that supports the target protocol; and forwarding the target data to the second node through the real connection and the pseudo-connection. By establishing a unique pseudo-connection corresponding to the target application, each request data can have its own dedicated connection for the target application. This allows the target application to support the target protocol that supports multiple data streams simultaneously within a single TCP connection and to communicate through the target protocol without rewriting the target application, i.e., without needing to adapt the target application to the target protocol. Attached Figure Description

[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 This is a flowchart illustrating an optional communication method according to an embodiment of this application;

[0047] Figure 2 This is a flowchart illustrating another optional communication method according to an embodiment of this application;

[0048] Figure 3 This is a flowchart illustrating another optional communication method according to an embodiment of this application;

[0049] Figure 4 This is a structural block diagram of an optional communication device according to an embodiment of this application;

[0050] Figure 5 This is a structural block diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0051] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0052] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0053] According to one aspect of the embodiments of this application, a communication method is provided. Optionally, in this embodiment, the above-described communication method can be applied to a hardware environment consisting of a terminal and a server. The server connects to the terminal via a network and can be used to provide services (such as message push services, application services, etc.) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services to the server.

[0054] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal is not limited to PC, mobile phone, tablet computer, etc.

[0055] The communication method of this application embodiment can be executed by a server, a terminal, or both. Alternatively, the terminal can execute the communication method of this application embodiment via a client installed on it.

[0056] Taking the communication method in this embodiment executed by the server as an example, such as Figure 1 As shown in the figure, this application provides a communication method, including the following steps:

[0057] Step S101: Obtain request data from the first node, wherein the request data comes from the target application on the first node;

[0058] The communication method in this embodiment can be applied to scenarios where an application can support multiple data streams sharing a single connection without modifying existing applications that support protocols that can only transmit one data stream per connection. Examples include enabling an application supporting HTTP / 1.1 to communicate via HTTP / 2.0, enabling an application supporting HTTP / 1.1 to communicate via HTTP / 3.0, and enabling an application with a protocol that supports only one data stream per connection to support other protocols that allow multiple data streams to share a single connection. This embodiment uses the example of enabling an application supporting HTTP / 1.1 to communicate via HTTP / 2.0 to illustrate the above communication method. The above communication method is equally applicable to other types of communication protocols, provided there is no contradiction.

[0059] Taking the scenario of enabling a target application that supports the HTTP / 1.1 protocol to communicate via the HTTP / 2.0 protocol as an example, another connection uniquely corresponding to the target application is added between the application layer and the HTTP / 2.0 protocol connection, so that the target application mistakenly believes that it is still using the HTTP / 1.1 protocol.

[0060] The first node can be a node that can communicate with other nodes. When this application is applied to a CDN scenario, the first node can be an edge node that interfaces with the client.

[0061] The target data can be data generated by the target application on the first node; it can also be data forwarded from other ends by the target application on the first node; or it can be data obtained by the target application after processing the raw data received by the first node from other ends, which is then used to request data from the second node.

[0062] The target application can be an application that supports a protocol that allows only one data stream to be transmitted per connection, such as an application that supports the HTTP 1.1 protocol.

[0063] For example, in a CDN scenario, after an edge node (i.e., the first node) receives request data from a client, if the data corresponding to the access request does not exist on that edge node, the target application on the edge node requests the data required by the client from the upper-level node through the request data.

[0064] Step S102: Encapsulate the request data into target data of the target protocol, wherein the target protocol is a protocol that supports multiple data streams in a single TCP connection.

[0065] After obtaining the requested data, in order to communicate via the target protocol, the requested data needs to be encapsulated into target data of the target protocol. The target protocol is a protocol that supports multiple data streams within a single TCP connection, such as HTTP / 2 or HTTP / 3.0.

[0066] For example, after obtaining the request data, if the target protocol is determined to be HTTP / 2.0, the request data can be encapsulated into HTTP / 2.0 frame format, such as HTTP / 2.0 header frames and data frames.

[0067] Step S103: Establish a unique fake connection corresponding to the target application. The fake connection is used to transmit the target application's data to the real connection corresponding to the target application. The real connection is a TCP connection between the first node and the second node that supports the target protocol.

[0068] After determining that the target application needs to send request data, and since the target application itself does not support the multi-stream multiplexing protocol, a fake connection uniquely corresponding to the target application is established so that the target application is aware that the protocol it uses is still a protocol for transmitting a single data stream via a single connection.

[0069] A spurious connection can be used to make the target application aware that it is still communicating via the original HTTP 1.1 protocol. Through a spurious connection, request data can be transferred to the real connection.

[0070] A true connection can be a TCP connection between the first node and the second node that supports the target protocol. In other words, a true connection can be a protocol that supports multiple data streams in a single TCP connection.

[0071] Optionally, when the first node corresponds to a parent node, the target application can have a unique corresponding pseudo-connection; when the first node corresponds to a parent node, the target application can have pseudo-connections corresponding to each parent node. Furthermore, pseudo-connections can be used to transfer data from the target application to the corresponding real connection. That is, the target application does not directly transmit requested data through the real connection, but rather uses pseudo-connections to transfer the target application's data to the corresponding real connection.

[0072] Step S104: Forward the target data to the second node through real and fake connections.

[0073] Once the fake connection corresponding to the target application and the real connection used for the fake connection are identified, the target data can be forwarded to the second node through the real connection and the fake connection.

[0074] The method in this embodiment allows each requested data to have a dedicated connection for the target application. This enables the target application to support multiple data streams within a single TCP connection and communicate through the target protocol without requiring any rewriting of the target application or adaptation to the target protocol.

[0075] As an optional implementation, as described above, step S103, establishing a unique pseudo-connection corresponding to the target application, includes the following steps:

[0076] Step S201: Determine the flow number of the target flow corresponding to the target application in the real connection, and create a fake connection;

[0077] Step S202: Establish the correspondence between pseudo-connections and flow numbers.

[0078] When it is determined that the target application needs to send requested data, it can first check if there is a keep-alive connection with the second node. If there is, it can be used directly; otherwise, a new connection needs to be established. If there is, the number of data streams currently in the keep-alive connection can be determined, and then the flow number of the target flow corresponding to the target application can be determined. For example, if there are two data streams, the flow number of the target flow is 2 (starting from 0). If there is no keep-alive connection, a new connection is established. Generally, there are no existing data streams in the new connection, so the flow number is 0.

[0079] To allow the target application to exclusively use a connection, a dummy connection is created; and a mapping is established between this dummy connection and the stream number. Therefore, after the requested data is scheduled to the dummy connection according to the stream number, the dummy connection can schedule the requested data to the target stream corresponding to the stream number in the real connection, and then send the target data to the second node through the real connection.

[0080] The method in this embodiment achieves the purpose of establishing a false connection corresponding to the target flow in the true connection, which facilitates the subsequent sending of the target data requested by the target application to the second node through the false connection and the true connection to the second node.

[0081] like Figure 2 As shown, as an optional implementation, the method described above, step S104, which forwards the target data to the second node via a true connection and a false connection, includes the following steps:

[0082] Step S301: If the network conditions between the first node and the second node do not meet the preset requirements, the target data is sent to the target sending queue through a fake connection. The target sending queue is a sending queue used to cache the data to be sent by the real connection.

[0083] Step S302: If the network conditions meet the preset requirements, send the target data in the target sending queue to the second node through a true connection.

[0084] If the network conditions between the first node and the second node do not meet the preset requirements, it could be that the network latency between the first node and the second node is higher than the preset threshold (e.g., 60ms) or the network is disconnected.

[0085] If the network conditions between the first node and the second node do not meet the preset requirements, the target data is first cached and then sent to the target sending queue through a fake connection.

[0086] The target sending queue can be a sending queue in the buffer.

[0087] If the network conditions meet the preset requirements, the true connection reads the target sending queue and, if the target data is found, it can send the target data to the second node through the true connection, thus ultimately achieving the purpose of sending packets through the true connection.

[0088] Furthermore, when the network condition between the first node and the second node indicates smooth operation (e.g., network latency is less than or equal to a preset threshold (e.g., 60ms)), the target data is directly scheduled to the true connection so that the target data can be sent directly through the true connection.

[0089] The method in this embodiment can determine whether to directly schedule target data to a real connection based on network conditions, thereby ensuring communication stability.

[0090] like Figure 3 As shown, as an optional implementation, the method described above, before forwarding the request data to the second node via a true connection and a false connection in step S104, further includes the following steps:

[0091] Step S401: If the resource utilization rate of the first node reaches the preset upper limit, send the fake connection to the queue to be processed.

[0092] When the first node is an edge node in the CDN system and experiences a large number of accesses in a short period of time, resulting in high concurrency, the resource utilization of the first node will reach the preset limit. At the same time, since the packet sending process is prone to blocking, it will further affect the resource utilization of the first node.

[0093] Resource utilization can include, but is not limited to, bandwidth utilization, computing resource utilization, etc.

[0094] If the resource utilization of the first node reaches the preset limit, the fake connection can be sent to the waiting queue.

[0095] The pending queue can be a queue used to store low-priority processing tasks.

[0096] For example, when the first node is an edge node, if a blockage occurs during the packet sending process of the first node, the real connection will send the blocked fake connection to the post queue (a queue that exists in Nginx) and wait for epoll (an interface provided by the operating system to the application layer to provide the application layer with information about the kernel-mode data read and write status) to trigger a write event before processing the fake connection.

[0097] Step 104, which forwards the target data to the second node via both real and fake connections, includes:

[0098] Step S402: If it is determined that a real connection can be used for data transmission, the write callback of the fake connection on the pending queue is called back.

[0099] Step S403: According to the write callback, wake up the target application to send the target data to the fake connection.

[0100] If the system at the first node determines that a true connection can be used for data transmission, and the target data is not present in the true connection, a callback function can be used to implement a write callback to the fake connection in the pending queue, thereby waking up the target application to send the target data to the fake connection.

[0101] Step S404: Forward the target data from the fake connection to the second node through the real connection.

[0102] Once the target data is scheduled to the fake connection, it can be forwarded to the second node via the real connection.

[0103] The method in this embodiment can be used to plan strategies for handling false connections based on the resource utilization of the first node, thereby improving the system's operating efficiency at a macro level.

[0104] As an optional implementation, as described above, step S102, which encapsulates the request data into target data of the target protocol, includes the following steps:

[0105] Step S501: Encapsulate the request data into the initial data of the target protocol.

[0106] After obtaining the requested data, it can be encapsulated according to the target protocol on which the communication is based to obtain the initial data. For example, the requested data can be encapsulated into initial data in HTTP / 2.0 frame format.

[0107] After obtaining the initial data, since the connection or data stream information for transmitting the initial data is not yet clear, the connection or stream number information of the initial data can be assigned an initial value, such as "0".

[0108] Step S502: If the true connection corresponding to the initial data is determined, the initial flow number in the initial data is modified according to the number of current flows already existing in the true connection to obtain the target data; and / or, the flow control window of the target flow corresponding to the requested data is determined; the initial data is encapsulated according to the flow control window to obtain the target data, wherein the data volume of each frame in the target data is less than or equal to the flow size of the flow control window.

[0109] Once the true connection corresponding to the initial data is determined, the number of current streams already existing in the true connection can be determined. A current stream can be a data stream that existed in the true connection before the target stream corresponding to the requested data was established.

[0110] Since stream 0 is the control flow for the entire connection and does not transmit data, odd-numbered streams are uplink data and even-numbered streams are downlink data. After determining the number N of the current streams, the initial stream number in the initial data can be modified to the stream number (i.e., 2N+1) to obtain the target data.

[0111] Additionally, the flow control window of the target stream corresponding to the requested data can be determined. The flow control window can be information used to limit the flow of the target stream.

[0112] After the flow control window is determined, the initial data can be encapsulated in accordance with the flow control window to obtain the target data. The data size of each frame in the target data is less than or equal to the flow size of the flow control window.

[0113] The method in this embodiment can be used to perform secondary encapsulation on the initial data so that the data transmitted in the final true connection meets the requirements of the true connection.

[0114] As an optional implementation, as described above, after forwarding the target data to the second node via a true connection and a false connection in step S104, the method further includes the following steps:

[0115] Step S601: Obtain the response header from the second node;

[0116] Step S602: By parsing the response header, the client corresponding to the response header is determined, wherein the request data is sent by the client to the first node;

[0117] Step S603: Read the response data corresponding to the response header;

[0118] Step S604: Encapsulate the response data according to the data types supported by the client to obtain the encapsulated data;

[0119] Step S605: Send the encapsulated data to the client.

[0120] After the target data is sent to the second node, the second node will respond to the target data and generate response data. Since the response data is received through a real connection, the response data from the second node can be received through the real connection. The response data is then scheduled to the corresponding fake connection according to the flow number, and the target application obtains the response data through the fake connection.

[0121] After receiving the response data, it can be encapsulated based on the data types that the client can parse (e.g., supported protocols) to obtain encapsulated data that the client can parse.

[0122] Once the encapsulated data is obtained, it can be sent to the client.

[0123] Using the method in this embodiment, after receiving the response data from the second node, the response data can be sent to the corresponding client.

[0124] As an optional implementation, as described above, after obtaining the request data from the first node in step S104, the method further includes the following steps:

[0125] Step S701: Obtain confirmation information indicating whether the second node supports the target protocol.

[0126] Optionally, the second node can be queried to determine whether it supports the target protocol, and confirmation information from the second node in response to the query can be obtained.

[0127] Confirmation information can be used to indicate whether the second node supports the target protocol.

[0128] For example, whether the second node supports the HTTP / 2 protocol can be determined via ALPN during the TLS handshake.

[0129] Step S702: If the confirmation information indicates that the second node supports the target protocol, execute the jump operation to the step of encapsulating the request data into target data of the target protocol.

[0130] Determining whether the second node supports the target protocol can be achieved either by the second node itself supporting the target protocol, or by the second node supporting the target protocol after negotiation upgrade.

[0131] If the confirmation information indicates that the second node supports the target protocol, it means that the second node can communicate through the target protocol, and can then perform a jump operation to encapsulate the request data into target data of the target protocol.

[0132] Step S703: If the confirmation information indicates that the second node does not support the target protocol, the request data is sent to the second node according to the candidate protocol jointly supported by the second node and the first node.

[0133] If the information indicates that the second node does not support the target protocol, the protocols supported by the second node and the first node can be determined. Then, a candidate protocol supported by both the second and first nodes can be determined, and the request data can be sent to the second node according to the candidate protocol.

[0134] For example, using the HTTP / 2 protocol can be divided into two modes: direct communication using HTTP / 2.0 and upgrading from HTTP / 1.1 to HTTP / 2.0 through negotiation. Furthermore, during the TLS handshake, it's possible to determine whether the second node supports HTTP / 2.0 via ALPN. If the second node does not support HTTP / 2.0, it can fall back to HTTP / 1.1, thus enabling communication between the first and second nodes. If the second node supports negotiated upgrade to HTTP / 2.0, then HTTP / 2.0 can be used for communication.

[0135] The method in this embodiment can determine the communication protocol based on the second node by assessing its support for different communication protocols, thus effectively ensuring the stability of the communication.

[0136] The following describes an application example that applies any of the foregoing embodiments:

[0137] 1. When edge nodes communicate with middleware nodes through Nginx, the data flow process goes through the following stages:

[0138] 1) Encapsulate the number of requests sent from edge nodes to middleware nodes: Encapsulate the request data into HTTP / 2.0 frames in HTTP / 2.0 frame format;

[0139] 2) Check if there is a live connection between the edge node and the middle layer node (i.e., check if an HTTP / 2.0 connection already exists). If there is, use the live connection directly. If not, the connection between the edge node and the middle layer node needs to be re-established.

[0140] 3) Processing data requests sent to intermediate layer nodes: Inspecting HTTP / 2.0 frames, performing secondary encapsulation if necessary to obtain the target data, and sending the target data to the intermediate layer nodes based on HTTP / 2.0;

[0141] 4) Parse the response headers from the intermediate layer nodes to determine the corresponding client;

[0142] 5) Send response headers to the client;

[0143] 6) Read and process the response data from the backend;

[0144] 7) Send response data to the client;

[0145] 2. In step 3), sending the target data to the intermediate layer node based on HTTP / 2.0, which is one of the optional implementation methods for implementing HTTP / 2.0 connection multi-stream multiplexing, is shown below:

[0146] 1) Create a fake connection for the HTTP / 2.0 stream to handle the original Nginx upstream (where the target application routes request data). The upstream will not be aware of the real connection. Therefore, the data processing flow of the Nginx upstream can be separated from the HTTP / 2.0 real connection. Each HTTP / 2.0 origin request has its own dedicated connection for the Nginx upstream. This can maximize the adaptation to the Nginx upstream data processing flow. In fact, multiple HTTP / 2.0 origin requests reuse a single connection to achieve the HTTP / 2.0 multi-stream multiplexing feature. The real connection is responsible for sending and receiving packets and read / write event callbacks at the HTTP / 2.0 protocol level.

[0147] 2) When epoll triggers a read event, the read callback of the real connection dispatches the data retrieved by recv to the fake connection of the corresponding stream and calls the read callback of the fake connection. The upstream obtains the data through the fake connection for processing.

[0148] 3) The upstream sends data through a fake connection, which then sends the data to the send queue of the real connection, and the real connection performs the actual packet sending.

[0149] 4) If a blockage occurs during packet sending (e.g., high concurrency due to high access volume), the real connection will send the blocked fake connection to the post queue (i.e., the queue to be processed) and wait for epoll to trigger a write event.

[0150] 5) When epoll triggers a write event, the real connection sends a packet, and then the write callback of the fake connection on the post queue is called back, which wakes up the upstream callback on the fake connection.

[0151] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0152] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0153] According to another aspect of the embodiments of this application, a communication apparatus for implementing the above-described communication method is also provided. Figure 4 This is a structural block diagram of an optional communication device according to an embodiment of this application, such as... Figure 4 As shown, the device may include:

[0154] Module 1 is used to obtain request data from the first node, wherein the request data comes from the target application on the first node;

[0155] Encapsulation module 2 is used to encapsulate the request data into target data of the target protocol, wherein the target protocol is a protocol that supports multiple data streams in a single TCP connection.

[0156] Module 3 is established to create a unique pseudo connection corresponding to the target application. The pseudo connection is used to transfer data from the target application to the real connection corresponding to the target application.

[0157] Sending module 4 is used to forward request data to the second node through real connections and fake connections, wherein the real connection is a TCP connection between the first node and the second node that supports the target protocol.

[0158] It should be noted that the acquisition module 1 in this embodiment can be used to perform the above step S101, the encapsulation module 2 in this embodiment can be used to perform the above step S102, the establishment module 3 in this embodiment can be used to perform the above step S103, and the sending module 4 in this embodiment can be used to perform the above step S104.

[0159] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of the device, can operate in implementing... Figure 1 The method shown can be implemented in either software or hardware within a hardware environment, where the hardware environment includes a network environment.

[0160] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described communication method is also provided. The electronic device may be a server, a terminal, or a combination thereof.

[0161] According to another embodiment of this application, an electronic device is also provided, comprising: Figure 5 As shown, the electronic device may include: a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.

[0162] Memory 1503 is used to store computer programs;

[0163] When processor 1501 executes the program stored in memory 1503, it performs the following steps:

[0164] Step S101: Obtain request data from the first node, wherein the request data comes from the target application on the first node;

[0165] Step S102: Encapsulate the request data into target data of the target protocol, wherein the target protocol is a protocol that supports multiple data streams in a single TCP connection.

[0166] Step S103: Establish a unique fake connection corresponding to the target application. The fake connection is used to transmit the target application's data to the real connection corresponding to the target application. The real connection is a TCP connection between the first node and the second node that supports the target protocol.

[0167] Step S104: Forward the target data to the second node through real and fake connections.

[0168] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.

[0169] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0170] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0171] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the method steps of the above method embodiments when it runs.

[0172] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0173] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0174] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0175] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0176] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.

[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the solution provided in this embodiment, depending on actual needs.

[0178] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0179] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A communication method characterized by comprising: The method comprises: obtaining request data from a first node, wherein the request data is from a target application on the first node; encapsulating the request data into target data of a target protocol, wherein the target protocol is a protocol supporting multiple data streams in one TCP connection; establishing a false connection corresponding to the target application, comprising: determining a flow number of a target flow corresponding to the target application in the true connection, and creating the false connection; establishing a correspondence between the false connection and the flow number, wherein the false connection is used to transmit data of the target application to a true connection corresponding to the target application, and the true connection is a TCP connection supporting the target protocol between the first node and a second node; forwarding the target data to the second node through the true connection and the false connection.

2. The method of claim 1, wherein, The forwarding of the target data to the second node through the true connection and the false connection comprises: in a case where network conditions between the first node and the second node do not meet preset requirements, sending the target data to a target sending queue through the false connection, wherein the target sending queue is a sending queue used to buffer to-be-sent data of the true connection; in a case where the network conditions meet the preset requirements, sending the target data in the target sending queue to the second node through the true connection.

3. The method of claim 1, wherein, Before the forwarding of the target data to the second node through the true connection and the false connection, the method further comprises: in a case where a resource usage rate of the first node reaches a preset upper limit, sending the false connection to a to-be-processed queue, wherein the false connection is used to make the target application perceive that a protocol adopted by the target application is a protocol in which one connection is used to transmit one data stream.

4. The method of claim 3, wherein, The forwarding of the target data to the second node through the true connection and the false connection comprises: in a case where it is determined that the true connection can be used for data transmission, calling back a write callback of the false connection on the to-be-processed queue; according to the write callback, waking up the target application to send the target data to the false connection; forwarding the target data from the false connection to the second node through the true connection.

5. The method of claim 1, wherein, The encapsulation of the request data into target data of a target protocol comprises: encapsulating the request data into initial data of the target protocol; in a case where it is determined that the initial data corresponds to the true connection, modifying an initial flow number in the initial data according to a number of current flows already existing in the true connection, to obtain the target data; and / or, determining a flow control window of a target flow corresponding to the request data; and encapsulating the initial data according to the flow control window to obtain the target data, wherein a data amount of each frame of data in the target data is less than or equal to a flow size of the flow control window.

6. The method according to any one of claims 1 to 5, characterized in that, After the forwarding of the target data to the second node through the true connection and the false connection, the method further comprises: obtaining a response header from the second node; In the response header is parsed, it is determined that the response header corresponds to the client, wherein the target data is sent to the first node by the client; Read the response data corresponding to the response header; According to the data type supported by the client, the response data is encapsulated to obtain the encapsulated data; The encapsulated data is sent to the client.

7. The method according to any one of claims 1 to 5, characterized in that, After the request data from the first node is obtained, the method further comprises: Obtain the confirmation information for indicating whether the second node supports the target protocol; In the case that the confirmation information indicates that the second node supports the target protocol, perform the jump operation for jumping to the step of encapsulating the request data into the target data of the target protocol; In the case that the confirmation information indicates that the second node does not support the target protocol, the request data is sent to the second node according to the candidate protocol supported by the second node and the first node.

8. A communication device, characterized by Comprise: The acquisition module is used for obtaining the request data from the first node, wherein the request data is from the target application on the first node; The encapsulation module is used for encapsulating the request data into the target data of the target protocol, wherein the target protocol is a protocol supporting multiple data streams in one TCP connection; The establishment module is used for establishing a false connection corresponding to the target application, comprising: determining the flow number of the target flow corresponding to the target application in the true connection, creating the false connection; Establish the correspondence between the false connection and the flow number, wherein the false connection is used to transmit the data of the target application to the true connection corresponding to the target application, and the true connection is a TCP connection between the first node and the second node supporting the target protocol; The sending module is used for forwarding the target data to the second node through the true connection and the false connection.

9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein, The processor, the communication interface and the memory complete the communication among each other through the communication bus, characterized in that, The memory is used for storing a computer program; The processor is used for executing the method steps of any one of claims 1 to 7 by running the computer program stored on the memory.

10. A computer readable storage medium, characterized in that, The storage medium has a computer program stored therein, wherein the computer program is configured to execute the method steps in any one of claims 1 to 7 when running. The storage medium has a computer program stored therein, wherein the computer program is configured to execute the method steps in any one of claims 1 to 7 when running.

Citation Information

Patent Citations

  • Signal negotiation method and device for realizing RTP data stream multiplexing

    CN101616156A

  • Detecting malware on SPDY connections

    CN108605039A