Message processing method and device, storage medium and program product
By analyzing and configuring the sub-connection information between the OPC client and the OPC server, the communication abnormality between the OPC client and the OPC server is solved at the same time at the network address, ensuring the normality of communication and the access capability of the gateway device.
Patent Information
- Application Number
- CN202411967343.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-30
AI Technical Summary
In the industrial gateway device access scenario, communication between the OPC client and the OPC server may occur abnormally, especially when the network address of the child connection and the parent connection are different.
By receiving the parent connection message returned by the OPC server, parsing and configuring the expected connection information of the child connection, including the network protocol type, destination IP address, destination port and source port. Configure the destination IP address in the parent connection information and the destination IP address in the child connection information to ensure that the communication connection between the OPC client and the OPC server is normal.
When the destination IP addresses of the parent and child connections are different or the network protocol types are different, ensuring that the communication between the OPC client and the OPC server is normal, enhancing the access capability of the gateway device.
Smart Images

Figure CN119766858A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of message processing, and specifically to a message processing method, device, storage medium and program product. Background Art
[0002] In the field of industrial automation, data collection and transmission are crucial links. OPC DA (full name is OLE for Process Control Data Access, i.e. OLE for process control) defines an industrial standard interface for real-time data access. The OPC server of the OPC DA protocol listens on port number TCP-135. After creating an object, the OPC server will return a new dynamic port number for data communication of the OPC DA protocol.
[0003] The dynamic port number returned by the OPC DA protocol OPC server is an important basis for the industrial gateway device to decide whether to allow OPC DA protocol data connectivity. In the existing industrial gateway product implementation, if the OPC DA protocol connection is based on IPv4 network protocol communication, the data connection is also controlled according to the IPv4 network protocol; if the OPC DA protocol connection is based on IPv6 network protocol communication, the data connection is also controlled according to the IPv6 network protocol.
[0004] However, when there are multiple IP addresses that can be connected on the interfaces of the OPC client host, OPC server host, and gateway device that communicate with it, the IP address to be selected for communication is determined by the OPC DA protocol OPC client, which cannot be predicted in advance and may cause communication anomalies. Therefore, in the industrial gateway device access scenario, when the network address of the OPC DA protocol OPC client to initiate the data connection is uncertain, if the network addresses of the child connection and the parent connection are different, there may be communication anomalies between the OPC client and the OPC server. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a message processing method, device, storage medium and program product to solve the problem in the prior art that the OPC client and the OPC server cannot communicate normally when the network addresses of the child connection and the parent connection are different.
[0006] In order to achieve the above-mentioned object, the first aspect of the present application provides a message processing method, including:
[0007] Receive the parent connection message returned by the OPC server, wherein the parent connection message is a response message generated by the OPC server after receiving the parent connection request forwarded by the gateway device, and the parent connection request is sent by the OPC client to the gateway device;
[0008] In the case where the parent connection message is a response type message, parsing the parent connection message to obtain parent connection information and child connection information of at least one child connection that the OPC client can initiate;
[0009] According to each sub-connection information, configure the first network protocol type, the first destination IP address, the first destination port, and the source port in the expected connection information corresponding to each sub-connection;
[0010] Configure the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information;
[0011] When the access mode of the gateway device is routing access, the parent connection message is forwarded to the OPC client to establish a communication connection between the OPC server and the OPC client;
[0012] Receive and parse the sub-connection request message sent by the OPC client to obtain the five-tuple information in the sub-connection request message;
[0013] Process the sub-connection request message based on the five-tuple information and all the expected connection information on the gateway device.
[0014] In an embodiment of the present application, configuring the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information includes: for any child connection information, when the destination IP address in the parent connection information is the same as the destination IP address in any child connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any child connection information, when the destination IP address in the parent connection information is different from the destination IP address in any child connection information, configuring the first source IP address according to the first network protocol type in each child connection information.
[0015] In an embodiment of the present application, configuring the first network protocol type, the first destination IP address, the first destination port and the source port in the expected connection information corresponding to each sub-connection according to each sub-connection information includes: configuring the first network protocol type as the network protocol type in the corresponding sub-connection information; configuring the first destination IP address as the destination IP address in the corresponding sub-connection information; configuring the first destination port as the destination port in the corresponding sub-connection information; and configuring the source port as a preset port.
[0016] In an embodiment of the present application, the method also includes: when the access mode of the gateway device is proxy access, configuring a NAT conversion flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information; configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each sub-connection information; modifying each expected connection information and each child connection information in the parent connection message according to each NAT conversion information; forwarding the modified parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; receiving the sub-connection request message sent by the OPC client, and parsing the sub-connection request message to obtain the five-tuple information in the sub-connection request message; processing the sub-connection request message according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection.
[0017] In an embodiment of the present application, configuring the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information includes: configuring the second network protocol type as the network protocol type in the corresponding sub-connection information; configuring the second destination IP address as the destination IP address in the corresponding sub-connection information; configuring the second destination port as the destination port in the corresponding sub-connection information; and configuring the original destination port as the destination port in the corresponding sub-connection information.
[0018] In an embodiment of the present application, configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each child connection information includes: when the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, configuring the proxy IP address of the parent connection corresponding to the parent connection message as the original destination IP address; when the network protocol type in the parent connection information is different from the network protocol type in each child connection information, configuring the original destination IP address to be the same as the network protocol type of each child connection information configured on the interface of the gateway device where the proxy IP address of the parent connection is located.
[0019] In an embodiment of the present application, modifying each expected connection information and each child connection information in the parent connection message according to each NAT conversion information includes: replacing the destination IP address and destination port in each child connection information with the original destination address and original destination port in each NAT conversion information to obtain a modified parent connection message; replacing the first destination IP address and the first destination port in each expected connection information with the original destination address and original destination port in each NAT conversion information to obtain the modified expected connection information.
[0020] In an embodiment of the present application, processing a request message of a sub-connection according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection includes: when the five-tuple information hits the modified expected connection information of any sub-connection, modifying the destination IP address and destination port in the request message of the sub-connection to the second destination IP address and second destination port in the NAT conversion information of the sub-connection; modifying the second source IP address of the request message of the sub-connection according to the modified destination IP address in the request message of the sub-connection; performing TCP checksum processing on the modified request message of the sub-connection, and forwarding the modified request message of the sub-connection to the corresponding OPC server.
[0021] A second aspect of the present application provides a message processing device, including:
[0022] a memory configured to store instructions;
[0023] The processor is configured to call instructions from the memory and implement the above-mentioned message processing method when executing the instructions.
[0024] A third aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned message processing method.
[0025] A fourth aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned message processing method when executed by a processor.
[0026] Through the above technical solution, a parent connection message returned by an OPC server is received; when the parent connection message is a response type message, the parent connection message is parsed to obtain parent connection information and child connection information of at least one child connection that can be initiated by the OPC client; the first network protocol type, the first destination IP address, the first destination port and the source port in the expected connection information corresponding to each child connection are configured according to each child connection information; the first source IP address in the expected connection information corresponding to each child connection is configured according to the destination IP address in the parent connection information and the destination IP address in each child connection information; when the access mode of the gateway device is routing access, the parent connection message is forwarded to the OPC client to establish a communication connection between the OPC server and the OPC client; the child connection request message sent by the OPC client is received and parsed to obtain the five-tuple information in the child connection request message; the child connection request message is processed according to the five-tuple information and all the expected connection information on the gateway device, and when the parent connection and the child connection destination IP addresses are different or the network protocol types are different, the communication between the OPC client and the OPC server can be ensured to be normal.
[0027] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0029] Figure 1 A schematic diagram of an application environment of a message processing method according to an embodiment of the present application is schematically shown;
[0030] Figure 2 The following is a schematic diagram showing a flow chart of a message processing method according to an embodiment of the present application;
[0031] Figure 3 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0033] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0034] The message processing method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the gateway device 104 communicates with the OPC client 102 and the OPC server 106 through the network respectively. Among them, the gateway device 104 can be an industrial gateway, and the gateway device 104 includes an ALG (Application level gateway) module. The OPC client 102 refers to the client of the OPC DA protocol, and the OPC client 102 can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The OPC server 106 refers to the server of the OPC DA protocol, and the OPC server 106 can be implemented with an independent server or a server cluster composed of multiple servers.
[0035] Figure 2 The flowchart of the message processing method according to the embodiment of the present application is schematically shown. Figure 2 As shown, in one embodiment of the present application, a message processing method is provided. This embodiment mainly applies the method to the above Figure 1 Taking the gateway device 104 in FIG. 1 as an example, the following steps are included:
[0036] Step 201: Receive a parent connection message returned by the OPC server, wherein the parent connection message is a response message generated by the OPC server after receiving a parent connection request forwarded by a gateway device, and the parent connection request is sent by the OPC client to the gateway device.
[0037] The OPC client can send a parent connection request to the gateway device, and the gateway device can send the parent connection request to the OPC server. The OPC server can generate a parent connection message based on the parent connection request initiated by the OPC client, and return the parent connection message to the gateway device. The gateway device can receive the parent connection message returned by the OPC server.
[0038] Step 202: When the parent connection message is a response type message, parse the parent connection message to obtain parent connection information and child connection information of at least one child connection that the OPC client can initiate.
[0039] After receiving the parent connection message, the gateway device can determine the data packet type of the parent connection message. When the data packet type of the parent connection message is RemoteCreateInstance response, that is, the parent connection message is a response type message, at this time, the gateway device can parse the NetworkAddr field in the parent connection message to obtain the parent connection information and the child connection information of at least one child connection that the OPC client can initiate. Among them, the parent connection information includes the five-tuple information of the parent connection. The child connection information of each child connection includes the five-tuple information of each child connection. The five-tuple information may include the network protocol type, destination IP address, destination port, source IP address and source port.
[0040] Step 203: According to each sub-connection information, configure the first network protocol type, the first destination IP address, the first destination port and the source port in the expected connection information corresponding to each sub-connection.
[0041] The gateway device can configure the first network protocol type, the first destination IP address, the first destination port, and the source port in the expected connection information corresponding to each sub-connection according to each sub-connection information. That is, the OPC client can initiate at least one sub-connection, each sub-connection corresponds to a sub-connection information, and each sub-connection information corresponds to an expected connection information. The expected connection information may include the first network protocol type, the first destination IP address, the first destination port, the source IP address, and the source port of the corresponding sub-connection.
[0042] In an embodiment of the present application, configuring the first network protocol type, the first destination IP address, the first destination port and the source port in the expected connection information corresponding to each sub-connection according to each sub-connection information includes: configuring the first network protocol type as the network protocol type in the corresponding sub-connection information; configuring the first destination IP address as the destination IP address in the corresponding sub-connection information; configuring the first destination port as the destination port in the corresponding sub-connection information; and configuring the source port as a preset port.
[0043] The gateway device may configure the first network protocol type as the network protocol type in the corresponding sub-connection information. Specifically, if the destination IP address in the corresponding sub-connection information is 10.10.10.3, the network protocol type in the corresponding sub-connection information is IPv4. At this time, the first network protocol type in the expected connection information of the corresponding sub-connection is IPv4. If the destination IP address in the corresponding sub-connection information is 1000::2, the network protocol type in the corresponding sub-connection information is IPv6. At this time, the first network protocol type in the expected connection information of the corresponding sub-connection is IPv6. The gateway device may configure the first destination IP address as the destination IP address in the corresponding sub-connection information, and may configure the first destination port as the destination port in the corresponding sub-connection information. Since the OPC client cannot confirm the client source port before initiating a sub-connection, the gateway device may configure the source port as a preset port, that is, fill the source port with 0, and the source port is not specified.
[0044] Step 204: configure the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information.
[0045] The gateway device may configure the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information. Specifically, the gateway device may compare the destination IP address in the parent connection information with the destination IP address in each child connection information, and configure the first source IP address in the corresponding expected connection information according to the comparison result of the destination IP address.
[0046] In an embodiment of the present application, configuring the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information includes: for any child connection information, when the destination IP address in the parent connection information is the same as the destination IP address in any child connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any child connection information, when the destination IP address in the parent connection information is different from the destination IP address in any child connection information, configuring the first source IP address according to the first network protocol type in each child connection information.
[0047] For any child connection information, if the destination IP address in the parent connection information is the same as the destination IP address in the child connection information, the gateway device can configure the first source IP address as the second source IP address in the parent connection information, so as to accurately control the source of the child connection when the OPC client and the OPC server communicate and the parent connection and the child connection have the same network layer protocol.
[0048] For any sub-connection information, when the destination IP address in the parent connection information is different from the destination IP address in the sub-connection information, the gateway device can configure the first source IP address according to the first network protocol type in the sub-connection information. Specifically, if the first network protocol type is IPv4, the first source IP address is filled with 0.0.0.0. If the first network protocol type is Ipv6, the first source IP address is filled with 0::0. This configuration method, that is, the source IP address is not specified, can better adapt to the scenario where the OPC client randomly selects the destination IP address to establish a sub-link with the server when the OPC client communicates with the OPC server and the parent connection and the sub-connection have different network protocols or network addresses.
[0049] Table 1 below shows a simplified structure of expected connection information.
[0050] Table 1
[0051]
[0052]
[0053] The network protocol type in the expected connection information needs to be filled with the resolved network address protocol type. If the resolved IP address is 10.10.10.3, the family is filled with IPv4; if the resolved IP address is 1000::2, the family is filled with IPv6. The destination IP address and destination port number in the expected connection information are filled with the content (destination IP address and destination port) resolved in the message. There are as many expected connection information as there are addresses in total to ensure one-to-one correspondence. The source IP address in the expected connection information needs to be filled in the following two situations: 1) If the destination IP address filled in the expected connection information is the same as the destination IP address of the current message, the source IP address of the expected connection information can be filled with the source IP address of the current message. 2) If the destination IP address filled in the expected connection information is different from the destination IP address of the current message, it is filled according to the network protocol type. If the network protocol type is IPv4, it is filled with 0.0.0.0; if the network protocol type is IPv6, it is filled with 0::0; that is, the source address is not specified. The source port in the expected connection information is filled with 0, that is, the source port is not specified.
[0054] Step 205: When the access mode of the gateway device is routing access, the parent connection message is forwarded to the OPC client to establish a communication connection between the OPC server and the OPC client.
[0055] If the access mode of the gateway device is routing access, the gateway device is deployed in the OPC DA protocol network environment in routing access mode. At this time, there is no need to modify the message network address (destination IP address) and TCP port (destination port), and there is no need to configure the corresponding NAT conversion information. The gateway device can forward the parent connection message directly to the OPC client to establish a communication connection between the gateway device and the OPC client.
[0056] Step 206: Receive and parse the sub-connection request message sent by the OPC client to obtain the five-tuple information in the sub-connection request message.
[0057] The OPC client can send a sub-connection request message to the gateway device. The gateway device can receive and parse the sub-connection request message to obtain the five-tuple information in the sub-connection request message. The five-tuple information may include the network protocol type, destination IP address, destination port, source IP address, and source port of the sub-connection.
[0058] Step 207: Process the sub-connection request message according to the five-tuple information and all the expected connection information on the gateway device.
[0059] The gateway device can process the sub-connection request message according to the five-tuple information and the expected connection information. Specifically, the gateway device can match the five-tuple information with all the expected connection information. If the corresponding expected connection information is matched, that is, the expected connection information is hit, the connection information on the gateway device corresponding to the sub-connection request can be marked as an OPCDA protocol sub-connection, and the expected connection information obtained by the match is deleted. At this time, the gateway device can directly forward the sub-connection request message to the OPC server to realize the communication between the OPC server and the OPC client.
[0060] In an embodiment of the present application, the method also includes: when the access mode of the gateway device is proxy access, configuring a NAT conversion flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information; configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each sub-connection information; modifying each expected connection information and each child connection information in the parent connection message according to each NAT conversion information; forwarding the modified parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; receiving the sub-connection request message sent by the OPC client, and parsing the sub-connection request message to obtain the five-tuple information in the sub-connection request message; processing the sub-connection request message according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection.
[0061] When the access mode of the gateway device is proxy access, it means that the gateway device is deployed in the OPC DA protocol network environment in proxy access mode. The gateway device acts as a proxy server for the OPC client, and the destination server IP address and port are the real OPC server. In this case, the corresponding NAT conversion flag and NAT conversion information need to be configured. The gateway device can configure the NAT conversion flag for the expected connection information corresponding to each sub-connection. That is, the expected connection information also includes the NAT conversion flag and NAT conversion information.
[0062] The gateway device can configure the second network protocol type, the second destination IP address, the second destination port, and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information. That is, each expected connection information includes NAT conversion information. Specifically, in an embodiment of the present application, configuring the second network protocol type, the second destination IP address, the second destination port, and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information includes: configuring the second network protocol type as the network protocol type in the corresponding sub-connection information; configuring the second destination IP address as the destination IP address in the corresponding sub-connection information; configuring the second destination port as the destination port in the corresponding sub-connection information; and configuring the original destination port as the destination port in the corresponding sub-connection information.
[0063] The gateway device may configure the second network protocol type as the network protocol type in the corresponding sub-connection information. Specifically, if the destination IP address in the corresponding sub-connection information is 10.10.10.3, the network protocol type in the corresponding sub-connection information is IPv4, and at this time, the second network protocol type in the NAT conversion information of the corresponding sub-connection is IPv4. If the destination IP address in the corresponding sub-connection information is 1000::2, the network protocol type in the corresponding sub-connection information is IPv6, and at this time, the second network protocol type in the NAT conversion information of the corresponding sub-connection is IPv6.
[0064] The gateway device may configure the second destination IP address as the destination IP address in the corresponding sub-connection information, the gateway device may configure the second destination port as the destination port in the corresponding sub-connection information, and the gateway device may configure the original destination port as the destination port in the corresponding sub-connection information.
[0065] The gateway device can configure the original destination IP address in the NAT conversion information corresponding to each sub-connection according to the network protocol type in the parent connection information and the network protocol type in each sub-connection information. The original destination IP address is the proxy address of the sub-connection. Specifically, the gateway device can compare the network protocol type in the parent connection information with the network protocol type in each sub-connection information, and configure the original destination IP address in the NAT conversion information corresponding to each sub-connection according to the comparison result of the network protocol type.
[0066] In an embodiment of the present application, configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each child connection information includes: when the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, configuring the proxy IP address of the parent connection corresponding to the parent connection message as the original destination IP address; when the network protocol type in the parent connection information is different from the network protocol type in each child connection information, configuring the original destination IP address to be the same as the network protocol type of each child connection information configured on the interface of the gateway device where the proxy IP address of the parent connection is located.
[0067] When the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, the gateway device can configure the proxy IP address of the parent connection corresponding to the parent connection message as the original destination IP address. When the network protocol type in the parent connection information is different from the network protocol type in each child connection information, the gateway device can configure the original destination IP address as the IP address configured on the interface of the gateway device where the proxy IP address of the parent connection is located, which is the same as the network protocol type of each child connection information. Among them, the network protocol type in the parent connection information is the network type of the network layer IP address, and the network protocol type in the child connection information is the network type of the IP address in the OPCDA protocol content.
[0068] When the gateway device is deployed in the OPC DA protocol network environment in proxy access mode, it is necessary to set the flags to fill in the NAT conversion information. The network protocol type in the NAT conversion information needs to be filled in with the protocol type of the resolved network IP address. If the resolved IP address is 10.10.10.3, the family is filled with IPV4; if the resolved IP address is 1000::2, the family is filled with IPV6. The converted destination address and converted destination port in the NAT conversion information are filled with the content parsed in the message. The original destination address in the NAT conversion information is the proxy address of the sub-link. There are two cases: 1) If the protocol type of the resolved network address is the same as the network type of the current message, the proxy IP address of the connection to which the message belongs is used as the original destination IP address of the data connection (sub-connection). 2) If the protocol type of the resolved network address is different from the network type of the message, it is necessary to obtain the IP address of the same network protocol type as the sub-connection configured on the interface where the proxy IP address of the parent connection of the industrial gateway device is located as the original destination IP address. The original destination port number in the NAT translation information is filled with the TCP port number parsed from the message.
[0069] The following Table 2 shows a simplified structure of NAT conversion information.
[0070] Table 2
[0071]
[0072]
[0073] When the access mode of the gateway device is proxy access, the gateway device modifies the destination IP address and destination port of the sub-connection, that is, the proxy IP address and proxy port of the OPC client to initiate the connection to the gateway device. Thus, the gateway device can modify each expected connection information and each sub-connection information in the parent connection message according to each NAT conversion information.
[0074] Specifically, in an embodiment of the present application, modifying each expected connection information and each child connection information in the parent connection message according to each NAT conversion information includes: replacing the destination IP address and destination port in each child connection information with the original destination address and original destination port in each NAT conversion information to obtain a modified parent connection message; replacing the first destination IP address and the first destination port in each expected connection information with the original destination address and original destination port in each NAT conversion information to obtain the modified expected connection information.
[0075] The gateway device may replace the destination IP address and destination port in each child connection information with the original destination address and original destination port in each NAT translation information to obtain a modified parent connection message. The gateway device may replace the first destination IP address and first destination port in each expected connection information with the original destination address and original destination port in each NAT translation information to obtain the modified expected connection information.
[0076] The gateway device may forward the modified parent connection message to the OPC client to establish a communication connection with the OPC client. The OPC client may initiate a request message for a child connection to the gateway device. The gateway device may receive and parse the request message for the child connection to obtain the five-tuple information in the request message for the child connection. The five-tuple information may include the network protocol type, destination IP address, destination port, source IP address, and source port of the child connection.
[0077] The gateway device can process the request message of the sub-connection according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection. Specifically, the gateway device can match the five-tuple information with all the modified expected connection information. If the corresponding modified expected connection information is matched, that is, the modified expected connection information is hit, the connection information on the gateway device corresponding to the sub-connection request can be marked as an OPC DA protocol sub-connection, and the modified expected connection information obtained by the match is deleted. The gateway device can modify the request message of the sub-connection according to the NAT conversion information of the sub-connection corresponding to the sub-connection request, thereby forwarding the modified request message of the sub-connection to the corresponding server.
[0078] In an embodiment of the present application, processing a request message of a sub-connection according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection includes: when the five-tuple information hits the modified expected connection information of any sub-connection, modifying the destination IP address and destination port in the request message of the sub-connection to the second destination IP address and second destination port in the NAT conversion information of the sub-connection; modifying the second source IP address of the request message of the sub-connection according to the modified destination IP address in the request message of the sub-connection; performing TCP checksum processing on the modified request message of the sub-connection, and forwarding the modified request message of the sub-connection to the corresponding OPC server.
[0079] The gateway device can match the five-tuple information with all the modified expected connection information. If the corresponding expected connection information is matched, that is, the expected connection information is hit, the gateway device can modify the destination IP address and destination port in the request message of the sub-connection to the second destination IP address and second destination port in the NAT conversion information of the sub-connection. The gateway device can search the routing table policy of the gateway device according to the modified destination IP address in the request message of the sub-connection, determine the interface between the gateway device and the corresponding server, and the IP address corresponding to the interface, and can modify the second source IP address of the request message of the sub-connection to the IP address corresponding to the interface. The gateway device can perform TCP checksum processing on the modified request message of the sub-connection, and then the gateway device can forward the modified request message of the sub-connection to the corresponding OPC server.
[0080] In one embodiment, the gateway device can update the five-tuple information (network protocol type, source IP address, destination IP address, source port number, destination port number) after the OPC DA protocol data connection message is converted into the connection information of the industrial gateway device, so as to ensure that after the gateway device hits the expected connection information and deletes the corresponding expected connection information, subsequent connection messages can be converted into business message NAT information through the five-tuple information recorded in the connection information of the gateway device.
[0081] Through the above technical solution, when the destination IP addresses of the parent connection and the child connection are different or the network protocol types are different, the communication between the OPC client and the OPC server can be ensured to be normal, so that even if the OPC DA protocol client initiates an IPv4 network protocol connection to the server, the data connection (child connection) can also be communicated through an IPV6 network protocol connection; or even if the OPC DA protocol client initiates an IPV6 network protocol connection to the server, the data connection (child connection) can also be communicated through an IPV4 network protocol connection; or even if the network protocol of the OPC DA protocol data connection (child connection) is the same as the parent connection network protocol, but the communication IP addresses are different, connection communication can be carried out, thereby enhancing the access capability of the gateway device.
[0082] Figure 2 FIG. 1 is a flow chart of a message processing method in an embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0083] In one embodiment, a message processing device is provided, comprising:
[0084] a memory configured to store instructions;
[0085] The processor is configured to call instructions from the memory and implement the above-mentioned message processing method when executing the instructions.
[0086] In one embodiment, a machine-readable storage medium is provided, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned message processing method.
[0087] In one embodiment, a processor is provided, and the processor is used to run a program, wherein the above-mentioned message processing method is executed when the program is run.
[0088] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data such as five-tuple information in the request message of the sub-connection. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a message processing method is implemented.
[0089] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0090] The embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: receiving a parent connection message returned by the OPC server, wherein the parent connection message is a response message generated by the OPC server after receiving a parent connection request forwarded by a gateway device, and the parent connection request is sent by the OPC client to the gateway device; in the case where the parent connection message is a response type message, parsing the parent connection message to obtain parent connection information and child connection information of at least one child connection that the OPC client can initiate; configuring the expected connection information corresponding to each child connection according to each child connection information The first network protocol type, the first destination IP address, the first destination port and the source port of the parent connection; configure the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information; when the access mode of the gateway device is routing access, forward the parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; receive and parse the child connection request message sent by the OPC client to obtain the five-tuple information in the child connection request message; process the child connection request message according to the five-tuple information and all the expected connection information on the gateway device.
[0091] In one embodiment, configuring the first source IP address in the expected connection information corresponding to each child connection based on the destination IP address in the parent connection information and the destination IP address in each child connection information includes: for any child connection information, when the destination IP address in the parent connection information is the same as the destination IP address in any child connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any child connection information, when the destination IP address in the parent connection information is different from the destination IP address in any child connection information, configuring the first source IP address according to the first network protocol type in each child connection information.
[0092] In one embodiment, configuring the first network protocol type, the first destination IP address, the first destination port and the source port in the expected connection information corresponding to each sub-connection according to each sub-connection information includes: configuring the first network protocol type as the network protocol type in the corresponding sub-connection information; configuring the first destination IP address as the destination IP address in the corresponding sub-connection information; configuring the first destination port as the destination port in the corresponding sub-connection information; and configuring the source port as a preset port.
[0093] In one embodiment, the method also includes: when the access mode of the gateway device is proxy access, configuring a NAT conversion flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information; configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each sub-connection information; modifying each expected connection information and each sub-connection information in the parent connection message according to each NAT conversion information; forwarding the modified parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; receiving the sub-connection request message sent by the OPC client, and parsing the sub-connection request message to obtain the five-tuple information in the sub-connection request message; processing the sub-connection request message according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection.
[0094] In one embodiment, configuring the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information according to each sub-connection information includes: configuring the second network protocol type as the network protocol type in the corresponding sub-connection information; configuring the second destination IP address as the destination IP address in the corresponding sub-connection information; configuring the second destination port as the destination port in the corresponding sub-connection information; and configuring the original destination port as the destination port in the corresponding sub-connection information.
[0095] In one embodiment, configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each child connection information includes: when the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, configuring the proxy IP address of the parent connection corresponding to the parent connection message as the original destination IP address; when the network protocol type in the parent connection information is different from the network protocol type in each child connection information, configuring the original destination IP address as the IP address configured on the interface of the gateway device where the proxy IP address of the parent connection is located, which is the same as the network protocol type of each child connection information.
[0096] In one embodiment, modifying each expected connection information and each child connection information in the parent connection message according to each NAT conversion information includes: replacing the destination IP address and destination port in each child connection information with the original destination address and original destination port in each NAT conversion information to obtain a modified parent connection message; replacing the first destination IP address and the first destination port in each expected connection information with the original destination address and original destination port in each NAT conversion information to obtain the modified expected connection information.
[0097] In one embodiment, processing a request message of a sub-connection according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection includes: when the five-tuple information hits the modified expected connection information of any one sub-connection, modifying the destination IP address and destination port in the request message of the sub-connection to the second destination IP address and second destination port in the NAT conversion information of the sub-connection; modifying the second source IP address of the request message of the sub-connection according to the modified destination IP address in the request message of the sub-connection; performing TCP checksum processing on the modified request message of the sub-connection, and forwarding the modified request message of the sub-connection to the corresponding OPC server.
[0098] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the steps of the message processing method.
[0099] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0100] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0101] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0103] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0104] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0105] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0106] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0107] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A message processing method, characterized in that: Applied to a gateway device, the method comprises: Receive a parent connection message returned by the OPC server, wherein the parent connection message is a response message generated by the OPC server after receiving the parent connection request forwarded by the gateway device, and the parent connection request is sent by the OPC client to the gateway device; In the case where the parent connection message is a response type message, parsing the parent connection message to obtain parent connection information and child connection information of at least one child connection that can be initiated by the OPC client; According to each sub-connection information, configure the first network protocol type, the first destination IP address, the first destination port, and the source port in the expected connection information corresponding to each sub-connection; According to the destination IP address in the parent connection information and the destination IP address in each child connection information, configure the first source IP address in the expected connection information corresponding to each child connection; When the access mode of the gateway device is routing access, forwarding the parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; Receive and parse the sub-connection request message sent by the OPC client to obtain the five-tuple information in the sub-connection request message; The request message of the sub-connection is processed according to the five-tuple information and all the expected connection information on the gateway device.
2. The message processing method according to claim 1, characterized in that: The configuring the first source IP address in the expected connection information corresponding to each child connection according to the destination IP address in the parent connection information and the destination IP address in each child connection information comprises: For any child connection information, if the destination IP address in the parent connection information is the same as the destination IP address in any child connection information, configure the first source IP address as the second source IP address in the parent connection information; For any child connection information, when the destination IP address in the parent connection information is different from the destination IP address in any child connection information, the first source IP address is configured according to the first network protocol type in each child connection information.
3. The message processing method according to claim 1, characterized in that: The configuring, according to each sub-connection information, the first network protocol type, the first destination IP address, the first destination port, and the source port in the expected connection information corresponding to each sub-connection includes: Configuring the first network protocol type as the network protocol type in the corresponding sub-connection information; Configuring the first destination IP address as the destination IP address in the corresponding sub-connection information; Configuring the first destination port as the destination port in the corresponding sub-connection information; The source port is configured as a preset port.
4. The message processing method according to claim 1, characterized in that: The method further comprises: When the access mode of the gateway device is proxy access, configuring a NAT conversion flag for the expected connection information corresponding to each sub-connection; According to each sub-connection information, configure the second network protocol type, the second destination IP address, the second destination port and the original destination port in the NAT conversion information included in each expected connection information; Configure the original destination IP address in the NAT translation information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each child connection information; Modify each expected connection information and each child connection information in the parent connection message according to each NAT translation information; Forwarding the modified parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; Receiving a sub-connection request message sent by the OPC client, and parsing the sub-connection request message to obtain quintuple information in the sub-connection request message; The request message of the sub-connection is processed according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection.
5. The message processing method according to claim 4, characterized in that: The configuring, according to each sub-connection information, the second network protocol type, the second destination IP address, the second destination port, and the original destination port in the NAT conversion information included in each expected connection information comprises: Configuring the second network protocol type as the network protocol type in the corresponding sub-connection information; Configuring the second destination IP address as the destination IP address in the corresponding sub-connection information; Configuring the second destination port as the destination port in the corresponding sub-connection information; The original destination port is configured as the destination port in the corresponding sub-connection information.
6. The message processing method according to claim 4, characterized in that: The configuring the original destination IP address in the NAT conversion information included in each expected connection information according to the network protocol type in the parent connection information and the network protocol type in each child connection information comprises: In the case where the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, configuring the proxy IP address of the parent connection corresponding to the parent connection message as the original destination IP address; When the network protocol type in the parent connection information is different from the network protocol type in each child connection information, the original destination IP address is configured as an IP address with the same network protocol type as each child connection information configured on the interface of the gateway device where the proxy IP address of the parent connection is located.
7. The message processing method according to claim 4, characterized in that: The modifying of each expected connection information and each child connection information in the parent connection message according to each NAT conversion information comprises: The destination IP address and the destination port in each child connection information are replaced with the original destination address and the original destination port in each NAT translation information to obtain a modified parent connection message; The first destination IP address and the first destination port in each expected connection information are replaced with the original destination address and the original destination port in each NAT translation information to obtain modified expected connection information.
8. The message processing method according to claim 4, characterized in that: The processing of the request message of the sub-connection according to the five-tuple information and the modified expected connection information and NAT conversion information of each sub-connection comprises: In the case where the five-tuple information hits the modified expected connection information of any sub-connection, modifying the destination IP address and the destination port in the request message of the sub-connection to the second destination IP address and the second destination port in the NAT translation information of the sub-connection; Modify the second source IP address of the request message of the sub-connection according to the modified destination IP address in the request message of the sub-connection; After performing TCP checksum processing on the request message of the modified sub-connection, the request message of the modified sub-connection is forwarded to the corresponding OPC server.
9. A message processing device, characterized in that: The device comprises: a memory configured to store instructions; A processor is configured to call the instruction from the memory and implement the message processing method according to any one of claims 1 to 8 when executing the instruction.
10. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the message processing method according to any one of claims 1 to 8.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the message processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Message forwarding method and device, storage device and program product
CN109802951A
Method and device for adjusting industrial control firewall data transmission, equipment and storage medium
CN114006809A
Multi-connection protocol message detection method and device, equipment and storage medium
CN115412330A