CN111049947A - Message forwarding method and device, electronic equipment and storage medium - Google Patents

Message forwarding method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111049947A
CN111049947A CN201911367279.6A CN201911367279A CN111049947A CN 111049947 A CN111049947 A CN 111049947A CN 201911367279 A CN201911367279 A CN 201911367279A CN 111049947 A CN111049947 A CN 111049947A
Authority
CN
China
Prior art keywords
address
source
version
communication protocol
internet communication
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911367279.6A
Other languages
Chinese (zh)
Other versions
CN111049947B (en
Inventor
方海名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou DPTech Technologies Co Ltd
Original Assignee
Hangzhou DPTech Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou DPTech Technologies Co Ltd filed Critical Hangzhou DPTech Technologies Co Ltd
Priority to CN201911367279.6A priority Critical patent/CN111049947B/en
Publication of CN111049947A publication Critical patent/CN111049947A/en
Application granted granted Critical
Publication of CN111049947B publication Critical patent/CN111049947B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/251Translation of Internet protocol [IP] addresses between different IP versions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/659Internet protocol version 6 [IPv6] addresses
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application provides a message forwarding method and device, electronic equipment and a storage medium; the method is applied to forwarding equipment, and can perform protocol conversion on a source IP address in a control message under the condition of receiving the control message sent by a client, and replace the IP address of target equipment in the control message with the converted source IP address, so that a server can identify the converted source IP address after receiving the control message, and use the converted source IP address as the target IP address of a data message. Further, after the source IP address of the control packet is converted, the conversion relationship may be locally recorded in the forwarding device, so that the forwarding device replaces the destination IP address in the data packet with the IP address of the target device based on the conversion relationship when receiving the data packet returned by the server, thereby achieving the purpose of sending the data packet to the target device, i.e., achieving data transmission between devices using different protocols.

Description

Message forwarding method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of network communications, and in particular, to a method and an apparatus for forwarding a packet, an electronic device, and a storage medium.
Background
Network Protocol version 4 (IPv 4) is the most widely used network Protocol version currently, but with the increase of devices in the network, the network address (i.e., IPv4 address) adopting the Protocol is already exhausted. For this reason, a large number of devices use a network Protocol version 6(Internet Protocol version 6, IPv6) instead to solve the problem of insufficient network addresses.
However, after a large number of devices change to network protocol version 6, there is a problem of incompatibility between the devices due to the fact that different devices adopt different network protocol versions.
Disclosure of Invention
In view of this, the present application provides a message forwarding method and apparatus, an electronic device, and a storage medium, which can convert a network protocol version adopted by a message in a message forwarding process, so as to solve a compatibility problem caused by adopting different network protocol versions between devices.
In order to achieve the above purpose, the present application provides the following technical solutions:
according to a first aspect of the present application, a packet forwarding method is provided, which is applied to a forwarding device, and the method includes:
receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol;
converting a source IP address adopting the first version of the Internet communication protocol into a source IP address adopting a second version of the Internet communication protocol, and replacing the IP address of the target equipment contained in the control message with the converted source IP address, so that when a server returns a data message responding to the control message, the converted source IP address is set as a destination IP address of the data message;
locally recording the mapping relation between the IP address of the target equipment and the converted source IP address, and replacing the target IP address in the data message with the IP address of the target equipment according to the mapping relation under the condition that the target IP address of the data message returned by the server is matched with the converted source IP address;
and forwarding the data message with the replaced destination IP address to the target equipment.
According to a second aspect of the present application, a packet forwarding apparatus is provided, which is applied to a forwarding device, and the apparatus includes:
the receiving unit is used for receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol;
a conversion unit, configured to convert a source IP address using the first version of the internet communication protocol into a source IP address using a second version of the internet communication protocol, and replace an IP address of the target device included in the control message with the converted source IP address, so that when a server returns a data packet responding to the control packet, the converted source IP address is set as a destination IP address of the data packet;
a recording unit, configured to locally record a mapping relationship between the IP address of the target device and the converted source IP address, and replace the target IP address in the data packet with the IP address of the target device according to the mapping relationship when the target IP address of the data packet received from the server matches the converted source IP address;
and the forwarding unit is used for forwarding the data message with the replaced destination IP address to the target equipment.
According to a third aspect of the present application, there is provided an electronic device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method as in any of the above embodiments by executing the executable instructions.
According to a fourth aspect of the present application, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method as described in any of the above embodiments.
In the technical scheme of the application, the forwarding device performs protocol conversion on the source IP address in the received control message, and replaces the IP address of the target device carried in the control message with the converted source IP address, so that the problem that the server cannot identify the IP address of the target device after receiving the control message is solved; on the other hand, after receiving the control message, the server can return a data message to the forwarding device based on the replaced source IP address.
Further, after replacing the IP address of the target device carried in the control message with the source IP address of the control message, the forwarding device also records the conversion relationship locally, so that when receiving the data message returned by the server, the forwarding device can convert the target IP address in the data message into the IP address of the target device based on the conversion relationship, thereby achieving the purpose of forwarding the data message to the target device. In other words, the technical scheme of the application realizes data transmission between devices adopting different protocols.
Drawings
Fig. 1 is a flowchart illustrating a message forwarding method according to an exemplary embodiment of the present application.
Fig. 2 is an interaction diagram of a message forwarding method according to an exemplary embodiment of the present application.
Fig. 3 is an interaction diagram of another packet forwarding method according to an exemplary embodiment of the present application.
Fig. 4 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application.
Fig. 5 is a block diagram of a message forwarding apparatus according to an exemplary embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In order to solve the above technical problem, the present application provides a message forwarding method. Referring to fig. 1, fig. 1 is a flowchart illustrating a message forwarding method according to an exemplary embodiment of the present application. As shown in fig. 1, the method is applied to a forwarding device, and may include the following steps:
step S102, receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol.
In the related art, when the first version of internet communication protocol is IPv4 and the second version of internet communication protocol is IPv6, the received control packet is usually sent to the NAT device first, and the NAT device converts the received IP information using IPv4 into the IP information using IPv6 (i.e., NAT64 protocol conversion technology) based on the stored protocol conversion mapping table, so as to send the control packet to the service end using IPv 6. Similarly, the case where the first version of internet communication protocol is IPv6 and the second version of internet communication protocol is IPv4 is also similar, and details are not described here. However, such a method cannot perform protocol conversion on the IP address of the target device carried in the control packet, so that the server cannot identify the IP address of the target device when receiving the control packet, and cannot send the data packet to the target device.
In this embodiment, the forwarding device may be a NAT device. In actual operation, in order to avoid the high load work of the forwarding device, only the control messages sent by a part of the clients to some of the servers are usually subjected to protocol conversion. Therefore, before receiving the control message, the method may further include a process of screening the received message, and specifically, the method may include the following steps: receiving a monitoring linked list configuration instruction sent by a developer, and reading at least one group of quintuple information in the configuration instruction; and storing the read quintuple information to a monitoring linked list so as to match the quintuple of the message with the quintuple information stored in the linked list under the condition of receiving the message, so as to judge whether to perform protocol conversion on the message.
In this embodiment, the IP address of the target device carried in the control message is used to instruct the server to forward the data message according to the IP address. The client and the target device both adopt a first version of internet communication protocol, and the server adopts a second version of internet communication protocol. The client and the target device may be the same device or different devices. For example, when two devices are the same device, the IP address may be changed, so that the changed IP address needs to be carried by the control message to instruct the server to send the data message according to the changed IP address; when the two devices are different devices, the client can be a mobile phone terminal, and the target device can be a PC, and the mobile phone terminal instructs the server to send the data message to the PC by sending the IP address of the PC to the server.
Step S104, the source IP address adopting the first version of the Internet communication protocol is converted into the source IP address adopting the second version of the Internet communication protocol, the IP address of the target device contained in the control message is replaced by the converted source IP address, so that the server sets the converted source IP address as the destination IP address of the data message when returning the data message responding to the control message.
In this embodiment, the source IP address using the first version of the internet communication protocol is converted into the source IP address using the second version of the internet communication protocol, and the source IP address can be converted by the NAT64 protocol conversion technology. However, although the protocol conversion only on the source IP address can realize the message forwarding to the server, after receiving the message, the server still cannot identify the IP address of the target device due to different protocols. Therefore, the forwarding device replaces the IP address of the target device carried in the control message with the converted source IP address, so that the service end can identify the IP address carried in the control message. Specifically, the IP address of the target device may be located by searching for the keyword and according to the length of the character string of the IP address of the target device. For example, taking the target device as IPv4, the string length of the IP address of the target device is 32 bits. At this time, assuming that the IP address of the target device is recorded after the keyword "Transport", it is possible to determine 32 bits after "Transport" as the IP address of the target device by looking up the "Transport" keyword. The replacement process may be implemented by replacing the determined 32-bit IP address with the translated source IP address.
Further, in order to enable the server to identify the IP information in the control message, the first keyword in the control message needs to be replaced with the second keyword. The first keyword is used for indicating that the control message adopts a first version of internet communication protocol; the second key is used for indicating that the control message adopts a second version of internet communication protocol. For example, when the first version of internet communication protocol is IPv4 and the second version of internet communication protocol is IPv6, the first key may be "IN · IP 4" and the second key may be "IN · IP 6", and then "IN · IP 4" IN the control message is replaced with "IN · IP 6". Similarly, when the first version of internet communication protocol is IPv6, and the second version of internet communication protocol is IPv4, the description thereof is also omitted here.
In this embodiment, in addition to performing protocol conversion on the IP address of the target device, original port information of the target device included in the control message needs to be checked for duplication, where the original port information is used to indicate which port the server uses as the destination port to forward the data packet. Specifically, under the condition that the original port information is extracted, the original port information is matched with the port information occupied by the locally used port, and when the corresponding table entry is matched, the original port information is indicated to be occupied by other messages (at the same time, a plurality of messages may be transmitted, that is, multi-channel data transmission, and it is highly possible that a certain channel occupies the original port information in the plurality of channels). At this time, the original port information is replaced by another unoccupied port information, so that when the server returns the data message responding to the control message, the another port information is set as the destination port of the data message. And meanwhile, locally recording the replacement relationship between the original port information of the target equipment and the other port information, so that under the condition of receiving the data message returned by the server, the target port in the data message is replaced by the original port information according to the replacement relationship, and the data message is forwarded to the target equipment. In this way, data transmission between devices adopting different protocols can be realized.
In this embodiment, the source IP address of the control packet is recorded in the transport layer of the control packet, and the IP address of the target device is recorded in the application layer of the control packet.
Further, to implement forwarding of the control packet, it is further required to convert the destination IP address of the internet communication protocol in the control packet, which adopts the first version, into the destination IP address of the internet communication protocol in the second version. Similarly, in order to forward the data packet to the target device, the source IP address of the data packet using the second version of the internet communication protocol needs to be converted into the source IP address of the data packet using the first version of the internet communication protocol. The destination IP address of the control message may also be recorded at the transport layer.
In the present embodiment, in the case where the first version of the internet communication protocol is IPv4, the second version of the internet communication protocol is IPv 6; in the case where the first version of the internet communication protocol is IPv6, the second version of the internet communication protocol is IPv 4.
And step S106, locally recording the mapping relation between the IP address of the target equipment and the converted source IP address, and replacing the target IP address in the data message with the IP address of the target equipment according to the mapping relation under the condition that the target IP address of the data message returned by the server is matched with the converted source IP address.
In this embodiment, after replacing the destination IP address in the data packet with the IP address of the destination device according to the mapping relationship, a security label may be further added to the data packet, where the security label is used to indicate that the security device passes through the data packet.
Step S108, the data message with the replaced destination IP address is forwarded to the target device.
According to the technical scheme, the forwarding device performs protocol conversion on the source IP address in the control message, and replaces the IP address of the target device carried in the message with the source IP address after the protocol conversion, so that the problem that the server cannot identify the IP address of the target device due to different protocols is solved, and the server can send the data message to the forwarding device based on the replaced source IP address when receiving the control message.
Furthermore, after the IP address of the target device is replaced by the converted source IP address, the mapping relationship between the source IP address and the destination IP address is locally stored, so that when a data packet returned by the server is received, the destination IP address of the data packet can be replaced by the IP address of the target device according to the mapping relationship, and the data packet is further forwarded to the target device, that is, data transmission between devices adopting different protocols is realized.
For convenience of understanding, the technical solution of the present application is introduced by taking the target device as the client itself as an example.
Referring to fig. 2, fig. 2 is an interaction diagram of a packet forwarding method according to an exemplary embodiment of the present application. As shown in fig. 2, the method is applied to a NAT device, and may include the following steps:
step S201, the client creates a control packet.
In this embodiment, the forwarding device is a NAT device, the client uses IPv4, and the server uses IPv 6. In this step, the control packet created by the client records a five-tuple in the transport layer, that is, the client IP address (source IP address) using IPv4, the source port, the protocol number, and the server IP address (destination IP address) using IPv 4; and the IP address of the target device (i.e. the IP address of the client for receiving the data packet) and the original port information (the port information for receiving the data packet) are recorded in the application layer. For convenience of understanding, the original port of the target device is taken as port 1.0 as an example, and at this time, the IP information and the port information carried in the control message may refer to table 1 below.
Figure BDA0002338758480000081
TABLE 1
Step S202, the client sends the created control message to the NAT device.
Step S203, the NAT device receives the control packet sent by the client.
Step S204, the NAT device converts the source IP address and the destination IP address recorded in the control message transmission layer into the source IP address and the destination IP address adopting IPv 6.
In this embodiment, the quintuple in the control message is recorded in the transport layer. Since the server uses IPv6, in order to send the control packet to the server, the source IP address needs to be converted into a source IP address using IPv6, and the destination IP address needs to be converted into a destination IP address using IPv 6. Specifically, the IP address in the control packet transport layer after protocol conversion is: client IP address (source IP address) using IPv 6; the server IP address (destination IP address) of IPv6 is used.
Step S205, the NAT device replaces the IP address of the target device recorded in the control packet application layer with the source IP address using IPv6 after the conversion, and records the replacement relationship.
In this embodiment, since the IP address of the target device is IPv4, if the IP address is not subjected to protocol conversion, the server cannot identify the IP address, and further cannot send the data packet to the target device according to the IP address. Therefore, in this step, the IP address is replaced with the translated source IP address. Obviously, since the translated source IP address adopts IPv6, the server can identify the translated source IP address, so that the server can send the data packet based on the translated source IP address.
Further, the replacement relationship (i.e., "IP address of target device — source IP address after conversion/client IP address using IPv 6") is recorded locally, so that when the server returns the data packet, the destination IP address of the data packet (IP address of client using IPv6) can be replaced with the IP address of the target device based on the replacement relationship, and forwarding of the data packet to the target device is further achieved.
In addition, in this step, the original port of the target device may be checked for duplication, specifically, the port information of the target device is compared with the port information of the locally used port of the NAT device, and when it is found that the locally used port occupies the port information, the original port information is replaced with another port information that is not occupied. The purpose of duplicate checking of the original port information is to prevent data mistransmission caused by the fact that two destination ports can be found in NAT equipment when a server returns a data message. For example, assuming that the original port information is 1.0, and a piece of port information of another target device is also 1.0 recorded locally in the NAT device, at this time, if the target port information in the data packet returned by the target device is still 1.0, the NAT device cannot determine to which target device 1.0 the data packet should be sent, so in this step, when a piece of port information 1.0 already exists locally, the original port information of the current control packet may be replaced with 1.1, 1.2, and the like, and the replacement relationship is recorded, and the purpose of forwarding to the correct target device can be achieved only by rewriting again according to the replacement relationship when the data packet returned by the NAT device is received.
For convenience of understanding, it is assumed that the replaced another port information is port 1.1, and at this time, the IP information and the port information of the control packet may refer to table 2.
Figure BDA0002338758480000091
Figure BDA0002338758480000101
TABLE 2
Notably, the "client" under "the source port in the table refers to the port that the source port is the client; likewise, so does the destination port.
Step S206, the NAT equipment transmits the control message to the server based on the translated destination IP address.
Step S207, the server reads the IP address in the control packet application layer, and creates a data packet using the IP address as the destination IP address of the data packet.
In this step, the IP address included in the control message application layer is the client IP address adopting IPv6, that is, the server will use the client IP address adopting IPv6 as the destination IP address of the data message. If the original port information is replaced with another port information in step S205, the IP information and the port information in the data packet may refer to table 3 at this time.
Figure BDA0002338758480000102
TABLE 3
It should be noted that the source port of the datagram is the server port, and the destination port information is another port information replaced in step S205.
And step S208, the server side sends a data message to the NAT equipment.
Step S209, the NAT device replaces the destination IP address of the data packet with the IP address of the destination device based on the stored replacement relationship.
In this embodiment, the original destination IP in the data packet is the client IP address using IPv6, and after the replacement is performed through the replacement relationship, the destination IP is changed to the IP address of the target device using IPv 4. Meanwhile, the source IP address adopting IPv6 needs to be changed to the source IP address adopting IPv4 (this process can be implemented by using NAT64 protocol translation technology), and another port information needs to be replaced with the original port information of the target device, so as to forward the data packet to the target device. Specifically, the IP information and the port information of the converted data packet may refer to table 4.
Figure BDA0002338758480000111
TABLE 4
Step S210, the NAT device forwards the data packet to the target device based on the replaced IP address of the target device.
In this embodiment, after the NAT device replaces the destination IP address in the data packet with the IP address of the destination device, a security identifier may be further added to the data packet to indicate that the security device passes the data packet. By the mode, detection of the safety equipment can be avoided, and transmission efficiency is improved.
Step S211, the target device receives the data packet and reads the content of the data packet.
According to the technical scheme, the protocol conversion can be performed on the IP address of the target device stored in the control message application layer, so that on one hand, the server can identify the IP address recorded in the application layer under the condition that the server receives the control message; on the other hand, the IP address in the control message application layer is used as the destination IP address of the data message to send the data message to the NAT equipment, the replacement relation is stored on the basis of the NAT equipment, the destination IP address is replaced by the IP address of the target equipment, and the purpose of forwarding the data message to the target equipment is achieved.
Furthermore, the NAT device performs duplicate checking on the original port information of the target device, and replaces the original port information with another unoccupied port information when the matched used port information is found, so that the problem of data mistransmission caused by two transmission channels occupying the same port information at the same time is solved.
Next, taking the target device and the client as different devices as an example, a technical solution of the present application is introduced.
Referring to fig. 3, fig. 3 is an interaction diagram of another packet forwarding method according to an exemplary embodiment of the present application. As shown in fig. 3, the method is applied to a NAT device, and may include the following steps:
step S301, the client establishes a control message.
In this embodiment, similar to the previous embodiment, the forwarding device is a NAT device, the client uses IPv4, and the server uses IPv6 as an example. Next, in the present embodiment, most steps are similar to those in the previous embodiment, and related contents may refer to the description of the previous embodiment, which is not described herein again.
It is to be noted that, in this embodiment, since the target device and the client are not the same device, in this embodiment, it is actually an interaction between four devices (i.e., an interaction between the client, the NAT device, the server, and the target device).
Step S302, the client sends the created control message to the NAT device.
Step S303, the NAT device receives the control packet sent by the client.
Step S304, the NAT device converts the source IP address and the destination IP address recorded in the control message transmission layer into the source IP address and the destination IP address adopting IPv 6.
Step S305, the NAT device replaces the IP address of the target device recorded by the control message application layer with the source IP address which is converted and then adopts IPv6, and records the replacement relation.
Step S306, the NAT equipment forwards the control message to the server based on the translated destination IP address.
Step S307, the server reads the IP address in the control message application layer, and creates the data message by taking the IP address as the destination IP address of the data message.
Step S308, the server sends data message to NAT device.
Step S309, the NAT device replaces the destination IP address of the data message with the IP address of the target device based on the stored replacement relationship.
Step S310, the NAT equipment transmits the data message to the target equipment based on the IP address of the target equipment after replacement.
Step S311, the target device receives the data packet and reads the content of the data packet.
Compared with the previous embodiment, the client and the target device of the present embodiment are different devices. Therefore, the operation that the client instructs the server to send the data to the target device can be realized.
For example, the client may be a mobile phone terminal of the user, and the target device may be a PC of the user. When a user wants to project a certain video resource on a PC, the method can be adopted. Specifically, the mobile phone terminal can write the IP address of the PC into the application layer of the control message and send the control message to the server, so that the server sends the data message carrying the video data to the PC based on the IP address of the application layer.
Fig. 4 is a schematic block diagram illustrating an electronic device according to an exemplary embodiment of the present application. Referring to fig. 4, at the hardware level, the electronic device includes a processor 402, an internal bus 404, a network interface 406, a memory 408 and a non-volatile memory 410, but may also include hardware required for other services. The processor 402 reads a corresponding computer program from the non-volatile memory 410 into the memory 408 and then runs the computer program to form a message forwarding apparatus on a logical level. Of course, besides the software implementation, the present application does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Referring to fig. 5, in a software implementation, the message forwarding apparatus may include:
a receiving unit 501, configured to receive a control packet from a client, where the control packet includes a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol;
a conversion unit 502, configured to convert a source IP address using the first version of the internet communication protocol into a source IP address using a second version of the internet communication protocol, and replace an IP address of the target device included in the control message with the converted source IP address, so that when the server returns a data packet responding to the control message, the converted source IP address is set as a destination IP address of the data packet;
a recording unit 503, configured to locally record a mapping relationship between the IP address of the target device and the converted source IP address, and replace the destination IP address in the data packet with the IP address of the target device according to the mapping relationship when the destination IP address of the data packet received and returned by the server matches the converted source IP address;
a forwarding unit 504, configured to forward the data packet with the destination IP address replaced to the target device.
Optionally, the method further includes:
a determining unit 505, configured to determine a first keyword in the control packet, where the first keyword is used to indicate that the control packet adopts the first version of internet communication protocol;
a replacing unit 506, configured to replace the first keyword with a second keyword, where the second keyword is used to indicate that the control packet adopts the second version of internet communication protocol.
Optionally, the method further includes:
the replacing unit 506 is further configured to extract original port information of the target device included in the control packet; under the condition that the original port information is occupied by a locally used port of the forwarding equipment, replacing the original port information with another unoccupied port information, so that when a server returns a data message responding to the control message, the another port information is set as the destination port information of the data message;
the recording unit 503 is further configured to locally record a replacement relationship between the original port information of the target device and the another port information, and replace destination port information in the data packet with the original port information according to the replacement relationship.
Optionally, the source IP address of the client is recorded in the transport layer of the control packet, and the IP address of the target device is recorded in the application layer of the control packet.
Optionally, the method further includes:
an adding unit 507, configured to add a security label to the data packet after replacing the destination IP address in the data packet with the IP address of the target device, where the security label is used to indicate that the security device passes through the data packet.
Optionally, the method further includes:
the replacing unit 506 is further configured to convert a destination IP address of the control message that uses the first version of the internet communication protocol into a destination IP address of the control message that uses the second version of the internet communication protocol;
the replacing unit 506 is further configured to convert the source IP address of the data packet using the second version of internet communication protocol into the source IP address using the first version of internet communication protocol.
Optionally, in a case that the first version of internet communication protocol is IPv4, the second version of internet communication protocol is IPv 6;
in the case that the first version of internet communication protocol is IPv6, the second version of internet communication protocol is IPv 4.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
In an example embodiment, there is also provided a non-transitory computer readable storage medium, for example a memory, comprising instructions executable by a processor of a message forwarding device to implement a method as in any of the above embodiments, such as the method may comprise: receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol; converting a source IP address adopting the first version of the Internet communication protocol into a source IP address adopting a second version of the Internet communication protocol, and replacing the IP address of the target equipment contained in the control message with the converted source IP address, so that when a server returns a data message responding to the control message, the converted source IP address is set as a destination IP address of the data message; locally recording the mapping relation between the IP address of the target equipment and the converted source IP address, and replacing the target IP address in the data message with the IP address of the target equipment according to the mapping relation under the condition that the target IP address of the data message returned by the server is matched with the converted source IP address; and forwarding the data message with the replaced destination IP address to the target equipment.
The non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc., which is not limited in this application.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the scope of protection of the present application.

Claims (10)

1. A message forwarding method is applied to forwarding equipment, and the method comprises the following steps:
receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol;
converting a source IP address adopting the first version of the Internet communication protocol into a source IP address adopting a second version of the Internet communication protocol, and replacing the IP address of the target equipment contained in the control message with the converted source IP address, so that when a server returns a data message responding to the control message, the converted source IP address is set as a destination IP address of the data message;
locally recording the mapping relation between the IP address of the target equipment and the converted source IP address, and replacing the target IP address in the data message with the IP address of the target equipment according to the mapping relation under the condition that the target IP address of the data message returned by the server is matched with the converted source IP address;
and forwarding the data message with the replaced destination IP address to the target equipment.
2. The method of claim 1, further comprising:
determining a first keyword in the control message, wherein the first keyword is used for indicating that the control message adopts the first version of internet communication protocol;
and replacing the first keyword with a second keyword, wherein the second keyword is used for indicating that the control message adopts the internet communication protocol of the second version.
3. The method of claim 1, further comprising:
extracting original port information of the target equipment contained in the control message;
under the condition that the original port information is occupied by a locally used port of the forwarding equipment, replacing the original port information with another unoccupied port information, so that when a server returns a data message responding to the control message, the another port information is set as the destination port information of the data message;
locally recording the replacement relationship between the original port information of the target device and the other port information, and replacing the destination port information in the data message with the original port information according to the replacement relationship.
4. The method of claim 1, wherein the source IP address of the client is recorded in a transport layer of the control packet, and the IP address of the target device is recorded in an application layer of the control packet.
5. The method of claim 1, further comprising:
and after replacing the destination IP address in the data message with the IP address of the target equipment, adding a security mark to the data message, wherein the security mark is used for indicating security equipment to pass the data message.
6. The method of claim 1, further comprising:
converting the destination IP address of the Internet communication protocol adopting the first version in the control message into the destination IP address of the Internet communication protocol adopting the second version;
and converting the source IP address adopting the second version of Internet communication protocol in the data message into the source IP address adopting the first version of Internet communication protocol.
7. The method of claim 1,
in the case that the first version of internet communication protocol is IPv4, the second version of internet communication protocol is IPv 6;
in the case that the first version of internet communication protocol is IPv6, the second version of internet communication protocol is IPv 4.
8. A message forwarding apparatus is applied to a forwarding device, and the apparatus comprises:
the receiving unit is used for receiving a control message from a client, wherein the control message comprises a source IP address corresponding to the client and an IP address of a target device; the source IP address of the client and the IP address of the target device both adopt a first version of Internet communication protocol, and the server adopts a second version of Internet communication protocol;
a conversion unit, configured to convert a source IP address using the first version of the internet communication protocol into a source IP address using a second version of the internet communication protocol, and replace an IP address of the target device included in the control message with the converted source IP address, so that when a server returns a data packet responding to the control packet, the converted source IP address is set as a destination IP address of the data packet;
a recording unit, configured to locally record a mapping relationship between the IP address of the target device and the converted source IP address, and replace the target IP address in the data packet with the IP address of the target device according to the mapping relationship when the target IP address of the data packet received from the server matches the converted source IP address;
and the forwarding unit is used for forwarding the data message with the replaced destination IP address to the target equipment.
9. An electronic device, comprising:
a processor;
a memory for storing processor executable tasks;
wherein the processor implements the method of any one of claims 1-7 by executing the executable instructions.
10. A computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, perform the steps of the method according to any one of claims 1-7.
CN201911367279.6A 2019-12-26 2019-12-26 Message forwarding method and device, electronic equipment and storage medium Active CN111049947B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911367279.6A CN111049947B (en) 2019-12-26 2019-12-26 Message forwarding method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911367279.6A CN111049947B (en) 2019-12-26 2019-12-26 Message forwarding method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111049947A true CN111049947A (en) 2020-04-21
CN111049947B CN111049947B (en) 2023-03-28

Family

ID=70240355

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911367279.6A Active CN111049947B (en) 2019-12-26 2019-12-26 Message forwarding method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111049947B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111565237A (en) * 2020-07-15 2020-08-21 腾讯科技(深圳)有限公司 Network parameter determination method and device, computer equipment and storage medium
CN112666905A (en) * 2020-12-21 2021-04-16 哈尔滨天达控制股份有限公司 Multi-channel communication control system and channel control method
CN115001846A (en) * 2022-06-28 2022-09-02 湖北天融信网络安全技术有限公司 Method, isolation device, device and medium for cross-network data transmission

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040133692A1 (en) * 2003-01-07 2004-07-08 Hexago Inc. Method and apparatus for connecting IPV6 devices through an IPv4 network and a network address translator (NAT) using a tunnel setup protocol
CN103428303A (en) * 2012-05-22 2013-12-04 中兴通讯股份有限公司 Method and system for IPv6 host to have access to IPv4 server
CN107835198A (en) * 2017-12-13 2018-03-23 睿哲科技股份有限公司 Method, apparatus and the electronic equipment that PPTP is passed through are carried out in IPv4 IPv6 intercommunication scenes
CN108011989A (en) * 2017-11-30 2018-05-08 杭州盈高科技有限公司 A kind of reorientation method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040133692A1 (en) * 2003-01-07 2004-07-08 Hexago Inc. Method and apparatus for connecting IPV6 devices through an IPv4 network and a network address translator (NAT) using a tunnel setup protocol
CN103428303A (en) * 2012-05-22 2013-12-04 中兴通讯股份有限公司 Method and system for IPv6 host to have access to IPv4 server
CN108011989A (en) * 2017-11-30 2018-05-08 杭州盈高科技有限公司 A kind of reorientation method and device
CN107835198A (en) * 2017-12-13 2018-03-23 睿哲科技股份有限公司 Method, apparatus and the electronic equipment that PPTP is passed through are carried out in IPv4 IPv6 intercommunication scenes

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ERICSSON LM等: "S3i150255 "Reporting of UE local IP address and port"", 《3GPP TSG_SA\WG3_SECURITY》 *
干露等: "IPv4向IPv6演进策略的分析研究", 《中国新通信》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111565237A (en) * 2020-07-15 2020-08-21 腾讯科技(深圳)有限公司 Network parameter determination method and device, computer equipment and storage medium
CN112666905A (en) * 2020-12-21 2021-04-16 哈尔滨天达控制股份有限公司 Multi-channel communication control system and channel control method
CN112666905B (en) * 2020-12-21 2024-01-30 哈尔滨天达控制股份有限公司 Multichannel communication control system and channel control method
CN115001846A (en) * 2022-06-28 2022-09-02 湖北天融信网络安全技术有限公司 Method, isolation device, device and medium for cross-network data transmission

Also Published As

Publication number Publication date
CN111049947B (en) 2023-03-28

Similar Documents

Publication Publication Date Title
US11374863B2 (en) Segment routing extension headers
CN111049947B (en) Message forwarding method and device, electronic equipment and storage medium
KR101764402B1 (en) Network packet encapsulation and routing
US9378245B2 (en) Name database server, name resolution system, entry search method and entry search program
US7245622B2 (en) Allowing IPv4 clients to communicate over an IPv6 network when behind a network address translator with reduced server workload
US20070162968A1 (en) Rule-based network address translation
CN108259347B (en) Message transmission method and device
CN110808879B (en) Protocol identification method, device, equipment and readable storage medium
US9679022B2 (en) Name database server, name resolution system, entry search method and entry search program
CN107682470B (en) Method and device for detecting public network IP availability in NAT address pool
JP2005244408A (en) Gateway apparatus connected to plurality of networks with different network segments, and program and method for transferring ip packet
CN111131544A (en) Method for realizing NAT traversal
CN111064804B (en) Network access method and device
CN110932934A (en) Network packet loss detection method and device
CN111131539B (en) Message forwarding method and device
CN108881247B (en) Message conversion method, device, gateway equipment and storage medium
CN105450527B (en) The method and device for handling message, sending information, receiving information
CN114328190B (en) Method, system and server for automatically splitting IPS (in-plane switching) event
CN107547687B (en) Message transmission method and device
CN107196981A (en) Access record retransmission method, equipment and system
CN114285718B (en) Topology generation method and device, electronic equipment and storage medium
KR102663914B1 (en) Electronic apparatus and method for analyzing http traffic thereby
JP5289345B2 (en) Address translation device, communication system, message communication method, and program
CN117938974A (en) Protocol conversion method and device based on transparent mode, electronic equipment and storage medium
CN117135094A (en) In-band detection implementation method and device, network communication equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant