[go: up one dir, main page]

CN106301997A - Gateway device response to network connectedness method and apparatus - Google Patents

Gateway device response to network connectedness method and apparatus Download PDF

Info

Publication number
CN106301997A
CN106301997A CN201510369825.5A CN201510369825A CN106301997A CN 106301997 A CN106301997 A CN 106301997A CN 201510369825 A CN201510369825 A CN 201510369825A CN 106301997 A CN106301997 A CN 106301997A
Authority
CN
China
Prior art keywords
message
address
gateway device
icmp message
icmp
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.)
Withdrawn
Application number
CN201510369825.5A
Other languages
Chinese (zh)
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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN201510369825.5A priority Critical patent/CN106301997A/en
Priority to PCT/CN2016/086017 priority patent/WO2017000790A1/en
Publication of CN106301997A publication Critical patent/CN106301997A/en
Withdrawn legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0811Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks

Landscapes

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

Abstract

The invention discloses a kind of gateway device response to network connectedness method, when receiving control protocol message i.e. icmp message between the net that terminal sends, line card obtains ip address, source and the purpose ip address of described icmp message;Mate with the ip address of the gateway device at its place in described purpose ip address, and when ip address, described source is mated with the IP address in the routing table of described gateway device, described line card generates response icmp message based on described icmp message;Described line card feeds back described response icmp message to described terminal.The invention also discloses a kind of gateway device response to network connectivity means.The present invention improves the speed of gateway device response terminal ping request.

Description

网关设备响应网络连通性方法和装置Gateway device response network connectivity method and device

技术领域technical field

本发明涉及计算机通讯领域,尤其涉及一种网关设备响应网络连通性方法和装置。The invention relates to the field of computer communication, in particular to a gateway device response network connectivity method and device.

背景技术Background technique

网络连通性检测技术ping技术是ip网络中用于测试网络连通性的一种技术。目前作为运营商或企业数据中心的网关设备基本上都是由主控和线卡组成的,网关设备在接收到终端发送的ping请求时,基本上都是通过线卡获取终端的控制协议报文icmp报文,然后线卡将获取到的icmp报文上报给主控的进行处理,而当大量终端用户同时ping网关设备时,且其它协议报文也在主控中处理时,网关设备的主控利用率会升高,导致主控处理icmp报文的时间过长,响应终端ping请求的时间也延长了,从而降低了网关设备响应终端ping请求的速度。Network connectivity detection technology ping technology is a technology used to test network connectivity in ip network. At present, the gateway equipment used as the operator or enterprise data center is basically composed of the main control and the line card. When the gateway equipment receives the ping request sent by the terminal, it basically obtains the control protocol message of the terminal through the line card. icmp message, and then the line card will report the obtained icmp message to the main control for processing, and when a large number of end users ping the gateway device at the same time, and other protocol messages are also processed in the main control, the main control of the gateway device The utilization rate of the controller will increase, causing the master controller to take too long to process the icmp message, and the time to respond to the terminal ping request is also prolonged, thereby reducing the speed of the gateway device responding to the terminal ping request.

发明内容Contents of the invention

本发明的主要目的在于提出一种网关设备响应网络连通性方法和装置,旨在解决大量终端用户同时ping网关设备时,网关设备响应终端ping请求的速度低的技术问题。The main purpose of the present invention is to propose a gateway device response network connectivity method and device, aiming to solve the technical problem that the gateway device responds to the terminal ping request at a low speed when a large number of terminal users ping the gateway device at the same time.

为实现上述目的,本发明提供的一种网关设备响应网络连通性方法,所述网关设备响应网络连通性方法包括以下步骤:In order to achieve the above object, the present invention provides a gateway device response network connectivity method, the gateway device response network connectivity method includes the following steps:

在接收到终端发送的网间控制协议报文即icmp报文时,线卡获取所述icmp报文的源ip地址和目的ip地址;When receiving the Internet control protocol message sent by the terminal, that is, the icmp message, the line card obtains the source ip address and the destination ip address of the icmp message;

在所述目的ip地址与其所在的网关设备的ip地址匹配,且所述源ip地址与所述网关设备的路由表中的IP地址匹配时,所述线卡基于所述icmp报文生成响应icmp报文;When the destination ip address matches the ip address of the gateway device where it is located, and the source ip address matches the IP address in the routing table of the gateway device, the line card generates a response icmp based on the icmp message message;

所述线卡反馈所述响应icmp报文至所述终端。The line card feeds back the response icmp message to the terminal.

优选地,所述线卡基于所述icmp报文生成响应icmp报文的步骤包括:Preferably, the step of generating a response icmp message based on the icmp message by the line card includes:

所述线卡计算所述icmp报文的校验和并判断所述校验和是否为0;The line card calculates the checksum of the icmp message and determines whether the checksum is 0;

若所述校验和为0,所述线卡互换所述icmp报文的源ip地址和目的ip地址;If the checksum is 0, the line card exchanges the source ip address and the destination ip address of the icmp message;

所述线卡计算互换ip地址后的icmp报文中icmp报文头的校验和,并将计算后的校验和写入到icmp报文头对应的位置;The line card calculates the checksum of the icmp header in the icmp message after the ip address is exchanged, and writes the calculated checksum into the corresponding position of the icmp header;

所述线卡计算整个icmp报文的校验和,并将计算后的校验和写入到icmp报文对应的位置;The line card calculates the checksum of the entire icmp message, and writes the calculated checksum into the corresponding position of the icmp message;

所述线卡将所述网络设备的mac地址作为源mac地址以及将所述终端对应的mac地址作为目的mac地址,并将所述源mac地址和目的mac地址封装至所述icmp报文中,以生成响应icmp报文。The line card uses the mac address of the network device as the source mac address and the mac address corresponding to the terminal as the destination mac address, and encapsulates the source mac address and the destination mac address into the icmp message, To generate a response icmp message.

优选地,所述线卡反馈所述响应icmp报文至所述终端的步骤包括:Preferably, the step of feeding back the response icmp message to the terminal by the line card includes:

所述线卡查找路由表中与所述源ip地址对应的下一跳表的输出端口;The line card looks up the output port of the next hop table corresponding to the source ip address in the routing table;

所述线卡将所述响应icmp报文通过所述输出端口发送给终端。The line card sends the response icmp message to the terminal through the output port.

优选地,所述在接收到终端发送的网间控制协议报文即icmp报文时,所述线卡获取所述icmp报文的源ip地址和目的ip地址的步骤之前,所述网关设备响应网络连通性方法包括:Preferably, when the Internet control protocol message sent by the terminal is received, that is, the icmp message, before the line card obtains the source ip address and the destination ip address of the icmp message, the gateway device responds Network connectivity methods include:

在接收到终端发送的报文时,所述线卡检测所述网关设备是否处于快速响应icmp报文的模式;When receiving the message sent by the terminal, the line card detects whether the gateway device is in the mode of quickly responding to the icmp message;

若检测到网关设备处于快速响应icmp报文的模式,所述线卡判断当前接收到的报文是否为icmp报文。If it is detected that the gateway device is in the mode of quickly responding to icmp messages, the line card judges whether the currently received message is an icmp message.

优选地,所述网关设备响应网络连通性方法还包括:Preferably, the gateway device response network connectivity method further includes:

在接收到终端发送的报文,且所述报文不是icmp报文时,所述线卡将接收到的报文发送给主控,以供主控响应所述报文。When receiving the message sent by the terminal and the message is not an icmp message, the line card sends the received message to the main control, so that the main control responds to the message.

此外,为实现上述目的,本发明还提出一种网关设备响应网络连通性装置,所述网关设备响应网络连通性装置包括:In addition, in order to achieve the above purpose, the present invention also proposes a gateway device responding network connectivity device, the gateway device responding network connectivity device comprising:

获取模块,用于在接收到终端发送的网间控制协议报文即icmp报文时,获取所述icmp报文的源ip地址和目的ip地址;The obtaining module is used to obtain the source ip address and the destination ip address of the icmp message when receiving the Internet control protocol message sent by the terminal, that is, the icmp message;

