CN100488204C - Method for enquiring IPSec tunnel state - Google Patents

Method for enquiring IPSec tunnel state Download PDF

Info

Publication number
CN100488204C
CN100488204C CNB2006100805699A CN200610080569A CN100488204C CN 100488204 C CN100488204 C CN 100488204C CN B2006100805699 A CNB2006100805699 A CN B2006100805699A CN 200610080569 A CN200610080569 A CN 200610080569A CN 100488204 C CN100488204 C CN 100488204C
Authority
CN
China
Prior art keywords
ipsec tunnel
query
party
ipsec
message
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
Application number
CNB2006100805699A
Other languages
Chinese (zh)
Other versions
CN1845549A (en
Inventor
杨银柱
毛昱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Technologies Co Ltd
Original Assignee
Hangzhou H3C Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou H3C Technologies Co Ltd filed Critical Hangzhou H3C Technologies Co Ltd
Priority to CNB2006100805699A priority Critical patent/CN100488204C/en
Publication of CN1845549A publication Critical patent/CN1845549A/en
Application granted granted Critical
Publication of CN100488204C publication Critical patent/CN100488204C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种查询IPSec隧道状态的方法,根据要查询IPSec隧道的特征参数,对IPSec隧道的状态进行查询,确定IPSec隧道的状态。本发明所提供的方法,避免了由于间接查询,即通过查询其他的状态来反映当前IPSec隧道的状态,而造成由于错误确定IPSec隧道的状态,使通信中断,系统延时、客户服务质量降低、通信可靠性下降等问题。本发明提供的方法能够准确、快速、可靠的查询到IPSec隧道当前的真实状态,降低了系统延时、提高了通信的可靠性、有力的保证了通信网络的正常运行。

Figure 200610080569

The invention discloses a method for inquiring the state of the IPSec tunnel. According to the characteristic parameters of the IPSec tunnel to be inquired, the state of the IPSec tunnel is inquired to determine the state of the IPSec tunnel. The method provided by the present invention avoids indirect inquiry, that is, reflects the state of the current IPSec tunnel by inquiring about other states, and causes the state of the IPSec tunnel to be determined incorrectly, interrupting communication, delaying the system, reducing the quality of customer service, problems such as decreased communication reliability. The method provided by the invention can accurately, quickly and reliably query the current real state of the IPSec tunnel, reduces system delay, improves communication reliability, and effectively guarantees the normal operation of the communication network.

Figure 200610080569

Description

一种查询IPSec隧道状态的方法 A Method of Querying the State of IPSec Tunnel

技术领域 technical field

本发明涉及网络安全检测技术,尤指一种查询IP安全(IPSec)隧道状态的方法。The invention relates to a network security detection technology, in particular to a method for querying the state of an IP security (IPSec) tunnel.

背景技术 Background technique

IPSec是互联网工程任务组(IETF)制定的一个开放的IP层安全框架协议,为一个三层隧道协议。IPSec在网络层起作用,能够为传输敏感数据提供安全保护,对参与IPSec的设备之间传输的IP数据包进行保护和认证。有了IPSec,数据在通过公共网络传输时,不需担心被攻击者监视、窜改以及伪造。IPSec is an open IP layer security framework protocol formulated by the Internet Engineering Task Force (IETF), and it is a three-layer tunneling protocol. IPSec works at the network layer, can provide security protection for sensitive data transmission, and protect and authenticate IP data packets transmitted between devices participating in IPSec. With IPSec, when data is transmitted through the public network, there is no need to worry about being monitored, tampered with and forged by attackers.

IPSec协议对数据的保护,是通过安全联盟(Security Association,SA)来实现的。IPSec SA中定义了通信双方对通信过程中某些要素的约定,例如,使用哪种协议、协议的操作模式、密码算法、特定流中保护数据的共享密钥、以及密钥的生存周期等。IPSec SA由一个三元组进行唯一标识,该三元组包括:安全参数索引(SPI)、目的IP地址、以及安全协议。The protection of data by the IPSec protocol is realized through a Security Association (SA). IPSec SA defines the agreement between the two parties on certain elements in the communication process, such as which protocol to use, the operating mode of the protocol, the cryptographic algorithm, the shared key for protecting data in a specific flow, and the life cycle of the key. IPSec SA is uniquely identified by a triplet, which includes: Security Parameter Index (SPI), destination IP address, and security protocol.

在通信双方建立IPSec隧道后,通信双方必须保持该IPSec隧道的SA一致并同时存在,才能保证协商消息和数据消息正常的进行加密和解密,即才能保证通信双方正常使用该IPSec隧道进行数据通信。因此,就需要某种机制来查询IPSec隧道,即在通信双方的IPSec隧道建立起来后,查询通信双方的IPSec SA是否同时存在,以便在通信双方IPSec SA不同时存在时,触发删除原IPSec隧道,重新建立新的IPSec隧道,保证数据的正常通信。After the communication parties establish the IPSec tunnel, the communication parties must keep the SA of the IPSec tunnel consistent and exist at the same time, so as to ensure the normal encryption and decryption of negotiation messages and data messages, that is, to ensure that the communication parties can normally use the IPSec tunnel for data communication. Therefore, a certain mechanism is needed to query the IPSec tunnel, that is, after the IPSec tunnels of both communication parties are established, query whether the IPSec SAs of both communication parties exist at the same time, so as to trigger deletion of the original IPSec tunnel when the IPSec SAs of both communication parties do not exist at the same time. Re-establish a new IPSec tunnel to ensure the normal communication of data.

在现有技术中,对IPSec隧道状态的查询通常是通过互联网密钥交换协议(IKE)中的死亡对端检测(DPD)来实现。In the prior art, querying the status of an IPSec tunnel is usually implemented through Dead Peer Detection (DPD) in the Internet Key Exchange Protocol (IKE).

DPD通过检测与IPSec SA对应的IKE SA的状态,来确定IPSec SA的状态,进而确定要查询的IPSec的状态。这里,所述IKE SA或IPSec SA的状态为:IKE SA或IPSec SA是否存在;所述IPSec隧道的状态为:IPSec隧道是否可用。但是,在现有技术中,IKE SA的状态并不能代表对应IPSecSA的状态,也就是说,即使在IKE SA存在的情况下,与IKE SA对应的IPSecSA也不一定会存在。因此通过查询IKE SA的状态确认IPSec隧道的状态并不合理,如果错误确定了IPSec隧道的状态,会使这种检测机制失去作用,并且造成数据通信的中断,使数据通信长时间无法自动恢复,给网络实际运行带来不良影响。The DPD determines the state of the IPSec SA by detecting the state of the IKE SA corresponding to the IPSec SA, and then determines the state of the IPSec to be queried. Here, the state of the IKE SA or the IPSec SA is: whether the IKE SA or the IPSec SA exists; the state of the IPSec tunnel is: whether the IPSec tunnel is available. However, in the prior art, the state of the IKE SA cannot represent the state of the corresponding IPSecSA, that is, even if the IKE SA exists, the IPSecSA corresponding to the IKE SA does not necessarily exist. Therefore, it is unreasonable to confirm the status of the IPSec tunnel by querying the status of the IKE SA. If the status of the IPSec tunnel is incorrectly determined, this detection mechanism will be ineffective, and the data communication will be interrupted, so that the data communication cannot be automatically restored for a long time. Bring adverse effects to the actual operation of the network.

发明内容 Contents of the invention

有鉴于此,本发明的主要目的在于提供一种查询IPSec隧道状态的方法,应用该方法能够准确、可靠的查询到IPSec隧道当前的状态。In view of this, the main purpose of the present invention is to provide a method for inquiring about the state of the IPSec tunnel, which can accurately and reliably inquire about the current state of the IPSec tunnel.

为达到上述目的,本发明的技术方案是这样实现的:In order to achieve the above object, technical solution of the present invention is achieved in that way:

一种查询IPSec隧道状态的方法,该方法包括以下步骤:A method for querying the state of an IPSec tunnel, the method comprising the following steps:

A、查询方向应答方发送IPSec隧道查询消息,IPSec隧道查询消息中携带至少一条要查询的IPSec隧道的特征参数;A. The query direction sends an IPSec tunnel query message to the responding party, and the IPSec tunnel query message carries at least one characteristic parameter of the IPSec tunnel to be queried;

B、应答方获得IPSec隧道查询消息中携带的特征参数,查询自身是否存在相同的特征参数,并将查询结果返回给查询方;B. The responding party obtains the characteristic parameter carried in the IPSec tunnel query message, inquires whether the same characteristic parameter exists in itself, and returns the query result to the inquiring party;

C、查询方根据应答方返回的查询结果,当应答方存在相同的特征参数时,则确定所述相同的特征参数对应的IPSec隧道可用;当应答方不存在相同的特征参数时,则确定所述不存在相同的特征参数对应的IPSec隧道不可用。C. According to the query result returned by the responding party, when the responding party has the same characteristic parameter, it is determined that the IPSec tunnel corresponding to the same characteristic parameter is available; when the responding party does not have the same characteristic parameter, it is determined that the corresponding The IPSec tunnel that does not have the same characteristic parameters as above is unavailable.

另外,当要查询一条以上IPSec隧道时,步骤B中,所述将查询结果返回给查询方为:In addition, when more than one IPSec tunnel is to be queried, in step B, the query result is returned to the query party as follows:

通过一条消息将一条以上IPSec隧道的查询结果返回给查询方;或Return the query results of more than one IPSec tunnel to the querying party in one message; or

针对每条IPSec隧道,分别向查询方返回一条查询结果。For each IPSec tunnel, return a query result to the querying party.

其中,步骤B中,所述将查询结果返回给查询方为:Wherein, in step B, the query result returned to the query party is:

当应答方存在相同的特征参数时,则针对所述相同的特征参数向查询方返回IPSec隧道查询成功消息;当应答方不存在相同的特征参数时,则针对所述不存在相同的特征参数向查询方响应失败。When the answering party has the same feature parameter, then return the IPSec tunnel query success message to the query side for the same feature parameter; The queryer failed to respond.

其中,所述响应失败为:应答方向查询方返回IPSec隧道查询失败消息。Wherein, the response failure is: the responder returns an IPSec tunnel query failure message to the inquiring party.

另外,进一步设置等待定时器及等待时长,当查询方发送IPSec隧道查询消息时,启动等待定时器;In addition, the waiting timer and the waiting time are further set, and when the inquiring party sends an IPSec tunnel query message, the waiting timer is started;

步骤B中,所述响应失败为:当应答方不存在要查询IPSec隧道的特征参数时,不向查询方返回查询结果;In step B, the response failure is: when the responding party does not have the characteristic parameters to query the IPSec tunnel, the query result is not returned to the querying party;

步骤C中,所述当应答方存在相同的特征参数时,则确定所述相同的特征参数对应的IPSec隧道可用为:当等待定时器到达等待时长时,查询方收到了查询结果,则确定所述查询结果对应的IPSec隧道可用;所述当应答方不存在相同的特征参数时,则确定所述不存在相同的特征参数对应的IPSec隧道不可用为:当等待定时器到达等待时长时,查询方未收到查询结果,则确定所述查询结果对应的IPSec隧道不可用。In step C, when the responding party has the same characteristic parameter, it is determined that the IPSec tunnel corresponding to the same characteristic parameter can be used as follows: when the waiting timer reaches the waiting time, the inquiring party receives the query result, then determines that the IPSec tunnel corresponding to the same characteristic parameter is: The IPSec tunnel corresponding to the query result is available; when the responder does not have the same characteristic parameter, then determining that the IPSec tunnel corresponding to the same characteristic parameter does not exist is unavailable: when the waiting timer reaches the waiting time, query If the party does not receive the query result, it is determined that the IPSec tunnel corresponding to the query result is unavailable.

另外,进一步设置查询定时器以及查询周期,步骤A中当查询方发送IPSec隧道查询消息时,启动查询定时器;当查询定时器到达查询周期时,判断当前要查询IPSec隧道的状态是否已经确定,如果是,则查询定时器停止计时;否则,查询方针对没有确定状态的IPSec隧道发送IPSec隧道查询消息。In addition, the query timer and the query cycle are further set. In step A, when the inquiring party sends an IPSec tunnel query message, the query timer is started; when the query timer reaches the query cycle, it is judged whether the status of the IPSec tunnel to be inquired is determined at present, If so, the query timer stops counting; otherwise, the querying party sends an IPSec tunnel query message to the IPSec tunnel with no definite state.

另外,进一步设置最大查询次数,对查询方发送的IPSec隧道查询消息进行计数,在查询方针对没有确定状态的IPSec隧道发送IPSec隧道查询消息之前,进一步判断当前发送的IPSec隧道查询消息是否小于或等于最大查询次数,如果是,则执行所述发送IPSec隧道查询消息;否则,结束当前处理流程。In addition, further set the maximum number of queries, count the IPSec tunnel query messages sent by the query party, and further judge whether the currently sent IPSec tunnel query messages are less than or equal to The maximum number of queries, if yes, execute the sending of the IPSec tunnel query message; otherwise, end the current processing flow.

另外,在步骤C之前,进一步包括:In addition, before step C, further include:

判断应答方返回的查询结果是否为当前查询周期内查询方发送查询消息的响应,如果是,则执行步骤C;否则,拒绝处理当前应答方返回的查询结果。Determine whether the query result returned by the responding party is the response to the query message sent by the querying party in the current query period, and if so, perform step C; otherwise, refuse to process the query result returned by the current responding party.

其中,当查询方需要向应答方发送数据或查询周期到达时,执行步骤A。Wherein, step A is performed when the inquiring party needs to send data to the responding party or when the query period is reached.

其中,所述特征参数为:IPSec隧道出方向安全联盟的安全参数索引、目的IP地址、和安全协议;或IPSec隧道入方向安全联盟的安全参数索引、目的IP地址、和安全协议;或IPSec隧道出方向安全联盟的安全参数索引、目的IP地址、和安全协议、和入方向安全联盟的安全参数索引、目的IP地址、和安全协议。Wherein, the characteristic parameters are: the security parameter index, the destination IP address, and the security protocol of the security association of the outgoing direction of the IPSec tunnel; or the security parameter index, the destination IP address, and the security protocol of the security association of the incoming direction of the IPSec tunnel; or the IPSec tunnel The security parameter index, destination IP address, and security protocol of the outbound SA, and the security parameter index, destination IP address, and security protocol of the inbound SA.

本发明所提供的一种查询IPSec隧道状态的方法,根据要查询IPSec隧道的特征参数,对IPSec隧道的状态进行查询,确定IPSec隧道的状态。本发明所提供的方法,避免了由于间接查询,即通过查询其他的状态来反映当前IPSec隧道的状态,而造成由于错误确定IPSec隧道的状态,使通信中断,系统延时、客户服务质量降低、通信可靠性下降等问题。本发明提供的方法能够准确、快速、可靠的查询到IPSec隧道当前的真实状态,降低了系统延时、提高了通信的可靠性、有力的保证了通信网络的正常运行。The method for inquiring the state of the IPSec tunnel provided by the present invention is to inquire the state of the IPSec tunnel according to the characteristic parameters of the IPSec tunnel to be inquired, and determine the state of the IPSec tunnel. The method provided by the present invention avoids that due to indirect query, that is, reflecting the state of the current IPSec tunnel by inquiring about other states, the state of the IPSec tunnel is incorrectly determined, communication is interrupted, system delay, customer service quality is reduced, problems such as decreased communication reliability. The method provided by the invention can accurately, quickly and reliably query the current real state of the IPSec tunnel, reduces system delay, improves communication reliability, and effectively guarantees the normal operation of the communication network.

附图说明 Description of drawings

图1为本发明实施例一方法的流程图;Fig. 1 is the flowchart of the method of embodiment one of the present invention;

图2为本发明实施例二方法的流程图。Fig. 2 is a flow chart of the method in Embodiment 2 of the present invention.

具体实施方式 Detailed ways

在本发明中通过查询建立IPSec隧道的通信双方是否存在相同的IPSecSA,确定通信双方建立的IPSec隧道是否可用。在建立IPSec隧道时,会同时产生两个IPSec SA,在此假设建立IPSec隧道的双方分别是:A和B,产生的两个IPSec SA分别为1和2;如果IPSec SA1为A的出方向SA、IPSecSA2为A的入方向SA;则IPSec SA1为B的入方向SA、IPSec SA2为B的出方向SA。这里,对每个IPSec隧道的通信方的出方向SA和入方向SA的区别在于,通信方利用出方向SA中的密钥加密发送数据;用入方向SA中的密钥解密接收数据。这里,所述的通信双方存在相同的IPSec SA是指:通信双方同时存在IPSec隧道对应的两个IPSec SA。In the present invention, it is determined whether the IPSec tunnel established by the communication parties is available by inquiring whether the communication parties establishing the IPSec tunnel have the same IPSec SA. When an IPSec tunnel is established, two IPSec SAs will be generated at the same time. Here, it is assumed that the two parties establishing the IPSec tunnel are: A and B, and the two generated IPSec SAs are 1 and 2 respectively; if IPSec SA1 is the outbound direction SA of A , IPSec SA2 is the inbound SA of A; then IPSec SA1 is the inbound SA of B, and IPSec SA2 is the outbound SA of B. Here, the difference between the outbound SA and the inbound SA of the communication party of each IPSec tunnel is that the communication party uses the key in the outbound SA to encrypt the sent data; uses the key in the inbound SA to decrypt the received data. Here, the existence of the same IPSec SA between the two communicating parties means that both communicating parties simultaneously have two IPSec SAs corresponding to the IPSec tunnel.

由于为建立IPSec隧道而产生的两个IPSec SA是同时存在的,因此在本发明中,可以通过确定通信双方是否同时存在其中一个IPSec SA,确定通信双方是否存在两个相同的IPSec SA,进而确定通信双方建立的IPSec隧道是否可用。Since the two IPSec SAs generated for establishing an IPSec tunnel exist simultaneously, in the present invention, it is possible to determine whether two identical IPSec SAs exist at both parties by determining whether there is one IPSec SA at the same time at both parties of communication, and then determine Whether the IPSec tunnel established by the communication parties is available.

由于,IPSec SA是通过安全参数索引(SPI)、目的IP地址和安全协议组成的三元组来唯一标识。因此,这里IPSec SA相同的含义即为:通信双方具有相同三元组的IPSec SA。由于对应于同一IPSec隧道的两个IPSec SA是同时产生、同时存在、并且相互绑定的,因此这两个IPSec SA三元组均可以单独唯一标识IPSec隧道,因此这两个IPSec SA的三元组均可以称为IPSec隧道的特征参数。Because, IPSec SA is uniquely identified by the triplet composed of Security Parameter Index (SPI), destination IP address and security protocol. Therefore, the meaning of the same IPSec SA here is: both communication parties have IPSec SAs with the same triplet. Since two IPSec SAs corresponding to the same IPSec tunnel are generated, exist at the same time, and are bound to each other, these two IPSec SA triples can uniquely identify the IPSec tunnel alone, so the triplets of these two IPSec SAs Each group can be called a characteristic parameter of the IPSec tunnel.

为使本发明的目的、技术方案及优点更加清楚明白,在发明中列举两个实施例,对本发明做进一步的详细说明。In order to make the object, technical solution and advantages of the present invention clearer, two embodiments are listed in the invention, and the present invention is further described in detail.

这两个实施例的主要区别在于,实施例一为:在一次查询过程中仅查询通信双方建立的一条IPSec隧道;实施例二为:在一次的查询过程中查询通信双方建立的一条以上的IPSec隧道。以下分别对这两个实施例进行详细说明。The main difference between these two embodiments is that the first embodiment is: only one IPSec tunnel established by both communication parties is inquired in a query process; the second embodiment is: more than one IPSec tunnel established by both communication parties is inquired in a query process. tunnel. The two embodiments are described in detail below respectively.

实施例一Embodiment one

当通信双方建立的IPSec隧道长时间没有数据流量时,通信的一方在发起数据传输之前,则必须先确认自身到对端的IPSec隧道是否可用。这里,为方便描述,将通信的发起方,在本发明中为查询的发起方,称为查询方;将通信发起方欲进行数据传输的对端,即查询的应答者,称为应答方。在实际的应用过程中,还可以在查询方每次发起通信之前,均查询自身当前所需使用的IPSec隧道是否可用。具体查询IPSec隧道是否可用的流程如图1所示:When the IPSec tunnel established by the communication parties has no data traffic for a long time, the communication party must first confirm whether the IPSec tunnel from itself to the peer end is available before initiating data transmission. Here, for the convenience of description, the initiator of the communication, which is the initiator of the query in the present invention, is called the inquiring party; the opposite end to which the communication initiator intends to transmit data, that is, the responder of the query, is called the responding party. In an actual application process, before each time the inquiring party initiates communication, it may also inquire whether the IPSec tunnel it currently needs to use is available. The process of specifically querying whether an IPSec tunnel is available is shown in Figure 1:

步骤101:查询方向应答方发送IPSec隧道查询消息,IPSec隧道查询消息中携带自身当前即将使用的IPSec隧道的特征参数。Step 101: The queryer sends an IPSec tunnel query message to the responder, and the IPSec tunnel query message carries characteristic parameters of the IPSec tunnel that it will use currently.

这里的特征参数可以是查询方的出方向SA三元组、也可以是查询方入方向SA三元组。为了简化描述,在下文中将IPSec隧道的两个IPSec SA统称为IPSec隧道SA,如果在IPSec隧道查询消息中使用的特征参数是出方向SA三元组,则相应的IPSec隧道SA为出方向SA;如果在IPSec隧道查询消息中使用的特征参数是入方向SA三元组,则相应的IPSec隧道SA为入方向SA。The characteristic parameter here may be the SA triplet in the outbound direction of the inquiring party, or the SA triplet in the inbound direction of the inquiring party. In order to simplify the description, the two IPSec SAs of the IPSec tunnel are collectively referred to as the IPSec tunnel SA in the following. If the characteristic parameter used in the IPSec tunnel query message is an outbound SA triplet, the corresponding IPSec tunnel SA is the outbound SA; If the characteristic parameter used in the IPSec tunnel query message is an inbound SA triplet, then the corresponding IPSec tunnel SA is an inbound SA.

IPSec隧道查询消息的数据格式,可以继承IKE DPD消息的格式,也可以采用自定义的格式。如果继承IKE DPD消息格式,则可以采用如表1所示的格式。The data format of the IPSec tunnel query message can inherit the format of the IKE DPD message, or can adopt a self-defined format. If the IKE DPD message format is inherited, the format shown in Table 1 can be used.

Figure C200610080569D00091
Figure C200610080569D00091

表1Table 1

表1所示的消息格式沿用了IKE DPD查询消息的消息格式架构。其中,每个字段的含义以及作用,均与原IKE DPD查询消息相同,在此不在赘述。由于本发明是通过查询IPSec SA的状态来确定对应IPSec隧道的状态,因此在查询消息中需携带用于查询IPSec SA状态的信息,进而在查询消息的相应字段内,也会存在不一样的内容,具体说明如下:The message format shown in Table 1 follows the message format architecture of the IKE DPD query message. Among them, the meaning and function of each field are the same as the original IKE DPD query message, and will not be repeated here. Since the present invention determines the state of the corresponding IPSec tunnel by querying the state of the IPSec SA, the query message needs to carry information for querying the state of the IPSec SA, and then in the corresponding field of the query message, there will also be different content , the details are as follows:

解释域(Domain of Interpretation,DOI)中填入的标准代码是用来对消息字段中各种数字含义进行说明,报文中每个数字代表什么样的含义是根据不同的标准确定,在IPSec协议栈中有两个标准,一个是isakmp标准,即IKE标准,代码为0,另一个是IPSec标准,即符合RFC 2407的标准,代码为1,由于本实施例中,是针对IPSec隧道的,因此这里填入1。载荷长度(Payload Length)字段中填入当前查询消息的长度,不包括该消息对应的报文头部。协议号(Protocol-ID)字段中填入当前查询IPSec隧道支持的安全协议,验证头协议(AH)或是封装安全载荷(ESP),即通过协议号字段携带IPSec SA三元组中的安全协议。SPI长度中填入,SPI的长度,为4字节。在消息类型字段中,填入本消息的消息类型,如果是IPSec隧道查询消息则填入IPSec-DPD-Request,如果是IPSec隧道响应消息则填入IPSec-DPD-Response。在SPI字段中,填入当前要查询IPSec隧道的SPI,即通过SPI字段携带IPSec SA三元组中的SPI。下一个载荷(Next Payload)字段填零,表明这个报文中只有一个载荷。保留字段(RESERVED)填零,表明保留位暂时不使用。通知数据(Notification Data)字段,填入这条消息的序列号。The standard code filled in the domain of interpretation (Domain of Interpretation, DOI) is used to explain the meaning of various numbers in the message field. The meaning of each number in the message is determined according to different standards. In the IPSec protocol There are two standards in the stack, one is the isakmp standard, that is, the IKE standard, and the code is 0, and the other is the IPSec standard, that is, the standard that complies with RFC 2407, and the code is 1. Since in this embodiment, it is for the IPSec tunnel, therefore Fill in 1 here. Fill in the length of the current query message in the Payload Length field, excluding the message header corresponding to the message. Fill in the protocol number (Protocol-ID) field to fill in the security protocol supported by the current query IPSec tunnel, authentication header protocol (AH) or encapsulating security payload (ESP), that is, carry the security protocol in the IPSec SA triplet through the protocol number field . Fill in the SPI length, the length of the SPI is 4 bytes. In the message type field, fill in the message type of this message, if it is an IPSec tunnel query message, fill in IPSec-DPD-Request, if it is an IPSec tunnel response message, fill in IPSec-DPD-Response. In the SPI field, fill in the SPI of the current IPSec tunnel to be queried, that is, carry the SPI in the IPSec SA triplet through the SPI field. The Next Payload (Next Payload) field is filled with zeros, indicating that there is only one payload in this message. The reserved field (RESERVED) is filled with zeros, indicating that the reserved bits are not used temporarily. In the Notification Data field, fill in the serial number of this message.

在此,将填入IPSec SA信息的查询消息称为IPSec DPD消息。由表1可以看出,在IPSec DPD消息中没有明显携带IPSec SA三元组中必须的目的IP地址信息,原因是:IPSec DPD消息由IP报文承载,由于IP报文的报文头中必定携带了该消息发往的目的IP地址,因此从节约资源的方面考虑,IPSec DPD就不需要另外设置目的IP地址字段,用来携带IPSec SA三元组中的目的IP地址。Here, the query message filled with IPSec SA information is called IPSec DPD message. It can be seen from Table 1 that the IPSec DPD message does not obviously carry the necessary destination IP address information in the IPSec SA triplet. It carries the destination IP address to which the message is sent, so from the aspect of saving resources, IPSec DPD does not need to additionally set the destination IP address field, which is used to carry the destination IP address in the IPSec SA triplet.

IPSec隧道查询消息还可以采用自定义的消息格式,不论自定义的消息格式采用何种的格式架构,只要在自定义的消息格式中携带需要查询IPSec隧道的SA三元组即可。如果采用自定义格式,则需要预先在通信双方的设备设置这个格式,使通信双方的设备均支持这中自定义的消息格式,以便在接收到该自定义的消息后,对消息进行识别、解析。The IPSec tunnel query message can also adopt a self-defined message format, no matter what format structure the self-defined message format adopts, as long as the self-defined message format carries the SA triplet that needs to query the IPSec tunnel. If you use a custom format, you need to set this format in advance on the devices of both parties in the communication, so that the devices of both parties in the communication support the custom message format, so that after receiving the custom message, the message can be identified and parsed .

步骤102:应答方接收查询方发送给自身的IPSec隧道查询消息,从接收到的IPSec隧道查询消息中获得携带的IPSec SA三元组。根据获得的IPSecSA三元组在自身设备的数据库中查找,判断是否存在相同的IPSec SA三元组,如果存在,则向查询方返回IPSec隧道查询成功消息;否则,则向查询方响应IPSec隧道查询失败消息。这里,IPSec隧道查询成功消息以及IPSec隧道查询失败消息,统称为IPSec隧道查询响应消息。Step 102: The answering party receives the IPSec tunnel query message sent to itself by the querying party, and obtains the carried IPSec SA triplet from the received IPSec tunnel query message. According to the obtained IPSec SA triplet, search in the database of its own device to determine whether there is the same IPSec SA triplet, and if it exists, return the IPSec tunnel query success message to the inquiring party; otherwise, respond to the IPSec tunnel query to the inquiring party failure message. Here, the IPSec tunnel query success message and the IPSec tunnel query failure message are collectively referred to as an IPSec tunnel query response message.

应答方从接收到的IPSec隧道查询消息中获得IPSec SA三元组为:应答方首先解析接收消息中的消息类型字段,判断是否为IPSec隧道查询消息,如果是,则根据每个字段所占字节数,按照现有技术的方法对IPSec隧道查询消息进行解析,获得其中携带的SPI和安全协议、以及IPSec隧道查询消息报文头中携带的目的IP地址;否则,根据获得消息的类型对接收到的消息进行相应处理。The answering party obtains the IPSec SA triplet from the received IPSec tunnel query message as follows: the responding party first parses the message type field in the received message, and judges whether it is an IPSec tunnel query message, and if so, according to the words occupied by each field According to the method in the prior art, the IPSec tunnel query message is parsed to obtain the SPI and security protocol carried therein and the destination IP address carried in the IPSec tunnel query message header; otherwise, according to the type of the obtained message, the receiving Received messages are processed accordingly.

应答方向查询方返回的IPSec隧道查询响应消息,也可以采用如表1所示的格式,具体为:The IPSec tunnel query response message returned by the responding direction to the inquiring party may also adopt the format shown in Table 1, specifically:

当应答方向查询方返回的IPSec隧道查询成功消息时,则将接收到的查询方发送的IPSec隧道查询消息中的消息类型改为IPSec-DPD-Response后,发送给查询方。When responding to the IPSec tunnel query success message returned by the inquiring party, the message type in the received IPSec tunnel query message sent by the inquiring party is changed to IPSec-DPD-Response, and then sent to the inquiring party.

当应答方向查询方返回的IPSec隧道查询失败消息,则将接收到的查询方发送的IPSec隧道查询消息中的消息类型改为IPSec-DPD-Response,并将其中的SPI和/或安全协议字段中的内容删除后,发送给查询方。When the IPSec tunnel query failure message returned by the responding direction to the inquiring party, the message type in the IPSec tunnel query message sent by the received inquiring party is changed to IPSec-DPD-Response, and the SPI and/or security protocol fields in it are changed to IPSec-DPD-Response After the content of is deleted, it is sent to the querying party.

这里,应答方还可以通过其他的方式向查询方返回IPSec隧道查询响应消息,例如,可以向查询方通过返回一个指令,指令中只需携带成功或者失败的指示。Here, the answering party may also return an IPSec tunnel query response message to the inquiring party in other ways, for example, may return an instruction to the inquiring party, and the instruction only needs to carry an indication of success or failure.

步骤103:根据应答方返回的IPSec隧道查询响应消息,查询方判断应答方是否存在相同的IPSec SA,即判断是收到了IPSec隧道查询成功消息还是IPSec隧道查询失败消息,如果存在,则确定查询方当前查询的IPSec隧道可用,查询方可以利用该IPSec隧道与应答方进行安全的数据通信;否则,确定查询方当前查询的IPSec隧道不可用,查询方则不能利用该IPSec隧道与应答方进行安全的数据通信,查询方则可以删除该IPSec隧道,以便重新建立与应答方之间的IPSec隧道。Step 103: According to the IPSec tunnel query response message returned by the responding party, the querying party judges whether the responding party has the same IPSec SA, that is, judges whether it has received the IPSec tunnel query success message or the IPSec tunnel query failure message, and if it exists, then determine the querying party The currently queried IPSec tunnel is available, and the inquiring party can use the IPSec tunnel to securely communicate with the responding party; otherwise, it is determined that the IPSec tunnel currently inquired by the inquiring party is unavailable, and the inquiring party cannot use the IPSec tunnel to securely communicate with the responding party. For data communication, the inquiring party can delete the IPSec tunnel in order to re-establish the IPSec tunnel with the responding party.

通常情况下,由于网络环境的恶劣、攻击者的攻击,以及其他一些因素,会导致查询方可能不能或延时接收到应答方返回的响应消息。这样就需要在查询方设置等待定时器以及等待时长,当等待定时器到达等待时长时,则视为应答方没有与查询方相同的IPSec SA,查询方则确定当前要查询的IPSec隧道不可用。具体实施过程可以是如下形式:Usually, due to a bad network environment, an attack by an attacker, and other factors, the inquiring party may not be able to or delay receiving the response message returned by the responding party. In this way, it is necessary to set the waiting timer and waiting time on the querying side. When the waiting timer reaches the waiting time, it is considered that the responding side does not have the same IPSec SA as the querying side, and the querying side determines that the IPSec tunnel to be queried is currently unavailable. The specific implementation process can be as follows:

查询方在发送IPSec隧道查询报文的同时,启动等待定时器;当等待定时器到达等待时长时,查询方判断自身是否已经接收到了应答方返回的IPSec隧道查询响应消息,如果收到了,则根据收到的IPSec隧道查询响应消息确定当前要查询的IPSec隧道的状态;否则,查询方则确定当前要查询的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程,即不再处理后续接收到的IPSec隧道查询响应消息。When the inquiring party sends the IPSec tunnel query message, it starts the waiting timer; when the waiting timer reaches the waiting time, the inquiring party judges whether it has received the IPSec tunnel querying response message returned by the responding party. The received IPSec tunnel query response message determines the status of the IPSec tunnel to be queried; otherwise, the inquiring party determines that the IPSec tunnel to be queried is unavailable, and ends the processing flow of currently querying the IPSec tunnel status, that is, no further processing of subsequent received IPSec tunnel query response message.

在充分考虑网络环境的恶劣以及网络攻击的存在,本实施例中在充分考虑当前查询IPSec隧道的有效性和可靠性的情况下,还可以设置查询定时器、查询周期以及最大查询次数,进行重复查询。其中,当查询定时器每次到达查询周期时,查询方则根据当前查询IPSec隧道的情况,确定是否需要再次发送IPSec隧道查询消息。这里,最大查询次数用来规定查询方总共可以发送IPSec隧道查询消息的次数。重复查询具体实施过程可以是如下形式:In full consideration of the harshness of the network environment and the existence of network attacks, in this embodiment, under the condition of fully considering the effectiveness and reliability of the current query IPSec tunnel, the query timer, query cycle and maximum number of queries can also be set to repeat Inquire. Wherein, when the query timer reaches the query period every time, the querying party determines whether to send the IPSec tunnel query message again according to the current situation of querying the IPSec tunnel. Here, the maximum number of queries is used to specify the total number of times that the query party can send IPSec tunnel query messages. The specific implementation process of repeated query can be in the following form:

查询方在发送IPSec隧道查询报文的同时,启动查询定时器,并开始对查询方向应答方发送的查询消息开始计数。当查询定时器到达查询周期时,查询方则判断自身是否已经确定了要查询IPSec隧道状态,如果已经确定,则查询定时器停止计时,结束当前查询流程;如果没有确定,查询方则再判断当前已经发送IPSec隧道查询消息的次数是否小于或等于设置的最大查询次数,如果不是,则查询定时器停止计时,结束当前查询流程,如果是,则再次向应答方发送IPSec隧道查询消息,并且在已经发送的查询消息数上加1。While sending the IPSec tunnel query message, the queryer starts the query timer and starts counting the query messages sent from the query to the responder. When the query timer reaches the query period, the inquiring party judges whether it has determined to query the status of the IPSec tunnel. If it is determined, the query timer stops timing and ends the current query process; Whether the number of times the IPSec tunnel query message has been sent is less than or equal to the set maximum number of queries, if not, the query timer stops counting, and the current query process ends, if yes, the IPSec tunnel query message is sent to the responder again, and after the Add 1 to the number of query messages sent.

在设置查询定时器以及查询周期的情况下,查询方在接收到应答方返回的IPSec隧道查询响应消息时,还可以进一步判断当前收到的响应消息是否为当前周期内发送的查询消息的响应消息,如果是,则处理当前接收到的响应消息;否则,不处理当前接收到的响应消息。为了简化描述,在本文中将IPSec隧道查询消息简称为查询消息;将IPSec隧道查询响应消息简称为响应消息。In the case of setting the query timer and query period, when the query party receives the IPSec tunnel query response message returned by the responder, it can further judge whether the currently received response message is the response message of the query message sent in the current period , if yes, process the currently received response message; otherwise, do not process the currently received response message. To simplify the description, the IPSec tunnel query message is referred to as query message for short in this document; the IPSec tunnel query response message is referred to as response message for short.

这里,判断当前收到的响应消息是否为当前周期内发送查询消息的响应消息,可以根据如下的方法:对每个查询消息进行编号,该编号能唯一标识该查询消息,并建立查询消息编号与查询次数一一对应的关系,在应答方响应查询消息时,在响应消息中携带对应查询消息的编号;查询方接收到应答方返回的响应消息后,判断当前收到的响应消息中携带的编号是否与当前的查询次数对应,如果对应,则处理当前接收到的响应消息;否则,不处理当前接收到的响应消息。其中,查询消息编号可以携带在表1中的通知数据字段内。这里,对查询消息的编号可以是当前记录的查询次数。Here, judging whether the currently received response message is a response message for sending a query message in the current period can be performed according to the following method: each query message is numbered, the number can uniquely identify the query message, and the query message number and There is a one-to-one relationship between query times. When the responder responds to the query message, it carries the number of the corresponding query message in the response message; after receiving the response message returned by the responder, the query party judges the number of Whether the number corresponds to the current number of queries, and if so, process the currently received response message; otherwise, do not process the currently received response message. Wherein, the query message number may be carried in the notification data field in Table 1. Here, the number of the query message may be the number of queries currently recorded.

这里,还可以仅对查询方收到应答方返回的IPSec隧道查询成功消息进行处理,不对查询方收到应答方返回的IPSec隧道查询失败消息进行处理,因为即使IPSec隧道查询失败消息是攻击者伪造,通信的双方只需重新建立IPSec隧道即可,通信质量以及通信的安全性并不会产生太大的影响。因此,在这种实施方式下,当查询方接收到的消息为IPSec隧道查询成功消息时,再进一步判断当前收到的IPSec隧道查询成功消息是否为当前周期内发送的查询消息的响应消息,如果是,则处理当前接收到的IPSec隧道查询成功消息;否则,不处理当前接收到的IPSec隧道查询成功消息。Here, it is also possible to process only the IPSec tunnel query success message returned by the inquiring party to the responder, and not to process the IPSec tunnel query failure message returned by the inquiring party to the responder, because even if the IPSec tunnel query failure message is forged by an attacker , the two sides of the communication only need to re-establish the IPSec tunnel, and the communication quality and security of the communication will not be greatly affected. Therefore, under this implementation mode, when the message received by the inquiring party is an IPSec tunnel query success message, it is further judged whether the currently received IPSec tunnel query success message is a response message to the query message sent in the current period, if If yes, process the currently received IPSec tunnel query success message; otherwise, do not process the currently received IPSec tunnel query success message.

在步骤102中,应答方不存在相同的IPSec SA三元组时,还可以不向查询方返回任何消息,即通过不返回消息的方式向查询方表示自身不存在相同的IPSec SA三元组。那么在这种情况下,就需要查询方在发送IPSec隧道查询报文的同时,启动等待定时器;当等待定时器到达等待时长时,查询方判断自身是否已经接收到了应答方返回的IPSec隧道查询响应消息,如果收到了,则根据收到的IPSec隧道查询响应消息确定消息对应的隧道可用;否则,查询方则确定当前要查询的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程。In step 102, when the responding party does not have the same IPSec SA triple, it may also not return any message to the querying party, that is, to indicate to the querying party that it does not have the same IPSec SA triple by not returning a message. Then in this case, the inquiring party needs to start the waiting timer while sending the IPSec tunnel query message; when the waiting timer reaches the waiting time, the inquiring party judges whether it has received the IPSec tunnel query returned by the responding party. If the response message is received, it is determined that the tunnel corresponding to the message is available according to the received IPSec tunnel query response message; otherwise, the inquiring party determines that the current IPSec tunnel to be queried is unavailable, and ends the current processing flow of querying the IPSec tunnel status.

在应答方通过不返回消息的方式向查询方表示自身不存在相同的IPSecSA三元组时,也可以设置查询定时器、查询周期以及最大查询次数,进行重复查询。重复查询的过程如上所述,在此不再赘述。When the answering party indicates to the inquiring party that it does not have the same IPSecSA triplet by not returning a message, it can also set the query timer, query cycle and maximum query times to perform repeated queries. The process of repeated query is as described above, and will not be repeated here.

在本实施例中,除了可以在查询方需要使用与应答方之间的IPSec隧道之前,触发查询方查询自身与应答方之间IPSec隧道的状态,还可以进行周期性的查询,即设置定时器,当定时器到达触发周期时,即触发查询方查询与应答方之间的IPSec隧道。In this embodiment, in addition to triggering the inquiring party to inquire about the state of the IPSec tunnel between itself and the responding party before the inquiring party needs to use the IPSec tunnel with the responding party, it is also possible to perform periodic inquiries, that is, to set a timer , when the timer reaches the trigger period, the IPSec tunnel between the inquiring party and the responding party is triggered.

在本发明中,将周期性对IPSec隧道的查询以及在需要发送消息前对IPSec隧道的查询,称为查询IPSec隧道的时机。In the present invention, the periodic query of the IPSec tunnel and the query of the IPSec tunnel before a message needs to be sent are referred to as the timing of querying the IPSec tunnel.

实施例二Embodiment two

本实施例介绍的是:查询方通过一条IPSec隧道查询消息查询一条以上自身与应答方之间的IPSec隧道状态。具体过程如图2所示:This embodiment introduces that: the inquiring party queries the status of more than one IPSec tunnel between itself and the responding party through an IPSec tunnel query message. The specific process is shown in Figure 2:

步骤201:查询方向应答方发送IPSec隧道查询消息,IPSec隧道查询消息中携带当前需要查询的一条以上IPSec隧道SA三元组。Step 201: The queryer sends an IPSec tunnel query message to the responder, and the IPSec tunnel query message carries more than one IPSec tunnel SA triplet currently to be queried.

IPSec隧道查询消息的数据格式,可以继承IKE DPD消息的格式、也可以采用自定义的格式。如果继承IKE DPD消息格式,则可以采用如表2所示的格式。The data format of the IPSec tunnel query message can inherit the format of the IKE DPD message or adopt a self-defined format. If the IKE DPD message format is inherited, the format shown in Table 2 can be used.

Figure C200610080569D00141
Figure C200610080569D00141

表2Table 2

表2中各字段的含义与表1中各字段的含义相同,在此不在赘述。表2与表1相比,只是增加了协议号字段、SPI长度字段、保留字段和SPI字段,用来携带更多的IPSec隧道SA的信息,具体增加的个数可以根据需要查询的IPSec隧道的个数进行确定。其中,增加的保留字段可以填零、也可以去掉。这里,在消息类型字段内,需填入IPSec-DPD-Multi-Request,用来表示查询方是针对多个IPSec隧道进行查询;相应的,应答方在使用相同的消息格式向查询方返回响应消息时,则需要在消息类型字段内填入IPSec-DPD-Multi-Response。The meaning of each field in Table 2 is the same as that of each field in Table 1, and will not be repeated here. Compared with Table 1, Table 2 only adds the protocol number field, SPI length field, reserved field and SPI field to carry more IPSec tunnel SA information. number is determined. Wherein, the added reserved fields may be filled with zeros or removed. Here, in the message type field, you need to fill in IPSec-DPD-Multi-Request, which is used to indicate that the inquiring party is querying for multiple IPSec tunnels; correspondingly, the responding party returns a response message to the inquiring party using the same message format , you need to fill in IPSec-DPD-Multi-Response in the message type field.

步骤202:应答方接收查询方发送给自身的IPSec隧道查询消息,从接收到的IPSec隧道查询消息中获得其中携带的多个IPSec SA的三元组。根据获得各IPSec SA的三元组在自身的数据库中查找,针对各IPSec SA三元组判断自身是否存在相同的IPSec SA三元组,针对存在相同的IPSec SA三元组向查询方返回IPSec隧道查询成功消息;针对不存在相同的IPSec SA三元组向查询方返回IPSec隧道查询失败消息。Step 202: The answering party receives the IPSec tunnel query message sent to itself by the inquiring party, and obtains triplets of multiple IPSec SAs carried in the received IPSec tunnel query message. Search in its own database according to the triplets of each IPSec SA, judge whether there is the same IPSec SA triplet for each IPSec SA triplet, and return the IPSec tunnel to the query party for the existence of the same IPSec SA triplet Query success message; return IPSec tunnel query failure message to the query party if there is no identical IPSec SA triple.

应答方解析收到报文的过程可以按照与实施例一中步骤102中所介绍的方法。The process of parsing the received message by the responding party may follow the method described in step 102 in the first embodiment.

这里,针对存在相同的IPSec SA三元组向查询方返回IPSec隧道查询成功消息;以及针对不存在相同的IPSec SA三元组向查询方返回IPSec隧道查询失败消息,可以是针对不同的IPSec SA三元组分别向查询方返回IPSec隧道查询成功或失败消息。例如,查询方当前查询自身与应答方之间的6个IPSec隧道,其中应答方针对第1、2和3条IPSec隧道均在自身查询到相同的IPSec SA三元组;而针对第4、5和6条IPSec隧道均没有查询到相同的IPSec SA三元组。则此时,应答方分别针对第1、2和3条IPSec隧道向查询方返回IPSec隧道查询成功消息,并同时分别针对第4、5和6条IPSec隧道向应答方返回IPSec隧道查询失败消息。Here, the IPSec tunnel query success message is returned to the inquiring party for the existence of the same IPSec SA triple; and the IPSec tunnel query failure message is returned to the inquiring party for the absence of the same IPSec SA triple. The tuple returns the success or failure message of the IPSec tunnel query to the querying party respectively. For example, the inquiring party currently inquires 6 IPSec tunnels between itself and the responding party, and the responding party finds the same IPSec SA triplet for the 1st, 2nd and 3rd IPSec tunnels; The same IPSec SA triplet was not queried for the six IPSec tunnels. Then, at this time, the responding party returns IPSec tunnel query success messages to the querying party for the 1st, 2nd and 3rd IPSec tunnels respectively, and simultaneously returns IPSec tunnel querying failure messages to the responding party respectively for the 4th, 5th and 6th IPSec tunnels.

应答方还可以通过一条消息,将当前查询方和应答方之间各IPSec隧道的查询情况一起返回给查询方。当查询方接收到应答方返回的响应消息时,查询方则可以根据响应消息中携带的内容确定要查询的各IPSec隧道的状态。The answering party may also return the current inquiry status of each IPSec tunnel between the inquiring party and the responding party to the inquiring party through a message. When the inquiring party receives the response message returned by the responding party, the inquiring party can determine the status of each IPSec tunnel to be queried according to the content carried in the response message.

应答方通过一条消息向查询方返回响应消息的格式也可以是如表2所示的格式。具体的方法可以是通过在每个SPI字段增加后再一个字段,以表示在前的SPI字段所对应IPSec SA是否查询成功;也可以对于查询成功的IPSec SA保留SPI和协议号,对于查询失败的IPSec SA删除SPI或协议号。The format in which the responding party returns a response message to the querying party through a message may also be in the format shown in Table 2. The specific method can be to add another field after each SPI field to indicate whether the IPSec SA corresponding to the previous SPI field is successfully queried; it is also possible to reserve the SPI and protocol number for the IPSec SA that is queried successfully, and for the IPSec SA that fails to query IPSec SA removes SPI or protocol number.

步骤203:查询方接收应答方返回的响应消息,并根据响应消息中各IPSec隧道的查询情况,确定当前需要查询的各IPSec隧道的状态。Step 203: the inquiring party receives the response message returned by the responding party, and determines the status of each IPSec tunnel that needs to be queried currently according to the query status of each IPSec tunnel in the response message.

例如,如果应答方通过一条消息向查询方返回响应消息,第1、2和3条IPSec隧道均在自身查询到相同的IPSec SA三元组,而针对第4、5和6条IPSec隧道均没有查询到相同的IPSec SA三元组;则查询方根据消息的内容确定,应答方查询IPSec隧道1、2和3成功,而查询IPSec隧道4、5和6失败,则查询方确定IPSec隧道1、2和3的状态为可用,IPSec隧道4、5和6为不可用。For example, if the responder returns a response message to the inquiring party through a message, the 1st, 2nd and 3rd IPSec tunnels all query the same IPSec SA triplet in themselves, but for the 4th, 5th and 6th IPSec tunnels, none If the same IPSec SA triple is queried; the inquiring party determines according to the content of the message, the responding party succeeds in inquiring about IPSec tunnels 1, 2 and 3, but fails in inquiring about IPSec tunnels 4, 5 and 6, then the inquiring party determines that IPSec tunnels 1, The statuses of 2 and 3 are available, and IPSec tunnels 4, 5, and 6 are unavailable.

如果应答方针对每条IPSec隧道返回响应消息,则查询方根据每条响应消息,确定该条消息对应的IPSec隧道的状态,在这种情况下,可以参见实施例一中的步骤103。If the responding party returns a response message for each IPSec tunnel, the querying party determines the status of the IPSec tunnel corresponding to the message according to each response message. In this case, refer to step 103 in the first embodiment.

在实施例二中,当应答方通过一条消息向查询方返回响应消息时,也可以和实施例一相同设置等待定时器以及等待时长,当等待定时器到达等待时长时,判断自身是否已经接收到了应答方返回的IPSec隧道查询响应消息,如果收到了,则根据IPSec隧道响应消息中各IPSec隧道的查询情况,确定当前各IPSec隧道的状态;否则,查询方则确定当前要查询的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程。In the second embodiment, when the responding party returns a response message to the querying party through a message, it can also set the waiting timer and the waiting time length in the same way as in the first embodiment. When the waiting timer reaches the waiting time, it judges whether it has received If the IPSec tunnel query response message returned by the responding party is received, the status of each IPSec tunnel is determined according to the query status of each IPSec tunnel in the IPSec tunnel response message; otherwise, the querying party determines that the IPSec tunnel to be queried is currently unavailable to end the current process of querying the status of the IPSec tunnel.

当应答方采用针对不同IPSec隧道分别向查询方返回IPSec隧道查询成功或失败消息时,也可以和实施例一相同设置等待定时器以及等待时长,当等待定时器到达等待时长时,根据自身当前已收到的响应消息,确定响应消息所对应IPSec隧道的状态;如果针对某些IPSec隧道应答方没有返回响应消息,则确定没有返回响应消息所对应的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程。When the answering party returns the IPSec tunnel query success or failure message to the querying party respectively for different IPSec tunnels, it can also set the waiting timer and the waiting time length in the same way as in Embodiment 1. When the waiting timer reaches the waiting time length, according to its own current The received response message determines the state of the IPSec tunnel corresponding to the response message; if the responder does not return a response message for some IPSec tunnels, it is determined that the IPSec tunnel corresponding to the response message is not returned is unavailable, and ends the current query of the IPSec tunnel state processing flow.

当应答方采用针对不同IPSec隧道分别向查询方返回IPSec隧道查询成功或失败消息时,在实施例二中,还可以和实施例一相同进行重复查询,设置查询定时器、查询周期以及查询次数。查询方在发送IPSec隧道查询报文的同时,启动查询定时器,并开始对查询方向应答方发送的查询消息开始计数。当查询定时器到达查询周期时,查询方则判断自身是否已经确定了所有要查询IPSec隧道的状态,如果所有要查询IPSec隧道的状态都已经确定,则查询定时器停止计时,结束当前查询流程;在要查询的IPSec隧道中只要存在一条IPSec隧道的状态没有确定,查询方则再判断当前已经发送IPSec隧道查询消息的次数是否小于或等于设置的最大查询次数,如果不是,则查询定时器停止计时,结束当前查询流程,如果是,则再次向应答方发送IPSec隧道查询消息,其中携带当前没有确定可用状态的IPSec隧道的SA三元组,并且在已经发送的查询消息数上加1。When the answering party returns the success or failure message of the IPSec tunnel inquiry to the inquiring party respectively for different IPSec tunnels, in embodiment two, it is also possible to repeat the same query as in embodiment one, and set the query timer, query cycle and query times. While sending the IPSec tunnel query message, the queryer starts the query timer and starts counting the query messages sent from the query to the responder. When the query timer reaches the query period, the inquiring party judges whether it has determined the status of all IPSec tunnels to be queried. If all the statuses of the IPSec tunnels to be queried have been determined, the query timer stops timing and ends the current query process; As long as there is an IPSec tunnel whose status is not confirmed in the IPSec tunnel to be queried, the inquiring party will then judge whether the number of times the IPSec tunnel query message has been sent is less than or equal to the maximum number of queries set, if not, the query timer stops counting , end the current query process, if yes, send the IPSec tunnel query message to the responder again, which carries the SA triplet of the IPSec tunnel that is currently not confirmed to be available, and add 1 to the number of query messages that have been sent.

当设置查询定时器以及查询周期的情况下,查询方在接收到应答方返回的IPSec隧道查询响应消息时,还可以进一步判断当前收到的响应消息是否为当前周期内发送的查询消息的响应消息,如果是,则处理当前接收到的响应消息;否则,不处理当前接收到的响应消息。When the query timer and query period are set, the queryer can further judge whether the currently received response message is the response message of the query message sent in the current period when receiving the IPSec tunnel query response message returned by the responder , if yes, process the currently received response message; otherwise, do not process the currently received response message.

这里,还可以仅对查询方收到应答方返回的IPSec隧道查询成功消息进行处理,不对查询方收到应答方返回的IPSec隧道查询失败消息进行处理,因为即使IPSec隧道查询失败消息是攻击者伪造,通信的双方只需重新建立IPSec隧道即可,并通信质量以及通信的安全性并不会产生太大的影响。因此,在这种实施方式下,当查询方接收到的消息为IPSec隧道查询成功消息时,才进一步判断当前收到的IPSec隧道查询成功消息是否为当前周期内发送的查询消息的响应消息,如果是,则处理当前接收到的IPSec隧道查询成功消息;否则,不处理当前接收到的IPSec隧道查询成功消息。Here, it is also possible to process only the IPSec tunnel query success message returned by the inquiring party to the responder, and not to process the IPSec tunnel query failure message returned by the inquiring party to the responder, because even if the IPSec tunnel query failure message is forged by an attacker , the two sides of the communication only need to re-establish the IPSec tunnel, and the communication quality and communication security will not be greatly affected. Therefore, in this implementation mode, when the message received by the inquiring party is an IPSec tunnel query success message, it is further judged whether the currently received IPSec tunnel query success message is a response message to the query message sent in the current cycle, if If yes, process the currently received IPSec tunnel query success message; otherwise, do not process the currently received IPSec tunnel query success message.

在实施例二中,在应答方不存在要查询IPSec的IPSec SA三元组时,也可以采用实施例一中的处理方式,即通过不返回响应消息的方式向查询方表示自身不存在要查询IPSec隧道的IPSec SA三元组。则此时需要设置等待定时器以及等待时长。在应答方通过一条消息向查询方返回响应消息的情况下,当等待定时器到达等待时长时,查询方判断自身是否已经接收到了应答方返回的IPSec隧道查询响应消息,如果收到了,则根据IPSec隧道响应消息中各IPSec隧道的查询情况,确定当前各IPSec隧道的状态;否则,查询方则确定当前要查询的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程。在应答方采用针对不同IPSec隧道分别向查询方返回IPSec隧道查询成功或失败消息的情况下,也需要设置等待定时器以及等待时长,当等待定时器到达等待时长时,根据自身当前已收到的响应消息,确定响应消息所对应IPSec隧道的状态;如果针对某些IPSec隧道应答方没有返回响应消息,则确定没有返回响应消息所对应的IPSec隧道不可用,结束当前查询IPSec隧道状态的处理流程。In Embodiment 2, when the responding party does not have an IPSec SA triple to query IPSec, the processing method in Embodiment 1 may also be used, that is, to indicate to the querying party that it does not exist to query by not returning a response message. IPSec SA triplet of the IPSec tunnel. At this time, it is necessary to set the waiting timer and the waiting time. When the answering party returns a response message to the inquiring party through a message, when the waiting timer reaches the waiting time, the inquiring party judges whether it has received the IPSec tunnel query response message returned by the responding party. The query status of each IPSec tunnel in the tunnel response message determines the current status of each IPSec tunnel; otherwise, the inquiring party determines that the current IPSec tunnel to be queried is unavailable, and ends the current processing flow of querying the IPSec tunnel status. In the case that the answering party returns IPSec tunnel query success or failure messages to the querying party for different IPSec tunnels, it also needs to set the waiting timer and the waiting time length. When the waiting timer reaches the waiting time length, according to the received The response message determines the state of the IPSec tunnel corresponding to the response message; if the responder does not return a response message for some IPSec tunnels, it is determined that the IPSec tunnel corresponding to the response message is not returned is unavailable, and ends the current processing flow of querying the state of the IPSec tunnel.

当应答方针对分别各要查询的IPSec隧道向查询方返回IPSec隧道查询成功消息或不返回响应消息时,也可以设置查询定时器、查询周期以及查询次数进行重复查询,具体过程与实施例二中的重复查询相同,在此不再赘述。When the answering party returns an IPSec tunnel query success message or does not return a response message to the querying party for each IPSec tunnel to be queried, it can also set the query timer, query cycle and query times to perform repeated queries. The specific process is the same as in the second embodiment The repeated queries are the same, and will not be repeated here.

在本发明中,当应答方查询IPSec SA三元组不成功时,有两种实现方式,一种是向查询方返回IPSec隧道查询失败消息,一种是不向查询方返回任何消息,这两种实现方式可以统称为应答方向查询方响应失败。In the present invention, when the answering party is unsuccessful in inquiring about the IPSec SA triplet, there are two implementations, one is to return an IPSec tunnel query failure message to the inquiring party, and the other is not to return any message to the inquiring party. These two implementations can be collectively referred to as failure to respond to the inquiring party in the responding direction.

在本发明中,除了可以通过确定通信双方是否存在其中一个IPSec SA,确定通信双方是否存在两个相同的IPSec SA,进而确定通信双方建立的IPSec隧道是否可用;还可以同时确定通信双方是否存在两个相同的IPSecSA,确定通信双方建立的IPSec隧道是否可用。即在IPSec隧道查询消息中同时携带查询方的出方向SA三元组和入方向SA三元组,再由应答方同时检查两个SA的三元组是否存在,进而确定通信双方建立的IPSec隧道是否可用,这里其他的处理过程与实施例一和实施例二中所述的过程相同,在此不再详述。In the present invention, in addition to determining whether there is one IPSec SA in both communication parties, determine whether there are two identical IPSec SAs in both communication parties, and then determine whether the IPSec tunnel established by both communication parties is available; the same IPSecSA to determine whether the IPSec tunnel established by the communication parties is available. That is, the IPSec tunnel query message carries the inquiring party's outbound SA triplet and inbound SA triplet at the same time, and then the responder checks whether the two SA triplets exist at the same time, and then determines the IPSec tunnel established by the two communicating parties. Whether it is available or not, other processing procedures here are the same as those described in Embodiment 1 and Embodiment 2, and will not be described in detail here.

以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention.

Claims (10)

1、一种查询IPSec隧道状态的方法,其特征在于,该方法包括以下步骤:1. A method for inquiring about the state of an IPSec tunnel, characterized in that the method may further comprise the steps: A、查询方向应答方发送IPSec隧道查询消息,IPSec隧道查询消息中携带至少一条要查询的IPSec隧道的特征参数;A. The query direction sends an IPSec tunnel query message to the responding party, and the IPSec tunnel query message carries at least one characteristic parameter of the IPSec tunnel to be queried; B、应答方获得IPSec隧道查询消息中携带的特征参数,查询自身是否存在相同的特征参数,并将查询结果返回给查询方;B. The responding party obtains the characteristic parameter carried in the IPSec tunnel query message, inquires whether the same characteristic parameter exists in itself, and returns the query result to the inquiring party; C、查询方根据应答方返回的查询结果,当应答方存在相同的特征参数时,则确定所述相同的特征参数对应的IPSec隧道可用;当应答方不存在相同的特征参数时,则确定所述不存在相同的特征参数对应的IPSec隧道不可用。C. According to the query result returned by the responding party, when the responding party has the same characteristic parameter, it is determined that the IPSec tunnel corresponding to the same characteristic parameter is available; when the responding party does not have the same characteristic parameter, it is determined that the corresponding The IPSec tunnel that does not have the same characteristic parameters as above is unavailable. 2、根据权利要求1所述的方法,其特征在于,当要查询一条以上IPSec隧道时,步骤B中,所述将查询结果返回给查询方为:2. The method according to claim 1, wherein when more than one IPSec tunnel is to be queried, in step B, the query result returned to the query party is: 通过一条消息将一条以上IPSec隧道的查询结果返回给查询方;或Return the query results of more than one IPSec tunnel to the querying party in one message; or 针对每条IPSec隧道,分别向查询方返回一条查询结果。For each IPSec tunnel, return a query result to the querying party. 3.根据权利要求1所述的方法,其特征在于,步骤B中,所述将查询结果返回给查询方为:3. The method according to claim 1, characterized in that, in step B, returning the query result to the querying party is: 当应答方存在相同的特征参数时,则针对所述相同的特征参数向查询方返回IPSec隧道查询成功消息;When the answering party has the same characteristic parameter, then return an IPSec tunnel query success message to the inquiring party for the same characteristic parameter; 当应答方不存在相同的特征参数时,则针对所述不存在相同的特征参数向查询方响应失败。When the responding party does not have the same characteristic parameter, it fails to respond to the inquiring party regarding the absence of the same characteristic parameter. 4、根据权利要求3所述的方法,其特征在于,所述响应失败为:应答方向查询方返回IPSec隧道查询失败消息。4. The method according to claim 3, wherein the response failure is: the responder returns an IPSec tunnel query failure message to the inquiring party. 5、根据权利要求3所述的方法,其特征在于,进一步设置等待定时器及等待时长,当查询方发送IPSec隧道查询消息时,启动等待定时器;5. The method according to claim 3, characterized in that a waiting timer and a waiting period are further set, and when the inquiring party sends an IPSec tunnel query message, the waiting timer is started; 步骤B中,所述响应失败为:当应答方不存在要查询IPSec隧道的特征参数时,不向查询方返回查询结果;In step B, the response failure is: when the responding party does not have the characteristic parameters to query the IPSec tunnel, the query result is not returned to the querying party; 步骤C中,所述当应答方存在相同的特征参数时,则确定所述相同的特征参数对应的IPSec隧道可用为:当等待定时器到达等待时长时,查询方收到了查询结果,则确定所述查询结果对应的IPSec隧道可用;所述当应答方不存在相同的特征参数时,则确定所述不存在相同的特征参数对应的IPSec隧道不可用为:当等待定时器到达等待时长时,查询方未收到查询结果,则确定所述查询结果对应的IPSec隧道不可用。In step C, when the responding party has the same characteristic parameter, it is determined that the IPSec tunnel corresponding to the same characteristic parameter can be used as follows: when the waiting timer reaches the waiting time, the inquiring party receives the query result, then determines that the IPSec tunnel corresponding to the same characteristic parameter is: The IPSec tunnel corresponding to the query result is available; when the responder does not have the same characteristic parameter, then determining that the IPSec tunnel corresponding to the same characteristic parameter does not exist is unavailable: when the waiting timer reaches the waiting time, query If the party does not receive the query result, it is determined that the IPSec tunnel corresponding to the query result is unavailable. 6、根据权利要求1、3、4或5所述的方法,其特征在于,进一步设置查询定时器以及查询周期,步骤A中当查询方发送IPSec隧道查询消息时,启动查询定时器;6. The method according to claim 1, 3, 4 or 5, wherein a query timer and a query period are further set, and in step A, when the querying party sends an IPSec tunnel query message, the query timer is started; 当查询定时器到达查询周期时,判断当前要查询IPSec隧道的状态是否已经确定,如果是,则查询定时器停止计时;否则,查询方针对没有确定状态的IPSec隧道发送IPSec隧道查询消息。When the query timer reaches the query period, it is judged whether the state of the IPSec tunnel to be queried is determined, and if so, the query timer stops counting; otherwise, the querying party sends an IPSec tunnel query message for the IPSec tunnel without a certain state. 7、根据权利要求6所述的方法,其特征在于,进一步设置最大查询次数,对查询方发送的IPSec隧道查询消息进行计数,7. The method according to claim 6, characterized in that the maximum number of queries is further set to count the IPSec tunnel query messages sent by the querying party, 在查询方针对没有确定状态的IPSec隧道发送IPSec隧道查询消息之前,进一步判断当前发送的IPSec隧道查询消息是否小于或等于最大查询次数,如果是,则执行所述发送IPSec隧道查询消息;否则,结束当前处理流程。Before the inquiring party sends the IPSec tunnel query message for the IPSec tunnel that does not have a definite state, further judge whether the currently sent IPSec tunnel query message is less than or equal to the maximum number of queries, if yes, then execute the sending IPSec tunnel query message; otherwise, end current processing flow. 8、根据权利要求6所述的方法,其特征在于,在步骤C之前,进一步包括:8. The method according to claim 6, characterized in that, before step C, further comprising: 判断应答方返回的查询结果是否为当前查询周期内查询方发送查询消息的响应,如果是,则执行步骤C;否则,拒绝处理当前应答方返回的查询结果。Determine whether the query result returned by the responding party is the response to the query message sent by the querying party in the current query period, and if so, perform step C; otherwise, refuse to process the query result returned by the current responding party. 9、根据权利要求1所述的方法,其特征在于,当查询方需要向应答方发送数据或查询周期到达时,执行步骤A。9. The method according to claim 1, characterized in that step A is performed when the inquiring party needs to send data to the responding party or the inquiry period is reached. 10、根据权利要求1所述的方法,其特征在于,所述特征参数为:10. The method according to claim 1, wherein the characteristic parameters are: IPSec隧道出方向安全联盟的安全参数索引、目的IP地址、和安全协议;The security parameter index, destination IP address, and security protocol of the SA in the outbound direction of the IPSec tunnel; 或IPSec隧道入方向安全联盟的安全参数索引、目的IP地址、和安全协议;Or the security parameter index, destination IP address, and security protocol of the SA in the inbound direction of the IPSec tunnel; 或IPSec隧道出方向安全联盟的安全参数索引、目的IP地址、和安全协议,和入方向安全联盟的安全参数索引、目的IP地址、和安全协议。Or the security parameter index, destination IP address, and security protocol of the SA in the outbound direction of the IPSec tunnel, and the security parameter index, destination IP address, and security protocol of the SA in the inbound direction of the IPSec tunnel.
CNB2006100805699A 2006-05-17 2006-05-17 Method for enquiring IPSec tunnel state Expired - Fee Related CN100488204C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100805699A CN100488204C (en) 2006-05-17 2006-05-17 Method for enquiring IPSec tunnel state

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100805699A CN100488204C (en) 2006-05-17 2006-05-17 Method for enquiring IPSec tunnel state

Publications (2)

Publication Number Publication Date
CN1845549A CN1845549A (en) 2006-10-11
CN100488204C true CN100488204C (en) 2009-05-13

Family

ID=37064462

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100805699A Expired - Fee Related CN100488204C (en) 2006-05-17 2006-05-17 Method for enquiring IPSec tunnel state

Country Status (1)

Country Link
CN (1) CN100488204C (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101521602B (en) * 2008-02-29 2012-09-05 上海博达数据通信有限公司 Realizing method for utilizing IKE to monitor the state of communication nodes in IPSec VPN
CN103716196B (en) * 2012-09-28 2018-10-09 新华三技术有限公司 A kind of network equipment and detection method
WO2016106589A1 (en) * 2014-12-30 2016-07-07 华为技术有限公司 Dead peer detection method, ipsec peer and network device
CN107682284B (en) 2017-08-02 2021-06-01 华为技术有限公司 Method and network device for sending message
CN111641545B (en) * 2020-05-15 2022-06-21 深信服科技股份有限公司 Tunnel detection method and device, equipment and storage medium
CN112737965B (en) * 2020-12-31 2022-12-23 网络通信与安全紫金山实验室 Method, system and computer readable storage medium for solving problem of limitation of concurrent access network element

Also Published As

Publication number Publication date
CN1845549A (en) 2006-10-11

Similar Documents

Publication Publication Date Title
US6668282B1 (en) System and method to monitor and determine if an active IPSec tunnel has become disabled
US6816462B1 (en) System and method to determine connectivity of a VPN secure tunnel
US11159361B2 (en) Method and apparatus for providing notification of detected error conditions in a network
Ford et al. TCP extensions for multipath operation with multiple addresses
TWI362859B (en)
CN107682284B (en) Method and network device for sending message
US6915436B1 (en) System and method to verify availability of a back-up secure tunnel
Schulzrinne et al. GIST: general internet signalling transport
Lau et al. Layer two tunneling protocol-version 3 (L2TPv3)
EP1943802B1 (en) Method for protecting against denial of service attacks
US7472411B2 (en) Method for stateful firewall inspection of ICE messages
EP1746801A2 (en) Transmission of packet data over a network with a security protocol
CN102571497B (en) A kind of method, Apparatus and system of ipsec tunnel fault detect
CN102377524B (en) Fragment processing method and system
US20140095862A1 (en) Security association detection for internet protocol security
JP2004295891A (en) Method for authenticating packet payload
CN102546661B (en) A kind of method and system preventing IPv6 gateway neighbours spoofing attack
WO2006100970A1 (en) Method and system for providing internet key exchange (ike) during sip session
CN100488204C (en) Method for enquiring IPSec tunnel state
EP3599751B1 (en) Maintaining internet protocol security tunnels
CN116094978A (en) An information reporting method, information processing method and device
CN109600277B (en) IPSec tunnel keep-alive method and device based on NAT equipment
CN111641545B (en) Tunnel detection method and device, equipment and storage medium
JP2003244194A (en) Data encrypting apparatus, encryption communication processing method, and data relaying apparatus
CN115603994A (en) A trusted communication method, device, equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No.

Patentee after: Xinhua three Technology Co., Ltd.

Address before: 310053 Hangzhou hi tech Industrial Development Zone, Zhejiang province science and Technology Industrial Park, No. 310 and No. six road, HUAWEI, Hangzhou production base

Patentee before: Huasan Communication Technology Co., Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090513

Termination date: 20200517