The present disclosure relates to network communications technologies, and in particular, to a method, a terminal, and a gateway for transmitting an IPv6 packet in an IPv4 network.
Because IPv4 addresses will be exhausted soon, operators need to switch their networks and subscribers to IPv6. If an existing network used to support an IPv4 service is upgraded to support IPv6, the investment will be too large and an unpredictable problem may arise due to the network upgrade. Therefore, a mechanism is needed to provide an IPv6 service in an existing IPv4 network. In an existing solution for traversal of an IPv6 packet through an IPv4 network, each IPv6 address corresponds to one IPv4 address, which cannot solve a problem of IPv4 address shortage.
Embodiments of the present disclosure provides a method, a terminal, and a gateway for transmitting an IPv6 packet in an IPv4 network, so as to implement traversal of the IPv6 packet through the IPv4 network and save IPv4 addresses.
In a first aspect, an embodiment of the present disclosure provides a method for transmitting an IPv6 packet in an IPv4 network. In the method, an IPv6 terminal obtains an IPv6 address of the terminal, where the IPv6 address includes an IPv4 address. The IPv4 address includes an IPv4 address of a gateway or an IPv4 address designated by the gateway. The gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network. Multiple IPv6 terminals are connected to the gateway. IPv6 addresses of all the IPv6 terminals connected to the gateway include the same IPv4 address. The IPv6 terminal sends an IPv6 packet to the gateway, where IPv6 packet includes the IPv6 address as a source address.
In a second aspect, an embodiment of the present disclosure provides a method for transmitting an IPv6 packet in an IPv4 network. In the method, a first gateway receives an IPv6 packet sent by an IPv6 terminal, where the IPv6 packet includes a destination IPv6 address. If the destination IPv6 address includes an IPv4 address, the first gateway encapsulates the IPv6 packet in an IPv4 packet of which a destination address is the IPv4 address, and sends the IPv4 packet to a second gateway. The IPv4 address included in the destination IPv6 address includes an IPv4 address of the second gateway or an IPv4 address designated by the second gateway. The second gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network. IPv6 addresses of all IPv6 terminals connected to the second gateway include the same IPv4 address.
In a third aspect, an embodiment of the present disclosure provides a terminal having a processor. The terminal includes: an obtaining module, configured to obtain, in the processor, an IPv6 address of the terminal, where the IPv6 address includes an IPv4 address, the IPv4 address is an IPv4 address of a gateway or an IPv4 address designated by the gateway, the gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network, multiple IPv6 terminals are connected to the gateway, and IPv6 addresses of all the IPv6 terminals connected to the gateway include the same IPv4 address; and a sending module, configured to send, by the processor, an IPv6 packet to the gateway, where the IPv6 packet includes the IPv6 address as a source address.
In a fourth aspect, an embodiment of the present disclosure provides a gateway having a processor. The gateway includes: a receiving module, configured to receive an IPv6 packet sent by an IPv6 terminal, where the IPv6 packet includes a destination IPv6 address; and a first encapsulating module, configured to, if the destination IPv6 address includes an IPv4 address, encapsulate the IPv6 packet in an IPv4 packet of which a destination address is the IPv4 address, and send the IPv4 packet to a second gateway, where the IPv4 address included in the destination IPv6 address is an IPv4 address of the second gateway or an IPv4 address designated by the second gateway, the second gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network, and IPv6 addresses of all IPv6 terminals connected to the second gateway include the same IPv4 address.
From the foregoing solutions, it can be known that, in the method and device for transmitting the IPv6 packet in the IPv4 network according to the embodiments of the present disclosure, by encapsulating the IPv6 packet in the IPv4 packet, the traversal of the IPv6 packet through the IPv4 network can be implemented, and an IPv4 address of a gateway corresponding to multiple IPv6 terminals is used as a destination address of the IPv4 packet after encapsulation, which may make the multiple IPv6 terminals correspond to the same IPv4 address, to save IPv4 addresses.
To illustrate solutions in embodiments of the present disclosure more clearly, accompanying drawings to be used for describing the embodiments are introduced briefly in the following. Apparently, the accompanying drawings in the following description are some embodiments of the present disclosure, and persons of ordinary skill in the art can further obtain other drawings according to these accompanying drawings without making creative efforts.
a is a schematic diagram of a format of an IPv6 address according to an embodiment of the present disclosure;
b is a schematic diagram of another format of an IPv6 address according to an embodiment of the present disclosure;
To make objectives, solutions, and advantages of embodiments of the present disclosure clearer, the solutions in the embodiments of the present disclosure are described below with reference to accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are merely part rather than all of the embodiments of the present disclosure. All other embodiments obtained by persons of ordinary skill in the art without creative effort based on the embodiments of the present disclosure fall within the protection scope of the present disclosure.
Step 11: An IPv6 terminal obtains an IPv6 address of the terminal, where the IPv6 address includes an IPv4 address, the IPv4 address is an IPv4 address of a gateway or an IPv4 address designated by the gateway, the gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network, multiple IPv6 terminals are connected to the gateway, and IPv6 addresses of all the IPv6 terminals connected to the gateway include the same IPv4 address.
Optionally, the IPv4 address of the gateway may be a compressed IPv4 address. For example, IPv4 addresses which can be assigned by a same operator usually have a same prefix, the foregoing same prefix may be omitted in the IPv4 address that is included in the IPv6 address and is of the gateway or designated by the gateway, that is, the IPv6 address includes a compressed IPv4 address. Because the compressed IPv4 address is always in one-to-one correspondence with an IPv4 address of a gateway in an operator network, the compressed IPv4 address may be used as the IPv4 address of the gateway.
Optionally, to identify that the IPv6 address includes an IPv4 address, a specific field in the IPv6 address may be set to a specific value and then indicate that the IPv6 address includes an IPv4 address, that is, the IPv6 address further includes a specific field value used to indicate that the IPv6 address includes an IPv4 address.
The IPv4 address may be included in the first 64 bits of the IPv6 address, that is, a prefix (prefix) part of the IPv6 address. The IPv4 address may also be included in the last 64 bits of the IPv6 address, that is, a link address part of the IPv6 address.
Step 12: The IPv6 terminal sends an IPv6 packet to the gateway, where the IPv6 packet includes the IPv6 address as a source address.
In this embodiment, the IPv6 address includes the IPv4 address, so the IPv6 packet can be encapsulated in the IPv4 packet when traversing an IPv4 network, to implement traversal of the IPv6 packet through the IPv4 network; and multiple IPv6 terminals correspond to one IPv4 address, which can save IPv4 address resources.
Step 21: A first gateway receives an IPv6 packet sent by an IPv6 terminal, where the IPv6 packet includes a destination IPv6 address.
Step 22: If the destination IPv6 address includes an IPv4 address, the first gateway encapsulates the IPv6 packet in an IPv4 packet of which a destination address is the IPv4 address, and sends the IPv4 packet to a second gateway, where the IPv4 address included in the destination IPv6 address is an IPv4 address of the second gateway or an IPv4 address designated by the second gateway, the second gateway is a device connecting an IPv6 network to an IPv4 network, or a device connecting a layer 2 network to an IPv4 network, and IPv6 addresses of all IPv6 terminals connected to the second gateway include the same IPv4 address.
Optionally, if the IPv4 address of the gateway or designated by the gateway may be a compressed IPv4 address, when the first gateway encapsulates the IPv6 packet in the IPv4 packet of which the destination address is the IPv4 address, the first gateway first recovers the compressed IPv4 address, and then encapsulates the IPv6 packet in an IPv4 packet of which a destination address is the recovered IPv4 address. For example, IPv4 addresses which can be assigned by a same operator usually have a same prefix, and the foregoing same prefix may be omitted in the IPv4 address that is included in the IPv6 address and is of the gateway or designated by the gateway. The first gateway adds the omitted part, that is, the foregoing same prefix, before the IPv4 address to obtain the recovered IPv4 address.
Optionally, the first gateway may judge, according to whether the destination IPv6 address includes a related indication, whether an IPv4 address is included, that is, if the destination IPv6 address includes a specific field value which is used to indicate that the destination IPv6 address includes an IPv4 address, the first gateway judges that the destination IPv6 address includes an IPv4 address.
In addition, this embodiment may further include that: if the destination IPv6 address does not include an IPv4 address, the first gateway encapsulates the IPv6 packet in an IPv4 packet, where a destination IPv4 address of the IPv4 packet is an IPv4 address of a specific gateway.
To enable the second gateway to perform decapsulation correctly, this embodiment further includes that: the first gateway sets a protocol type in a header of the IPv4 packet to a specific value to identify that an IPv6 packet is encapsulated in the IPv4 packet.
The IPv4 address may be included in the first 64 bits of the IPv6 address. In addition, the IPv4 address may also be included in the last 64 bits of the IPv6 address.
In this embodiment, by encapsulating the IPv6 packet in the IPv4 packet, traversal of the IPv6 packet through an IPv4 network can be implemented, and an IPv4 address of a gateway corresponding to multiple IPv6 terminals is used as a destination address of an IPv4 packet after encapsulation, which may make the multiple IPv6 terminals correspond to the same IPv4 address, to save IPv4 addresses.
In the embodiment of the present disclosure, to make the IPv6 packet traverse the IPv4 network, the assignment of the IPv6 address needs to be improved, so that the IPv6 address includes an IPv4 address, and the IPv4 address corresponds to multiple IPv6 terminals. For example, an IPv6 address shown in
a is a schematic diagram of a format of an IPv6 address according to an embodiment of the present disclosure. Referring to
Definitely, it can be understood that, in
For example, the position of the IPv4 address may be at the prefix part of the IPv6 address.
b is a schematic diagram of another format of an IPv6 address according to an embodiment of the present disclosure. The IPv6 address includes: an identification part occupying 3 bits (which is specifically 001), a prefix part occupying 61 bits, and a link address (link address) part occupying 64 bits. In the embodiment of the present disclosure, the prefix part includes an address prefix assigned by an operator, a compressed IPv4 address, and a subnet ID.
An improved solution for the IPv6 address has been described above, and a procedure that an IPv6 packet traverses an IPv4 network will be described in the following.
Step 41: The first terminal sends an IPv6 packet to the first gateway.
If what is between the first terminal and the first gateway is an IPv6 network, the first terminal may send the IPv6 packet to the first gateway; if what is between the first terminal and the first gateway is a layer 2 network, because the layer 2 network doesn't care an upper layer protocol, the first terminal may send the IPv6 packet to the first gateway as well.
In
In the embodiment of the present disclosure, an example where the IPv4 address is the IPv4 address of the gateway is used.
Step 42: The first gateway encapsulates the IPv6 packet in an IPv4 packet, where a destination address of the IPv4 packet is the IPv4 address included in the IPv6 address.
Because what is between the first gateway and the second gateway is an IPv4 network, and the IPv6 packet cannot be transmitted directly, the IPv6 packet needs to be encapsulated, and the IPv6 packet may be encapsulated as a payload in the IPv4 packet. In addition, the IPv4 packet has a source IPv4 address being an IPv4 address of the first gateway, and the destination IPv4 address being the IPv4 address included in the IPv6 packet.
In addition, a value of a protocol type in a header of the IPv4 packet may be set to a specific value, where the specific value indicates that an IPv6 packet is encapsulated in the IPv4 packet.
Step 43: The first gateway sends the IPv4 packet to the second gateway.
Step 44: The second gateway decapsulates the IPv4 packet to obtain the IPv6 packet.
After determining, according to the protocol type in the header of the IPv4 packet, that an IPv6 packet is encapsulated in the IPv4 packet, the second gateway decapsulates the IPv4 packet to obtain the IPv6 packet.
In some cases, for example that the gateway uses, by default, an encapsulation manner in the embodiment of the present disclosure, the second gateway may also directly determine that an IPv6 packet is encapsulated in the IPv4 packet, and decapsulate the IPv4 packet to obtain the IPv6 packet.
Step 45: The second gateway sends the second terminal the IPv6 packet obtained through decapsulation.
In this embodiment, the example where the first terminal sends the IPv6 packet to the second terminal is used. A similar process may be used when the second terminal sends an IPv6 packet to the first terminal, and the only difference is that the first terminal and the second terminal need to interchange their roles, and the first gateway and the second gateway need to interchange their roles. For example, when an IPv6 packet sent by the second terminal is sent to the second gateway, the second gateway encapsulates the IPv6 packet in an IPv4 packet, where the IPv4 packet has a destination IPv4 address being the IPv4 address of the first gateway. Further, the second gateway sets a protocol type value of the IPv4 packet to a specific value, so that the first gateway parses the received IPv4 packet to obtain the IPv6 packet.
In this embodiment, by using an IPv4 address of a gateway as a destination IPv4 address of an IPv4 packet for encapsulating an IPv6 packet, the consumption of IPv4 addresses may not be increased, thereby saving IPv4 addresses. By setting that terminals under a same gateway correspond to a same IPv4 address, only a pair of IPv4 routing paths in the IPv4 network may be needed when the multiple terminals are used as destination ends, thereby reducing routing overheads. By using an IPv4 address, included in an IPv6 address, as a destination address during IPv4 packet encapsulation, the establishment and maintenance of a tunnel may be avoided.
In the third embodiment, an example of communication between peers is used, that is, IPv6 addresses of both the first terminal and the second terminal are in the format shown in
The following describes a procedure that an IPv6 packet traverses an IPv4 network, when an IPv4 address is a compressed IPv4 address.
The first terminal sends an IPv6 packet to the first gateway.
If what is between the first terminal and the first gateway is an IPv6 network, the first terminal may send the IPv6 packet to the first gateway; if a layer 2 network is provided between the first terminal and the first gateway, because the layer 2 network doesn't care an upper layer protocol, the first terminal may also send the IPv6 packet to the first gateway as well.
In actual implementation, the second gateway may be connected to multiple second terminals, where IPv6 addresses of all the multiple terminals include an IPv4 address of the second gateway, and the IPv4 address of the second gateway is a compressed IPv4 address. When the second gateway is connected to multiple second terminals and the first terminal needs to send an IPv6 packet to any one of the multiple second terminals, a destination IPv6 address of the IPv6 packet includes the IPv4 address of the second gateway, where with a same part of a same operator network being omitted, the IPv4 address is a compressed IPv4 address.
The first gateway encapsulates the IPv6 packet in an IPv4 packet, where a destination address of the IPv4 packet is the IPv4 address included in the IPv6 address.
Because what is between the first gateway and the second gateway is an IPv4 network, and the IPv6 packet cannot be transmitted directly, the IPv6 packet needs to be encapsulated, and the IPv6 packet may be encapsulated as a payload in the IPv4 packet. In addition, the IPv4 packet has a source IPv4 address being an IPv4 address of the first gateway, and the destination IPv4 address being the IPv4 address included in the IPv6 packet. Because the IPv4 address included in the IPv6 packet is a compressed IPv4 address, the first gateway first recovers the compressed IPv4 address, that is, adds the omitted part to the IPv4 address, to obtain the recovered IPv4 address, where the destination IPv4 address of the IPv4 packet is the recovered IPv4 address.
In addition, a value of a protocol type in a header of the IPv4 packet may be set to a specific value, where the specific value indicates that an IPv6 packet is encapsulated in the IPv4 packet.
Step 43: The first gateway sends the IPv4 packet to the second gateway.
Step 44: The second gateway decapsulates the IPv4 packet to obtain the IPv6 packet.
The second gateway may determine, according to the protocol type in the header of the IPv4 packet, that an IPv6 packet is encapsulated in the IPv4 packet, and decapsulate the IPv4 packet to obtain the IPv6 packet.
In some cases, for example that the gateway uses, by default, an encapsulation manner in the embodiment of the present disclosure, the second gateway may also directly determine that an IPv6 packet is encapsulated in the IPv4 packet, and decapsulate the IPv4 packet to obtain the IPv6 packet.
Step 45: The second gateway sends the second terminal the IPv6 packet obtained through decapsulation.
In this embodiment, the example where the first terminal sends the IPv6 packet to the second terminal is used. A similar process may be used when the second terminal sends an IPv6 packet to the first terminal, and the only difference is that the first terminal and the second terminal need to interchange their roles, and the first gateway and the second gateway need to interchange their roles. For example, when an IPv6 packet sent by the second terminal is sent to the second gateway, the second gateway encapsulates the IPv6 packet in an IPv4 packet, where the IPv4 packet has a destination IPv4 address being the IPv4 address of the first gateway. Further, the second gateway may set a protocol type value of the IPv4 packet to a specific value, so that the first gateway parses the received IPv4 packet to obtain the IPv6 packet.
In this embodiment, by using an IPv4 address of a gateway as a destination IPv4 address of an IPv4 packet for encapsulating an IPv6 packet, the consumption of IPv4 addresses may not be increased, thereby saving IPv4 addresses. By setting that terminals under a same gateway correspond to a same IPv4 address, only a pair of IPv4 routing paths in the IPv4 network may be needed when the multiple terminals are used as destination ends, thereby reducing routing overheads. By using an IPv4 address, included in an IPv6 address, as a destination address during IPv4 packet encapsulation, the establishment and maintenance of a tunnel may be avoided.
Step 61: The first terminal sends an IPv6 packet to the first gateway.
For details, reference may be made to step 41.
Step 62: The first gateway encapsulates the IPv6 packet in an IPv4 packet, where a destination address of the IPv4 packet is an IPv4 address of the third gateway.
In a certain network, a specific gateway may be set, and the specific gateway may be a gateway between the network and another network. For example, referring to
Therefore, when the first gateway receives an IPv6 packet, and obtains that an IPv6 address in the IPv6 packet is not in the format shown in
In addition, a value of a protocol type in a header of the IPv4 packet may be set to a specific value, where the specific value indicates that an IPv6 packet is encapsulated in the IPv4 packet.
Step 63: The first gateway sends the IPv4 packet to the third gateway.
Step 64: The third gateway decapsulates the IPv4 packet to obtain the IPv6 packet.
After determining, according to the protocol type in the header of the IPv4 packet, that an IPv6 packet is encapsulated in the IPv4 packet, the third gateway decapsulates the IPv4 packet to obtain the IPv6 packet.
Step 65: The third gateway sends the third terminal the IPv6 packet obtained through decapsulation.
In this embodiment, the example where the first terminal sends the IPv6 packet to the third terminal is used. A similar process may be used when the third terminal sends an IPv6 packet to the first terminal, and the only difference is that the first terminal and the third terminal need to interchange their roles, and the first gateway and the third gateway need to interchange their roles. For example, when an IPv6 packet sent by the third terminal is sent to the third gateway, the third gateway encapsulates the IPv6 packet in an IPv4 packet, where the IPv4 packet has a destination IPv4 address being the IPv4 address of the first gateway, and a source IPv4 address being the IPv4 address of the third gateway. Further, the third gateway sets a protocol type value of the IPv4 packet to a specific value, so that the first gateway parses the received IPv4 packet to obtain the IPv6 packet.
In this embodiment, by using an IPv4 address of a gateway as a destination IPv4 address, the consumption of IPv4 addresses may not be increased, thereby saving IPv4 addresses. By setting that terminals under a same gateway correspond to a same IPv4 address, only a pair of IPv4 routing paths in the IPv4 network may be needed when the multiple terminals are used as destination ends, thereby reducing routing overheads. By using an IPv4 address, included in an IPv6 address, as a destination address during IPv4 packet encapsulation, the establishment and maintenance of a tunnel may be avoided.
The IPv4 address of the gateway may be a compressed IPv4 address.
The IPv6 address obtained by the obtaining module 81 further includes a specific field value used to indicate that the IPv6 address includes an IPv4 address.
The IPv4 address that is included in the IPv6 address obtained by the obtaining module 81 may be in the first 64 bits of the IPv6 address. The IPv4 address that is included in the IPv6 address obtained by the obtaining module 81 may also be in the last 64 bits of the IPv6 address.
In this embodiment, because the IPv6 address includes the IPv4 address, the IPv6 packet may be encapsulated in the IPv4 packet when traversing an IPv4 network, so as to implement traversal of the IPv6 packet through the IPv4 network; and because multiple IPv6 terminals correspond to one IPv4 address, IPv4 address resources can be saved.
Optionally, the first encapsulating module may be configured to, if the destination IPv6 address includes an IPv4 address and the IPv4 address in the IPv6 packet received by the receiving module is a compressed IPv4 address, recover the compressed IPv4 address, and encapsulate the IPv6 packet in an IPv4 packet of which a destination address is the recovered IPv4 address.
Optionally, this embodiment may further include a determining module 93, where the determining module 93 is configured to, according to a specific field value that is included in the destination IPv6 address and used to indicate that the destination IPv6 address includes an IPv4 address, determine that the destination IPv6 address includes an IPv4 address.
In addition, this embodiment may further include and a second encapsulating module 94, where the second encapsulating module 94 is configured to, if the destination IPv6 address does not include an IPv4 address, encapsulate the IPv6 packet in an IPv4 packet, where a destination IPv4 address of the IPv4 packet is an IPv4 address of a specific gateway.
The first encapsulating module 92 may be further configured to set a protocol type in a header of the IPv4 packet to a specific value, to identify that an IPv6 packet is encapsulated in the IPv4 packet.
In this embodiment, by encapsulating the IPv6 packet in the IPv4 packet, traversal of the IPv6 packet through an IPv4 network can be implemented, and an IPv4 address of a gateway corresponding to multiple IPv6 terminals is used as a destination address of the IPv4 packet after encapsulation, which may make the multiple IPv6 terminals correspond to the same IPv4 address, to save IPv4 addresses.
It can be understood that, for related features in the foregoing methods and devices, reference may be made to each other. In addition, “first” and “second” in the foregoing embodiments are used to differentiate the embodiments, but do not imply the preference among the embodiments.
Persons of ordinary skill in the art can understand that all or part of the steps in the foregoing method embodiments may be implemented by a program instructing relevant hardware such as a hardware processor. The program may be stored in a computer readable storage medium accessible to the hardware processor. When the program runs, the steps of the foregoing method embodiments are executed. The storage medium may include various media capable of storing program codes, such as a ROM, a RAM, a magnetic disk, or a CD-ROM.
Finally, it should be noted that the foregoing embodiments are merely provided for illustrating the solutions of the present disclosure, but not intended to limit the present disclosure. Although the present disclosure are illustrated in detail with reference to the embodiments, persons of ordinary skill in the art should understand that, they still can make modifications to the solution recorded in each of the embodiments, or equivalent replacements to some features in the solution; and such modifications or replacements do not cause the essence of corresponding solutions to depart from the spirit and scope of the solutions in each of the embodiments of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201010508123.8 | Oct 2010 | CN | national |
201010547912.2 | Nov 2010 | CN | national |
This application is a continuation of International Application No. PCT/CN2011/074823, filed on May 28, 2011, which claims priority to Chinese Patent Application No. CN 201010508123.8, filed with the Chinese Patent Office on Oct. 9, 2010, and Chinese Patent Application No. CN 201010547912.2, filed with the Chinese Patent Office on Nov. 17, 2010, all of which are incorporated herein by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2011/074823 | May 2011 | US |
Child | 13708716 | US |