生成模块,用于在所述目的ip地址与其所在的网关设备的ip地址匹配,且所述源ip地址与所述网关设备的路由表中的ip地址匹配时,基于所述icmp报文生成响应icmp报文;A generating module, configured to generate a response based on the icmp message when the destination ip address matches the ip address of the gateway device where the destination ip address is located, and the source ip address matches the ip address in the routing table of the gateway device icmp message;

反馈模块,用于反馈所述响应icmp报文至所述终端。A feedback module, configured to feed back the response icmp message to the terminal.

优选地,所述生成模块包括:Preferably, the generating module includes:

计算单元,用于计算所述icmp报文的校验和并判断所述校验和是否为0;A calculation unit, configured to calculate the checksum of the icmp message and determine whether the checksum is 0;

互换单元,用于若所述校验和为0,互换所述icmp报文的源ip地址和目的ip地址;an exchange unit, configured to exchange the source ip address and the destination ip address of the icmp message if the checksum is 0;

处理单元,用于计算互换ip地址后的icmp报文中icmp报文头的校验和,并将计算后的校验和写入到icmp报文头对应的位置;The processing unit is used to calculate the checksum of the icmp message header in the icmp message after the ip address is exchanged, and write the calculated checksum into the corresponding position of the icmp message header;

所述处理单元,还用于计算整个icmp报文的校验和,并将计算后的校验和写入到icmp报文对应的位置;The processing unit is also used to calculate the checksum of the entire icmp message, and write the calculated checksum into the corresponding position of the icmp message;

生成单元,用于将所述网络设备的mac地址作为源mac地址以及将所述终端对应的mac地址作为目的mac地址,并将所述源mac地址和目的mac地址封装至所述icmp报文中,以生成响应icmp报文。A generating unit, configured to use the mac address of the network device as the source mac address and the mac address corresponding to the terminal as the destination mac address, and encapsulate the source mac address and the destination mac address into the icmp message , to generate a response icmp message.

优选地,所述反馈模块包括:Preferably, the feedback module includes:

查找单元,用于查找路由表中与所述源ip地址对应的下一跳表的输出端口;A lookup unit, configured to look up the output port of the next hop table corresponding to the source ip address in the routing table;

发送单元,用于将所述响应icmp报文通过所述输出端口发送给终端。A sending unit, configured to send the response icmp message to the terminal through the output port.

优选地,所述网关设备响应网络连通性装置还包括:Preferably, the gateway device response network connectivity device further includes:

检测模块,用于在接收到终端发送的报文时,检测所述网关设备是否处于快速响应icmp报文模式;A detection module, configured to detect whether the gateway device is in the quick response icmp message mode when receiving the message sent by the terminal;

判断模块,用于若检测到网关设备处于快速响应icmp报文模式,判断当前接收到的报文是否为icmp报文。The judging module is used to judge whether the currently received message is an icmp message if it is detected that the gateway device is in the fast response icmp message mode.

优选地,所述网关设备响应网络连通性装置还包括:Preferably, the gateway device response network connectivity device further includes:

处理模块,用于在接收到终端发送的报文,且所述报文不是icmp报文时,将接收到的报文发送给主控,以供主控响应所述报文。The processing module is configured to send the received message to the main control when the message sent by the terminal is received and the message is not an icmp message, so that the main control can respond to the message.

本发明提出的网关设备响应网络连通性方法和装置,网关设备的线卡先获取icmp报文的源ip地址和目的ip地址,再对所述icmp报文进行处理以生成响应icmp报文,最后将所述响应icmp报文发送给终端,以响应终端ping网关设备的请求,而不是通过线卡获取终端的icmp报文,然后线卡再将获取到的icmp报文上报给主控进行处理,因为主控要处理各类报文,因此响应icmp报文的时间会变长,而通过线卡直接处理icmp报文并发送给终端的方式,提高了网关设备响应终端ping请求的速度。In the gateway device response network connectivity method and device proposed by the present invention, the line card of the gateway device first obtains the source ip address and the destination ip address of the icmp message, then processes the icmp message to generate a response icmp message, and finally Send the response icmp message to the terminal to respond to the request of the terminal to ping the gateway device, instead of obtaining the icmp message of the terminal through the line card, and then the line card reports the obtained icmp message to the main control for processing, Because the main control has to process various messages, it takes longer to respond to icmp messages, and the method of directly processing icmp messages and sending them to the terminal through the line card improves the speed of the gateway device responding to the ping request of the terminal.

附图说明Description of drawings

图1为本发明网关设备响应网络连通性方法第一实施例的流程示意图;FIG. 1 is a schematic flowchart of a first embodiment of a gateway device response network connectivity method according to the present invention;

图2为本发明所述线卡基于所述icmp报文生成响应icmp报文较佳实施例的流程示意图;Fig. 2 is a schematic flow diagram of a preferred embodiment of the line card generating a response icmp message based on the icmp message of the present invention;

图3为本发明所述线卡反馈所述响应icmp报文至所述终端较佳实施例的流程示意图;Fig. 3 is a flow diagram of a preferred embodiment of the line card feeding back the response icmp message to the terminal in the present invention;

图4为本发明网关设备响应网络连通性方法第四实施例的流程示意图;4 is a schematic flowchart of a fourth embodiment of a method for a gateway device responding to network connectivity according to the present invention;

图5为本发明网关设备响应网络连通性装置第一实施例的功能模块示意图;FIG. 5 is a schematic diagram of functional modules of the first embodiment of the gateway device response network connectivity device of the present invention;

图6为图5中生成模块的较佳实施例细化功能模块示意图;Fig. 6 is a schematic diagram of a preferred embodiment of the generation module in Fig. 5, which refines the functional modules;

图7为图5中反馈模块的较佳实施例细化功能模块示意图;Fig. 7 is a schematic diagram of a preferred embodiment of the feedback module in Fig. 5 and refines the functional modules;

图8为本发明网关设备响应网络连通性装置第四实施例的功能模块示意图。FIG. 8 is a schematic diagram of functional modules of a fourth embodiment of an apparatus for a gateway device responding to network connectivity according to the present invention.

本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.

具体实施方式detailed description

应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

本发明提供一种网关设备响应网络连通性方法。The invention provides a gateway device response network connectivity method.

参照图1,图1为本发明网关设备响应网络连通性方法第一实施例的流程示意图。Referring to FIG. 1 , FIG. 1 is a schematic flowchart of a first embodiment of a method for a gateway device responding to network connectivity according to the present invention.

本实施例提出一种网关设备响应网络连通性方法,所述网关设备响应网络连通性方法包括:This embodiment proposes a method for a gateway device to respond to network connectivity, and the method for the gateway device to respond to network connectivity includes:

步骤S10,在接收到终端发送的网间控制协议报文即icmp报文时,线卡获取所述icmp报文的源ip地址和目的ip地址;Step S10, when receiving the Internet control protocol message sent by the terminal, that is, the icmp message, the line card obtains the source ip address and the destination ip address of the icmp message;

