Message forwarding method and device for multi-source client, equipment and storage medium
By using the target client to generate a request message containing a one-way incrementing time stamp in a cloud network environment, and generate and send forward messages by the network forwarding device, the problem of failure of multi-client connection request verification is solved, and the success rate of communication connection and network stability are improved.
Patent Information
- Application Number
- CN202411815013.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-03-14
AI Technical Summary
In a cloud network environment, when multiple clients send connection requests to the server through the same network forwarding device, the connection request may not be verified, resulting in the inability to establish a communication connection between the client and the server, affecting the normal transmission of message data.
The request message is generated by a target client running within the target device node deployed in the first cluster and sent to the network forwarding device. The request message includes a first sending feature and a first time stamp. The first sending feature represents the socket address of the target client and the target server. The first time stamp represents the node system time when the request message was sent. In the request message of multiple clients, the first time stamp is incremented in one direction. The network forwarding device generates a first forwarding message based on these characteristics and sends it to the target server to create a communication connection.
By ensuring that the timestamp in the request message is increased in one-way, the problem that the server in the connection-closed state cannot be checked when receiving the forwarded message, thereby improving the success rate of establishing a communication connection between the client and the server, and improving the operation stability of the network server.
Smart Images

Figure CN119629216A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of cloud computing technology, and in particular to a message forwarding method, device, equipment and storage medium for multi-source clients. Background Art
[0002] When a client deployed in a cloud network environment communicates with a server, it is first necessary to create a communication connection, and then transmit messages based on the created communication connection. In the prior art, after receiving a connection request, the server in a connection-closed state will, based on the communication protocol, check the header field in the connection request that represents the time when the request was sent, so as to determine whether the connection request is a duplicate message from an old connection, and create a communication connection after the check passes.
[0003] However, when multiple clients send connection requests to the server through the same network forwarding device, the connection requests may fail to pass the verification, resulting in failure to establish a communication connection between the client and the server, affecting the normal sending of message data. Summary of the invention
[0004] The disclosed embodiments provide a message forwarding method, apparatus, device and storage medium for multi-source clients to overcome the problem that when multiple clients send connection requests to a server via the same network forwarding device, the connection requests may fail to pass verification.
[0005] In a first aspect, an embodiment of the present disclosure provides a message forwarding method for a multi-source client, which is applied to a network forwarding device, including:
[0006] A request message is generated by a target client running in a target device node deployed in the first cluster, and sent to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, and the target device node runs multiple clients and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing;
[0007] Generate, by the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp;
[0008] The first forwarding message is sent to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0009] In a second aspect, an embodiment of the present disclosure provides a message forwarding device for a multi-source client, including:
[0010] A client module, used to generate a request message through a target client running in a target device node deployed in the first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing;
[0011] A first forwarding module, configured to generate, through the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp;
[0012] The second forwarding module is used to send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0013] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
[0014] The memory stores computer-executable instructions;
[0015] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect is implemented.
[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect.
[0018] The message forwarding method, apparatus, device and storage medium for multi-source clients provided in this embodiment generate a request message through a target client running in a target device node deployed in a first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in a second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients run in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing; the network forwarding device generates a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp; the network forwarding device sends the first forwarding message to the target server to establish a communication connection between the target client and the target server. By deploying the target client in the first cluster, a request message with a first timestamp representing the node system time is generated and unidirectionally increased, and the message is sent to the network forwarding device. The network forwarding device then generates a first forwarding message and sends it to the target server, thereby completing the message forwarding process. Since the first timestamp of the request message received by the network forwarding device is unidirectionally increased, the timestamp in the generated first forwarding message can be guaranteed to be unidirectionally increased, thereby avoiding the problem that the target server in the connection closed state cannot pass the inspection when receiving the first forwarding message, thereby improving the success rate of establishing the communication connection between the client and the server, and improving the operating stability of the network server. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 An application scenario diagram of the message forwarding method for multi-source clients provided in an embodiment of the present disclosure;
[0021] Figure 2 Schematic diagram of the process of the message forwarding method for multi-source clients provided in the embodiment of the present disclosure Figure 1 ;
[0022] Figure 3 for Figure 2 A flowchart of a specific implementation method of step S101 in the illustrated embodiment;
[0023] Figure 4 for Figure 2 A flowchart of a specific implementation method of step S102 in the illustrated embodiment;
[0024] Figure 5 A schematic diagram of a process for generating a first forwarding message provided by an embodiment of the present disclosure;
[0025] Figure 6 Schematic diagram of the process of the message forwarding method for multi-source clients provided in the embodiment of the present disclosure Figure 2 ;
[0026] Figure 7 for Figure 6 A flowchart of a specific implementation method of step S202 in the illustrated embodiment;
[0027] Figure 8 for Figure 7 A flowchart of a specific implementation method of step S2021 in the illustrated embodiment;
[0028] Fig. 9 for Figure 6 A flowchart of a specific implementation method of step S203 in the illustrated embodiment;
[0029] Fig.10 A schematic diagram of a message forwarding process provided by an embodiment of the present disclosure;
[0030] Fig.11 A structural block diagram of a message forwarding device for multi-source clients provided in an embodiment of the present disclosure;
[0031] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure;
[0032] Fig.13 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0034] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0035] The application scenarios of the embodiments of the present disclosure are explained below:
[0036] Figure 1 An application scenario diagram of the message forwarding method for multi-source clients provided in the embodiment of the present disclosure. The message forwarding method for multi-source clients provided in the embodiment of the present disclosure can be applied in a cloud network scenario, and more specifically, can be applied to multiple clients deployed in the cloud network, in the process of sending connection requests to the server through the same network forwarding device. The executor of this embodiment can be a cloud network system, a cloud network platform, a virtual device or physical device in which clients and network forwarding devices are deployed in the cloud network, or a control server in the cloud network, or other electronic devices that perform similar functions. Among them, reference Figure 1 As shown, the cloud network includes clients Client_1, Client_2 and Client_3, and the corresponding server Server. The client implements the corresponding application function by requesting data from the server. In this process, when the clients Client_1, Client_2 and Client_3 located in the private network interact with the server Server located in the external network, the request message for creating the connection needs to be forwarded by the network forwarding device N1. Specifically, the request message is subjected to network address translation (NAT) at the forwarding device N1, that is, one network address is mapped / converted to another network address, thereby realizing access between different private networks and the external network. For example, as shown in the figure, the clients Client_1 and Client_2 have private addresses 192.168.0.2 and 192.168.0.3 respectively. When accessing the server Server through a network forwarding device, the source address in the request message sent by the clients Client_1 and Client_2 will be replaced with the external address 10.0.1.3 of the network forwarding device N1. This process is also called source network address translation (SNAT).
[0037] In the above application scenario, after receiving a connection request, the server in the connection closed state will check the header field representing the request sending time in the connection request based on the communication protocol to determine whether the connection request is a duplicate message from the old connection (old duplicate), and after the check is passed, create a communication connection to achieve subsequent message data transmission. However, when multiple clients send connection requests to the server through the same network forwarding device, since the network protocol stacks between the multiple clients are independent of each other, the timestamp representing the request sending time contained in the request message of the new connection does not meet the monotonically increasing condition compared with the old connection, so it will be mistaken for a duplicate message from the old connection, resulting in failure to pass the above check and being rejected by the server. As a result, the communication connection between the client and the server cannot be established, affecting the normal transmission of message data.
[0038] The embodiments of the present disclosure provide a message forwarding method, apparatus, device and storage medium for multi-source clients to solve the above problems.
[0039] refer to Figure 2 , Figure 2 Schematic diagram of the process of the message forwarding method for multi-source clients provided in the embodiment of the present disclosure Figure 1 The method of this embodiment can be applied in a cloud network platform. The message forwarding method for multi-source clients includes:
[0040] Step S101: Generate a request message by a target client running in a target device node deployed in the first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing.
[0041] Step S102: Generate a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp through the network forwarding device.
[0042] Step S103: Send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0043] refer to Figure 1The schematic diagram of the application scenario shown, for example, first, the target client located in the first cluster will respond to a specific client function request and generate a request message, which is used to send to the target server, and create a connection with the target server, or send information to the target server. The target server is the server corresponding to the above-mentioned target client, which is used to provide services and functions to the target client so that the target client can implement the above-mentioned client function request, wherein the target client is deployed in the first cluster (the target device node), and the target server is deployed in the second cluster, that is, the target client and the target server are located in different networks, for example, the target client is located in a private network, and the server is located in a public network. When the two are interacting with each other, the request message needs to be forwarded through a network forwarding device to achieve the mapping of the source network address. Furthermore, multiple target clients can be run in the target device node, and messages can be sent at the same time, that is, message forwarding of multiple source clients.
[0044] Furthermore, the request message generated by the target client includes a first sending feature and a first timestamp, and the first sending feature represents the socket address of the target client and the target server receiving the request message, wherein a socket is an abstraction of an endpoint for two-way communication between application processes on different hosts in a network, and a socket address has a fixed data result, which can be represented in the form of "network address + port number". In short, the socket address is the network address and port number of the communication endpoint. In this embodiment, the first sending feature included in the request message represents the socket address of the target client and the target server receiving the request message. In a possible implementation, the first sending feature includes the network address and port number of the target client, and the network address and port number of the target server. The first sending feature is information required for communication based on a network protocol (such as TCP / IP protocol), which will not be specifically introduced this time.
[0045] On the other hand, the request message contains a first timestamp, which represents the node system time when the request message is sent. In the corresponding request messages generated by multiple target clients respectively, the first timestamp contained therein increases unidirectionally, that is, the first timestamp in the request message is unique, and compared with the first timestamp in the previously generated request message, it increases unidirectionally. Afterwards, after generating the request message, the target client sends the request message to the network forwarding device, and the network forwarding device performs subsequent processing. Among them, the above process of sending the request message to the network forwarding device is determined based on the pre-generated routing table / routing rules, which will not be described in detail this time.
[0046] In a possible implementation, multiple target clients are deployed in the first cluster, such as Figure 3As shown, the specific implementation of step S101 includes:
[0047] Step S1011: each target client obtains the node system time of the first cluster and the corresponding first sending feature when responding to the target request.
[0048] Step S1012: according to the task queue, the system time of each node is processed in sequence to generate a first timestamp that increases in a unidirectional direction.
[0049] Step S1013: construct a request message according to each first timestamp and the corresponding first sending feature and send it to the network forwarding device.
[0050] Exemplarily, for multiple target clients in the first cluster, when each target client responds to a target request (for example, executing the A function of the target client, which needs to call the function and data of the target client), the node system time of the target node device and the corresponding first sending feature are first obtained, wherein the first sending feature is information determined based on the network protocol and is not described in detail; and the node system time is a standard time for the target device node, which has the characteristic of unidirectional increase. By using the unidirectional increase characteristic of the node system time of the same target device node, a unidirectional increase timestamp, i.e., a first timestamp, can be obtained by calling the access interface of the node system time multiple times. In a possible implementation, the node system time can be the coordinated universal time (UTC) or the time recorded by the private timing system for the target device node, which is not limited this time. Afterwards, a unidirectional increase first timestamp is generated according to each node system time. Exemplarily, after obtaining the node system time, each target client sends it to the maintenance task queue in the first cluster, and through the task queue, it is successively converted into a corresponding, unidirectional increase first timestamp, and returned to the target client. Thereafter, the target client constructs a request message according to the first timestamp and the corresponding first sending feature, and may send the request message to the network forwarding device through one or more sending queues according to the order of the first timestamp.
[0051] In the steps of this embodiment, the unified node system time is processed based on the task queue to generate a unique and increasing first timestamp, and then the corresponding request message is generated based on the first timestamp, so that the first timestamp in each request message is increased unidirectionally, thereby avoiding the problem that the generated first forwarding message cannot be verified by the target server due to the inconsistent timestamp calculation method of each target client.
[0052] Step S102: Generate a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp through the network forwarding device.
[0053] Exemplarily, after receiving the request message sent by the target client, the network forwarding device will modify the source network address in the request message to form a first forwarding message, and then forward the first forwarding message to the target server. Specifically, the network forwarding device will construct a sending feature applicable to the first forwarding message based on the first sending feature, that is, the second sending feature. Afterwards, based on the agreement of the network protocol, the request message is encrypted to generate the first forwarding message.
[0054] In one possible implementation, Figure 4 As shown, the specific implementation of step S102 includes:
[0055] Step S1021: obtaining a second sending feature according to the network address of the network forwarding device and the first sending feature, wherein the second sending feature represents the network addresses of the network forwarding device and the target server;
[0056] Step S1022: Obtain a random encryption value according to the second sending feature;
[0057] Step S1023: Based on the random encryption value, the first timestamp in the request message is modified to a second timestamp to obtain a first forwarded message.
[0058] Exemplarily, after receiving the request message, the network forwarding device obtains the above-mentioned first timestamp and first sending feature from the header field of the request message, wherein the first sending feature includes the socket address of the target server, and the socket address of the target server includes the network address and port number of the target server; then, the network forwarding device generates a second sending feature based on its own network address and the network address of the target server. Then, based on the second sending feature, a random encryption value is calculated, and based on the random encryption value, the first timestamp in the request message is modified to a second timestamp to generate a first forwarding message. Among them, the random encryption value is a value generated based on a random function algorithm, and its purpose is to ensure data security by avoiding leakage of the timestamp of the message sender. Specifically, for example, the first timestamp stored in the first header field in the request message is M, and the random encryption value calculated according to the second sending feature is F, then the second timestamp is M+F. Therefore, based on the random encryption value, the first timestamp in the request message is modified to the second timestamp to obtain the first forwarded message, that is, the first forwarded message is obtained by modifying the field value M in the first header field in the request message to M+F.
[0059] In the steps of this embodiment, the second sending feature is calculated, and a random encryption value is calculated based on the second sending feature to generate a first forwarding message, thereby improving the security of data transmission during data forwarding.
[0060] Step S103: Send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0061] Further, after generating the first forwarding message, the network forwarding device sends the first forwarding message to the target server in the connection closed state. The connection closed state of the target server is first introduced below. Specifically, the target server in the connection closed state may have the following two states:
[0062] a. There is an old connection with the same four-tuple on the target server that has not been completely closed and is in the TIME-WAIT state.
[0063] b. The target server currently does not have a connection with the same quadruple, but it existed before, which is also called an old connection.
[0064] For connections in the TIME-WAIT state (case a), the target server will enter the TIME-WAIT state after confirming the FIN request from the other end (target client), and will wait for, for example, 2MSL time (usually 1 minute in Linux) before changing to the final CLOSED state, that is, entering a completely closed state. Connections in the TIME-WAIT state are allowed to be reopened, provided that the request message for reopening the connection is not a duplicate message from the old connection. For connections in non-TIME-WAIT states (case b), the target server will maintain a per-host timestamp cache, and use this timestamp to identify and reject message requests from old connections. The judgment method is similar to TIME-WAIT. This cache can last for about 60 seconds in common Linux systems.
[0065] In the above two cases, that is, when the target server is in a connection closed state, in order to ensure that the received message is not a request message from an old connection, the timestamp in the received message will be judged. Specifically, in this embodiment, the target server obtains the timestamp in the first forwarded message and judges the timestamp. Since the first forwarded message is generated based on the request message, and the first timestamp in the request message increases unidirectionally, the timestamp in the first forwarded message can also have a unidirectional increasing characteristic. Therefore, after the target server obtains the timestamp in the first forwarded message and verifies it, it can successfully pass the verification and establish a communication connection with the target client.
[0066] Figure 5 A schematic diagram of a process for generating a first forwarding message provided in an embodiment of the present disclosure is shown below in conjunction with Figure 5 The above embodiment process is described in more detail. Figure 5As shown, exemplarily, first, the request message obtained by the network forwarding device includes a first timestamp T1 and a first sending feature P1, and exemplarily, the first sending feature P1 = [192.168.0.2:3000, 10.0.1.3:80]. Among them, 192.168.0.2:3000 is the socket address of the target client, which is composed of the network address 192.168.0.2 and the port number 3000; 10.0.1.3:80 is the socket address of the target server, which is composed of the network address 10.0.1.3 and the port number 80. Afterwards, the network forwarding device generates a second sending feature P2=[10.0.1.2:4000, 10.0.1.3:80] through its own network address addr_1=10.0.1.2 and the socket address 10.0.1.3:80 of the target server, where 10.0.1.2:4000 is the socket address of the network forwarding device and 4000 is a randomly generated port number. Afterwards, a random encryption value R is generated according to the second sending feature P2, for example, a hash calculation is performed on the second sending feature P2, that is, hash(P2) is calculated to obtain the random encryption value R, and then the first timestamp T1 is modified using the random encryption value R to obtain the second timestamp T2. Specifically, for example, the sum of the random encryption value R and the first timestamp T1 (i.e., R+T1) is calculated, and for another example, the product of the random encryption value R and the first timestamp T1 (i.e., R*T1) is calculated. Finally, the first forwarding message is generated using the second sending feature P2 and the second timestamp T2, and is sent to the target server to establish a communication connection between the target client and the target server.
[0067] In this embodiment, a request message sent by a target client deployed in the first cluster is received, and the request message includes a first sending feature and a first timestamp, wherein the first sending feature represents the socket address of the target client and the target server receiving the request message, and the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, and the node system time corresponding to the first timestamp in multiple request messages received in sequence increases unidirectionally; according to the network address of the network forwarding device, a first forwarding message corresponding to the request message is generated; the first forwarding message is sent to the target server to create a communication connection between the target client and the target server. By deploying the target client in the first cluster, a request message with a first timestamp representing the node system time is generated and unidirectionally increased, and the message is sent to the network forwarding device. The network forwarding device then generates a first forwarding message and sends it to the target server, thereby completing the message forwarding process. Since the first timestamp of the request message received by the network forwarding device is unidirectionally increased, the timestamp in the generated first forwarding message can be guaranteed to be unidirectionally increased, thereby avoiding the problem that the target server in the connection closed state cannot pass the inspection when receiving the first forwarding message, thereby improving the success rate of establishing the communication connection between the client and the server, and improving the operating stability of the network server.
[0068] refer to Figure 6 , Figure 6 Schematic diagram of the process of the message forwarding method for multi-source clients provided in the embodiment of the present disclosure Figure 2 In this embodiment Figure 2 On the basis of the illustrated embodiment, step S102 is further refined, and the message forwarding method for multi-source clients includes:
[0069] Step S201: Generate a request message by a target client running in a target device node deployed in the first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing.
[0070] Step S202: According to the network address of the network forwarding device and the first sending characteristic, a second sending characteristic is obtained, where the second sending characteristic represents the network address of the network forwarding device and the target server.
[0071] Exemplarily, the first sending feature includes the network address of the target server and the corresponding target port, such as Figure 7 As shown, the specific implementation of step S202 includes:
[0072] Step S2021: Obtain the forwarding port of the network forwarding device.
[0073] Step S2022: Generate a second sending feature according to the network address and corresponding forwarding port of the network forwarding device, and the network address and corresponding target port of the target server.
[0074] Exemplarily, the forwarding port of the network forwarding device can be a preset value, a random value, or a dynamic value dynamically determined by the network forwarding device according to the current occupancy of each port, and there is no restriction for this time. Afterwards, the network forwarding device generates a second sending feature based on the network address and the corresponding forwarding port, as well as the network address and the corresponding target port of the target server. For example, the network address of the network forwarding device is [10.0.1.2], the corresponding forwarding port is
[4000] , and the network address of the target server is [10.0.1.3], and the corresponding target port is
[80] . Then the second sending feature can be a combination of the above two socket addresses, that is, [10.0.1.2:4000, 10.0.1.3:80].
[0075] Furthermore, the first sending feature also includes the network address of the target client and the corresponding source port, such as Figure 8 As shown, the specific implementation of step S2021 includes:
[0076] Step S2021-1: Obtain the message type of the request message, which is a handshake message or a service message. The handshake message is used to create a data connection, and the service message is used to send service information of the target client.
[0077] Step S2021 - 2: If the request message is a handshake message, a forwarding port is allocated to the network forwarding device.
[0078] Step S2021-3: If the request message is a business message, the pre-generated initial forwarding characteristics are queried through the network address of the target client and the corresponding source port to obtain the forwarding port of the network forwarding device. The initial forwarding characteristics include the socket address of the client and the socket address of the corresponding network forwarding device.
[0079] Exemplarily, the message type of the request message corresponds to different message functions, wherein the handshake message is used to create a data connection, that is, a communication connection channel between the target client and the target server; and the business message is used to send the business information of the target client, such as data sent to the target server for processing. Generally speaking, the target client will first send a request message of the handshake message type to the target server. After the target client and the target server establish a connection, it will first send a request message of the business message type to the target server to achieve the transmission of business information. Specifically, in the steps of this embodiment, if the request message is a handshake message, a forwarding port is allocated to the network forwarding device, specifically, for example, an unoccupied port is randomly allocated as the forwarding port; if the request message is a business message, the pre-generated initial forwarding feature is queried through the network address of the target client and the corresponding source port to obtain the forwarding port of the network forwarding device. Among them, the initial forwarding feature is the information generated and stored in the network forwarding device during the process of creating a communication connection between the target client and the target server, including the socket addresses of different clients and the socket addresses of the corresponding network forwarding devices. For example, the initial forwarding feature F1 is [192.168.1.2:3000, 10.0.1.3:80], which means that the target client with a socket address of 192.168.1.2:3000 has sent a request message to the network forwarding device with a socket address of 10.0.1.3:80 and established a connection with the corresponding target server.
[0080] In this embodiment, when the request message is a business message, that is, after the communication connection between the target client and the target server has been established, a query is performed based on the initial forwarding characteristics stored in the network forwarding device to obtain the forwarding port of the network forwarding device, and then a second sending characteristic is generated based on the forwarding port. There is no need to perform additional steps such as port idle detection, thereby improving the generation efficiency of the second sending characteristic and reducing device resource overhead.
[0081] Further, optionally, the method further includes: after allocating a forwarding port to the network forwarding device, generating an initial forwarding feature corresponding to the target client according to the socket address of the target client and the network forwarding device.
[0082] Exemplarily, when the request message is a handshake message, after allocating a forwarding port to the network forwarding device, the network address (i.e., socket address) of the forwarding port and the network forwarding device, as well as the mapped socket address of the target client are saved to generate an initial forwarding feature. Subsequently, when the request message is a business message, the forwarding port can be quickly obtained based on the steps in the previous embodiment (step S2021-3).
[0083] Step S203: Obtain a random encryption value according to the second sending feature.
[0084] Exemplarily, after generating the second sending feature, the network forwarding device needs to encrypt the sending timestamp recorded in the request message, that is, the first timestamp, based on the second sending feature, so as to improve the security of the request message. In a possible implementation, a random encryption value can be obtained by calculating a hash on the second sending feature.
[0085] Furthermore, in a possible implementation, Fig. 9 As shown, the specific implementation of step S203 includes:
[0086] Step S2031: Obtaining a first network address of the network forwarding device and a second network address of the server through the second sending feature;
[0087] Step S2032: Using the first network address and the second network address as operators, generate a random number to obtain a random encryption value.
[0088] Exemplarily, first, obtain the first network address of the network forwarding device and the second network address of the target server. For example, the first network address of the network forwarding device is addr1=[10.0.1.2]; the second network address of the target server is addr2=[10.0.1.3]. Both of the above network addresses can be directly obtained and will not be described in detail. Afterwards, use the first network address and the second network address as operators to generate random numbers. For example, call the function rand_func(addr1, addr2), where rand_func is a random generation function, and addr1 and addr2 are two function operators (parameters) of the random generation function, thereby obtaining a random encrypted value.
[0089] Step S204: Based on the random encryption value, the first timestamp in the request message is modified to a second timestamp to obtain a first forwarded message.
[0090] Exemplarily, after obtaining the random encryption value, the first forwarding message is obtained by calculating the weighted sum or weighted product of the random encryption value and the first timestamp, and writing the calculation result into the field corresponding to the first timestamp in the request message.
[0091] In a possible implementation, the specific implementation of step S204 includes:
[0092] Step S2041: Obtain a second timestamp according to the sum of the first timestamp and the random encryption value, and write the second timestamp into the first header field of the request message;
[0093] Step S2042: write the network address and the corresponding forwarding port of the network forwarding device into the second header field of the request message, and update the checksum of the request message to obtain a first forwarding message.
[0094] Exemplarily, in the request message, at least a first header field and a second header field are included, wherein the first header field is used to record the sending time of the message, and the second header field is used to record the source address and source port of the request message. In the steps of this embodiment, firstly, the second timestamp is obtained by calculating the sum of the first timestamp and the random encryption value, and the second timestamp is the encrypted first timestamp. Then, the second timestamp is written into the first header field of the request message to complete the update of the first timestamp; then, the network address and the corresponding forwarding port of the network forwarding device obtained based on the previous steps are written into the second header field of the request message to complete the update of the source network address and the source port. Then, the checksum of the request message is updated to obtain the first forwarding message.
[0095] Step S205: Send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0096] Optionally, after step S205, the method further includes:
[0097] Step S206: Receive a response message returned by the target server, wherein the response message includes a third sending feature and a second timestamp, wherein the third sending feature represents the socket addresses of the target server and the target client.
[0098] Step S207: query the pre-generated connection information according to the third sending feature to obtain a random encryption value, wherein the connection information includes the first sending feature, the second sending feature and the corresponding random encryption value.
[0099] Step S208: Based on the random encryption value, the second timestamp in the response message is modified to the first timestamp to obtain a second forwarding message, and the second forwarding message is sent to the target client.
[0100] Exemplarily, after the request message sent by the target client is forwarded to the target server through the network forwarding device, the target server will usually return the corresponding response result to the target client through the network forwarding device. Specifically, the network forwarding device receives a response message containing the response result returned by the target server, and the response message contains a third sending feature and a second timestamp, wherein the third sending feature represents the socket address of the target server and the target client, that is, the address information of the sender and the receiver. In addition, the response message may also include other functional information. The specific content of the functional information is determined by the specific content of the request message and the network transmission protocol, and will not be repeated here. After receiving the response message, the network forwarding device will query the pre-generated connection information according to the third sending feature and the second timestamp contained in the response message. The connection information is the information generated by the network forwarding device forwarding the request message in the above steps, and can be used to characterize the forwarding process of creating the communication connection corresponding to the request message. Specifically, the connection information includes a first sending feature, a second sending feature, and a corresponding random encryption value, that is, in the above steps, the process of generating the first sending feature, the second sending feature, and the corresponding random encryption value, that is, the process of generating the connection information, can be specifically referred to the introduction of the corresponding content in steps S202-204. The pre-generated connection information is queried through the third sending feature, that is, the first sending feature is queried through the socket address of the target server and the target client, so as to obtain the corresponding random encryption value. Afterwards, based on the random encryption value, the second timestamp in the response message is modified, and the second timestamp is modified to the first timestamp to obtain a second forwarding message. Among them, exemplarily, the first timestamp in the request message represents the timestamp of the sender (TSval), and correspondingly, the second timestamp in the response message represents the timestamp (TSecr) of the opposite end recorded by the sender. After the second timestamp in the response message is modified to the first timestamp, a second forwarding message is obtained, and the second forwarding message is sent to the target client to complete the transmission process of the response message. Through the above processing, the second timestamp can be “restored” and the communication connection creation process can be completed, thereby ensuring that the entire message and response process can be successfully executed.
[0101] Fig.10 A schematic diagram of a message forwarding process provided by an embodiment of the present disclosure, such as Fig.10As shown, exemplarily, first, the target client sends a request message to the network forwarding device, and the first message contains a first sending feature P1=[192.168.0.3:3000, 10.0.1.3:80] and a first timestamp T1, wherein T1=M, M is the node system time, and then the network forwarding device modifies the header field in the request message to generate a first forwarding message, and the first forwarding message contains a second sending feature P2=[10.0.1.2:4000, 10.0.1.3:80] and a second timestamp T2, at which time, the second timestamp T2 represents the sending end timestamp (TSval). Wherein, T2=T1+F, F=rand(10.0.1.2, 10.0.1.3, securekey), rand() is a random function, specifically, such as a hash function, and securekey is a random operator. Afterwards, the network forwarding device forwards the first forwarding message to the target server. After the target server receives the first forwarding message, it is equivalent to receiving the request message sent by the target client. After that, the target server parses and processes it, and sends the processing result to the network forwarding device through a response message. The response message contains the third sending feature P3 = [10.0.1.3:80, 10.0.1.2:4000] and the second timestamp T2. At this time, the second timestamp T2 is the timestamp (TSecr) of the other end recorded by the sending end. After receiving the response message, the network forwarding device queries the pre-generated connection information to obtain the random encryption value F, and modifies the header field in the request message based on the random encryption value to generate a second forwarding message. Specifically, the second forwarding message contains the fourth sending feature P4 = [10.0.1.2:4000, 192.168.0.2:3000] and the first timestamp T1, where T1 = T2-F. Finally, the target client receives the second forwarded message and establishes a communication connection with the target client. The forwarding process of the response message in the above process is equivalent to the reverse process of the forwarding process of the request message, and the specific implementation method will not be repeated.
[0102] In this embodiment, the implementation method of step S201 and step S205 is the same as that of the present disclosure. Figure 2 The implementation methods of step S101 and step S103 in the illustrated embodiment are the same and will not be described in detail here.
[0103] The present disclosure provides a method for forwarding packets for a multi-source client, which is applied to a network forwarding device and includes:
[0104] Receive a request message sent by a target client deployed in the first cluster, where the request message includes a first sending feature and a first timestamp, wherein the first sending feature represents the socket address of the target client and the target server receiving the request message, and the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, and the node system time corresponding to the first timestamp in multiple request messages received in sequence increases unidirectionally; generate a first forwarding message corresponding to the request message according to the network address of the network forwarding device; and send the first forwarding message to the target server.
[0105] Corresponding to the message forwarding method for multi-source clients in the above embodiment, Fig.11 A structural block diagram of a message forwarding device for multi-source clients provided in an embodiment of the present disclosure. The method described in the above embodiment can be executed by the message forwarding device for multi-source clients, which can be implemented by software and / or hardware, and can be integrated in an electronic device with certain data processing functions. Among them, the electronic device can include but is not limited to mobile terminals with big data processing capabilities, and fixed terminals with big data processing capabilities such as desktop computers and supercomputers.
[0106] For the sake of convenience, only the parts related to the embodiments of the present disclosure are shown. Fig.11 , the message forwarding device 3 for multi-source clients includes:
[0107] The client module 31 is used to generate a request message through a target client running in a target device node deployed in the first cluster, and send it to the network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, and the target device node runs multiple clients and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing;
[0108] A first forwarding module 32, configured to generate a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp through a network forwarding device;
[0109] The second forwarding module 33 is used to send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0110] According to one or more embodiments of the present disclosure, the first forwarding module 32 is specifically used to: obtain a second sending characteristic based on the network address of the network forwarding device and the first sending characteristic, the second sending characteristic representing the network address of the network forwarding device and the target server; obtain a random encryption value based on the second sending characteristic; based on the random encryption value, modify the first timestamp in the request message to the second timestamp to obtain a first forwarding message.
[0111] According to one or more embodiments of the present disclosure, the first sending characteristic includes the network address of the target server and the corresponding target port; when the first forwarding module 32 obtains the second sending characteristic based on the network address of the network forwarding device and the first sending characteristic, it is specifically used to: obtain the forwarding port of the network forwarding device; generate the second sending characteristic based on the network address and the corresponding forwarding port of the network forwarding device, and the network address and the corresponding target port of the target server.
[0112] According to one or more embodiments of the present disclosure, the first sending feature also includes the network address of the target client and the corresponding source port. When the first forwarding module 32 obtains the forwarding port of the network forwarding device, it is specifically used to: obtain the message type of the request message, the message type is a handshake message or a business message, wherein the handshake message is used to create a data connection, and the business message is used to send the business information of the target client; if the request message is a handshake message, a forwarding port is allocated to the network forwarding device; if the request message is a business message, the pre-generated initial forwarding feature is queried through the network address and the corresponding source port of the target client to obtain the forwarding port of the network forwarding device, and the initial forwarding feature includes the socket address of the client and the corresponding socket address of the network forwarding device.
[0113] According to one or more embodiments of the present disclosure, the first forwarding module 32 is further used to: after allocating a forwarding port to the network forwarding device, generate an initial forwarding feature corresponding to the target client according to the socket address of the target client and the network forwarding device.
[0114] According to one or more embodiments of the present disclosure, when the first forwarding module 32 obtains the random encryption value according to the second sending characteristic, it is specifically used to: obtain the first network address of the network forwarding device and the second network address of the server through the second sending characteristic; use the first network address and the second network address as operators to generate random numbers to obtain the random encryption value.
[0115] According to one or more embodiments of the present disclosure, when the first forwarding module 32 modifies the first timestamp in the request message to the second timestamp based on the random encryption value to obtain the first forwarding message, it is specifically used to: obtain the second timestamp based on the sum of the first timestamp and the random encryption value, and write the second timestamp into the first header field of the request message; write the network address and the corresponding forwarding port of the network forwarding device into the second header field of the request message, and update the checksum of the request message to obtain the first forwarding message.
[0116] According to one or more embodiments of the present disclosure, multiple target clients are deployed in the first cluster, and the client module 31 is specifically used to: when each target client responds to a target request, obtain the node system time of the first cluster and the corresponding first sending feature; according to the task queue, process the system time of each node in turn to generate a unidirectionally increasing first timestamp; according to each first timestamp and the corresponding first sending feature, construct a request message and send it to the network forwarding device.
[0117] According to one or more embodiments of the present disclosure, after sending the first forwarding message to the target server, the second forwarding module 33 is also used to: receive a response message returned by the target server, the response message containing a third sending feature and a second timestamp, wherein the third sending feature represents the socket address of the target server and the target client; query the pre-generated connection information according to the third sending feature to obtain a random encryption value, wherein the connection information includes the first sending feature, the second sending feature and the corresponding random encryption value; based on the random encryption value, modify the second timestamp in the response message to the first timestamp to obtain a second forwarding message, and send the second forwarding message to the target client.
[0118] The client module 31, the first forwarding module 32 and the second forwarding module 33 are connected in sequence. The message forwarding device 3 for multi-source clients provided in this embodiment can implement the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated in this embodiment.
[0119] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown in FIG. Fig.12 As shown, the electronic device 4 includes:
[0120] A processor 41, and a memory 42 communicatively connected to the processor 41;
[0121] The memory 42 stores computer executable instructions;
[0122] The processor 41 executes the computer execution instructions stored in the memory 42 to implement the following Figure 2-Figure 10 The message forwarding method for multi-source clients in the illustrated embodiment.
[0123] Optionally, the processor 41 and the memory 42 are connected via a bus 43 .
[0124] For related instructions, please refer to Figure 2-Figure 10 The relevant descriptions and effects corresponding to the steps in the corresponding embodiments can be understood, and no further elaboration is made here.
[0125] The present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which are used to implement the present invention when executed by a processor. Figure 2-Figure 10 Any one of the corresponding embodiments provides a message forwarding method for multi-source clients.
[0126] The present invention provides a computer program product, including a computer program. When the computer program is executed by a processor, the present invention is realized. Figure 2-Figure 10 Any one of the corresponding embodiments provides a message forwarding method for multi-source clients.
[0127] In order to implement the above embodiment, the embodiment of the present disclosure also provides an electronic device.
[0128] refer to Fig.13 , which shows a schematic diagram of the structure of an electronic device 900 suitable for implementing the embodiment of the present disclosure, and the electronic device 900 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.13 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0129] like Fig.13As shown, the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 to a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0130] Typically, the following devices may be connected to the I / O interface 905: input devices 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 908 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.13 The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0131] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0132] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0133] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0134] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0135] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0136] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0137] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit or module does not, in some cases, constitute a limitation on the unit itself.
[0138] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0139] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0140] In a first aspect, according to one or more embodiments of the present disclosure, a method for forwarding messages to a multi-source client is provided, comprising:
[0141] A request message is generated by a target client running in a target device node deployed in the first cluster, and sent to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node, and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing; a first forwarding message corresponding to the request message is generated by the network forwarding device based on the first sending feature and the first timestamp; the first forwarding message is sent to the target server by the network forwarding device to establish a communication connection between the target client and the target server.
[0142] According to one or more embodiments of the present disclosure, the first forwarding message corresponding to the request message is generated by the network forwarding device based on the first sending feature and the first timestamp, including: obtaining a second sending feature according to the network address of the network forwarding device and the first sending feature, the second sending feature representing the network addresses of the network forwarding device and the target server; obtaining a random encryption value according to the second sending feature; and based on the random encryption value, modifying the first timestamp in the request message to a second timestamp to obtain the first forwarding message.
[0143] According to one or more embodiments of the present disclosure, the first sending characteristic includes the network address of the target server and the corresponding target port; the second sending characteristic is obtained based on the network address of the network forwarding device and the first sending characteristic, including: obtaining the forwarding port of the network forwarding device; generating the second sending characteristic based on the network address of the network forwarding device and the corresponding forwarding port, and the network address of the target server and the corresponding target port.
[0144] According to one or more embodiments of the present disclosure, the first sending feature also includes the network address of the target client and the corresponding source port, and obtaining the forwarding port of the network forwarding device includes: obtaining the message type of the request message, the message type is a handshake message or a business message, wherein the handshake message is used to create a data connection, and the business message is used to send the business information of the target client; if the request message is a handshake message, a forwarding port is allocated to the network forwarding device; if the request message is a business message, the pre-generated initial forwarding feature is queried through the network address of the target client and the corresponding source port to obtain the forwarding port of the network forwarding device, and the initial forwarding feature includes the socket address of the client and the socket address of the corresponding network forwarding device.
[0145] According to one or more embodiments of the present disclosure, the method further includes: after allocating a forwarding port to the network forwarding device, generating an initial forwarding feature corresponding to the target client according to the socket address of the target client and the network forwarding device.
[0146] According to one or more embodiments of the present disclosure, obtaining a random encryption value based on the second sending feature includes: obtaining a first network address of the network forwarding device and a second network address of the server through the second sending feature; and generating random numbers using the first network address and the second network address as operators to obtain the random encryption value.
[0147] According to one or more embodiments of the present disclosure, the first timestamp in the request message is modified to a second timestamp based on the random encryption value to obtain the first forwarding message, including: obtaining the second timestamp based on the sum of the first timestamp and the random encryption value, and writing the second timestamp into the first header field of the request message; writing the network address and the corresponding forwarding port of the network forwarding device into the second header field of the request message, and updating the checksum of the request message to obtain the first forwarding message.
[0148] According to one or more embodiments of the present disclosure, a plurality of the target clients are deployed in the first cluster, and the target clients deployed and running in the target device nodes in the first cluster generate a request message and send it to the network forwarding device, including: each of the target clients obtains the node system time of the first cluster and the corresponding first sending feature when responding to the target request; processes the system time of each node in turn according to the task queue to generate a unidirectionally increasing first timestamp; and constructs the request message according to each of the first timestamps and the corresponding first sending feature and sends it to the network forwarding device.
[0149] According to one or more embodiments of the present disclosure, after sending the first forwarding message to the target server, it also includes: receiving a response message returned by the target server, the response message including a third sending feature and the second timestamp, wherein the third sending feature represents the socket address of the target server and the target client; querying the pre-generated connection information according to the third sending feature to obtain the random encryption value, wherein the connection information includes the first sending feature, the second sending feature and the corresponding random encryption value; based on the random encryption value, modifying the second timestamp in the response message to the first timestamp to obtain a second forwarding message, and sending the second forwarding message to the target client.
[0150] In a second aspect, according to one or more embodiments of the present disclosure, a message forwarding device for a multi-source client is provided, including:
[0151] A client module, used to generate a request message through a target client running in a target device node deployed in the first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing;
[0152] A first forwarding module, configured to generate, through the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp;
[0153] The second forwarding module is used to send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
[0154] According to one or more embodiments of the present disclosure, the first forwarding module is specifically used to: obtain a second sending characteristic based on the network address of the network forwarding device and the first sending characteristic, the second sending characteristic representing the network address of the network forwarding device and the target server; obtain a random encryption value based on the second sending characteristic; based on the random encryption value, modify the first timestamp in the request message to a second timestamp to obtain the first forwarding message.
[0155] According to one or more embodiments of the present disclosure, the first sending characteristic includes the network address of the target server and the corresponding target port; when the first forwarding module obtains the second sending characteristic based on the network address of the network forwarding device and the first sending characteristic, it is specifically used to: obtain the forwarding port of the network forwarding device; generate the second sending characteristic based on the network address of the network forwarding device and the corresponding forwarding port, as well as the network address of the target server and the corresponding target port.
[0156] According to one or more embodiments of the present disclosure, the first sending feature also includes the network address of the target client and the corresponding source port. When the first forwarding module obtains the forwarding port of the network forwarding device, it is specifically used to: obtain the message type of the request message, the message type is a handshake message or a business message, wherein the handshake message is used to create a data connection, and the business message is used to send the business information of the target client; if the request message is a handshake message, a forwarding port is allocated to the network forwarding device; if the request message is a business message, the pre-generated initial forwarding feature is queried through the network address of the target client and the corresponding source port to obtain the forwarding port of the network forwarding device, and the initial forwarding feature includes the socket address of the client and the socket address of the corresponding network forwarding device.
[0157] According to one or more embodiments of the present disclosure, the first forwarding module is further used to: after allocating a forwarding port to the network forwarding device, generate an initial forwarding feature corresponding to the target client according to the socket address of the target client and the network forwarding device.
[0158] According to one or more embodiments of the present disclosure, when the first forwarding module obtains the random encryption value according to the second sending characteristic, it is specifically used to: obtain the first network address of the network forwarding device and the second network address of the server through the second sending characteristic; use the first network address and the second network address as operators to generate random numbers to obtain the random encryption value.
[0159] According to one or more embodiments of the present disclosure, when the first forwarding module modifies the first timestamp in the request message to a second timestamp based on the random encryption value to obtain the first forwarding message, it is specifically used to: obtain the second timestamp based on the sum of the first timestamp and the random encryption value, and write the second timestamp into the first header field of the request message; write the network address and the corresponding forwarding port of the network forwarding device into the second header field of the request message, and update the checksum of the request message to obtain the first forwarding message.
[0160] According to one or more embodiments of the present disclosure, a plurality of the target clients are deployed in the first cluster, and the client module is specifically used to: when each of the target clients responds to a target request, obtain the node system time of the first cluster and the corresponding first sending feature; according to the task queue, process the system time of each node in turn to generate a unidirectionally increasing first timestamp; according to each of the first timestamps and the corresponding first sending feature, construct the request message and send it to the network forwarding device.
[0161] According to one or more embodiments of the present disclosure, after sending the first forwarding message to the target server, the second forwarding module is further used to: receive a response message returned by the target server, the response message including a third sending feature and the second timestamp, wherein the third sending feature represents the socket address of the target server and the target client; query the pre-generated connection information according to the third sending feature to obtain the random encryption value, wherein the connection information includes the first sending feature, the second sending feature and the corresponding random encryption value; based on the random encryption value, modify the second timestamp in the response message to the first timestamp to obtain a second forwarding message, and send the second forwarding message to the target client.
[0162] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;
[0163] The memory stores computer-executable instructions;
[0164] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect.
[0165] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect is implemented.
[0166] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the message forwarding method for multi-source clients as described in the first aspect and various possible designs of the first aspect.
[0167] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0168] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0169] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A message forwarding method for multi-source clients, characterized in that: The method comprises: A request message is generated by a target client running in a target device node deployed in the first cluster, and sent to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent; the target device node runs multiple clients and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing; Generate, by the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp; The first forwarding message is sent to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
2. The method according to claim 1, characterized in that The generating, by the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp includes: According to the network address of the network forwarding device and the first sending feature, a second sending feature is obtained, wherein the second sending feature represents the network addresses of the network forwarding device and the target server; Obtaining a random encryption value according to the second sending feature; Based on the random encryption value, the first timestamp in the request message is modified to a second timestamp to obtain the first forwarding message, wherein the second timestamps in the multiple first forwarding messages sent sequentially by the network forwarding device to the target server are unidirectionally increased.
3. The method according to claim 2, characterized in that The first sending feature includes the network address of the target server and the corresponding target port; the second sending feature is obtained according to the network address of the network forwarding device and the first sending feature, including: Obtaining a forwarding port of the network forwarding device; The second sending feature is generated according to the network address of the network forwarding device and the corresponding forwarding port, and the network address of the target server and the corresponding target port.
4. The method according to claim 3, characterized in that The first sending feature also includes the network address of the target client and the corresponding source port, and obtaining the forwarding port of the network forwarding device includes: Acquire a message type of the request message, where the message type is a handshake message or a service message, wherein the handshake message is used to establish a data connection, and the service message is used to send service information of the target client; If the request message is a handshake message, allocating a forwarding port to the network forwarding device; If the request message is a business message, the pre-generated initial forwarding characteristics are queried through the network address of the target client and the corresponding source port to obtain the forwarding port of the network forwarding device. The initial forwarding characteristics include the socket address of the client and the socket address of the corresponding network forwarding device.
5. The method according to claim 4, characterized in that The method further comprises: After allocating a forwarding port to the network forwarding device, an initial forwarding feature corresponding to the target client is generated according to the target client and the socket address of the network forwarding device.
6. The method according to claim 2, characterized in that The obtaining a random encryption value according to the second sending feature includes: Obtaining, through the second sending feature, a first network address of the network forwarding device and a second network address of the server; The first network address and the second network address are used as operators to generate a random number to obtain the random encrypted value.
7. The method according to claim 2, characterized in that: The step of modifying the first timestamp in the request message to a second timestamp based on the random encryption value to obtain the first forwarded message includes: Obtaining the second timestamp according to the sum of the first timestamp and the random encryption value, and writing the second timestamp into the first header field of the request message; The network address and the corresponding forwarding port of the network forwarding device are written into the second header field of the request message, and the checksum of the request message is updated to obtain the first forwarding message.
8. The method according to claim 1, characterized in that The first cluster has multiple target clients deployed therein, and the target client running in the target device node deployed in the first cluster generates a request message and sends it to the network forwarding device, including: Each of the target clients obtains the node system time of the first cluster and the corresponding first sending feature when responding to the target request; According to the task queue, the system time of each node is processed in sequence to generate a first timestamp that increases in a unidirectional direction; According to each of the first timestamps and the corresponding first sending characteristics, the request message is constructed and sent to the network forwarding device.
9. The method according to claim 1, characterized in that: After sending the first forwarding message to the target server, the method further includes: Receive a response message returned by the target server, wherein the response message includes a third sending feature and the second timestamp, wherein the third sending feature represents the socket addresses of the target server and the target client; querying pre-generated connection information according to the third sending feature to obtain a random encrypted value, wherein the connection information includes the first sending feature, the second sending feature, and a corresponding random encrypted value; Based on the random encryption value, the second timestamp in the response message is modified to the first timestamp to obtain a second forwarding message, and the second forwarding message is sent to the target client.
10. A message forwarding device for multi-source clients, characterized in that: The device comprises: A client module, used to generate a request message through a target client running in a target device node deployed in the first cluster, and send it to a network forwarding device, wherein the request message includes a first sending feature and a first timestamp, the first sending feature represents the socket address of the target client and the target server receiving the request message, the target server is deployed in the second cluster and is in a connection closed state; the first timestamp represents the node system time when the request message is sent, multiple clients are running in the target device node and the first timestamps in the request messages from different clients sent sequentially to the network forwarding device are unidirectionally increasing; A first forwarding module, configured to generate, through the network forwarding device, a first forwarding message corresponding to the request message based on the first sending feature and the first timestamp; The second forwarding module is used to send the first forwarding message to the target server through the network forwarding device to establish a communication connection between the target client and the target server.
11. An electronic device, characterized in that: include: Processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the message forwarding method for multi-source clients according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the message forwarding method for multi-source clients according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for forwarding messages for multi-source clients according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
A determination method of the initiation relationship within TCP messages based on TCP timestamp options
CN101217429A
Method and device for accessing MongoDB replication set cluster, equipment and storage medium
CN111711710A
Data processing method and device and electronic equipment
CN113364818A
Message processing method, device and system
CN113726867A