Message processing methods, devices, storage media and program products
By parsing and configuring the connection information between the OPC client and the OPC server, and utilizing the routing or proxy access method of the gateway device, the problem of abnormal communication between the OPC client and the OPC server was solved, and normal communication between different network protocols and addresses was achieved.
Patent Information
- Application Number
- CN202411967343.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-30
AI Technical Summary
In industrial gateway device access scenarios, communication anomalies between OPC clients and OPC servers are caused by the different network addresses of child and parent connections.
By receiving the parent connection message returned by the OPC server, parsing the parent connection information and child connection information, configuring the network protocol type, destination IP address, destination port and source port in the expected connection information, and using the routing or proxy access method of the gateway device, a communication connection between the OPC client and the OPC server is established, and child connection request messages are processed to ensure normal communication.
When the destination IP addresses or network protocol types of the parent and child connections are different, this feature ensures normal communication between the OPC client and the OPC server, enhances the access capabilities of the gateway device, and supports communication connections with different network protocols and addresses.
Smart Images

Figure CN119766858B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of message processing technology, specifically to a message processing method, apparatus, storage medium, and program product. Background Technology
[0002] In the field of industrial automation, data acquisition and transmission are crucial. OPC DA (short for OLE for Process Control Data Access) defines an industry-standard interface for real-time data access. The OPC DA protocol's OPC server listens on port TCP-135, and after creating an object, the OPC server returns a new dynamic port number for data communication via the OPC DA protocol.
[0003] The dynamic port number returned by the OPC DA protocol OPC server is an important basis for industrial gateway devices to decide whether to allow OPC DA protocol data communication. 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 multiple connectable IP addresses exist on the interfaces of the OPC client host, OPC server host, and gateway device, the choice of which IP address to use for communication is determined by the OPC DA protocol OPC client and cannot be predicted in advance, potentially leading to communication anomalies. Therefore, in industrial gateway device access scenarios, when the network address for the OPC DA protocol OPC client to initiate a data connection is uncertain, and if the network addresses of the child connection and the parent connection are different, communication anomalies may occur between the OPC client and the OPC server. Summary of the Invention
[0005] The purpose of this application is to provide a message processing method, apparatus, storage medium, and program product to solve the problem in the prior art where OPC clients and OPC servers cannot communicate normally when the network addresses of sub-connections and parent connections are different.
[0006] To achieve the above objectives, the first aspect of this application provides a message processing method, comprising:
[0007] Receive the parent connection message returned by the OPC server. The parent connection message is the response message generated by the OPC server after receiving the parent connection request forwarded by the gateway device. The parent connection request is sent by the OPC client to the gateway device.
[0008] When the parent connection message is a response type message, parse the parent connection message to obtain the parent connection information and the sub-connection information of at least one sub-connection that the OPC client can initiate;
[0009] Configure the first network protocol type, first destination IP address, first destination port, and source port in the expected connection information corresponding to each sub-connection based on the information of each sub-connection;
[0010] Configure 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;
[0011] When the gateway device is accessed via routing, 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 5-tuple information in the sub-connection request message;
[0013] The request message for the sub-connection is processed based on the 5-tuple information and all expected connection information on the gateway device.
[0014] In this embodiment, configuring the first source IP address in the expected connection information corresponding to each sub-connection based on the destination IP address in the parent connection information and the destination IP address in each sub-connection information includes: for any sub-connection information, if the destination IP address in the parent connection information is the same as the destination IP address in any sub-connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any sub-connection information, if the destination IP address in the parent connection information is different from the destination IP address in any sub-connection information, configuring the first source IP address according to the first network protocol type in each sub-connection information.
[0015] In this embodiment of the application, configuring the first network protocol type, first destination IP address, first destination port, and 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 this embodiment, the method further includes: when the gateway device's access method is proxy access, configuring a NAT translation flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation information included in each expected connection information according to each sub-connection information; configuring 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 sub-connection information; modifying each expected connection information and each sub-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 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; and processing the sub-connection request message according to the five-tuple information, the modified expected connection information, and the NAT translation information of each sub-connection.
[0017] In this embodiment of the application, configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation 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 this embodiment, configuring 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 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 packet 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.
[0019] In this embodiment of the application, modifying each expected connection information and each sub-connection information in the parent connection packet according to each NAT translation information includes: replacing the destination IP address and destination port in each sub-connection information with the original destination address and original destination port in each NAT translation information to obtain the modified parent connection packet; and replacing 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.
[0020] In this embodiment, processing the request packet of a sub-connection based on the 5-tuple information and the modified expected connection information and NAT translation information of each sub-connection includes: if the 5-tuple information matches the modified expected connection information of any sub-connection, modifying the destination IP address and destination port in the request packet of the sub-connection to the second destination IP address and second destination port in the NAT translation information of the sub-connection; modifying the second source IP address of the request packet of the sub-connection based on the modified destination IP address in the request packet of the sub-connection; performing TCP checksum processing on the modified request packet of the sub-connection, and forwarding the modified request packet of the sub-connection to the corresponding OPC server.
[0021] A second aspect of this application provides a message processing apparatus, comprising:
[0022] The memory is configured to store instructions;
[0023] The processor is configured to retrieve instructions from memory and, when executing instructions, to implement the aforementioned message processing methods.
[0024] A third aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform the aforementioned message processing method.
[0025] The fourth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described message processing method.
[0026] The above technical solution receives the parent connection message returned by the OPC server; when the parent connection message is a response type message, it parses the parent connection message to obtain the parent connection information and the sub-connection information of at least one sub-connection that the OPC client can initiate; it configures the first network protocol type, first destination IP address, first destination port, and source port in the expected connection information corresponding to each sub-connection according to the sub-connection information; it configures the first source IP address 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 sub-connection information; when the gateway device's access method is routing access, it forwards the parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client; it receives and parses the sub-connection request message sent by the OPC client to obtain the five-tuple information in the sub-connection request message; it processes the sub-connection request message according to the five-tuple information and all the expected connection information on the gateway device, ensuring normal communication between the OPC client and the OPC server when the destination IP addresses or network protocol types of the parent connection and sub-connection are different.
[0027] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description
[0028] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings:
[0029] Figure 1 This illustration schematically shows an application environment diagram of the message processing method according to an embodiment of this application;
[0030] Figure 2 The schematic diagram illustrates a message processing method according to an embodiment of this application;
[0031] Figure 3 The diagram illustrates the internal structure of a computer device according to an embodiment of this application. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0033] It should be noted that if the embodiments of this application involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.
[0034] The message processing method provided in this application can be applied to, for example... Figure 1 In the application environment shown, gateway device 104 communicates with OPC client 102 and OPC server 106 via a network. Gateway device 104 can be an industrial gateway and includes an ALG (Application Level Gateway) module. OPC client 102 refers to a client using the OPC DA protocol, which can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. OPC server 106 refers to a server using the OPC DA protocol, which can be implemented as a standalone server or a server cluster consisting of multiple servers.
[0035] Figure 2 A schematic flowchart illustrating a message processing method according to an embodiment of this application is shown. Figure 2 As shown, in one embodiment of this application, a message processing method is provided. This embodiment mainly applies this method to the above-mentioned... Figure 1 Taking gateway device 104 as an example, the following steps are included:
[0036] Step 201: Receive the parent connection message returned by the OPC server. The parent connection message is a response message generated by the OPC server after receiving the parent connection request forwarded by the gateway device. The parent connection request is sent by the OPC client to the gateway device.
[0037] An OPC client can send a parent connection request to the gateway device, which can then forward the request to the OPC server. The OPC server can generate a parent connection message based on the request and return it to the gateway device. The gateway device can then receive the parent connection message returned by the OPC server.
[0038] Step 202: If the parent connection message is a response type message, parse the parent connection message to obtain the parent connection information and the sub-connection information of at least one sub-connection that the OPC client can initiate.
[0039] Upon receiving a 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, meaning the parent connection message is a response type message, the gateway device can parse the NetworkAddr field in the parent connection message to obtain the parent connection information and sub-connection information for at least one sub-connection that the OPC client can initiate. The parent connection information includes the parent connection's five-tuple information. The sub-connection information for each sub-connection includes the five-tuple information for each sub-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: Configure the first network protocol type, first destination IP address, first destination port and source port in the expected connection information corresponding to each sub-connection according to the sub-connection information.
[0041] The gateway device can configure the first network protocol type, first destination IP address, first destination port, and source port in the expected connection information corresponding to each sub-connection based on the sub-connection information. That is, an OPC client can initiate at least one sub-connection, each sub-connection corresponds to one sub-connection information, and each sub-connection information corresponds to one expected connection information. The expected connection information may include the first network protocol type, first destination IP address, first destination port, source IP address, and source port of the corresponding sub-connection.
[0042] In this embodiment of the application, configuring the first network protocol type, first destination IP address, first destination port, and 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 can configure the first network protocol type to 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, then the network protocol type in the corresponding sub-connection information is IPv4, and the first network protocol type in the expected connection information of the corresponding sub-connection will be IPv4. If the destination IP address in the corresponding sub-connection information is 1000::2, then the network protocol type in the corresponding sub-connection information is IPv6, and the first network protocol type in the expected connection information of the corresponding sub-connection will be IPv6. The gateway device can configure the first destination IP address to the destination IP address in the corresponding sub-connection information, and can configure the first destination port to 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 can configure the source port to a preset port, that is, fill the source port with 0, and do not specify the source port.
[0044] Step 204: Configure 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.
[0045] The gateway device can configure the first source IP address in the expected connection information corresponding to each sub-connection based on the destination IP address in the parent connection information and the destination IP address in each sub-connection information. Specifically, the gateway device can compare the destination IP address in the parent connection information with the destination IP address in each sub-connection information, and configure the first source IP address in the corresponding expected connection information based on the comparison result.
[0046] In this embodiment, configuring the first source IP address in the expected connection information corresponding to each sub-connection based on the destination IP address in the parent connection information and the destination IP address in each sub-connection information includes: for any sub-connection information, if the destination IP address in the parent connection information is the same as the destination IP address in any sub-connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any sub-connection information, if the destination IP address in the parent connection information is different from the destination IP address in any sub-connection information, configuring the first source IP address according to the first network protocol type in each sub-connection information.
[0047] For any sub-connection information, if the destination IP address in the parent connection information is the same as the destination IP address in the sub-connection information, the gateway device can configure the first source IP address as the second source IP address in the parent connection information. This allows for precise control of the source of the sub-connection when the OPC client and OPC server communicate and the parent and sub-connection network layer protocols are the same.
[0048] For any sub-connection, if the destination IP address in the parent connection information differs from the destination IP address in the sub-connection information, the gateway device can configure the first source IP address based on 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, where the source IP address is not specified, better adapts to scenarios where the OPC client randomly selects a destination IP address to establish a sub-connection with the server, especially when the OPC client and OPC server communicate and the parent and sub-connections have different network protocols or network addresses.
[0049] Table 1 below illustrates a simplified structure for expected connection information.
[0050] Table 1
[0051]
[0052]
[0053] The network protocol type in the expected connection information needs to be filled with the protocol type of the resolved network address. If the resolved IP address is 10.10.10.3, then the family is filled with IPv4; if the resolved IP address is 1000::2, then 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 from the packet. The number of expected connection information entries corresponds to the number of addresses, ensuring a one-to-one correspondence. The source IP address in the expected connection information is filled with the following two cases: 1) If the destination IP address in the expected connection information is the same as the destination IP address of the current packet, then the source IP address in the expected connection information can be filled with the source IP address of the current packet. 2) If the destination IP address in the expected connection information is different from the destination IP address of the current packet, then it is filled according to the network protocol type. If the network protocol type is IPv4, then 0.0.0.0 is filled; if the network protocol type is IPv6, then 0::0 is filled; that is, the source address is not specified. The source port in the expected connection information is filled with 0, meaning the source port is not specified.
[0054] Step 205: If the gateway device is accessed via routing, forward the parent connection message to the OPC client to establish a communication connection between the OPC server and the OPC client.
[0055] If the gateway device uses routed access, it is deployed in the OPC DA protocol network environment in routed access mode. In this case, there is no need to modify the packet network address (destination IP address) and TCP port (destination port), nor is it necessary to configure the corresponding NAT translation information. The gateway device can directly forward the parent connection packet 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 5-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 based on the 5-tuple information and all expected connection information on the gateway device.
[0059] The gateway device can process sub-connection request messages based on the five-tuple information and expected connection information. Specifically, the gateway device can match the five-tuple information with all expected connection information. If a matching expected connection is found, the gateway device can mark the connection information on the corresponding gateway device as an OPCDA protocol sub-connection and delete the matched expected connection information. At this time, the gateway device can directly forward the sub-connection request message to the OPC server, enabling communication between the OPC server and the OPC client.
[0060] In this embodiment, the method further includes: when the gateway device's access method is proxy access, configuring a NAT translation flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation information included in each expected connection information according to each sub-connection information; configuring 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 sub-connection information; modifying each expected connection information and each sub-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 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; and processing the sub-connection request message according to the five-tuple information, the modified expected connection information, and the NAT translation information of each sub-connection.
[0061] When the gateway device uses 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 OPC clients, while the destination server's IP address and port are the actual OPC server. In this case, corresponding NAT translation flags and NAT translation information need to be configured. The gateway device can configure NAT translation flags for the expected connection information corresponding to each sub-connection. That is, the expected connection information also includes NAT translation flags and NAT translation information.
[0062] The gateway device can configure the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation information included in each expected connection information according to each sub-connection information. That is, each expected connection information includes NAT translation information. Specifically, in the embodiments of this application, configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation 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 can configure the second network protocol type to match 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, then the network protocol type in the corresponding sub-connection information is IPv4, and the second network protocol type in the NAT translation information of the corresponding sub-connection will also be IPv4. If the destination IP address in the corresponding sub-connection information is 1000::2, then the network protocol type in the corresponding sub-connection information is IPv6, and the second network protocol type in the NAT translation information of the corresponding sub-connection will also be IPv6.
[0064] The gateway device can configure the second destination IP address as the destination IP address in the corresponding sub-connection information, the gateway device can configure the second destination port as the destination port in the corresponding sub-connection information, and the gateway device can 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 translation information corresponding to each sub-connection based on 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 and the network protocol type in each sub-connection information, and configure the original destination IP address in the NAT translation information corresponding to each sub-connection based on the comparison result.
[0066] In this embodiment, configuring 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 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 packet 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.
[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 packet 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 containing the proxy IP address of the parent connection, which has the same network protocol type as that in each child connection information. Here, 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 a gateway device is deployed in an OPC DA protocol network environment in proxy access mode, it needs to set flags and fill in NAT translation information. The network protocol type in the NAT translation information needs to be filled with the protocol type of the resolved network IP address. If the resolved IP address is 10.10.10.3, then the family is filled with IPv4; if the resolved IP address is 1000::2, then the family is filled with IPv6. The translated destination address and translated destination port in the NAT translation information are filled with the content parsed from the packet. The original destination address in the NAT translation 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 packet, then the proxy IP address of the connection to which the packet belongs is used as the original destination IP address of the data connection (sub-link). 2) If the protocol type of the resolved network address is different from the network type of the packet, then the IP address configured with the same network protocol type as the sub-link on the interface where the proxy IP address of the industrial gateway device's parent connection is located needs to be obtained 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 packet.
[0069] Table 2 below illustrates a simplified structure of NAT translation information.
[0070] Table 2
[0071]
[0072]
[0073] When the gateway device uses proxy access, the gateway device modifies the destination IP address and destination port for establishing sub-connections. That is, the proxy IP address and proxy port for the OPC client to initiate a connection to the gateway device. As a result, the gateway device can modify each expected connection information and each sub-connection information in the parent connection packet according to each NAT translation information.
[0074] Specifically, in the embodiments of this application, modifying each expected connection information and each sub-connection information in the parent connection packet according to each NAT translation information includes: replacing the destination IP address and destination port in each sub-connection information with the original destination address and original destination port in each NAT translation information to obtain the modified parent connection packet; and replacing 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.
[0075] The gateway device can replace the destination IP address and destination port in each sub-connection information with the original destination address and original destination port in each NAT translation information to obtain the modified parent connection packet. Similarly, the gateway device can 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 can forward the modified parent connection message to the OPC client to establish a communication connection with the OPC client. The OPC client can initiate 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.
[0077] The gateway device can process sub-connection request packets based on the 5-tuple information and the modified expected connection information and NAT translation information for each sub-connection. Specifically, the gateway device can match the 5-tuple information with all the modified expected connection information. If a match is found, i.e., a modified expected connection 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 matched modified expected connection information can be deleted. The gateway device can modify the sub-connection request packet according to the NAT translation information of the sub-connection corresponding to the sub-connection request, thereby forwarding the modified sub-connection request packet to the corresponding server.
[0078] In this embodiment, processing the request packet of a sub-connection based on the 5-tuple information and the modified expected connection information and NAT translation information of each sub-connection includes: if the 5-tuple information matches the modified expected connection information of any sub-connection, modifying the destination IP address and destination port in the request packet of the sub-connection to the second destination IP address and second destination port in the NAT translation information of the sub-connection; modifying the second source IP address of the request packet of the sub-connection based on the modified destination IP address in the request packet of the sub-connection; performing TCP checksum processing on the modified request packet of the sub-connection, and forwarding the modified request packet 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 a match is found, the gateway device can modify the destination IP address and destination port in the sub-connection's request packet to the second destination IP address and second destination port in the sub-connection's NAT translation information. The gateway device can then look up its routing table policy based on the modified destination IP address in the sub-connection's request packet to determine the interface between the gateway device and the corresponding server, as well as the IP address corresponding to that interface. It can also modify the second source IP address of the sub-connection's request packet to the IP address corresponding to that interface. Finally, the gateway device can perform TCP checksum processing on the modified sub-connection's request packet and then forward it to the corresponding OPC server.
[0080] In one embodiment, the gateway device can update the connection information of the industrial gateway device with the five-tuple information (network protocol type, source IP address, destination IP address, source port number, and destination port number) after the OPC DA protocol data connection message is converted. This ensures that after the gateway device hits the expected connection information and deletes the corresponding expected connection information, subsequent connection messages can be NAT-converted through the five-tuple information recorded in the connection information of the gateway device.
[0081] Through the above technical solutions, even when the destination IP addresses or network protocol types of the parent and child connections are different, normal communication between the OPC client and the OPC server can be ensured. This allows the data connection (child connection) to communicate using the IPv6 network protocol, even if the OPC DA protocol client initiates an IPv4 network protocol connection to the server; or even if the OPC DA protocol client initiates an IPv6 network protocol connection to the server, the data connection (child connection) can communicate using the IPv4 network protocol; or even if the network protocol of the OPC DA protocol data connection (child connection) is the same as that of the parent connection, but the communication IP addresses are different, connection communication can still be established, thus enhancing the access capabilities of the gateway device.
[0082] Figure 2 This is a flowchart illustrating a message processing method in one embodiment. It should be understood that, although... Figure 2 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2 At least some of the steps in the process 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 some of the sub-steps or stages of other steps.
[0083] In one embodiment, a message processing apparatus is provided, comprising:
[0084] The memory is configured to store instructions;
[0085] The processor is configured to retrieve instructions from memory and, when executing instructions, to implement the aforementioned message processing methods.
[0086] In one embodiment, a machine-readable storage medium is provided that stores instructions that, when executed by a processor, configure the processor to perform the message processing method described above.
[0087] In one embodiment, a processor is provided for running a program, wherein the program executes the message processing method described above during runtime.
[0088] In one embodiment, a computer device is provided, which 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, memory (not shown), and a database (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes 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). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A04. The database stores data such as the five-tuple information in sub-connection request messages. The network interface A02 communicates with external terminals via a network connection. When the computer program B02 is executed by the processor A01, it implements a message processing method.
[0089] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0090] This application provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: receiving a parent connection message returned by an 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; if the parent connection message is a response type message, parsing the parent connection message to obtain parent connection information and sub-connection information of at least one sub-connection that the OPC client can initiate; configuring expected connection information corresponding to each sub-connection based on each sub-connection information. The first network protocol type, first destination IP address, first destination port, and source port are selected; the first source IP address in the expected connection information corresponding to each sub-connection is configured based on the destination IP address in the parent connection information and the destination IP address in each sub-connection information; when the gateway device's access method 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 request message for the sub-connection sent by the OPC client is received and parsed to obtain the five-tuple information in the request message for the sub-connection; the request message for the sub-connection is processed based on the five-tuple information and all 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 sub-connection based on the destination IP address in the parent connection information and the destination IP address in each sub-connection information includes: for any sub-connection information, if the destination IP address in the parent connection information is the same as the destination IP address in any sub-connection information, configuring the first source IP address as the second source IP address in the parent connection information; for any sub-connection information, if the destination IP address in the parent connection information is different from the destination IP address in any sub-connection information, configuring the first source IP address according to the first network protocol type in each sub-connection information.
[0092] In one embodiment, configuring the first network protocol type, first destination IP address, first destination port, and 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 further includes: when the gateway device's access method is proxy access, configuring a NAT translation flag for the expected connection information corresponding to each sub-connection; configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation information included in each expected connection information according to each sub-connection information; configuring 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 sub-connection information; modifying each expected connection information and each sub-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 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; and processing the sub-connection request message according to the five-tuple information and the modified expected connection information and NAT translation information of each sub-connection.
[0094] In one embodiment, configuring the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation 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 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 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 packet 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 sub-connection information in the parent connection packet according to each NAT translation information includes: replacing the destination IP address and destination port in each sub-connection information with the original destination address and original destination port in each NAT translation information to obtain the modified parent connection packet; and replacing 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.
[0097] In one embodiment, processing the request packet of a sub-connection based on the 5-tuple information and the modified expected connection information and NAT translation information of each sub-connection includes: if the 5-tuple information matches the modified expected connection information of any sub-connection, modifying the destination IP address and destination port in the request packet of the sub-connection to the second destination IP address and second destination port in the NAT translation information of the sub-connection; modifying the second source IP address of the request packet of the sub-connection based on the modified destination IP address in the request packet of the sub-connection; performing TCP checksum processing on the modified request packet of the sub-connection, and forwarding the modified request packet of the sub-connection to the corresponding OPC server.
[0098] This application also provides a computer program product that, when executed on a data processing device, is suitable for executing a program with initialization steps for message processing methods.
[0099] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0100] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0101] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work 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 The 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 operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function 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] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0105] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0106] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0107] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A message processing method, characterized in that, Applied to a gateway device, the method includes: 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; If the parent connection message is a response type message, the parent connection message is parsed to obtain the parent connection information and the sub-connection information of at least one sub-connection that the OPC client can initiate; Configure the first network protocol type, first destination IP address, first destination port, and source port in the expected connection information corresponding to each sub-connection based on the information of each sub-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 gateway device uses 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. 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 for the sub-connection is processed based on the 5-tuple information and all expected connection information on the gateway device.
2. The message processing method according to claim 1, characterized in that, The step of 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 sub-connection information, if the destination IP address in the parent connection information is the same as the destination IP address in any sub-connection information, the first source IP address is configured as the second source IP address in the parent connection information; For any sub-connection information, if the destination IP address in the parent connection information is different from the destination IP address in any sub-connection information, the first source IP address is configured according to the first network protocol type in each sub-connection information.
3. The message processing method according to claim 1, characterized in that, The step of configuring the first network protocol type, first destination IP address, first destination port, and source port in the expected connection information corresponding to each sub-connection based on each sub-connection information includes: Configure the first network protocol type as the network protocol type in the corresponding sub-connection information; Configure the first destination IP address as the destination IP address in the corresponding sub-connection information; Configure the first destination port as the destination port in the corresponding sub-connection information; Configure the source port as a preset port.
4. The message processing method according to claim 1, characterized in that, The method further includes: When the gateway device uses proxy access, a NAT translation flag is configured for the expected connection information corresponding to each sub-connection. Configure each expected connection information according to the NAT translation information, including the second network protocol type, second destination IP address, second destination port, and original destination port; 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; The modified parent connection message is forwarded to the OPC client to establish a communication connection between the OPC server and the OPC client; Receive the sub-connection request message sent by the OPC client, and parse the sub-connection request message to obtain the five-tuple information in the sub-connection request message; The request message of the sub-connection is processed based on the 5-tuple information, the modified expected connection information of each sub-connection, and the NAT translation information.
5. The message processing method according to claim 4, characterized in that, The configuration of each expected connection information according to each sub-connection information includes the second network protocol type, second destination IP address, second destination port, and original destination port in the NAT translation information, which includes: Configure the second network protocol type as the network protocol type in the corresponding sub-connection information; Configure the second destination IP address as the destination IP address in the corresponding sub-connection information; Configure the second destination port as the destination port in the corresponding sub-connection information; Configure the original destination port as the destination port in the corresponding sub-connection information.
6. The message processing method according to claim 4, characterized in that, The step of configuring 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 includes: If the network protocol type in the parent connection information is the same as the network protocol type in each child connection information, the proxy IP address of the parent connection corresponding to the parent connection message will be configured as the original destination IP address. If 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 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.
7. The message processing method according to claim 4, characterized in that, The step of modifying each expected connection information and each child connection information in the parent connection packet according to each NAT translation information includes: Replace the destination IP address and destination port in each sub-connection information with the original destination address and original destination port in each NAT translation information to obtain the modified parent connection packet; Replace the first destination IP address and first destination port in each expected connection message with the original destination address and original destination port in each NAT translation message to obtain the modified expected connection message.
8. The message processing method according to claim 4, characterized in that, The process of processing the request message of the sub-connection based on the five-tuple information, the modified expected connection information of each sub-connection, and the NAT translation information includes: If the five-tuple information matches the modified expected connection information of any sub-connection, the destination IP address and destination port in the request message of the sub-connection will be modified to the second destination IP address and 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 modified sub-connection request message, the modified sub-connection request message is forwarded to the corresponding OPC server.
9. A message processing apparatus, characterized in that, The device includes: The memory is configured to store instructions; A processor is configured to retrieve the instructions from the memory and, when executing the instructions, to implement the message processing method according to any one of claims 1 to 8.
10. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by a processor, this instruction causes the processor to be configured to perform 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, it 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