在本实施例中,若接收到终端发送的报文为icmp报文,所述线卡先提取所述icmp报文的指针,所述指针是2层报文头的指针,需要通过偏移12个字节,指向报文的vlan字段,所述线卡再判断所述icmp报文是否是多vlan标签类型的报文,进一步获取icmp报文的vlan标签的个数,可以理解的是,icmp报文源mac地址和目的mac地址各占用6个字节,一共占用12个字节,一个vlan占用4个字节,再乘以vlan的标签数得到vlan信息一共占用的字节数,这样mac地址加上vlan一共占用的字节数就是3层报文头相对于2层报文头的偏移量,报文的2层头指针加上这个偏移量就指向了报文的3层信息头,3层信息头的前4个字节就是报文的目的ip地址,5-8个字节是报文的源ip地址,通过这种方法我们就获取到了报文的源ip和目的ip地址。In this embodiment, if the message sent by the terminal is received as an icmp message, the line card first extracts the pointer of the icmp message, and the pointer is a pointer of a layer 2 message header, which needs to be offset by 12 byte, pointing to the vlan field of the message, and the line card judges whether the icmp message is a message of the multi-vlan tag type, and further obtains the number of the vlan tags of the icmp message. It can be understood that the icmp The source mac address and the destination mac address of the message each occupy 6 bytes, a total of 12 bytes, and a vlan occupies 4 bytes, and then multiplied by the number of vlan tags to get the total number of bytes occupied by the vlan information, so mac The total number of bytes occupied by the address plus vlan is the offset of the Layer 3 header relative to the Layer 2 header. The Layer 2 header pointer of the packet plus this offset points to the Layer 3 information of the packet. Header, the first 4 bytes of the layer 3 information header is the destination ip address of the message, and the 5-8 bytes are the source ip address of the message. In this way, we can get the source ip and destination ip of the message address.

步骤S20,在所述目的ip地址与其所在的网关设备的ip地址匹配,且所述源ip地址与所述网关设备的路由表中的IP地址匹配时,所述线卡基于所述icmp报文生成响应icmp报文;Step S20, when the destination ip address matches the ip address of the gateway device where it is located, and the source ip address matches the IP address in the routing table of the gateway device, the line card based on the icmp message Generate a response icmp message;

在本实施例中,所述步骤S20包括步骤:In this embodiment, the step S20 includes the steps of:

步骤A,所述线卡判断所述目的ip地址是否是其所在的网关设备的网关ip地址;Step A, the line card judges whether the destination ip address is the gateway ip address of the gateway device where it is located;

在本实施例中,所述线卡判断所述目的ip地址是否是网关设备的网关ip地址优选方式为:线卡获取到icmp报文的目的ip后,判断所述ip是否是网关ip。一般来说,在配置网关ip的时候,网关设备会下发主机路由给硬件芯片路由表,即网关设备的网关ip,同时网关设备也会保存一份相同的记录在软件路由表中,不同类型的ip会有不同的类型标记,网关ip会被设备标记为本地ip标识,网关的环回口地址也会有一个loopback(环回地址)标识。用目的ip去查找软件路由表,如果找到该ip在主机路由表中,并且该ip的标识是本地ip标识或者是loopback标识,则证明该icmp报文是其他设备ping网关ip地址的,需要我们进行快速的回包处理,即需要进行ping请求的响应。In this embodiment, the preferred way for the line card to determine whether the destination ip address is the gateway ip address of the gateway device is as follows: after the line card obtains the destination ip of the icmp message, it determines whether the ip is the gateway ip. Generally speaking, when configuring the gateway ip, the gateway device will issue the host route to the hardware chip routing table, that is, the gateway ip of the gateway device, and the gateway device will also save a copy of the same record in the software routing table, different types The ip will have different types of marks, the gateway ip will be marked as a local ip by the device, and the loopback port address of the gateway will also have a loopback (loopback address) mark. Use the destination ip to search the software routing table. If the ip is found in the host routing table, and the ip ID is the local ip ID or the loopback ID, it proves that the icmp message is for other devices to ping the gateway ip address. We need Perform fast packet return processing, that is, a response to a ping request is required.

步骤B,所述线卡判断所述源ip地址是否存在所述网关设备的路由表中;Step B, the line card judges whether the source IP address exists in the routing table of the gateway device;

在本实施例中,所述线卡判断所述源ip地址是否存在所述网关设备的路由表中优选方式为:所述线卡判断icmp报文的源ip地址是否在网关设备的路由表中,这么做的目的是需要判断后续中将源ip地址和目的ip地址互换之后,最后发送出去的报文的目的ip(即收到的icmp报文的源ip)能找到响应的路由表,即可以找到实际的出端口。进一步地,如果判断源ip地址没有在网关设备的路由表中,那么就不会继续后面的流程,而是把icmp报文上送到主控的进行处理。In this embodiment, the preferred way for the line card to determine whether the source ip address exists in the routing table of the gateway device is: the line card determines whether the source ip address of the icmp message is in the routing table of the gateway device , the purpose of doing this is to judge that after the source ip address and the destination ip address are swapped in the follow-up, the destination ip of the last sent message (that is, the source ip of the received icmp message) can find the corresponding routing table, That is, the actual egress port can be found. Further, if it is judged that the source ip address is not in the routing table of the gateway device, then the subsequent process will not be continued, but the icmp message will be sent to the master for processing.

步骤C,所述线卡处理所述icmp报文,以生成响应的icmp报文。Step C, the line card processes the icmp message to generate a corresponding icmp message.

在本实施例中,优选所述线卡对所述icmp报文的校验和进行计算和检验等操作,并根据校验和的检验结果对源ip地址和目的ip地址进行互换等,以供最后发送出去的icmp报文的目的ip(即收到的icmp报文的源ip)能找到响应的路由表,即可以找到实际的输出端口,最后,所述线卡获取所述网络设备的源mac地址和所述路由表的目的mac地址,将所述源mac地址和目的mac地址封装至所述icmp报文中,以生成响应icmp报文。步骤S30,所述线卡反馈所述响应icmp报文至所述终端。In this embodiment, preferably, the line card calculates and checks the checksum of the icmp message, and exchanges the source ip address and the destination ip address according to the checksum check result, so as to The destination ip of the icmp message sent out at last (i.e. the source ip of the received icmp message) can find the corresponding routing table, that is, the actual output port can be found, and finally, the line card obtains the ip of the network device The source mac address and the destination mac address of the routing table are encapsulated into the icmp message to generate a response icmp message. Step S30, the line card feeds back the response icmp message to the terminal.

本实施例提出的网关设备响应网络连通性方法,网关设备的线卡先获取icmp报文的源ip地址和目的ip地址,再对所述icmp报文进行处理以生成响应icmp报文,最后将所述响应icmp报文发送给终端,以响应终端ping网关设备的请求,而不是通过线卡获取终端的icmp报文,然后线卡再将获取到的icmp报文上报给主控进行处理,因为主控要处理各类报文,因此响应icmp报文的时间会变长,而通过线卡直接处理icmp报文并发送给终端的方式,提高了网关设备响应终端ping请求的速度。In the gateway device response network connectivity method proposed in this embodiment, the line card of the gateway device first obtains the source ip address and the destination ip address of the icmp message, then processes the icmp message to generate a response icmp message, and finally The response icmp message is sent to the terminal in response to the request of the terminal to ping the gateway device, instead of obtaining the icmp message of the terminal through the line card, and then the line card reports the obtained icmp message to the main control for processing, because The main control has to process various messages, so the time to respond to icmp messages will be longer, and the method of directly processing icmp messages and sending them to the terminal through the line card improves the speed of the gateway device responding to the terminal ping request.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性方法的第二实施例,在本实施例,参照图2,所述步骤S20包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a second embodiment of the method for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, referring to FIG. 2, the step S20 includes :

步骤S21,所述线卡计算所述icmp报文的校验和并判断所述校验和是否为0;Step S21, the line card calculates the checksum of the icmp message and determines whether the checksum is 0;

在本实施例中,线卡先计算icmp报文的校验和并判断所述校验和是否为0,具体算法就是:把icmp报文的首部看成以16位为单位的数字组成,依次进行二进制反码求和,例如,当前获取的icmp报文的首部是32位的数字,将32的数字分为两个16进制数,分别进行二进制反码计算,并将计算的结构求和;然后检查计算出的校验和的结果是否为0,如果不为0就是代表校验和有误不进行后续的处理,返回错误,即停止下列步骤操作。In this embodiment, the line card first calculates the checksum of the icmp message and judges whether the checksum is 0. The specific algorithm is: regard the header of the icmp message as a number composed of 16 bits, and then Perform binary one’s complement summation. For example, the header of the currently acquired icmp message is a 32-bit number. Divide the 32 number into two hexadecimal numbers, perform binary one’s complement calculations, and sum the calculated structures ; Then check whether the result of the calculated checksum is 0, if it is not 0, it means that the checksum is wrong and no subsequent processing will be performed, and an error will be returned, that is, the following steps will be stopped.

