CN102843439B - Equipment communication method and device - Google Patents
Equipment communication method and device Download PDFInfo
- Publication number
- CN102843439B CN102843439B CN201110171450.3A CN201110171450A CN102843439B CN 102843439 B CN102843439 B CN 102843439B CN 201110171450 A CN201110171450 A CN 201110171450A CN 102843439 B CN102843439 B CN 102843439B
- Authority
- CN
- China
- Prior art keywords
- address
- ipv6
- hnd
- pnd6
- hgw
- 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.)
- Expired - Fee Related
Links
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明公开了设备通信方法及装置,一种设备通信方法包括:HND通过HGW与公网上的IPv6设备PND6进行通信时,HGW接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;HGW接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。采用本发明能够实现HND与PND6通信的同时提高通信的安全性。
The invention discloses a device communication method and device. A device communication method includes: when the HND communicates with the IPv6 device PND6 on the public network through the HGW, the HGW receives the uplink message sent by the HND, and converts the uplink message according to the configured mapping entry Translate it into an uplink message that PND6 can recognize, and forward it to PND6, where the configured mapping entry includes at least one IP address and port mapping relationship involved in the version of the Internet Protocol; HGW receives the downlink message sent by PND6, and according to the configured mapping The entry translates downlink packets into downlink packets that can be recognized by the HND and forwards them to the HND. Adopting the present invention can realize the communication between the HND and the PND6 while improving the security of the communication.
Description
技术领域technical field
本发明涉及通信领域,具体而言,涉及一种设备通信方法及装置。The present invention relates to the communication field, in particular, to a device communication method and device.
背景技术Background technique
在传统的纯因特网协议版本IPv4的网络环境下,家庭网络内部设备(HomeNetwork Device,HND),如个人计算机PC,一般使用私有因特网协议版本4(IPv4)地址,如“192.168.1.6”,而家庭网关(Home Gateway,HGW)可以获取公有IPv4地址;这种情况下,可以通过在家庭网关上建立PC的私网地址及端口与HGW的公网地址及端口的映射关系来完成PC与公网上的其它设备的通信。在这个过程中,由于PC所使用的地址及端口对外完全是不可见,在一定程度与提高了其安全性。In the traditional pure Internet protocol version IPv4 network environment, home network internal devices (HomeNetwork Device, HND), such as personal computers PC, generally use private Internet protocol version 4 (IPv4) addresses, such as "192.168.1.6", while the home The gateway (Home Gateway, HGW) can obtain a public IPv4 address; in this case, the mapping relationship between the PC’s private network address and port and the HGW’s public network address and port can be established on the home gateway to complete the connection between the PC and the public network. Communication with other devices. In this process, since the address and port used by the PC are completely invisible to the outside world, its security is improved to a certain extent.
这种地址及端口映射可以通过“通用即插即用”UPnP协议来自动灵活配置。在UPnP因特网网关设备(UPnP IGD)相关规范中,对这一过程有明确的描述和规定。随着IPv4网络规模的日益扩大,IPv4地址枯竭问题已经开始显现;IPv6网络技术开始逐渐取代IPv4,但由于IPv4已有的网络规模巨大,IPv4应用程序繁多,IPv6与IPv4两种网络共存将是一个长期的过程。This address and port mapping can be automatically and flexibly configured through the "Universal Plug and Play" UPnP protocol. This process is clearly described and regulated in the UPnP Internet Gateway Device (UPnP IGD) related specification. With the increasing scale of the IPv4 network, the problem of IPv4 address exhaustion has begun to appear; IPv6 network technology has gradually replaced IPv4, but due to the huge scale of the existing IPv4 network and the variety of IPv4 applications, the coexistence of IPv6 and IPv4 networks will be a challenge. long process.
在骨干网络是IPv6网络时,支持IPv4/IPv6双协议栈技术(以下简称双栈技术)的HGW具备IPv6全球唯一地址(GUA),而HND可以只具备IPv4私网地址或只具备GUA或两者兼备。因此,在HND通过HGW与公网上的IPv6设备(Public Network Device V6,,PND6)时,至少产生两种情形:When the backbone network is an IPv6 network, the HGW that supports IPv4/IPv6 dual protocol stack technology (hereinafter referred to as dual stack technology) has an IPv6 globally unique address (GUA), while the HND can only have IPv4 private network addresses or only have GUA or both both. Therefore, when the HND passes through the HGW and the IPv6 device (Public Network Device V6, PND6) on the public network, at least two situations occur:
1)HND使用GUA与PND6进行通信;1) HND uses GUA to communicate with PND6;
2)HND使用IPv4私网地址与PND6进行通信。2) HND uses IPv4 private network address to communicate with PND6.
情形1)不需要进行网络地址转换翻译就可以直接通信,而情形2)至少需要借助于HGW内部的IPv4到IPv6地址及协议转换翻译功能来进行。Situation 1) can directly communicate without performing network address translation and translation, while situation 2) at least requires the help of IPv4 to IPv6 address and protocol translation and translation functions inside the HGW.
以上情形虽可以完成端到端的通信,但相关技术中并没有类似于纯于IPv4网络环境下灵活的地址及端口映射的配置机制和基于这些配置进行实际转换翻译功能,HND与PND6的通信及其安全性将受到较大影响。Although the above situation can complete the end-to-end communication, there is no configuration mechanism similar to the flexible address and port mapping in the pure IPv4 network environment and the actual conversion and translation function based on these configurations in the related technology, the communication between HND and PND6 and its Security will be greatly affected.
针对相关技术中在IPv6网络或IPv6与IPv4两种网络共存时缺少灵活的地址及端口映射的配置机制和实际转换翻译功能,导致HND与PND6的通信及其安全性将受到较大影响的问题,目前尚未提出有效的解决方案。In view of the lack of flexible address and port mapping configuration mechanism and actual conversion translation function in the related technology when IPv6 network or IPv6 and IPv4 networks coexist, the communication between HND and PND6 and its security will be greatly affected. No effective solution has been proposed so far.
发明内容Contents of the invention
本发明的主要目的在于提供一种设备通信方法及装置,以至少解决上述相关技术中在IPv6网络或IPv6与IPv4两种网络共存时缺少灵活的地址及端口映射的配置机制和实际转换翻译功能,导致HND与PND6的通信及其安全性将受到较大影响的问题。The main purpose of the present invention is to provide a device communication method and device to at least solve the lack of a flexible address and port mapping configuration mechanism and actual conversion translation function when the IPv6 network or IPv6 and IPv4 networks coexist in the above-mentioned related technologies, The communication between HND and PND6 and its security will be greatly affected.
根据本发明的一个方面,提供了一种设备通信方法,包括:家庭网络内部设备HND通过家庭网关HGW与公网上的因特网协议版本IPv6设备PND6进行通信时,所述方法包括:所述HGW接收所述HND发送的上行报文,根据配置的映射条目将所述上行报文转换翻译为所述PND6能够识别的上行报文,并转发至所述PND6,其中,所述配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;所述HGW接收所述PND6发送的下行报文,根据所述配置的映射条目将所述下行报文转换翻译为所述HND能够识别的下行报文,并转发至所述HND。According to one aspect of the present invention, a device communication method is provided, including: when the device HND in the home network communicates with the Internet Protocol version IPv6 device PND6 on the public network through the home gateway HGW, the method includes: the HGW receiving the The uplink message sent by the HND is converted and translated into an uplink message that the PND6 can recognize according to the configured mapping entry, and forwarded to the PND6, wherein the configured mapping entry includes at least one The address and port mapping relationship involved in the version of the Internet Protocol; the HGW receives the downlink message sent by the PND6, and converts the downlink message into a downlink message that the HND can recognize according to the configured mapping entry text and forward it to the HND.
优选的,所述HGW能够使用IPv6地址或者同时使用IPv6和IPv4两类地址与所述HND及所述PND6进行通信。Preferably, the HGW can communicate with the HND and the PND6 using an IPv6 address or both IPv6 and IPv4 addresses.
优选的,所述映射关系包括下列至少之一:IPv6和IPv4之间的地址及端口映射关系;IPv6和IPv6之间的地址及端口映射关系。Preferably, the mapping relationship includes at least one of the following: an address and port mapping relationship between IPv6 and IPv4; an address and port mapping relationship between IPv6 and IPv6.
优选的,所述方法还包括:所述HND根据自身与所述PND6通信所需的地址及端口对所述配置的映射条目进行添加或删除操作。Preferably, the method further includes: the HND adds or deletes the configured mapping entries according to the address and port required for the HND to communicate with the PND6.
优选的,所述HND根据自身与所述PND6通信所需的地址及端口对所述配置的映射条目进行添加或删除操作,包括:所述HND通过查询接口获取已经配置的映射条目;所述HND根据自身与所述PND6通信所需的地址及端口确定通信需要的映射条目;所述HND比较所述需要的映射条目以及所述已经配置的映射条目,根据比较结果进行映射条目的添加或删除操作。Preferably, the HND adds or deletes the configured mapping entries according to the address and port required for communication between itself and the PND6, including: the HND obtains the configured mapping entries through a query interface; the HND Determine the mapping entry required for communication according to the address and port required for communication between itself and the PND6; the HND compares the required mapping entry and the configured mapping entry, and performs an addition or deletion operation of the mapping entry according to the comparison result .
优选的,所述配置的映射条目包括IPv6和IPv6之间地址及端口映射关系时,所述配置的映射条目包括下列至少之一:内部IPv6全球唯一地址GUA,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述;所述配置的映射条目包括IPv6和IPv4之间地址及端口映射关系时,所述配置的映射条目包括下列至少之一:内部IPv4地址,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述。Preferably, when the configured mapping entry includes the address and port mapping relationship between IPv6 and IPv6, the configured mapping entry includes at least one of the following: internal IPv6 globally unique address GUA, internal port, external GUA, external port, Protocol, remote host identifier, enable flag, mapping duration, mapping entry description; when the configured mapping entry includes the address and port mapping relationship between IPv6 and IPv4, the configured mapping entry includes at least one of the following: internal IPv4 address, internal port, external GUA, external port, protocol, remote host ID, enable flag, mapping duration, mapping entry description.
优选的,所述外部GUA包括:所述HGW上外部网络接口正在使用的GUA;或者,所述HGW所获取的IPv6前缀范围内的其他GUA。Preferably, the external GUA includes: the GUA being used by the external network interface on the HGW; or, other GUAs within the IPv6 prefix range acquired by the HGW.
优选的,所述远程主机标识包括:域名字符串;或者,有效的GUA地址;或者空字符串。Preferably, the remote host identifier includes: a domain name string; or, a valid GUA address; or an empty string.
优选的,所述远程主机标识为域名字符串时,所述HGW通过域名服务器DNS将所述域名字符串解析为GUA;所述远程主机标识不为所述空字符串时,所述HGW仅能够对指定的主机与所述HND进行通信。Preferably, when the remote host identifier is a domain name string, the HGW resolves the domain name string to GUA through the domain name server DNS; when the remote host identifier is not the empty string, the HGW can only The designated host communicates with the HND.
优选的,所述映射持续时间用以标明所述配置的映射条目的有效时间,当所述配置的映射条目超过所述映射持续时间时,所述配置的映射条目被删除。Preferably, the mapping duration is used to indicate the valid time of the configured mapping entry, and when the configured mapping entry exceeds the mapping duration, the configured mapping entry is deleted.
优选的,所述HGW使用IPv6地址与所述HND及所述PND6进行通信,包括:所述上行报文为上行IPv6报文时,若所述上行IPv6报文的源地址、源端口号及协议字段与所述配置的映射条目的源地址、源端口号及协议字段相匹配,所述HGW按照所述配置的映射条目进行源地址和源端口的转换,将转换翻译后的上行报文转发至所述PND6;所述下行报文为下行IPv6报文时,若所述下行IPv6报文的目的地址、目的端口号及协议字段与所述配置的映射条目的目的地址、目的端口号及协议字段相匹配,并且能够满足所述远程主机标识字段的限制要求,所述HGW按照所述配置的映射条目进行目的地址和目的端口的转换,将转换翻译后的下行报文转发至所述HND。Preferably, the HGW uses an IPv6 address to communicate with the HND and the PND6, including: when the uplink message is an uplink IPv6 message, if the source address, source port number and protocol of the uplink IPv6 message field matches the source address, source port number, and protocol field of the configured mapping entry, and the HGW converts the source address and source port according to the configured mapping entry, and forwards the translated uplink packet to The PND6; when the downlink message is a downlink IPv6 message, if the destination address, destination port number and protocol field of the downlink IPv6 message are the same as the destination address, destination port number and protocol field of the configured mapping entry match, and can meet the restriction requirements of the remote host identification field, the HGW converts the destination address and destination port according to the configured mapping entry, and forwards the translated downlink message to the HND.
优选的,所述HGW同时使用IPv6和IPv4两类地址与所述HND及所述PND6进行通信,包括:所述上行报文为上行IPv4报文时,若所述上行IPv4报文的源地址、目的地址、源端口号与所述配置的映射条目的源地址、目的地址、源端口号相匹配,所述HGW按照所述配置的映射条目将所述上行IPv4报文的源地址、目的地址、源端口号转换为对应的上行IPv6报文的源地址、目的地址、源端口号,将所述上行IPv4报文转换翻译为上行IPv6报文,将转换翻译后的上行报文转发至所述PND6;所述下行报文为下行IPv6报文时,若所述下行IPv6报文的目的地址、目的端口号及协议字段与所述配置的映射条目的目的地址、目的端口号及协议字段相匹配,并且能够满足所述远程主机标识字段的限制要求,所述HGW按照所述配置的映射条目将所述目的地址转换为指定的IPv4地址,所述目的端口转换为指定端口,所述源地址映射为预设范围的IPv4地址,将所述下行IPv6报文转换翻译为下行IPv4报文,将转换翻译后的下行报文转发至所述HND。Preferably, the HGW uses both IPv6 and IPv4 addresses to communicate with the HND and the PND6, including: when the uplink message is an uplink IPv4 message, if the source address of the uplink IPv4 message, The destination address and source port number match the source address, destination address, and source port number of the configured mapping entry, and the HGW converts the source address, destination address, and The source port number is converted into the source address, destination address, and source port number of the corresponding uplink IPv6 message, the uplink IPv4 message is converted and translated into an uplink IPv6 message, and the translated uplink message is forwarded to the PND6 ; When the downlink message is a downlink IPv6 message, if the destination address, destination port number and protocol field of the downlink IPv6 message match the destination address, destination port number and protocol field of the configured mapping entry, And can meet the restriction requirements of the remote host identification field, the HGW converts the destination address into a specified IPv4 address according to the configured mapping entry, converts the destination port into a specified port, and maps the source address to IPv4 addresses in a preset range, convert and translate the downlink IPv6 message into a downlink IPv4 message, and forward the converted and translated downlink message to the HND.
优选的,所述方法还包括:通过扩展通用即插即用因特网网关设备UPnP-IGD规范来配置所述映射条目。Preferably, the method further includes: configuring the mapping entry by extending the UPnP-IGD specification.
根据本发明的另一方面,提供了一种设备通信装置,设置于家庭网关HGW中,包括:第一处理模块,用于家庭网络内部设备HND通过所述HGW与公网上的IPv6设备PND6进行通信时,接收所述HND发送的上行报文,根据配置的映射条目将所述上行报文转换翻译为所述PND6能够识别的上行报文,并转发至所述PND6,其中,所述配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;第二处理模块,用于接收所述PND6发送的下行报文,根据所述配置的映射条目将所述下行报文转换翻译为所述HND能够识别的下行报文,并转发至所述HND。According to another aspect of the present invention, a device communication device is provided, which is set in the home gateway HGW, and includes: a first processing module, used for the home network internal device HND to communicate with the IPv6 device PND6 on the public network through the HGW , receive the uplink message sent by the HND, convert and translate the uplink message into an uplink message recognizable by the PND6 according to the configured mapping entry, and forward it to the PND6, wherein the configured mapping The entry includes at least one address and port mapping relationship involved in the Internet Protocol version; the second processing module is used to receive the downlink message sent by the PND6, and convert and translate the downlink message according to the configured mapping entry into The downlink message that the HND can identify is forwarded to the HND.
在本发明实施例中,当家庭网络内部设备HND通过家庭网关HGW与公网上的IPv6设备PND6进行通信时,HGW接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;HGW接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。即,在本发明实施例中,HND与PND6进行通信时,HGW对不同类型的报文进行转换翻译,将其转换翻译为目的设备能够识别的报文,从而实现HND与指定的PND6进行通信,并可以灵活地屏蔽HND与PND6进行通信时的所用的地址和端口信息,从而极大地提高了通信的安全性。In the embodiment of the present invention, when the internal device HND of the home network communicates with the IPv6 device PND6 on the public network through the home gateway HGW, the HGW receives the uplink message sent by the HND, and translates the uplink message into PND6 according to the configured mapping entries. The uplink message that can be identified is forwarded to PND6, wherein the configured mapping entry includes at least one IP address and port mapping relationship involved in the version of the Internet protocol; HGW receives the downlink message sent by PND6, and sends the downlink message according to the configured mapping entry The message is converted and translated into a downlink message that can be recognized by the HND, and forwarded to the HND. That is, in the embodiment of the present invention, when the HND communicates with the PND6, the HGW converts and translates different types of messages, and converts and translates them into messages that can be recognized by the destination device, thereby realizing the communication between the HND and the designated PND6. And it can flexibly shield the address and port information used when the HND communicates with the PND6, thereby greatly improving the security of the communication.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings described here are used to provide a further understanding of the present invention and constitute a part of the application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations to the present invention. In the attached picture:
图1是根据本发明实施例的设备通信方法的处理流程图;Fig. 1 is a processing flowchart of a device communication method according to an embodiment of the present invention;
图2是根据本发明实施例的添加/删除IPv6到IPv6地址及端口映射流程;Fig. 2 is the process of adding/deleting IPv6 to IPv6 address and port mapping according to an embodiment of the present invention;
图3是根据本发明实施例的添加/删除IPv4到IPv6地址及端口映射流程;Fig. 3 is the process of adding/deleting IPv4 to IPv6 address and port mapping according to an embodiment of the present invention;
图4是根据本发明实施例的IPv6地址及端口映射流程;Fig. 4 is the IPv6 address and port mapping process according to the embodiment of the present invention;
图5是根据本发明实施例的IPv4与IPv6之间转换翻译流程;Fig. 5 is according to the conversion translation process between IPv4 and IPv6 of the embodiment of the present invention;
图6是根据本发明实施例的设备通信装置的结构示意图。Fig. 6 is a schematic structural diagram of a device communication apparatus according to an embodiment of the present invention.
具体实施方式detailed description
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。Hereinafter, the present invention will be described in detail with reference to the drawings and examples. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
相关技术中提到,目前IPv6与IPv4两种网络共存是一个长期的过程,而在IPv6网络中或IPv6与IPv4两种网络共存时,由于缺少灵活的地址及端口映射的配置机制和实际转换翻译功能,会导致HND与PND6的通信及其安全性将受到较大影响。It is mentioned in related technologies that the coexistence of IPv6 and IPv4 networks is a long-term process at present, and when IPv6 networks or IPv6 and IPv4 networks coexist, due to the lack of flexible address and port mapping configuration mechanisms and actual translation translation function, the communication between HND and PND6 and its security will be greatly affected.
为解决上述技术问题,本发明实施例中提供了一种设备通信方法,当家庭网络内部设备HND通过家庭网关HGW与公网上的IPv6设备PND6进行通信时,设备间的通信的处理流程如图1所示,包括:In order to solve the above technical problems, an embodiment of the present invention provides a device communication method. When the device HND in the home network communicates with the IPv6 device PND6 on the public network through the home gateway HGW, the processing flow of the communication between devices is shown in Figure 1 shown, including:
步骤S102、HGW接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;Step S102, the HGW receives the uplink message sent by the HND, converts and translates the uplink message into an uplink message that can be recognized by PND6 according to the configured mapping entry, and forwards it to PND6, wherein the configured mapping entry includes at least one Internet protocol version The mapping relationship between addresses and ports involved;
步骤S104、HGW接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。Step S104, the HGW receives the downlink message sent by the PND6, converts and translates the downlink message into a downlink message that the HND can recognize according to the configured mapping entries, and forwards the message to the HND.
在本发明实施例中,当家庭网络内部设备HND通过家庭网关HGW与公网上的IPv6设备PND6进行通信时,HGW接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;HGW接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。即,在本发明实施例中,HND与PND6进行通信时,HGW对不同类型的报文进行转换翻译,将其转换翻译为目的设备能够识别的报文,从而实现HND与指定的PND6进行通信,并可以灵活地屏蔽HND与PND6进行通信时的所用的地址和端口信息,从而极大地提高了通信的安全性。In the embodiment of the present invention, when the internal device HND of the home network communicates with the IPv6 device PND6 on the public network through the home gateway HGW, the HGW receives the uplink message sent by the HND, and translates the uplink message into PND6 according to the configured mapping entries. The uplink message that can be identified is forwarded to PND6, wherein the configured mapping entry includes at least one IP address and port mapping relationship involved in the version of the Internet protocol; HGW receives the downlink message sent by PND6, and sends the downlink message according to the configured mapping entry The message is converted and translated into a downlink message that can be recognized by the HND, and forwarded to the HND. That is, in the embodiment of the present invention, when the HND communicates with the PND6, the HGW converts and translates different types of messages, and converts and translates them into messages that can be recognized by the destination device, thereby realizing the communication between the HND and the designated PND6. And it can flexibly shield the address and port information used when the HND communicates with the PND6, thereby greatly improving the security of the communication.
由图1所示流程可知,本发明实施例涉及网络通信技术领域,尤其涉及一种在家庭网络中因特网协议版本6(IPv6)或因特网协议版本4(IPv4)网络设备与外部IPv6网络设备之间通信时进行地址及端口映射的配置方法和根据配置进行实际地址及端口转换翻译的系统。It can be seen from the process shown in Figure 1 that the embodiment of the present invention relates to the field of network communication technology, and in particular relates to a communication between an Internet Protocol version 6 (IPv6) or Internet Protocol version 4 (IPv4) network device and an external IPv6 network device in a home network. A configuration method for address and port mapping during communication and a system for performing actual address and port conversion and translation according to the configuration.
实施时,HGW能够使用IPv6地址或者同时使用IPv6和IPv4两类地址与HND及PND6进行通信,当HGW同时使用IPv6和IPv4两类地址与HND及PND6进行通信时,HGW支持双栈技术。此时,上述提到的映射关系包括下列至少之一:IPv6和IPv4之间的地址及端口映射关系;IPv6和IPv6之间的地址及端口映射关系。当然,在具体实施时,映射关系还可以包括IPv4和IPv4之间的地址及端口映射关系,这与相关技术中描述相同,在此不做赘述。因此,本发明实施例提供的设备通信方法也可以应用于单纯的IPv4网络。During implementation, HGW can use IPv6 address or both IPv6 and IPv4 addresses to communicate with HND and PND6. When HGW uses both IPv6 and IPv4 addresses to communicate with HND and PND6, HGW supports dual-stack technology. At this time, the above-mentioned mapping relationship includes at least one of the following: an address and port mapping relationship between IPv6 and IPv4; an address and port mapping relationship between IPv6 and IPv6. Of course, during specific implementation, the mapping relationship may also include the address and port mapping relationship between IPv4 and IPv4, which is the same as that described in the related technology, and will not be repeated here. Therefore, the device communication method provided by the embodiment of the present invention can also be applied to a pure IPv4 network.
本发明实施例提供的设备通信方法还包括:HND根据自身与PND6通信所需的地址及端口对配置的映射条目进行添加或删除操作,从而实现映射条目的可配置、可更新的功能。映射条目的可更新性,更能够增加通信的安全性。The device communication method provided by the embodiment of the present invention further includes: the HND adds or deletes the configured mapping entries according to the address and port required for communication between itself and the PND6, so as to realize the configurable and updateable functions of the mapping entries. The updateability of the mapping entries can further increase the security of communication.
实施时,HND根据自身与PND6通信所需的地址及端口对配置的映射条目进行添加或删除操作,包括如下流程:During implementation, HND adds or deletes the configured mapping entries according to the address and port required for communication between itself and PND6, including the following process:
步骤一、HND通过查询接口获取已经配置的映射条目;Step 1. The HND obtains the configured mapping entries through the query interface;
步骤二、HND根据自身与PND6通信所需的地址及端口确定通信需要的映射条目;Step 2, HND determines the mapping entry required for communication according to the address and port required for communication between itself and PND6;
步骤三、HND比较需要的映射条目以及已经配置的映射条目,根据比较结果进行映射条目的添加或删除操作。Step 3: The HND compares the required mapping entries with the configured mapping entries, and adds or deletes the mapping entries according to the comparison result.
网络类型不同,涉及的映射条目的类型不同,映射条目包含的内容也不完全相同,例如:配置的映射条目包括IPv6和IPv6之间地址及端口映射关系时,配置的映射条目包括下列至少之一:内部GUA,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述;配置的映射条目包括IPv4和IPv6之间地址及端口映射关系时,配置的映射条目包括下列至少之一:内部IPv4地址,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述。Different network types involve different types of mapping entries, and the contents of the mapping entries are not exactly the same. For example, when the configured mapping entries include the address and port mapping relationship between IPv6 and IPv6, the configured mapping entries include at least one of the following : internal GUA, internal port, external GUA, external port, protocol, remote host ID, enable flag, mapping duration, mapping entry description; when the configured mapping entry includes the address and port mapping relationship between IPv4 and IPv6, the configured The mapping entry includes at least one of the following: internal IPv4 address, internal port, external GUA, external port, protocol, remote host identifier, enabling flag, mapping duration, mapping entry description.
在实际应用中,根据不同的网络以及不同设备之间的通信的特性,映射条目中还可能增加或删除部分内容,具体的修改根据实际情况而定,在此不做赘述。In practical applications, depending on the characteristics of different networks and communication between different devices, some content may be added or deleted in the mapping entry. The specific modification depends on the actual situation and will not be repeated here.
实施时,外部GUA可以包括:HGW上外部网络接口正在使用的GUA;或者,HGW所获取的IPv6前缀范围内的其他GUA。当然,外部GUA还可以选择其他地址,根据具体情况而定。During implementation, the external GUA may include: the GUA being used by the external network interface on the HGW; or other GUAs within the IPv6 prefix range obtained by the HGW. Of course, the external GUA can also choose other addresses, depending on the specific situation.
映射条目中包括的远程主机标识可以有多种情况,优选的,可以包括:域名字符串;或者,有效的GUA地址;或者空字符串。The remote host identifier included in the mapping entry can have many situations, preferably, it can include: a domain name string; or a valid GUA address; or an empty string.
当远程主机标识为域名字符串时,HGW通过域名服务器DNS将域名字符串解析为GUA;When the remote host is identified as a domain name string, HGW resolves the domain name string to GUA through the domain name server DNS;
当远程主机标识不为空字符串时,HGW能够限定仅有指定的PND6主机与才能HND进行通信。When the remote host identifier is not an empty string, the HGW can limit only the designated PND6 host to communicate with the HND.
实施时,映射持续时间用以标明配置的映射条目的有效时间,当配置的映射条目超过映射持续时间时,配置的映射条目被删除。During implementation, the mapping duration is used to indicate the valid time of the configured mapping entry, and when the configured mapping entry exceeds the mapping duration, the configured mapping entry is deleted.
实施时,上文提到,HGW能够使用IPv6地址或者同时使用IPv6和IPv4两类地址与HND及PND6进行通信。因此,存在两种情况:During implementation, as mentioned above, the HGW can communicate with the HND and the PND6 using an IPv6 address or using both IPv6 and IPv4 addresses. Therefore, there are two situations:
第一种情况,HGW使用IPv6地址与HND及PND6进行通信,根据报文类型不同,实施方式也不同,包括:In the first case, HGW uses IPv6 address to communicate with HND and PND6. According to different types of packets, the implementation methods are also different, including:
情况A、上行报文为上行IPv6报文时,若上行IPv6报文的源地址、源端口号及协议字段与配置的映射条目的源地址、源端口号及协议字段相匹配,HGW按照配置的映射条目进行源地址和源端口的转换,将转换翻译后的上行报文转发至PND6;Case A. When the uplink packet is an uplink IPv6 packet, if the source address, source port number, and protocol field of the uplink IPv6 packet match the source address, source port number, and protocol field of the configured mapping entry, the HGW follows the configured The mapping entry converts the source address and source port, and forwards the translated uplink message to PND6;
情况B、下行报文为下行IPv6报文时,若下行IPv6报文的目的地址、目的端口号及协议字段与配置的映射条目的目的地址、目的端口号及协议字段相匹配,并且能够满足远程主机标识字段的限制要求,HGW按照配置的映射条目进行目的地址和目的端口的转换,将转换翻译后的下行报文转发至HND。Case B. When the downlink packet is a downlink IPv6 packet, if the destination address, destination port number, and protocol field of the downlink IPv6 packet match the destination address, destination port number, and protocol field of the configured mapping entry, and the remote The restriction of the host identification field requires that the HGW convert the destination address and destination port according to the configured mapping entries, and forward the translated downlink message to the HND.
第二种情况,HGW同时使用IPv4和IPv6两类地址与HND及PND6进行通信,与第一种情况相类似,在报文类型不同的情况下,实施方式也不完全相同,包括:In the second case, the HGW uses both IPv4 and IPv6 addresses to communicate with the HND and PND6, which is similar to the first case. In the case of different message types, the implementation methods are not completely the same, including:
情况A、上行报文为上行IPv4报文时,若上行IPv4报文的源地址、目的地址、源端口号与配置的映射条目的源地址、目的地址、源端口号相匹配,HGW按照配置的映射条目将上行IPv4报文的源地址、目的地址、源端口号转换为对应的上行IPv6报文的源地址、目的地址、源端口号,将上行IPv4报文转换翻译为上行IPv6报文,将转换翻译后的上行报文转发至PND6;Case A: When the uplink packet is an uplink IPv4 packet, if the source address, destination address, and source port number of the uplink IPv4 packet match the source address, destination address, and source port number of the configured mapping entry, the HGW will follow the configured The mapping entry converts the source address, destination address, and source port number of the uplink IPv4 message into the source address, destination address, and source port number of the corresponding uplink IPv6 message, converts the uplink IPv4 message into an uplink IPv6 message, and converts the uplink IPv4 message into an uplink IPv6 message. Translate the translated uplink message and forward it to PND6;
情况B、下行报文为下行IPv6报文时,若下行IPv6报文的目的地址、目的端口号及协议字段与配置的映射条目的目的地址、目的端口号及协议字段相匹配,并且能够满足远程主机标识字段的限制要求,HGW按照配置的映射条目将目的地址转换为指定的IPv4地址,目的端口转换为指定端口,源地址映射为预设范围的IPv4地址,将下行IPv6报文转换翻译为下行IPv4报文,将转换翻译后的下行报文转发至HND。Case B. When the downlink packet is a downlink IPv6 packet, if the destination address, destination port number, and protocol field of the downlink IPv6 packet match the destination address, destination port number, and protocol field of the configured mapping entry, and the remote According to the restriction of the host identification field, the HGW translates the destination address into a specified IPv4 address according to the configured mapping entries, the destination port into a specified port, the source address into a preset range of IPv4 addresses, and translates downlink IPv6 packets into downlink IPv6 packets. For IPv4 packets, forward the translated downlink packets to the HND.
由上述内容可得,针对相关技术提到的技术问题,本发明实施例提供了一种基于UPnP协议的地址及端口映射方法。核心在于,一方面HND可过其通用即插即用控制点功能(UPnP CP)与HGW中的UPnP IGD功能进行交互实现IPv6地址及端口之间、IPv4与IPv6地址及端口之间的自动灵活配置;另一方面HGW中的地址及协议转换翻译功能可根据配置项进行具体的转换翻译工作;通过这两个方面可以灵活地屏蔽HND与PND6进行通信时的所用的地址和端口信息,同时还可以实现HND仅与指定的PND6进行通信,从而极大地提高了HND的安全性。It can be obtained from the above content that, aiming at the technical problems mentioned in the related art, the embodiment of the present invention provides an address and port mapping method based on the UPnP protocol. The core is that, on the one hand, HND can interact with the UPnP IGD function in HGW through its Universal Plug and Play Control Point function (UPnP CP) to realize automatic and flexible configuration between IPv6 addresses and ports, and between IPv4 and IPv6 addresses and ports ; On the other hand, the address and protocol conversion and translation function in HGW can perform specific conversion and translation work according to configuration items; through these two aspects, the address and port information used when HND and PND6 communicate can be flexibly shielded, and at the same time, it can be Realize that HND only communicates with designated PND6, thus greatly improving the security of HND.
实施例一Embodiment one
本例中涉及地址及端口映射自动配置及管理方法。其中,在连接IPv4与IPv6两种不同的网络时,HGW支持双栈技术,其中的UPnP IGD功能可以同时使用IPv4地址和IPv6两类地址与HND上的UPnP CP进行通信,以应对HND仅支持IPv4或仅支持IPv6的情况。This example involves address and port mapping automatic configuration and management methods. Among them, when connecting two different networks of IPv4 and IPv6, HGW supports dual-stack technology, and the UPnP IGD function can use both IPv4 addresses and IPv6 addresses to communicate with the UPnP CP on the HND, in case the HND only supports IPv4 Or the case where only IPv6 is supported.
HGW在获取到一个GUA地址或一个前缀并自动配置了GUA地址后就可以通过UPnPIGD功能宣告其自身的可用性。HND上的UPnP CP功能则可以根据UPnP协议自动发现HGW中的UPnP IGD功能。随后,UPnP CP可以通过与UPnP IGD进一步交互得知HGW上具备在IPv6地址及端口之间或IPv4与IPv6地址及端口之间进行映射的功能。在通过UPnP IGD提供的服务接口获取可用的外部GUA地址后,HND可再进一步再通过相关服务接口进行关于其自身与PND6通信所需的地址及端口映射条目的添加或删除操作。最后,UPnP IGD功能会将是否配置成功的结果返回给UPnP CP。在此过程中,UPnP CP还可以通过查询接口获取已经配置了哪些映射条目,以进行有针对性的添加或删除操作。整个配置过程无需人工干预,全部由软件自动完成。After obtaining a GUA address or a prefix and automatically configuring the GUA address, the HGW can declare its own availability through the UPnPIGD function. The UPnP CP function on the HND can automatically discover the UPnP IGD function in the HGW according to the UPnP protocol. Subsequently, the UPnP CP can further interact with the UPnP IGD to learn that the HGW has the function of mapping between IPv6 addresses and ports or between IPv4 and IPv6 addresses and ports. After obtaining the available external GUA address through the service interface provided by UPnP IGD, the HND can further add or delete the address and port mapping entries required for communication between itself and the PND6 through the relevant service interface. Finally, the UPnP IGD function will return the result of whether the configuration is successful to the UPnP CP. During this process, the UPnP CP can also obtain which mapping entries have been configured through the query interface, so as to perform targeted addition or deletion operations. The entire configuration process does not require manual intervention, and is automatically completed by the software.
对于IPv6之间地址及端口映射条目其组成部分包括:内部GUA,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述。对于IPv4到IPv6之间地址及端口映射条目其组成部分包括:内部IPv4地址,内部端口,外部GUA,外部端口,协议,远程主机标识,使能标记,映射持续时间,映射条目描述。外部GUA可以HGW上外部网络接口正在使用的GUA也可以是HGW所获取的IPv6前缀范围内的其它GUA。具体分配置时可以随机生成以提高安全性。远程主机标识可以是一个域名字符串或一个有效的GUA地址也可以为空字符串,如果是域名则由HGW通DNS将其解析为GUA即可。协议可以是TCP或UDP。如果远程主机标识是不为空则只允许指定的主机与家庭网络内部设备进行通信,否则不做限制。映射持续时间,用以标明映射条目有效时间,对于超过有效时间的映射条目将会被UPnP IGD自动删除。UPnP CP可以在映射条目过期之前重新添加。映射条目描述用以附加一些描述信息,可以为空字符串。The components of the address and port mapping entry between IPv6 include: internal GUA, internal port, external GUA, external port, protocol, remote host identifier, enabling flag, mapping duration, and mapping entry description. The components of the address and port mapping entry between IPv4 and IPv6 include: internal IPv4 address, internal port, external GUA, external port, protocol, remote host identifier, enabling flag, mapping duration, and mapping entry description. The external GUA may be the GUA being used by the external network interface on the HGW or other GUAs within the IPv6 prefix range obtained by the HGW. The specific configuration can be randomly generated to improve security. The remote host identifier can be a domain name string or a valid GUA address, and it can also be an empty string. If it is a domain name, it can be resolved to GUA by HGW through DNS. Protocol can be TCP or UDP. If the remote host ID is not empty, only the specified host is allowed to communicate with the internal devices of the home network, otherwise there is no restriction. The mapping duration is used to indicate the valid time of the mapping entry, and the mapping entry exceeding the valid time will be automatically deleted by the UPnP IGD. A UPnP CP can be re-added before the map entry expires. The mapping entry description is used to add some descriptive information, which can be an empty string.
实施例二Embodiment two
本例中涉及地址及端口或不同协议报文之间的转换翻译方法。This example involves the conversion and translation method between addresses and ports or packets of different protocols.
在配置了地址及端口映射条目后,实际通信过程中的地址及端口的转换翻译工作由HGW上的地址及协议转换翻译功能模块来完成。具体分以下两种情况来说明:After the address and port mapping entries are configured, the address and port conversion and translation work in the actual communication process is completed by the address and protocol conversion and translation function module on the HGW. Specifically, the following two situations are described:
1)HND使用GUA与PND6通信1) HND uses GUA to communicate with PND6
此种情况下,对于HND向PND6发出的报文(上行IPv6报文)其源地址、源端口号及协议字段如果能与已配置映射条目的源地址、源端口号及协议字段相匹配,则按映射条目进行源地址和端口的转换后再向PND6发出。对于PND6发送到HGW上的IPv6报文(下行IPv6报文),如果其目的地址、目的端口号及协议字段能与已配置映射条目的目的地址、目的端口号及协议字段相匹配,并且能满足远程主机标识字段的限制要求,则按映射条目进行目的地址和目的端口的转换后再发送到HND上。In this case, if the source address, source port number and protocol field of the message (uplink IPv6 message) sent by HND to PND6 can match the source address, source port number and protocol field of the configured mapping entry, then Convert the source address and port according to the mapping entry and then send it to PND6. For the IPv6 message (downlink IPv6 message) sent by PND6 to HGW, if its destination address, destination port number and protocol field can match the destination address, destination port number and protocol field of the configured mapping entry, and can satisfy According to the restriction requirements of the remote host identification field, the destination address and destination port are converted according to the mapping entry and then sent to the HND.
2)HND使用IPv4地址与PND6通信2) HND uses IPv4 address to communicate with PND6
此种情况下,一般由PND6先向家庭网络内部发起数据连接。其目的地址是已配置的IPv4到IPv6的映射条目中的外部GUA地址。由于这个GUA是可以动态随机变化的,实际使用过程中可以使用动态域名解析机制建立其与一个固定域名的对应关系,PND6可使用这个固定域名向家庭网络设备发起数据连接。对于从外部到达网关的IPv6报文(下行IPv6报文),如果其目的地址、目的端口号、协议字段能与已经配置的IPv4与IPv6地址及端口映射条目中的目的地址、目的端口号、协议字段相匹配,并且能满足远程主机标识字段的限制要求,则按映射条目把目的地址转换指定的IPv4地址,目的端口转换成指定端口,同时源地址映射为一个特定范围内的IPv4地址如(1.0.0.1~1.0.0.254)并记录和维护这个映射关系,最终将整个IPv6报文转换翻译翻译成IPv4报文后再发送到HND上。同样地,对于HND发送给外网设备的IPv4报文(上行IPv4报文),如果其源地址、目的地址、源端口号能与已经建立的映射条目匹配上,则分别将转换为相对应的IPv6地址和端口,将其完全转换翻译为一个IPv6报文后再发送到PND6。In this case, generally, the PND6 first initiates a data connection to the inside of the home network. Its destination address is the external GUA address in the configured IPv4-to-IPv6 mapping entry. Since the GUA can be dynamically and randomly changed, the dynamic domain name resolution mechanism can be used to establish its corresponding relationship with a fixed domain name during actual use, and the PND6 can use this fixed domain name to initiate a data connection to the home network device. For an IPv6 packet (downlink IPv6 packet) arriving at the gateway from the outside, if its destination address, destination port number, and protocol field can match the destination address, destination port number, and protocol field in the configured IPv4 and IPv6 address and port mapping entries Fields match, and can meet the restriction requirements of the remote host identification field, then according to the mapping entry, the destination address is converted to the specified IPv4 address, the destination port is converted to the specified port, and the source address is mapped to an IPv4 address in a specific range, such as (1.0 .0.1~1.0.0.254) and record and maintain this mapping relationship, and finally convert and translate the entire IPv6 message into an IPv4 message and then send it to the HND. Similarly, for the IPv4 message (uplink IPv4 message) sent by the HND to the external network device, if its source address, destination address, and source port number can match the established mapping entries, they will be converted into corresponding IPv6 address and port, it is completely converted and translated into an IPv6 message and then sent to PND6.
实施例三Embodiment Three
对于地址及端口映射的自动配置需在HGW上的UPnP IGD功能模块中对UPnP IGD2.0规范进行扩充来完成。具体扩充描述如下:The automatic configuration of address and port mapping needs to be completed by extending the UPnP IGD2.0 specification in the UPnP IGD function module on the HGW. The specific expansion is described as follows:
1)在WANIPConnection和WANPPPConnection的服务描述增加如下状态变量:1) Add the following state variables to the service descriptions of WANIPConnection and WANPPPConnection:
NATVersion,NAT版本,可以是NAT44,NAT46,NAT66一个值或多个值的组合,用以表明UPnP IGD可以配置IPv4到IPv4,IPv4到IPv6,IPv6到IPv6等几种类型的地址及端口映射的一种或多种;NATVersion, NAT version, can be a value of NAT44, NAT46, NAT66 or a combination of multiple values, used to indicate that UPnP IGD can configure several types of address and port mapping from IPv4 to IPv4, IPv4 to IPv6, and IPv6 to IPv6 one or more kinds;
RemoteHost6,远程IPv6结点标识,可以是域名或GUA地址;如果为空则表示不对远程主机进行限制;RemoteHost6, the remote IPv6 node identifier, which can be a domain name or GUA address; if it is empty, it means that there is no restriction on the remote host;
ExternalIPv6Address,外部IPv6GUA地址;ExternalIPv6Address, external IPv6GUA address;
InternalClinet6,内部设备GUA地址;InternalClinet6, internal device GUA address;
2)在WANIPConnection和WANPPPConnection的服务描述增加如下服务接口即Action:2) Add the following service interface, namely Action, to the service descriptions of WANIPConnection and WANPPPConnection:
GetNATVersion,获取UPnP IGD所支持的NAT版本,如果支持NAT46或NAT66则可以进行前面的地址及端口映射;相关参数如下:GetNATVersion, get the NAT version supported by UPnP IGD, if it supports NAT46 or NAT66, you can perform the previous address and port mapping; the relevant parameters are as follows:
NewNATVersion,输出,NATVersion;NewNATVersion, output, NATVersion;
GetExternalIPv6Address,获取外部GUA地址,相关参数如下:GetExternalIPv6Address, to obtain the external GUA address, the relevant parameters are as follows:
NewExternalIPAddress6,输出,外部IPv6GUA地址;NewExternalIPAddress6, output, external IPv6GUA address;
GetGenericPortMappingEntry66,根据索引号获取一个IPv6到IPv6地址及端口映射条目,相关参数如下:GetGenericPortMappingEntry66, according to the index number to obtain an IPv6 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewPortMappingIndex, 输入,条目索引;NewPortMappingIndex, input, entry index;
NewRemoteHost6, 输出,远程主机标识;NewRemoteHost6, output, remote host ID;
NewExternalPort, 输出,外部端口;NewExternalPort, output, external port;
NewProtocol, 输出,协议;NewProtocol, output, protocol;
NewInternelPort, 输出,内部端口;NewInternelPort, output, internal port;
NewInternalClient6, 输出,内部主机GUA;NewInternalClient6, output, internal host GUA;
NewEnabled, 输出,使能标记;NewEnabled, output, enable flag;
NewPortMappingDescription,输出,描述信息;NewPortMappingDescription, output, description information;
NewLeaseDuration,输出,持续时间(秒);NewLeaseDuration, output, duration (seconds);
GetSpecificPortMappingEntry66,获取一个指定的IPv6到IPv6地址及端口映射条目,相关参数如下:GetSpecificPortMappingEntry66, to obtain a specified IPv6 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
NewInternelPort, 输出,内部端口;NewInternelPort, output, internal port;
NewInternalClient6, 输出,内部主机GUA;NewInternalClient6, output, internal host GUA;
NewEnabled, 输出,使能标记;NewEnabled, output, enable flag;
NewPortMappingDescription, 输出,描述信息;NewPortMappingDescription, output, description information;
NewLeaseDuration, 输出,持续时间(秒);NewLeaseDuration, output, duration (seconds);
AddPortMapping66,添加一个IPv6到IPv6地址及端口映射条目,相关参数如下:AddPortMapping66, add an IPv6 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
NewInternelPort, 输入,内部端口;NewInternelPort, input, internal port;
NewInternalClient6, 输入,内部主机GUA;NewInternalClient6, input, internal host GUA;
NewEnabled, 输入,使能标记;NewEnabled, input, enable flag;
NewPortMappingDescription, 输入,描述信息;NewPortMappingDescription, input, description information;
NewLeaseDuration, 输入,持续时间(秒);NewLeaseDuration, input, duration (seconds);
其中,远程主机标识可以为空,表示不限定,持续时间为0表示静态配置,在删除之前一直有效;Among them, the remote host ID can be empty, which means unlimited, and the duration is 0, which means static configuration, which is valid until deleted;
DeltetePortMapping66,删除一个IPv6到IPv6地址及端口映射条目,相关参数如下:DeltetePortMapping66, delete an IPv6 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
GetGenericPortMappingEntry46,根据索引号获取一个IPv4到IPv6地址及端口映射条目,相关参数如下:GetGenericPortMappingEntry46, according to the index number to obtain an IPv4 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewPortMappingIndex,输入,条目索引;NewPortMappingIndex, input, entry index;
NewRemoteHost6, 输出,远程主机标识;NewRemoteHost6, output, remote host ID;
NewExternalPort, 输出,外部端口;NewExternalPort, output, external port;
NewProtocol, 输出,协议;NewProtocol, output, protocol;
NewInternelPort, 输出,内部端口;NewInternelPort, output, internal port;
NewInternalClient, 输出,内部主机IPv4地址;NewInternalClient, output, internal host IPv4 address;
NewEnabled, 输出,使能标记;NewEnabled, output, enable flag;
NewPortMappingDescription, 输出,描述信息;NewPortMappingDescription, output, description information;
NewLeaseDuration, 输出,持续时间(秒);NewLeaseDuration, output, duration (seconds);
GetSpecificPortMappingEntry46,获取一个指定的IPv4到IPv6地址及端口映射条目,相关参数如下:GetSpecificPortMappingEntry46, to obtain a specified IPv4 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
NewInternelPort, 输出,内部端口;NewInternelPort, output, internal port;
NewInternalClient, 输出,内部主机IPv4地址;NewInternalClient, output, internal host IPv4 address;
NewEnabled, 输出,使能标记;NewEnabled, output, enable flag;
NewPortMappingDescription, 输出,描述信息;NewPortMappingDescription, output, description information;
NewLeaseDuration, 输出,持续时间(秒);NewLeaseDuration, output, duration (seconds);
AddPortMapping46,添加一个IPv4到IPv6地址及端口映射条目,相关参数如下:AddPortMapping46, add an IPv4 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
NewInternelPort, 输入,内部端口;NewInternelPort, input, internal port;
NewInternalClient, 输入,内部主机IPv4地址;NewInternalClient, input, internal host IPv4 address;
NewEnabled, 输入,使能标记;NewEnabled, input, enable flag;
NewPortMappingDescription, 输入,描述信息;NewPortMappingDescription, input, description information;
NewLeaseDuration, 输入,持续时间(秒);NewLeaseDuration, input, duration (seconds);
其中,远程主机标识可以为空,表示不限定,持续时间为0表示静态配置,在删除之前一直有效;Among them, the remote host ID can be empty, which means unlimited, and the duration is 0, which means static configuration, which is valid until deleted;
DeltetePortMapping46,删除一个IPv4到IPv6地址及端口映射条目,相关参数如下:DeltetePortMapping46, delete an IPv4 to IPv6 address and port mapping entry, the relevant parameters are as follows:
NewRemoteHost6, 输入,远程主机标识;NewRemoteHost6, input, remote host ID;
NewExternalPort, 输入,外部端口;NewExternalPort, input, external port;
NewProtocol, 输入,协议;NewProtocol, input, protocol;
在对UPnP IGD进行扩充后,需要同时对HND上的UPnP CP功能进行相应的扩充,以识别这几类Action并按需要进行自动调用。具体方法,此处不再赘述。After expanding the UPnP IGD, it is necessary to expand the UPnP CP function on the HND at the same time to identify these types of Actions and automatically call them as needed. The specific method will not be repeated here.
实施例四Embodiment four
图2是根据本发明的用于添加或删除IPv6地址及端口映射的流程,适用于HND使用GUA与PND6进行通信的过程。Fig. 2 is a process for adding or deleting IPv6 address and port mapping according to the present invention, which is applicable to the process of HND using GUA to communicate with PND6.
如图2所示,HND的上UPnP CP功能通过UPnP协议,自动发现了HGW上的UPnP IGD后,添加了一条从(2001::2,2001)到(2001::1,3001)UDP协议的映射条目,其中没有对远程主机进行限定,有效性持续时间设为1800秒。As shown in Figure 2, the UPnP CP function of the HND automatically discovers the UPnP IGD on the HGW through the UPnP protocol, and adds a UDP protocol from (2001::2, 2001) to (2001::1, 3001) The mapping entry, in which no remote host is defined, has a validity duration set to 1800 seconds.
在这个过程中,首先是通过执行GetNATVersion得知HGW上的UPnP IGD可以进行IPv6到IPv6的地址及端口映射;随后通过执行GetGenericPortMappingEntry66查询已经添加了哪些映射条目;通过GetExternalIPv6Address获取映射所需的外部地址后即可通过AddPortMapping66完成映射条目的添加。In this process, first of all, by executing GetNATVersion, it is known that the UPnP IGD on the HGW can perform IPv6-to-IPv6 address and port mapping; then, by executing GetGenericPortMappingEntry66, query which mapping entries have been added; after obtaining the external address required for mapping through GetExternalIPv6Address The addition of the mapping entry can be completed through AddPortMapping66.
这里需要说明的是AddPortMapping66的参数中并不包括外部地址这一项。外部地址由UPnP IGD自动选择并与之前返回给UPnP CP的外部地址一致;在通信过程中,HND上的UPnPCP也可以根据需要将映射条目删除,在删除某一映射条目前,可以通过GetSpecicPortMappingEntry66进行查询以确定其是否存在,最后通过DeletePortMapping66将其删除。UPnP IGD在收到AddPortMapping66/DeletePortMapping66请求后会同步地将映射条目添加到HGW上的地址及协议转换翻译模块以备后用或将其从中删除。What needs to be explained here is that the parameter of AddPortMapping66 does not include the item of external address. The external address is automatically selected by the UPnP IGD and is consistent with the external address previously returned to the UPnP CP; during the communication process, the UPnPCP on the HND can also delete the mapping entry as needed. Before deleting a certain mapping entry, it can be queried through GetSpecicPortMappingEntry66 To determine whether it exists, and finally delete it through DeletePortMapping66. After receiving the AddPortMapping66/DeletePortMapping66 request, the UPnP IGD will synchronously add the mapping entry to the address and protocol translation module on the HGW for later use or delete it from it.
实施例五Embodiment five
图3是根据本发明的用于添加或删除IPv4到IPv6地址及端口映射的流程,适用于HND使用IPv4地址与PND6进行通信的过程。Fig. 3 is a process for adding or deleting IPv4 to IPv6 address and port mapping according to the present invention, which is applicable to the process of HND using IPv4 address to communicate with PND6.
如图3所示,HND的上UPnP CP功能通过UPnP协议,自动发现了HGW上的UPnP IGD后,添加了一条从(192.168.1.6,2000)到(2001::c0a8:106,3000)TCP协议的映射条目,其中限定了远程主机只能为2002::1,有效性持续时间是3600秒。这个过程中与图2中的流程类似,此处不再赘述。As shown in Figure 3, the UPnP CP function of the HND automatically discovers the UPnP IGD on the HGW through the UPnP protocol, and adds a TCP protocol from (192.168.1.6, 2000) to (2001::c0a8:106, 3000) The mapping entry, which limits the remote host to only 2002::1, and the validity duration is 3600 seconds. This process is similar to the flow in FIG. 2 , and will not be repeated here.
实施例六Embodiment six
对于HND与PND6在实际通信过程中具体的地址或协议转换翻译工作由HGW上的地址及协议转换翻译功能模块来完成,下面结合附图进行说明。The specific address or protocol conversion and translation work in the actual communication process between HND and PND6 is completed by the address and protocol conversion and translation function module on the HGW, which will be described below with reference to the accompanying drawings.
图4是根据本发明的用于进行IPv6地址及端口转换翻译的流程,适用于HND使用GUA与PND6进行通信的过程。Fig. 4 is a process for performing IPv6 address and port conversion and translation according to the present invention, which is applicable to the process of HND using GUA to communicate with PND6.
如图4所示,HND使用地址及端口(2001::2,2001)与PND6上的地址及端口(2002::1,2002)进行基于UDP协议的通信;由于之前添加了UDP协议的(2001::2,2001)与(2001::1,3001)之间的映射,因此所有从(2001::2,2001)发向(2002::1,2002)的UDP报文源地址和端口均被替换为(2001::1,3001)并发到PND6,而从(2002::1,2002)到(2001::1,3001)的UDP报文其目的地址和端口均被替换为(2001::2,2001)并发到HND。由此实现了HND使用GUA与PND6通信时对HND的地址及端口信息进行屏蔽的功效,提高了HND的安全性。As shown in Figure 4, the HND uses the address and port (2001::2, 2001) to communicate with the address and port (2002::1, 2002) on the PND6 based on the UDP protocol; since the (2001 ::2, 2001) and (2001::1, 3001), so the source addresses and ports of all UDP packets sent from (2001::2, 2001) to (2002::1, 2002) are is replaced by (2001::1, 3001) and sent to PND6, and the destination address and port of UDP packets from (2002::1, 2002) to (2001::1, 3001) are replaced by (2001: :2, 2001) concurrently to HND. Thus, the function of shielding the address and port information of the HND when the HND uses the GUA to communicate with the PND6 is realized, and the security of the HND is improved.
实施例七Embodiment seven
对于HND与PND6在实际通信过程中具体的地址或协议转换翻译工作由HGW上的地址及协议转换翻译功能模块来完成,下面结合附图进行说明。The specific address or protocol conversion and translation work in the actual communication process between HND and PND6 is completed by the address and protocol conversion and translation function module on the HGW, which will be described below with reference to the accompanying drawings.
图5是根据本发明的用于进行IPv4与IPv6报文间进行地址及端口转换翻译的流程,适用于HND使用IPv4地址与PND6进行通信的过程。FIG. 5 is a process for performing address and port translation between IPv4 and IPv6 messages according to the present invention, which is applicable to the process of HND using IPv4 address to communicate with PND6.
如图5所示,在PND6在HND进行访问前,HND通过UPnP IGD在HGW上添加了TCP协议的(192.168.1.6,2000)与(2001:c0a8:106,3000)之间的映射,同时限定了远程主机只能为2002::1。因此只有是来从2002::1发送过来的报文才会被处理。为把IPv6转换翻译成IPv4报文,这里需要由HGW上的地址及转换翻译模块动态生成一个2002::1与一个IPv4地址之间的映射关系。由于HGW之外的网络是IPv6网络,这个IPv4地址仅在HGW与HND之间使用,将其选择于一个不常用地址段即可。如本例中选择2002::1与对应1.0.0.2,则发送到HGW(2001:c0a8:106,3000)的TCP报文会根据映射规则最终被转换翻译为IPv4报文(src:1.0.0.2,2002,dst:192.168.1.6,2000)。与此对应,对于上行的TCP报文(src:192.168.1.6,2000,dst:1.0.0.2,2002),其源地址和端口会分别被转换为(2001:c0a8:106,3000),目的地址被转换为2002::1,最终整个报文被转换翻译为IPv6报文并发送给PND6。由此实现了HND使用IPv4地址与PND6通信时对HND的地址及端口信息进行屏蔽的功效,更进一步地对PND6也进行了限制,进而提高了HND的安全性。As shown in Figure 5, before PND6 accesses HND, HND adds the mapping between (192.168.1.6, 2000) and (2001:c0a8:106, 3000) of TCP protocol on HGW through UPnP IGD, and defines The remote host can only be 2002::1. Therefore, only packets sent from 2002::1 will be processed. In order to convert and translate IPv6 into IPv4 packets, the address and translation module on the HGW needs to dynamically generate a mapping relationship between 2002::1 and an IPv4 address. Since the network outside the HGW is an IPv6 network, this IPv4 address is only used between the HGW and the HND, and it can be selected in an uncommon address segment. For example, if you select 2002::1 and correspond to 1.0.0.2 in this example, then the TCP packets sent to HGW (2001:c0a8:106, 3000) will be converted and translated into IPv4 packets (src:1.0.0.2 , 2002, dst:192.168.1.6, 2000). Correspondingly, for the uplink TCP message (src:192.168.1.6, 2000, dst:1.0.0.2, 2002), its source address and port will be converted to (2001:c0a8:106, 3000), destination address is converted to 2002::1, and finally the entire message is translated into an IPv6 message and sent to PND6. In this way, the function of shielding the address and port information of the HND when the HND uses the IPv4 address to communicate with the PND6 is realized, and the PND6 is further restricted, thereby improving the security of the HND.
综上,本发明具有以下优点:一方面,HND上的UPnP CP可以通过UPnP协议与HGW上的UPnP IGD进行无缝对接实现对IPv6地址及端口之间以及IPv4与IPv6地址及端口之间映射关系的自动灵活配置,为提高HND的安全性提供了必要条件;另一方面,HGW上的地址及协议转换翻译模块可以根据已经配置的映射条目进行地址及端口转换翻译,这就在保证HND与PND6可以正常通信的同时极大地提高了HND的安全性。In summary, the present invention has the following advantages: On the one hand, the UPnP CP on the HND can seamlessly connect with the UPnP IGD on the HGW through the UPnP protocol to realize the mapping relationship between IPv6 addresses and ports and between IPv4 and IPv6 addresses and ports The automatic and flexible configuration of HND provides the necessary conditions for improving the security of HND; on the other hand, the address and protocol conversion and translation module on HGW can perform address and port conversion and translation according to the configured mapping entries, which ensures that HND and PND6 While normal communication is possible, the security of HND is greatly improved.
基于同一发明构思,本发明实施例还提供了一种设备通信装置,设置于家庭网关HGW中,其结构示意图如图6所示,包括:Based on the same inventive concept, the embodiment of the present invention also provides a device communication device, which is set in the home gateway HGW, and its structural diagram is shown in Figure 6, including:
第一处理模块601,用于家庭网络内部设备HND通过HGW与公网上的IPv6设备PND6进行通信时,接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;The first processing module 601 is used to receive the uplink message sent by the HND when the device HND in the home network communicates with the IPv6 device PND6 on the public network through the HGW, and convert and translate the uplink message into a PND6-recognizable one according to the configured mapping entries The uplink message is forwarded to PND6, wherein the configured mapping entry includes at least one address and port mapping relationship involved in the Internet Protocol version;
第二处理模块602,与第一处理模块601相连接,用于接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。The second processing module 602 is connected with the first processing module 601, and is used to receive the downlink message sent by the PND6, convert and translate the downlink message into a downlink message that can be recognized by the HND according to the configured mapping entries, and forward it to the HND.
从以上的描述中,可以看出,本发明实现了如下技术效果:From the above description, it can be seen that the present invention achieves the following technical effects:
在本发明实施例中,当家庭网络内部设备HND通过家庭网关HGW与公网上的IPv6设备PND6进行通信时,HGW接收HND发送的上行报文,根据配置的映射条目将上行报文转换翻译为PND6能够识别的上行报文,并转发至PND6,其中,配置的映射条目包括至少一种因特网协议版本涉及的地址及端口的映射关系;HGW接收PND6发送的下行报文,根据配置的映射条目将下行报文转换翻译为HND能够识别的下行报文,并转发至HND。即,在本发明实施例中,HND与PND6进行通信时,HGW对不同类型的报文进行转换翻译,将其转换翻译为目的设备能够识别的报文,从而实现HND与指定的PND6进行通信,并可以灵活地屏蔽HND与PND6进行通信时的所用的地址和端口信息,从而极大地提高了通信的安全性。In the embodiment of the present invention, when the internal device HND of the home network communicates with the IPv6 device PND6 on the public network through the home gateway HGW, the HGW receives the uplink message sent by the HND, and translates the uplink message into PND6 according to the configured mapping entries. The uplink message that can be identified is forwarded to PND6, wherein the configured mapping entry includes at least one IP address and port mapping relationship involved in the version of the Internet protocol; HGW receives the downlink message sent by PND6, and sends the downlink message according to the configured mapping entry The message is converted and translated into a downlink message that can be recognized by the HND, and forwarded to the HND. That is, in the embodiment of the present invention, when the HND communicates with the PND6, the HGW converts and translates different types of messages, and converts and translates them into messages that can be recognized by the destination device, thereby realizing the communication between the HND and the designated PND6. And it can flexibly shield the address and port information used when the HND communicates with the PND6, thereby greatly improving the security of the communication.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that each module or each step of the above-mentioned present invention can be realized by a general-purpose computing device, and they can be concentrated on a single computing device, or distributed in a network formed by multiple computing devices Alternatively, they may be implemented in program code executable by a computing device so that they may be stored in a storage device to be executed by a computing device, and in some cases in an order different from that shown here The steps shown or described are carried out, or they are separately fabricated into individual integrated circuit modules, or multiple modules or steps among them are fabricated into a single integrated circuit module for implementation. As such, the present invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (13)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110171450.3A CN102843439B (en) | 2011-06-23 | 2011-06-23 | Equipment communication method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110171450.3A CN102843439B (en) | 2011-06-23 | 2011-06-23 | Equipment communication method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102843439A CN102843439A (en) | 2012-12-26 |
CN102843439B true CN102843439B (en) | 2017-11-10 |
Family
ID=47370492
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110171450.3A Expired - Fee Related CN102843439B (en) | 2011-06-23 | 2011-06-23 | Equipment communication method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102843439B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105337808B (en) * | 2015-11-30 | 2019-01-04 | 网宿科技股份有限公司 | The method, apparatus and system of data transmission |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1691665A (en) * | 2004-04-21 | 2005-11-02 | 华为技术有限公司 | A method for realizing communication between IPv4 network and IPv6 network |
CN101136910A (en) * | 2006-08-30 | 2008-03-05 | 中国电信股份有限公司 | Network address and protocol translating equipment and application layer gateway equipment |
CN101175029A (en) * | 2006-10-31 | 2008-05-07 | 中兴通讯股份有限公司 | Device for implementing proxy to multiple isomorphic subnets |
CN101175043A (en) * | 2007-11-21 | 2008-05-07 | 中兴通讯股份有限公司 | System and method for supporting IPv6 terminal access to IPv4 core net |
-
2011
- 2011-06-23 CN CN201110171450.3A patent/CN102843439B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1691665A (en) * | 2004-04-21 | 2005-11-02 | 华为技术有限公司 | A method for realizing communication between IPv4 network and IPv6 network |
CN101136910A (en) * | 2006-08-30 | 2008-03-05 | 中国电信股份有限公司 | Network address and protocol translating equipment and application layer gateway equipment |
CN101175029A (en) * | 2006-10-31 | 2008-05-07 | 中兴通讯股份有限公司 | Device for implementing proxy to multiple isomorphic subnets |
CN101175043A (en) * | 2007-11-21 | 2008-05-07 | 中兴通讯股份有限公司 | System and method for supporting IPv6 terminal access to IPv4 core net |
Also Published As
Publication number | Publication date |
---|---|
CN102843439A (en) | 2012-12-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103141074B (en) | Name database server, name resolution system, entry search method | |
CN1965515B (en) | Arrangement for reaching IPv4 public network nodes by a node in an IPv4 private network via an IPv6 access network | |
CN100469038C (en) | ISATAP router and method for tunneling packets | |
US20150358232A1 (en) | Packet Forwarding Method and VXLAN Gateway | |
CN103067268B (en) | Method and server of virtual home gateway service delivery | |
US9602333B2 (en) | DNS server, gateways and methods for managing an identifier of a port range in the transmission of data | |
CN106254407B (en) | Method and device for sharing home network service | |
EP2632090A1 (en) | Name-database server, name-resolution system, entry-search method, and entry-search program | |
US20230216825A1 (en) | Gateway based ip address translation in communication networks | |
US20160080315A1 (en) | Enhanced dynamic host configuration protocol (dhcp) | |
TW201701635A (en) | Network transmission method and network transmission system for a multi-layer network address translator structure | |
CN104702707B (en) | A kind of data processing method and device | |
CN103051544B (en) | Realize method and the access device of IPv4 private network access IPv6 network | |
WO2014156143A1 (en) | Home gateway device and packet forwarding method | |
JP5333095B2 (en) | Address conversion / protocol conversion system, translator device and translator program | |
CN102843439B (en) | Equipment communication method and device | |
CN104935677B (en) | A NAT64 resource acquisition method and acquisition/allocation device | |
CN108011989B (en) | Redirection method and device | |
WO2016078235A1 (en) | Network translation realization method and apparatus for transiting to ipv6 on the basis of pant | |
CN102546845B (en) | Business access method, device and system | |
CN101572729B (en) | A method for processing virtual private network node information and related equipment and system | |
CN107040616B (en) | Conversion method and message receiving and transmitting method for TCP/DN/IP network compatible with TCP/IP network | |
JP2013126219A (en) | Transfer server and transfer program | |
WO2015184979A1 (en) | Methods and devices for processing packet, sending information, and receiving information | |
CN102684972B (en) | Communication method and communication system compatible with IP (internet protocol)v4 address |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20171110 |
|
CF01 | Termination of patent right due to non-payment of annual fee |