步骤S22,若所述校验和为0,所述线卡互换所述icmp报文的源ip地址和目的ip地址;Step S22, if the checksum is 0, the line card exchanges the source ip address and the destination ip address of the icmp message;

在本实施例中,所述线卡根据之前找到的指向报文的3层头指针信息,获取到报文的源ip地址和目的ip地址,然后把换后的目的ip地址写入3层指针的前4个字节中,把换后的源ip地址写到3层指针偏移的5到8字节中,这样完成了报文的源ip地址和目的ip地址的互换。In this embodiment, the line card obtains the source ip address and the destination ip address of the message according to the previously found layer 3 header pointer information pointing to the message, and then writes the changed destination ip address into the layer 3 pointer In the first 4 bytes of the message, write the changed source ip address into the 5 to 8 bytes of the layer 3 pointer offset, thus completing the exchange of the source ip address and the destination ip address of the message.

步骤S23,所述线卡计算互换ip地址后的icmp报文中icmp报文头的校验和,并将计算后的校验和写入到icmp报文头对应的位置;Step S23, the line card calculates the checksum of the icmp header in the icmp message after the ip address is exchanged, and writes the calculated checksum into the corresponding position of the icmp header;

在本实施例中,所述线卡对互换了源ip地址和目的ip地址后的报文的校验和进行重新计算,计算的算法是:把需校验的数据看成以16位为单位的数字组成,依次进行二进制反码求和;把得到的结果存入到icmp报文头对应的位置中。In this embodiment, the line card recalculates the checksum of the message after the source ip address and the destination ip address have been exchanged, and the calculation algorithm is: the data to be checked is regarded as 16-bit The number of the unit is composed of numbers, and the binary one's complement is summed sequentially; the obtained result is stored in the corresponding position of the icmp message header.

步骤S24,所述线卡计算整个icmp报文的校验和,并将计算后的校验和写入到icmp报文对应的位置;Step S24, the line card calculates the checksum of the entire icmp message, and writes the calculated checksum into the corresponding position of the icmp message;

在本实施例中,所述线卡还可事先设置ip报文的ttl值的,优选将ttl值设置为默认值255,可以理解的是,所述把ip报文的time to live字段即指定ip包被路由器丢弃之前允许通过的最大网段数量设置为默认值255,并再次计算整个ip报文的校验和,将计算的校验和写入到icmp报文对应的位置。In this embodiment, the line card can also set the ttl value of the ip message in advance, preferably the ttl value is set to a default value of 255. It can be understood that the time to live field of the ip message is specified The maximum number of network segments allowed to pass before the ip packet is discarded by the router is set to the default value of 255, and the checksum of the entire ip packet is calculated again, and the calculated checksum is written to the corresponding position of the icmp message.

步骤S25,所述线卡将所述网络设备的mac地址作为源mac地址以及将所述终端对应的mac地址作为目的mac地址,并将所述源mac地址和目的mac地址封装至所述icmp报文中,以生成响应icmp报文。Step S25, the line card uses the mac address of the network device as the source mac address and the mac address corresponding to the terminal as the destination mac address, and encapsulates the source mac address and the destination mac address into the icmp report In the text, to generate a response icmp message.

在本实施例中,所述线卡将所述源mac地址和目的mac地址封装至所述icmp报文中的方式优选为所述线卡先添加所述路由表相关联的下一跳表的mac地址到icmp报文的目的mac地址中,添加网关设备的网关mac地址到icmp报文的源mac地址中,然后将根据所述icmp报文的源ip地址在所述网关设备中的对应的路由表的下一跳表,查找到所述源ip地址的路由表的下一跳表,将所述查找到的下一跳表作为出端口,并将封装了源mac地址和目的mac地址的icmp报文发送给终端,以完成响应终端ping网关设备的请求。In this embodiment, the way the line card encapsulates the source mac address and the destination mac address into the icmp message is preferably that the line card first adds the next hop table associated with the routing table mac address to the destination mac address of the icmp message, add the gateway mac address of the gateway device to the source mac address of the icmp message, and then use the corresponding IP address in the gateway device according to the source ip address of the icmp message The next hop table of the routing table, find the next hop table of the routing table of the source ip address, use the next hop table found as the outgoing port, and encapsulate the source mac address and the destination mac address The icmp message is sent to the terminal to complete the response to the terminal's request to ping the gateway device.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性方法的第三实施例,在本实施例,参照图3,所述步骤S30包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a third embodiment of the method for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, referring to FIG. 3 , the step S30 includes :

步骤S31,所述线卡查找路由表中与所述源ip地址对应的的下一跳表的输出端口;Step S31, the line card looks up the output port of the next hop table corresponding to the source ip address in the routing table;

步骤S32,所述线卡将所述响应icmp报文通过所述输出端口发送给终端。Step S32, the line card sends the response icmp message to the terminal through the output port.

在本实施例中,可以理解的是,路由表中存储源ip地址对应的地址信息,但是,但是该地址信息不是源ip地址对应的出端口,即所述路由表中的地址信息为快速响应icmp报文的索引信息,当在所述路由表找到所述源ip地址对应地址信息时,根据所述地址信息索引到下一跳表中,并确认所述下一跳表中对应的位置为响应icmp报文的输出端口。In this embodiment, it can be understood that the address information corresponding to the source ip address is stored in the routing table, but the address information is not the outgoing port corresponding to the source ip address, that is, the address information in the routing table is a fast response The index information of the icmp message, when the address information corresponding to the source ip address is found in the routing table, index to the next hop table according to the address information, and confirm that the corresponding position in the next hop table is The output port that responds to icmp packets.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性方法的第四实施例,在本实施例,参照图4,所述步骤S10之前,所述网关设备响应网络连通性方法包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a fourth embodiment of the method for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, refer to FIG. 4, before the step S10 , the gateway device response network connectivity method includes:

步骤S40,在接收到终端发送的报文时,所述线卡检测所述网关设备是否处于快速响应icmp报文模式;Step S40, when receiving the message sent by the terminal, the line card detects whether the gateway device is in the quick response icmp message mode;

步骤S50,若检测到网关设备处于快速响应icmp报文模式,所述线卡判断当前接收到的报文是否为icmp报文。Step S50, if it is detected that the gateway device is in the fast response icmp message mode, the line card judges whether the currently received message is an icmp message.

在本实施例中,步骤S40之前包括配置开启快速响应ping请求指令的步骤,即用户可通过快速响应icmp报文的指令触发快速响应ping网关设备的指令,当用户处于快速响应ping网关设备的模式时,在接收到终端发送的ping请求时,网关设备将触发指令,并进入快速处理icmp报文的流程;若检测到网关设备处于快速响应icmp报文模式,所述线卡判断当前接收到的报文是否为icmp报文,即线卡先获取所述终端对应的报文,并判断所述获取的报文是否为icmp报文,所述判断所述获取的报文是否为icmp报文的方式优选通过acl规则(一种访问控制技术)进行判断,所述利用acl判断的方式优选通过获取报文的唯一标识如协议号,根据获取的协议号即可判断当前获取的报文的类型是否与icmp报文的类型相匹配,若匹配,线卡即可判断收到的报文为icmp报文。并进行快速响应ping请求的过程,若不是,进入报文正常处理流程,即通过线卡获取报文,线卡再将获取的报文上送给主控,通过主控进行一系列响应过程。In this embodiment, before step S40, it includes the step of configuring and enabling the quick response ping request command, that is, the user can trigger the command of the quick response ping gateway device through the command of the quick response icmp message, when the user is in the mode of the quick response ping gateway device When receiving the ping request sent by the terminal, the gateway device will trigger the command and enter the process of quickly processing the icmp message; if it detects that the gateway device is in the mode of quickly responding to the icmp message, the line card Whether the message is an icmp message, that is, the line card first obtains the message corresponding to the terminal, and judges whether the obtained message is an icmp message, and determines whether the obtained message is an icmp message The method is preferably judged by the acl rule (a kind of access control technology), and the method of using the acl judgment is preferably to obtain the unique identifier of the message such as the protocol number. According to the obtained protocol number, it can be judged whether the type of the currently obtained message is Matches the type of the icmp message. If it matches, the line card can determine that the received message is an icmp message. And carry out the process of quickly responding to the ping request. If not, enter the normal processing flow of the message, that is, obtain the message through the line card, and then send the obtained message to the main control, and perform a series of response processes through the main control.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性方法的第五实施例,在本实施例,所述网关设备响应网络连通性方法还包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a fifth embodiment of the method for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, the gateway device responds to the network connectivity method Also includes:

在接收到终端发送的报文,且所述报文不是icmp报文时,所述线卡将接收到的报文发送给主控,以供主控响应所述报文。When receiving the message sent by the terminal and the message is not an icmp message, the line card sends the received message to the main control, so that the main control responds to the message.

在本实施例中,优选判断接收到的是否为icmp报文,若不是,按照正常的流程发送主控,以供主控响应所述报文。In this embodiment, preferably, it is judged whether the received icmp message is received, and if not, the main control is sent according to a normal process for the main control to respond to the message.

本发明进一步提供一种网关设备响应网络连通性装置。The present invention further provides a gateway device responding network connectivity device.

参照图5,图5为本发明网关设备响应网络连通性装置较佳实施例的功能模块示意图。Referring to FIG. 5 , FIG. 5 is a schematic diagram of functional modules of a preferred embodiment of an apparatus for responding to network connectivity of a gateway device according to the present invention.

需要强调的是,对本领域的技术人员来说,图5所示功能模块图仅仅是一个较佳实施例的示例图,本领域的技术人员围绕图5所示的网关设备响应网络连通性装置的功能模块,可轻易进行新的功能模块的补充;各功能模块的名称是自定义名称,仅用于辅助理解该网关设备响应网络连通性装置的各个程序功能块,不用于限定本发明的技术方案,本发明技术方案的核心是,各自定义名称的功能模块所要达成的功能。It should be emphasized that, for those skilled in the art, the functional block diagram shown in FIG. 5 is only an example diagram of a preferred embodiment, and those skilled in the art respond to the network connectivity device shown in FIG. 5 Functional modules can easily supplement new functional modules; the names of each functional module are self-defined names, which are only used to assist in understanding the various program function blocks of the gateway device responding to the network connectivity device, and are not used to limit the technical solution of the present invention , the core of the technical solution of the present invention is the functions to be achieved by the function modules with self-defined names.

本实施例提出一种网关设备响应网络连通性装置,所述网关设备响应网络连通性装置包括:This embodiment proposes a device for responding to network connectivity of a gateway device. The device for responding to network connectivity of a gateway device includes:

获取模块10,用于在接收到终端发送的网间控制协议报文即icmp报文时,获取所述icmp报文的源ip地址和目的ip地址;Obtaining module 10, is used for when receiving the Internet Control Protocol message that terminal sends, i.e. icmp message, obtains the source ip address and destination ip address of described icmp message;

在本实施例中,若接收到终端发送的报文为icmp报文,所述获取模块10先提取所述icmp报文的指针,所述指针是2层报文头的指针,需要通过偏移12个字节,指向报文的vlan字段,再判断所述icmp报文是否是多vlan标签类型的报文,所述获取模块10进一步获取icmp报文的vlan标签的个数,可以理解的是,icmp报文源mac地址和目的mac地址各占用6个字节,一共占用12个字节,一个vlan占用4个字节,再乘以vlan的标签数得到vlan信息一共占用的字节数,这样mac地址加上vlan一共占用的字节数就是3层报文头相对于2层报文头的偏移量,报文的2层头指针加上这个偏移量就指向了报文的3层信息头,3层信息头的前4个字节就是报文的目的ip地址,5-8个字节是报文的源ip地址,通过这种方法我们就获取到了报文的源ip和目的ip地址。In this embodiment, if the received message sent by the terminal is an icmp message, the acquisition module 10 first extracts the pointer of the icmp message, and the pointer is a pointer of a layer 2 message header, which needs to be passed through the offset 12 bytes point to the vlan field of the message, and then judge whether the icmp message is a message of multiple vlan tag types, and the acquisition module 10 further obtains the number of the vlan tags of the icmp message, it can be understood that , the source mac address and the destination mac address of the icmp message each occupy 6 bytes, a total of 12 bytes, and a vlan occupies 4 bytes, and then multiplied by the number of vlan tags to get the total number of bytes occupied by the vlan information, In this way, the total number of bytes occupied by the mac address plus vlan is the offset of the layer 3 packet header relative to the layer 2 packet header, and the layer 2 header pointer of the packet plus this offset points to the 3 Layer information header, the first 4 bytes of the layer 3 information header is the destination ip address of the message, and the 5-8 bytes are the source ip address of the message. In this way, we can get the source ip and Destination IP address.

生成模块20,用于在所述目的ip地址与其所在的网关设备的ip地址匹配,且所述源ip地址与所述网关设备的路由表中的IP地址匹配时,基于所述icmp报文生成响应icmp报文;A generating module 20, configured to generate based on the icmp message when the destination ip address matches the ip address of the gateway device where it is located, and the source ip address matches the IP address in the routing table of the gateway device Respond to icmp message;

在本实施例中,所述生成模块20包括:In this embodiment, the generating module 20 includes:

判断单元,用于判断所述目的ip地址是否是其所在的网关设备的网关ip地址;A judging unit, configured to judge whether the destination ip address is the gateway ip address of the gateway device where it is located;

在本实施例中,所述判断单元判断所述目的ip地址是否是网关设备的网关ip地址优选方式为:获取模块10获取到icmp报文的目的ip后,判断单元判断所述ip是否是网关ip。一般来说,在配置网关ip的时候,网关设备会下发主机路由给硬件芯片路由表,即网关设备的网关ip,同时网关设备也会保存一份相同的记录在软件路由表中,不同类型的ip会有不同的类型标记,网关ip会被设备标记为本地ip标识,网关的环回口地址也会有一个loopback(环回地址)标识。用目的ip去查找软件路由表,如果找到该ip在主机路由表中,并且该ip的标识是本地ip标识或者是loopback标识,则证明该icmp报文是其他设备ping网关ip地址的,需要我们进行快速的回包处理,即需要进行ping请求的响应。In this embodiment, the judging unit judges whether the destination ip address is the gateway ip address of the gateway device. The preferred method is: after the acquisition module 10 obtains the destination ip of the icmp message, the judging unit judges whether the ip is a gateway ip. Generally speaking, when configuring the gateway ip, the gateway device will issue the host route to the hardware chip routing table, that is, the gateway ip of the gateway device, and the gateway device will also save a copy of the same record in the software routing table, different types The ip will have different types of marks, the gateway ip will be marked as a local ip by the device, and the loopback port address of the gateway will also have a loopback (loopback address) mark. Use the destination ip to search the software routing table. If the ip is found in the host routing table, and the ip ID is the local ip ID or the loopback ID, it proves that the icmp message is for other devices to ping the gateway ip address. We need Perform fast packet return processing, that is, a response to a ping request is required.

所述判断单元,还用于判断所述源ip地址是否存在所述网关设备的路由表中;The judging unit is also used to judge whether the source IP address exists in the routing table of the gateway device;

在本实施例中,所述判断单元判断所述源ip地址是否存在所述网关设备的路由表中优选方式为:所述判断单元判断icmp报文的源ip地址是否在网关设备的路由表中,这么做的目的是需要判断后续中将源ip地址和目的ip地址互换之后,最后发送出去的报文的目的ip(即收到的icmp报文的源ip)能找到响应的路由表,即可以找到实际的出端口。进一步地,如果所述判断单元判断源ip地址没有在网关设备的路由表中,那么就不会继续后面的流程,而是把icmp报文上送到主控的进行处理。In this embodiment, the preferred way for the judging unit to judge whether the source ip address exists in the routing table of the gateway device is: the judging unit judges whether the source ip address of the icmp message is in the routing table of the gateway device , the purpose of doing this is to judge that after the source ip address and the destination ip address are swapped in the follow-up, the destination ip of the last sent message (that is, the source ip of the received icmp message) can find the corresponding routing table, That is, the actual egress port can be found. Further, if the judging unit judges that the source ip address is not in the routing table of the gateway device, it will not continue the following process, but send the icmp message to the master for processing.

生成单元,用于处理所述icmp报文,以生成响应的icmp报文。A generating unit, configured to process the icmp message to generate a corresponding icmp message.

在本实施例中,优选所述生成单元对所述icmp报文的校验和进行计算和检验等操作,并根据校验和的检验结果对源ip地址和目的ip地址进行互换等,以供最后发送出去的icmp报文的目的ip(即收到的icmp报文的源ip)能找到响应的路由表,即可以找到实际的输出端口,最后,获取所述网络设备的源mac地址和所述路由表的目的mac地址,将所述源mac地址和目的mac地址封装至所述icmp报文中,以供生成单元生成响应icmp报文。In this embodiment, it is preferred that the generating unit calculates and checks the checksum of the icmp message, and exchanges the source ip address and the destination ip address according to the checksum check result, so as to The destination ip of the icmp message sent out at last (i.e. the source ip of the received icmp message) can find the corresponding routing table, that is, the actual output port can be found, and finally, the source mac address and the source mac address of the network device are obtained The destination mac address of the routing table encapsulates the source mac address and destination mac address into the icmp message for the generation unit to generate a response icmp message.

本实施例提出的网关设备响应网络连通性装置,网关设备的线卡先获取icmp报文的源ip地址和目的ip地址,再对所述icmp报文进行处理以生成响应icmp报文,最后将所述响应icmp报文发送给终端,以响应终端ping网关设备的请求,而不是通过线卡获取终端的icmp报文,然后线卡再将获取到的icmp报文上报给主控进行处理,因为主控要处理各类报文,因此响应icmp报文的时间会变长,而通过线卡直接处理icmp报文并发送给终端的方式,提高了网关设备响应终端ping请求的速度。In the gateway device response network connectivity device proposed in this embodiment, the line card of the gateway device first obtains the source ip address and the destination ip address of the icmp message, then processes the icmp message to generate a response icmp message, and finally The response icmp message is sent to the terminal in response to the request of the terminal to ping the gateway device, instead of obtaining the icmp message of the terminal through the line card, and then the line card reports the obtained icmp message to the main control for processing, because The main control has to process various messages, so the time to respond to icmp messages will be longer, and the method of directly processing icmp messages and sending them to the terminal through the line card improves the speed of the gateway device responding to the terminal ping request.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性装置的第二实施例,在本实施例,参照图6,所述生成模块20包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, the second embodiment of the device for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, referring to FIG. 6, the generation module 20 include:

计算单元21,用于计算所述icmp报文的校验和并判断所述校验和是否为0;Calculation unit 21, for calculating the checksum of the icmp message and judging whether the checksum is 0;

在本实施例中,计算单元21先计算icmp报文的校验和并判断所述校验和是否为0,具体算法就是:把icmp报文的首部看成以16位为单位的数字组成,依次进行二进制反码求和,例如,当前获取的icmp报文的首部是32位的数字,将32的数字分为两个16进制数,分别进行二进制反码计算,并将计算的结构求和;然后检查计算出的校验和的结果是否为0,如果不为0就是代表校验和有误不进行后续的处理,返回错误,即停止下列步骤操作。In the present embodiment, calculation unit 21 first calculates the checksum of the icmp message and judges whether the checksum is 0. The specific algorithm is as follows: the header of the icmp message is regarded as a 16-bit number, Carry out binary one’s complement summation sequentially. For example, the header of the currently acquired icmp message is a 32-bit number, divide the 32 number into two hexadecimal numbers, perform binary one’s complement calculation respectively, and calculate the calculated structure and; then check whether the result of the calculated checksum is 0, if it is not 0, it means that the checksum is wrong and no subsequent processing will be performed, and an error will be returned, that is, the following steps will be stopped.

互换单元22,用于若所述校验和为0,互换所述icmp报文的源ip地址和目的ip地址;The exchange unit 22 is used to exchange the source ip address and the destination ip address of the icmp message if the checksum is 0;

在本实施例中,所述互换单元22根据之前找到的指向报文的3层头指针信息,获取到报文的源ip地址和目的ip地址,然后把换后的目的ip地址写入3层指针的前4个字节中,把换后的源ip地址写到3层指针偏移的5到8字节中,这样完成了报文的源ip地址和目的ip地址的互换。In this embodiment, the exchange unit 22 obtains the source ip address and the destination ip address of the message according to the layer 3 header pointer information found before the message, and then writes the changed destination ip address into 3 In the first 4 bytes of the layer pointer, write the changed source ip address into the 5 to 8 bytes of the layer 3 pointer offset, thus completing the exchange of the source ip address and the destination ip address of the message.

处理单元23,用于计算互换ip地址后的icmp报文中icmp报文头的校验和,并将计算后的校验和写入到icmp报文头对应的位置;The processing unit 23 is used to calculate the checksum of the icmp header in the icmp message after the ip address is exchanged, and write the calculated checksum into the corresponding position of the icmp header;

在本实施例中,所述处理单元23对互换了源ip地址和目的ip地址后的报文的校验和进行重新计算,计算的算法是:把需校验的数据看成以16位为单位的数字组成,依次进行二进制反码求和;把得到的结果存入到icmp报文头对应的位置中。In this embodiment, the processing unit 23 recalculates the checksum of the message after the source ip address and the destination ip address have been exchanged, and the calculation algorithm is: regard the data to be checked as 16-bit Composed of numbers in unit, perform binary one's complement summation sequentially; store the obtained result in the corresponding position of the icmp message header.

所述处理单元23,还用于计算整个icmp报文的校验和,并将计算后的校验和写入到icmp报文对应的位置;The processing unit 23 is also used to calculate the checksum of the entire icmp message, and write the calculated checksum to the corresponding position of the icmp message;

在本实施例中,所述处理单元23还可事先设置ip报文的ttl值的,优选将ttl值设置为默认值255,可以理解的是,所述把ip报文的time to live字段即指定ip包被路由器丢弃之前允许通过的最大网段数量设置为默认值255,并再次计算整个ip报文的校验和,将计算的校验和写入到icmp报文对应的位置。In this embodiment, the processing unit 23 can also set the ttl value of the ip message in advance, preferably the ttl value is set to a default value of 255. It can be understood that the time to live field of the ip message is Specify the maximum number of network segments allowed to pass before the ip packet is discarded by the router, set the default value to 255, and calculate the checksum of the entire ip packet again, and write the calculated checksum to the corresponding position of the icmp packet.

生成单元24,用于将所述网络设备的mac地址作为源mac地址以及将所述终端对应的mac地址作为目的mac地址,并将所述源mac地址和目的mac地址封装至所述icmp报文中,以生成响应icmp报文。A generating unit 24, configured to use the mac address of the network device as the source mac address and the mac address corresponding to the terminal as the destination mac address, and encapsulate the source mac address and the destination mac address into the icmp message to generate a response icmp message.

在本实施例中,先将所述源mac地址和目的mac地址封装至所述icmp报文中的方式优选为所述生成单元24先添加所述路由表的mac地址到icmp报文的目的mac地址中,添加网关设备的网关mac地址到icmp报文的源mac地址中,然后将根据所述icmp报文的源ip地址在所述网关设备中的对应的路由表的下一跳表,查找到所述源ip地址的路由表的下一跳表,将所述查找到的下一跳表作为出端口,并将封装了源mac地址和目的mac地址的icmp报文发送给终端,以完成响应终端ping网关设备的请求。In this embodiment, the method of first encapsulating the source mac address and the destination mac address into the icmp message is preferably that the generating unit 24 first adds the mac address of the routing table to the destination mac of the icmp message In the address, add the gateway mac address of the gateway device to the source mac address of the icmp message, and then search according to the next hop table of the corresponding routing table in the gateway device according to the source ip address of the icmp message To the next hop table of the routing table of the source ip address, using the found next hop table as an outgoing port, and sending the icmp message encapsulating the source mac address and the destination mac address to the terminal to complete Respond to the request of the terminal to ping the gateway device.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性装置的第三实施例,在本实施例,参照图7,所述反馈模块30包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a third embodiment of the device for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, referring to FIG. 7, the feedback module 30 include:

查找单元31,用于查找路由表中与所述源ip地址对应的下一跳表的输出端口;A lookup unit 31, configured to look up the output port of the next hop table corresponding to the source ip address in the routing table;

发送单元32,用于将所述响应icmp报文通过所述输出端口发送给终端。A sending unit 32, configured to send the response icmp message to the terminal through the output port.

在本实施例中,可以理解的是,路由表中存储源ip地址对应的地址信息,但是,但是该地址信息不是源ip地址对应的出端口,即所述路由表中的地址信息为快速响应icmp报文的索引信息,当在所述路由表找到所述源ip地址对应地址信息时,查找单元31根据所述地址信息索引到下一跳表中,并确认所述下一跳表中对应的位置为响应icmp报文的输出端口。In this embodiment, it can be understood that the address information corresponding to the source ip address is stored in the routing table, but the address information is not the outgoing port corresponding to the source ip address, that is, the address information in the routing table is a fast response The index information of the icmp message, when the address information corresponding to the source ip address is found in the routing table, the search unit 31 indexes into the next hop table according to the address information, and confirms that the corresponding The location of is the output port of the response icmp message.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性装置的第四实施例,在本实施例,参照图8,所述网关设备响应网络连通性装置还包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, the fourth embodiment of the device for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, referring to FIG. 8, the gateway device responds to The network connectivity unit also includes:

检测模块40,用于在接收到终端发送的报文时,检测所述网关设备是否处于快速响应icmp报文模式;The detection module 40 is used to detect whether the gateway device is in the quick response icmp message mode when receiving the message sent by the terminal;

判断模块50,用于若检测到网关设备处于快速响应icmp报文模式,判断当前接收到的报文是否为icmp报文。The judging module 50 is configured to judge whether the currently received packet is an icmp packet if it is detected that the gateway device is in the fast response icmp packet mode.

在本实施例中,检测模块40还包括配置单元,用于配置开启快速响应ping请求,即用户可通过快速响应icmp报文的指令触发快速响应ping网关设备的指令,当用户处于快速响应ping网关设备的模式时,在接收到终端发送的ping请求时,网关设备将触发指令,并进入快速处理icmp报文的流程;若检测到网关设备处于快速响应icmp报文模式,所述判断模块50判断当前接收到的报文是否为icmp报文,即先获取所述终端对应的报文,并判断所述获取的报文是否为icmp报文,所述判断所述获取的报文是否为icmp报文的方式优选通过acl规则(一种访问控制技术)进行判断,所述利用acl判断的方式优选通过获取报文的唯一标识如协议号,根据获取的协议号即可判断当前获取的报文的类型是否与icmp报文的类型相匹配,若匹配,所述判断模块50即可判断收到的报文为icmp报文。并进行快速响应ping请求的过程,若不是,进入报文正常处理流程,即通过线卡获取报文,再将获取的报文上送给主控,通过主控进行一系列响应过程。In this embodiment, the detection module 40 also includes a configuration unit, configured to enable the quick response ping request, that is, the user can trigger the quick response ping gateway device instruction through the quick response icmp message instruction, when the user is in the quick response ping gateway In the mode of the device, when receiving the ping request sent by the terminal, the gateway device will trigger the instruction and enter the process of quickly processing the icmp message; if it is detected that the gateway device is in the fast response icmp message mode, the judgment module 50 judges Whether the currently received message is an icmp message, that is, first obtain the message corresponding to the terminal, and judge whether the obtained message is an icmp message, and determine whether the obtained message is an icmp message The way of text is preferably judged by acl rule (a kind of access control technology), and the mode of using acl judgment is preferably obtained by obtaining the unique identifier of the message such as the protocol number, and the currently obtained message can be judged according to the obtained protocol number Whether the type matches the type of the icmp message, if so, the judging module 50 can judge that the received message is an icmp message. And carry out the process of quickly responding to the ping request, if not, enter the normal processing flow of the message, that is, obtain the message through the line card, and then send the obtained message to the main control, and perform a series of response processes through the main control.

进一步地,为了增加网关设备响应网络连通性的灵活性,基于第一实施例提出本发明网关设备响应网络连通性装置的第五实施例,在本实施例,所述网关设备响应网络连通性装置还包括:Further, in order to increase the flexibility of the gateway device responding to the network connectivity, based on the first embodiment, a fifth embodiment of the device for the gateway device responding to the network connectivity of the present invention is proposed. In this embodiment, the gateway device responds to the network connectivity device Also includes:

处理模块,用于在接收到终端发送的报文,且所述报文不是icmp报文时,将接收到的报文发送给主控,以供主控响应所述报文。The processing module is configured to send the received message to the main control when the message sent by the terminal is received and the message is not an icmp message, so that the main control can respond to the message.

在本实施例中,优选所述处理模块判断接收到的是否为icmp报文,若不是,按照正常的流程发送主控,以供主控响应所述报文。In this embodiment, preferably, the processing module judges whether the received icmp message is received, and if not, sends the master control according to a normal process for the master control to respond to the message.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其它变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其它要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that, as used herein, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or system comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or system. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article or system comprising that element.

上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are for description only, and do not represent the advantages and disadvantages of the embodiments.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products are stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in various embodiments of the present invention.

以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其它相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.

Claims (10)

1. a gateway device response to network connectedness method, it is characterised in that described gateway device responds Network connectivty method comprises the following steps:
When receiving control protocol message i.e. icmp message between the net that terminal sends, line card obtains described The ip address, source of icmp message and purpose ip address;
Mate with the ip address of the gateway device at its place in described purpose ip address, and ip address, described source When mating with the IP address in the routing table of described gateway device, described line card is raw based on described icmp message Become response icmp message;
Described line card feeds back described response icmp message to described terminal.
2. gateway device response to network connectedness method as claimed in claim 1, it is characterised in that institute State line card step based on described icmp message generation response icmp message to include:
Whether described line card calculates the verification of described icmp message and and judges described verification and be 0;
If described verification and be 0, described line card exchanges ip address, source and purpose ip of described icmp message Address;
Described line card calculate exchange icmp heading in the icmp message behind ip address verification and, and will The position that verification after calculating is corresponding with being written to icmp heading;
Described line card calculate whole icmp message verification and, and will calculate after verification and be written to icmp The position that message is corresponding;
Described line card using the mac address of the described network equipment as mac address, source and by described terminal pair The mac address answered is as purpose mac address, and is encapsulated in mac address, described source and purpose mac address To described icmp message, to generate response icmp message.
3. gateway device response to network connectedness method as claimed in claim 1, it is characterised in that institute The step stating the line card described response icmp message of feedback extremely described terminal includes:
Described line card searches the output port of next skip list corresponding with ip address, described source in routing table;
Described response icmp message is sent to terminal by described output port by described line card.
4. gateway device response to network connectedness method as claimed in claim 1, it is characterised in that institute Stating when receiving control protocol message i.e. icmp message between the net that terminal sends, described line card obtains described Before the ip address, source of icmp message and the step of purpose ip address, described gateway device response to network connects Property method includes:
When receiving the message that terminal sends, described line card detects whether described gateway device is in quickly Response icmp message pattern;
If detecting, gateway device is in quickly response icmp message pattern, and described line card judges current reception To message whether be icmp message.
5. the gateway device response to network connectedness method as described in any one of claim 1-4, its feature Being, described gateway device response to network connectedness method also includes:
Receiving the message that terminal sends, and when described message is not icmp message, described line card will connect The message received is sent to master control, responds described message for master control.
6. a gateway device response to network connectivity means, it is characterised in that described gateway device responds Network connectivty device includes:
Acquisition module, is used for when receiving control protocol message i.e. icmp message between the net that terminal sends, Obtain ip address, source and the purpose ip address of described icmp message;
Generation module, for mating with the ip address of the gateway device at its place in described purpose ip address, And ip address, described source is when mating with the IP address in the routing table of described gateway device, based on described icmp Message generates response icmp message;
Feedback module, is used for feeding back described response icmp message to described terminal.
7. gateway device response to network connectivity means as claimed in claim 6, it is characterised in that institute State generation module to include:
Whether computing unit, for calculating the verification of described icmp message and and judging described verification and be 0;
Exchange unit, if for described verification and be 0, exchanging ip address, source and the mesh of described icmp message Ip address;
Processing unit, for calculate the verification exchanging icmp heading in the icmp message behind ip address and, And the verification position corresponding with being written to icmp heading after calculating;
Described processing unit, be additionally operable to calculate whole icmp message verification and, and the verification after calculating The position corresponding with being written to icmp message;
Signal generating unit, is used for the mac address of the described network equipment as mac address, source and by described Mac address corresponding to terminal is as purpose mac address, and by mac address, described source and purpose mac ground In location encapsulation extremely described icmp message, to generate response icmp message.
8. gateway device response to network connectivity means as claimed in claim 6, it is characterised in that institute State feedback module to include:
Search unit, for searching the outfan of next skip list corresponding with ip address, described source in routing table Mouthful;
Transmitting element, for being sent to terminal by described response icmp message by described output port.
9. gateway device response to network connectivity means as claimed in claim 6, it is characterised in that institute State gateway device response to network connectivity means also to include:
Detection module, for when receiving the message that terminal sends, detecting whether described gateway device is located In quickly response icmp message pattern;
Judge module, if for detecting that gateway device is in quickly response icmp message pattern, it is judged that when Before the message that receives whether be icmp message.
10. the gateway device response to network connectivity means as described in any one of claim 6-9, its feature Being, described gateway device response to network connectivity means also includes:
Processing module, for receiving the message that terminal sends, and when described message is not icmp message, The message received is sent to master control, responds described message for master control.
CN201510369825.5A 2015-06-29 2015-06-29 Gateway device response to network connectedness method and apparatus Withdrawn CN106301997A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201510369825.5A CN106301997A (en) 2015-06-29 2015-06-29 Gateway device response to network connectedness method and apparatus
PCT/CN2016/086017 WO2017000790A1 (en) 2015-06-29 2016-06-16 Gateway device network connectivity response method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510369825.5A CN106301997A (en) 2015-06-29 2015-06-29 Gateway device response to network connectedness method and apparatus

Publications (1)

Publication Number Publication Date
CN106301997A true CN106301997A (en) 2017-01-04

Family

ID=57607666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510369825.5A Withdrawn CN106301997A (en) 2015-06-29 2015-06-29 Gateway device response to network connectedness method and apparatus

Country Status (2)

Country Link
CN (1) CN106301997A (en)
WO (1) WO2017000790A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111937358A (en) * 2018-04-17 2020-11-13 思科技术公司 Multiple VRF generic device internet protocol addresses for fabric edge devices
CN112333048A (en) * 2020-11-23 2021-02-05 中盈优创资讯科技有限公司 Method and device for detecting on-line user and connectivity of opened service
CN113890838A (en) * 2021-09-24 2022-01-04 天津津航计算技术研究所 Network connectivity judgment method based on ICMP (Internet control protocol)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110162437B (en) * 2019-05-15 2023-10-27 杭州迪普科技股份有限公司 Frame type equipment internal connectivity detection method and system
CN113364793A (en) * 2021-06-17 2021-09-07 北京天融信网络安全技术有限公司 ICMP hidden tunnel detection method, device and storage medium
CN115941560A (en) * 2021-08-23 2023-04-07 中兴通讯股份有限公司 Network diagnosis method and network access device for cross-device link aggregation networking
CN118573601B (en) * 2024-07-29 2024-11-08 广州通则康威科技股份有限公司 ICMP-based DNAT connectivity test method, device and equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101026578A (en) * 2007-01-29 2007-08-29 中兴通讯股份有限公司 Method for rapid response to ICMP echo request message
CN101378333A (en) * 2008-10-08 2009-03-04 中兴通讯股份有限公司 System, apparatus and method for transmitting and receiving check information message continuously
CN101399697A (en) * 2007-09-30 2009-04-01 华为技术有限公司 System and method for automatically protection switching
US20090282291A1 (en) * 2008-05-08 2009-11-12 Nortel Networks Limited Internal maintenance association end point (mep) for sharing state information

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101026578A (en) * 2007-01-29 2007-08-29 中兴通讯股份有限公司 Method for rapid response to ICMP echo request message
CN101399697A (en) * 2007-09-30 2009-04-01 华为技术有限公司 System and method for automatically protection switching
US20090282291A1 (en) * 2008-05-08 2009-11-12 Nortel Networks Limited Internal maintenance association end point (mep) for sharing state information
CN101378333A (en) * 2008-10-08 2009-03-04 中兴通讯股份有限公司 System, apparatus and method for transmitting and receiving check information message continuously

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111937358A (en) * 2018-04-17 2020-11-13 思科技术公司 Multiple VRF generic device internet protocol addresses for fabric edge devices
CN111937358B (en) * 2018-04-17 2022-09-13 思科技术公司 Multiple VRF generic device internet protocol addresses for fabric edge devices
CN112333048A (en) * 2020-11-23 2021-02-05 中盈优创资讯科技有限公司 Method and device for detecting on-line user and connectivity of opened service
CN113890838A (en) * 2021-09-24 2022-01-04 天津津航计算技术研究所 Network connectivity judgment method based on ICMP (Internet control protocol)

Also Published As

Publication number Publication date
WO2017000790A1 (en) 2017-01-05

Similar Documents

Publication Publication Date Title
CN106301997A (en) Gateway device response to network connectedness method and apparatus
EP3346661B1 (en) Path detection method and device
CN113595897B (en) Path detection method and device
CN105634956B (en) A kind of message forwarding method, device and system
CN105490884B (en) A kind of VXLAN tunnel detection method and device
CN108965484A (en) A kind of transmission method of internet of things data, system and terminal
CN105827495B (en) The message forwarding method and equipment of VXLAN gateway
CN107645431B (en) Message forwarding method and device
CN102185766A (en) Unicast forwarding method and forwarding equipment for responding messages by DHCP (Dynamic host configuration protocol) server
CN103200100A (en) Method and device for packet transmitting
CN104579973B (en) Message forwarding method and device in a kind of Virtual Cluster
CN107566292B (en) Message forwarding method and device
CN105187311A (en) Message forwarding method and message forwarding device
CN112187648A (en) Multicast message forwarding method and device
CN105812221B (en) The device and method of data transmission in virtual expansible Local Area Network
CN109412851B (en) Link layer path detection method, device and system
CN102299862A (en) Quick forwarding equipment and method for two-layer tunnel
CN106850268A (en) A kind of linear protection switching realizes device and method
CN109246016A (en) Message processing method and device across VXLAN
CN110581792B (en) Message transmission method and device
CN110391984B (en) Message forwarding method and device
CN103607350A (en) Method and device for generating route
EP3806386B1 (en) Multicast fast switching method, device, apparatus, and storage medium
CN103986637B (en) A kind of error message processing method and tunnel device
CN107846291A (en) Message processing method, Fault Locating Method and the network equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20170104