WO2017185912A1 - 一种基于哈希节点的终端设备信息统计的方法及装置 - Google Patents

一种基于哈希节点的终端设备信息统计的方法及装置 Download PDF

Info

Publication number
WO2017185912A1
WO2017185912A1 PCT/CN2017/077416 CN2017077416W WO2017185912A1 WO 2017185912 A1 WO2017185912 A1 WO 2017185912A1 CN 2017077416 W CN2017077416 W CN 2017077416W WO 2017185912 A1 WO2017185912 A1 WO 2017185912A1
Authority
WO
WIPO (PCT)
Prior art keywords
address
data packet
source
hash
hash node
Prior art date
Application number
PCT/CN2017/077416
Other languages
English (en)
French (fr)
Inventor
赵冲
Original Assignee
上海斐讯数据通信技术有限公司
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 上海斐讯数据通信技术有限公司 filed Critical 上海斐讯数据通信技术有限公司
Publication of WO2017185912A1 publication Critical patent/WO2017185912A1/zh

Links

Images

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for collecting terminal device information based on a hash node.
  • the implementation of these anti-mite functions is based on some information of the terminal devices that can be correctly obtained by the router.
  • the information here refers to the IP address of the mobile phone or computer. , physical address, traffic information, etc.
  • the method adopted by the router of the general manufacturer is to read the client list of the DHCP (Dynamic Host Configuration Protocol) server, and obtain the corresponding IP address and physical address information, which is based on the application layer DHCP.
  • Device information obtained by the protocol has the following disadvantages: 1.
  • the device information acquisition method based on the DHCP server depends on the DHCP protocol. If the lease period is long (such as 24 hours), even if a device has already been offline, The device information can be read from the DHCP client list; 2. For a terminal with a static IP address set, the DHCP client list cannot find the device information.
  • the aging time of ARP entries may be very long, which is similar to the DHCP lease time; 2. The same one for a terminal The NIC device can set the IP addresses of multiple different network segments at the same time.
  • the ARP module of the kernel will perform statistics without distinction. When the ARP table is read, the MAC addresses of multiple records will be the same, but the IP address is different. The situation of the paragraph.
  • the present application describes a method for collecting terminal device information statistics based on a hash node, which is applied to a router connected to a plurality of the terminal devices, and provides a hash table.
  • the method includes the following steps:
  • the method further includes the steps of:
  • the method further comprises the steps of:
  • the traffic information of the source IP address is collected according to the downlink data packet, and the traffic information is saved to the hash node corresponding to the source IP address; if not, no processing is performed.
  • the method further comprises the steps of:
  • the IP address includes the source IP address of the uplink data packet and the target IP address of the downlink data packet.
  • the method further comprises the steps of:
  • the file system is a proc file system.
  • the traffic information includes real-time traffic information and accumulated traffic information.
  • the present invention also provides a device for counting terminal device information based on a hash node, which is applied to a router connected to a plurality of the terminal devices, and the device includes:
  • the source IP address obtaining unit is configured to obtain a source IP address of the uplink data packet when the data packet of the kernel protocol stack of the router is an uplink data packet;
  • a first search unit connected to the source IP address obtaining unit, to find whether a hash node corresponding to the source IP address exists in the hash table;
  • the parsing unit is connected to the inserting unit, and configured to parse the physical address of the uplink data packet corresponding to the source IP address when the hash node corresponding to the source IP address does not exist in the hash table, And adding the physical address to the hash node corresponding to the source IP address of the uplink data packet;
  • the first statistic unit is connected to the first locating unit and the inserting unit, respectively, for collecting traffic information of the source IP address according to the uplink data packet, and saving the traffic information to the source IP address.
  • the device further includes:
  • a target IP address obtaining unit configured to acquire a target IP address of the downlink data packet when the data packet is a downlink data packet
  • the second search unit is connected to the target IP address obtaining unit, and configured to search whether the corresponding hash node exists in the hash table according to the target IP address;
  • the second statistic unit is connected to the second locating unit, and configured to collect the source IP according to the downlink data packet when the corresponding hash node exists in the hash table in the target IP address.
  • the traffic information of the address is saved in the hash node corresponding to the source IP address.
  • the device further comprises:
  • timing unit for providing a time period
  • a deleting unit connected to the timing unit, configured to delete, from the hash table, the hash node corresponding to an IP address that does not have traffic passing through the protocol stack in the time period;
  • the IP address includes the source IP address of the uplink data and the target IP address of the habit data packet.
  • the device further comprises:
  • a writing unit configured to write data in the hash table to the file system one by one
  • a reading unit connected to the writing unit, for reading the file system to obtain the flow information.
  • the method provided by the present invention avoids the problem of insufficient information and poor effectiveness of simply acquiring information through the application layer, and avoids the user's troubles caused by the collection of redundant information.
  • the method also implements statistics on the traffic information of the device in a relatively real-time manner.
  • FIG. 1 is a schematic diagram of a flow chart of uplink data packet statistics in a method for counting terminal device information based on a hash node according to the present invention
  • FIG. 2 is a method for counting terminal device information based on a hash node according to the present invention. Schematic diagram of the flow chart of the downlink data packet;
  • FIG. 3 is a schematic flowchart of a aging process of a hash table in a method for collecting statistics of terminal devices based on a hash node according to the present invention
  • FIG. 4 is a schematic flowchart of extracting traffic information in a method for counting terminal device information based on a hash node according to the present invention
  • FIG. 5 is a schematic structural diagram 1 of an apparatus for counting information of a terminal device based on a hash node according to the present invention
  • FIG. 6 is a schematic structural diagram 2 of a device for counting terminal device information based on a hash node according to the present invention
  • FIG. 7 is a schematic structural diagram 3 of a device for counting terminal device information based on a hash node according to the present invention.
  • FIG. 8 is a schematic structural diagram 4 of an apparatus for counting information of a terminal device based on a hash node according to the present invention.
  • a method for counting terminal device information based on a hash node is applied to a router connected to multiple terminal devices, as described in FIG. 1 , including the steps of:
  • the traffic information of the source IP address is calculated according to the uplink data packet, and the traffic information is saved to the hash node corresponding to the source IP address.
  • the method further includes the steps of:
  • the traffic information of the corresponding IP address of the uplink data packet and the downlink data packet is separately stored for subsequent management.
  • a hash table is provided, which includes multiple hash nodes.
  • the traffic information of the internal network terminal device is mainly collected. Therefore, in the router, the uplink data packet is sent by the terminal device of the internal network, so the uplink data packet needs to be counted.
  • the IP address of the uplink data packet is searched, and the hash node corresponding to the IP address exists in the hash table. If yes, And storing, according to the uplink data packet, the traffic information corresponding to the IP address in the hash node; if not, first establishing a hash node corresponding to the IP address on the hash table, and the uplink data is The packet stores the corresponding traffic information of the IP address in the hash node. It is worth pointing out that the traffic information refers to real-time traffic information and accumulated traffic information.
  • the physical address in the uplink data packet that is, the physical address of the terminal device that sends the uplink data packet, needs to be added to the hash node corresponding to the source IP address of the uplink data packet.
  • a hash table composed of a plurality of hash nodes corresponding to the IP addresses, and continuously analyzing the IP address of the uplink data packet, collecting the traffic information of the corresponding IP address according to the uplink data packet, and storing the statistical structure.
  • This method implements the classification and statistics of all uplink data, and completes the statistics of the behavior data of the intranet terminals corresponding to all IP addresses.
  • the destination IP address of the downlink data packet is obtained, and according to the destination IP address, whether there is a corresponding hash node in the hash table. If yes, the downlink data packet is the terminal device of the internal network; otherwise, the downlink data packet is the external network device. Therefore, in order to prevent the flood attack of the external network, the abuse of the intranet resources is caused, and the hash node is not established for the downlink data packet, and only the search action can be performed.
  • the aging hash node is deleted periodically.
  • the process of periodically deleting the aging hash node includes the following steps:
  • a time period can be set according to actual business needs.
  • an expiration function is executed every time period, and the expiration function deletes the hash node corresponding to the IP address of the protocol stack in the time period from the hash table.
  • This method is advantageous for users to always obtain relatively real-time information when reading device information. It is worth pointing out that the IP address includes the source IP address of the upstream packet and the destination IP address of the downstream packet.
  • the method provided in this embodiment further includes the following steps:
  • the file system is the proc file system.
  • the Linux kernel provides a mechanism for communicating with the application layer, namely the proc file system.
  • the application layer reads the specified proc file through a standard read file operation, since the kernel has written the data in the hash table one by one into the file, the traffic information of the terminal device is read at this time.
  • the user can specify the corresponding firewall rule according to the traffic information, thereby implementing the defense network processing for some devices.
  • the terminal device is connected to the road no matter what way (such as DHCP, static IP)
  • the data packet will pass through the protocol stack of the kernel. Therefore, in the method, the data packet is parsed in the place where the data packet flows, and the hash table is established according to the parsed IP address, that is, each terminal device corresponds to one hash node.
  • the parsed physical address is used as part of the hash node statistics, and the upstream and downstream traffic of an IP address can be counted as needed, including accumulated traffic and real-time traffic per second, and these statistics are saved. Go to the corresponding hash node.
  • the application layer reads the statistics of these kernels from the system files as needed for subsequent management.
  • the method provided in this embodiment avoids the problem of insufficient information and poor effectiveness of simply obtaining information through the application layer, and avoids the trouble that the collection of redundant information is caused to the user. In addition, it is possible to comprehensively count terminal device information of various connection methods without introducing redundant information. Finally, the method can also compare the traffic information of the device in real time.
  • the embodiment provides a device for counting terminal device information based on the hash node.
  • a device for counting terminal device information based on a hash node is applied to a router connected to multiple terminal devices, as shown in FIG. 5, including:
  • the source IP address obtaining unit 11 is configured to obtain a source IP address of the uplink data packet when the data packet of the kernel protocol stack of the router is an uplink data packet;
  • the first searching unit 12 is connected to the source IP address obtaining unit 11 for searching for a hash. Whether there is a hash node corresponding to the source IP address in the table;
  • the insertion unit 13 is connected to the first search unit 12, and is configured to establish a new hash node according to the source IP address and insert the hash node into the hash table when the hash node corresponding to the source IP address does not exist in the hash table;
  • the first statistic unit 14 is connected to the first locating unit 12 and the arranging unit 13 for collecting the traffic information of the source IP address according to the uplink data packet, and saving the traffic information to the hash node corresponding to the source IP address.
  • the source IP address obtaining unit 11 acquires the source IP address of the uplink data packet. Then, the first search unit 12 searches the hash table for the source IP address to have a corresponding hash node. If not, the insert unit 13 needs to establish a new hash node according to the source IP address and insert it into the hash node. In the hash table. Finally, the first statistic unit 14 is used to collect the traffic information of the source IP address according to the uplink data packet, and save the traffic information to the hash node corresponding to the source IP address.
  • the apparatus provided in this embodiment further includes:
  • the parsing unit 15 is connected to the inserting unit 13 and configured to parse the physical address of the uplink data packet corresponding to the source IP address when the hash node corresponding to the source IP address does not exist in the hash table, and add the physical address. Go to the hash node corresponding to the source IP address of the upstream packet.
  • the apparatus provided in this embodiment further includes:
  • the target IP address obtaining unit 21 is configured to acquire a target IP address of the downlink data packet when the data packet is a downlink data packet;
  • the second search unit 22 is connected to the target IP address obtaining unit 21 for searching whether there is a corresponding hash node in the hash table according to the target IP address.
  • the second statistic unit 23 is connected to the second locating unit 22, and is configured to collect the traffic information of the source IP address according to the downlink data packet when the corresponding IP address exists in the hash table, and save the traffic information.
  • the hash node corresponding to the source IP address is connected to the second locating unit 22, and is configured to collect the traffic information of the source IP address according to the downlink data packet when the corresponding IP address exists in the hash table, and save the traffic information.
  • the hash node corresponding to the source IP address is connected to the second locating unit 22, and is configured to collect the traffic information of the source IP address according to the downlink data packet when the corresponding IP address exists in the hash table, and save the traffic information.
  • the hash node corresponding to the source IP address is connected to the second locating unit 22, and is configured to collect the traffic information of the source IP address according to the downlink data packet when the corresponding IP address exists in the hash table, and save the traffic information.
  • the hash node corresponding to the source IP address is
  • the destination IP address of the downlink data packet is first obtained by the second searching unit 22, and whether there is a corresponding hash node in the hash table according to the destination IP address. If yes, the downlink data packet is the terminal device of the internal network; otherwise, the downlink data packet is the external network device. Therefore, in order to prevent the flood attack of the external network, the abuse of the intranet resources is caused, and the hash node is not established for the downlink data packet, and only the search action can be performed. Finally, the second statistic unit 23 uses the downlink data packet to collect the traffic information of the source IP address, and saves the traffic information to the hash node corresponding to the source IP address.
  • the traffic information includes real-time traffic information and accumulated traffic information.
  • the apparatus provided in this embodiment further includes:
  • timing unit 31 configured to provide a time period
  • the deleting unit 32 is connected to the timing unit 31 for deleting, from the hash table, a hash node corresponding to an IP address whose traffic does not pass through the protocol stack in a time period.
  • a time period can be set by the timing unit 31 according to actual business needs.
  • the deleting unit 32 performs a delete operation periodically, that is, the deleting unit 32 deletes the hash node corresponding to the IP address of the protocol stack in the time period from the hash table. This method is beneficial for users to obtain when reading device information. Always relatively real-time information. It is worth pointing out that the IP address includes the source IP address of the upstream packet and the destination IP address of the downstream packet.
  • the apparatus provided in this embodiment further includes:
  • the writing unit 41 is configured to write the data in the hash table one by one into the file system
  • the reading unit 42 is connected to the writing unit 41 for reading the file system to obtain flow information.
  • the file system is the proc file system.
  • the Linux kernel provides a mechanism for communicating with the application layer, namely the proc file system.
  • the reading unit 42 reads the specified proc file by the standard read file operation, since the writing unit 41 has written the data in the hash table one by one into the file, the terminal is read at this time. Traffic information of the device.

Abstract

本发明提供一种基于哈希节点的终端设备信息统计的方法及装置,应用于连接有多个终端设备的路由器,提供一哈希表,该方法包括步骤:于经过路由器的内核协议栈的数据包为上行数据包时,获取上行数据包的源IP地址;查找哈希表中是否存在源IP地址对应的哈希节点;若不存在,根据源IP地址建立新的哈希节点并插入至哈希表中;若存在,不做处理;根据上行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。通过本发明提供的方法,避免了单纯通过应用层获取信息的信息不足和实效性差的问题,同时避免了对冗余信息的收集对用户产生的困扰。

Description

一种基于哈希节点的终端设备信息统计的方法及装置 技术领域
本发明涉及通信技术领域,尤其涉及一种基于哈希节点的终端设备信息统计的方法及装置。
背景技术
就目前而言,智能路由器大都具有防增网的功能,而这些防蹭网功能的实现是基于能够正确获取到的路由器连接的终端设备的一些信息,这里信息指的是手机或电脑的IP地址、物理地址、流量信息等。
在现有技术中,一般厂商路由器采用的办法是读取DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)服务器的客户端列表,获取对应的IP地址和物理地址信息,这是基于应用层的DHCP协议获取的设备信息。但是,这种方法存在着以下缺点:1、基于DHCP服务器的设备信息获取办法,依赖于DHCP协议,如果租约时期较长(如24小时),那么即使某个设备早就已经下线了,还是能够从DHCP客户端列表中读取到该设备信息;2、对于设置了静态IP地址的终端,DHCP客户端列表则无法找到该设备的信息。有的厂商为了弥补DHCP服务器的这种不足,采取了读路由器ARP (Address Resolution Protocol,地址解析协议)表的方法,该方法的缺点也很明显:1、ARP表项的老化时间可能会很长,该缺点同DHCP的租约时间类似;2、一个终端的同一个网卡设备能够同时设置多个不同网段的IP地址,内核的ARP模块会不加区分的进行统计,这样读取ARP表时,就会出现多条记录的MAC地址相同,而IP却是不同网段的情况。
发明内容
鉴于上述问题,本申请记载了一种基于哈希节点的终端设备信息统计的方法,应用于连接有多个所述终端设备的路由器,提供一哈希表,所述方法包括还步骤:
于经过所述路由器的内核协议栈的数据包为上行数据包时,获取所述上行数据包的源IP地址;
查找所述哈希表中是否存在所述源IP地址对应的哈希节点;
若不存在,根据所述源IP地址建立新的哈希节点并插入至所述哈希表中;若存在,不做处理;
根据所述上行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中。
较佳的,在将新建的所述哈希节点并插入至所述哈希表中时,所述方法还包括步骤:
解析所述上行数据包的物理地址,将所述物理地址添加到所述上行数据包的源IP地址对应的所述哈希节点中。
较佳的,所述方法还包括步骤:
于所述数据包为下行数据包时,获取所述下行数据包的目标IP地址;
根据所述目标IP地址查找所述哈希表中是否存在对应的哈希节点;
若存在,根据所述下行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中;若不存在,不做处理。
较佳的,所述方法还包括步骤:
提供一时间周期;
从所述哈希表中删除在所述时间周期内没有流量经过所述协议栈的IP地址对应的哈希节点;
其中,所述IP地址包括所述上行数据包的所述源IP地址和所述下行数据包的所述目标IP地址。
较佳的,所述方法还包括步骤:
提供一文件系统,将所述哈希表中的数据逐条写入所述文件系统中;
读取所述文件系统,以获取所述流量信息。
较佳的,所述文件系统为proc文件系统。
较佳的,所述流量信息包括实时流量信息和累计流量信息。
本发明还提供了一种基于哈希节点的终端设备信息统计的装置,应用于连接有多个所述终端设备的路由器,所述装置包括:
源IP地址获取单元,用以于经过所述路由器的内核协议栈的数据包为上行数据包时,获取所述上行数据包的源IP地址;
第一查找单元,与所述源IP地址获取单元相连,用以查找哈希表中是否存在所述源IP地址对应的哈希节点;
插入单元,与所述第一查找单元相连,根据所述源IP地址建立新的哈希节点并插入至所述哈希表中;
解析单元,与所述插入单元相连,用以于所述哈希表中不存在所述源IP地址对应的哈希节点时,解析所述源IP地址对应的所述上行数据包的物理地址,并将所述物理地址添加到所述上行数据包的源IP地址对应的所述哈希节点中;
第一统计单元,分别与所述第一查找单元以及所述插入单元相连,用以根据所述上行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中。
较佳的,,所述装置还包括:
目标IP地址获取单元,用以于所述数据包为下行数据包时,获取所述下行数据包的目标IP地址;
第二查找单元,与所述目标IP地址获取单元相连,用以根据所述目标IP地址查找所述哈希表中是否存在对应的哈希节点;
第二统计单元,与所述第二查找单元相连,用以于所述目标IP地址在所述哈希表中存在对应的所述哈希节点时,根据所述下行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中。
较佳的,所述装置还包括:
定时单元,用以提供一时间周期;
删除单元,与定时单元相连,用以从所述哈希表中删除在所述时间周期内没有流量经过所述协议栈的IP地址对应的所述哈希节点;
其中,所述IP地址包括所述上行数据的所述源IP地址和所述习性数据包的所述目标IP地址。
较佳的,所述装置还包括:
写入单元,用以将所述哈希表中的数据逐条写入文件系统中;
读取单元,与所述写入单元相连,用以读取所述文件系统,以获取所述流量信息。
上述技术方案具有如下优点或有益效果:通过本发明提供的方法,避免了单纯通过应用层获取信息的信息不足和实效性差的问题,同时避免了对冗余信息的收集对用户产生的困扰。此外,能够比较全面的统计各种连接方式的终端设备信息,同时不会带来冗余信息。最后,该方法还实现了能够较为实时的对设备的流量信息进行统计。
附图说明
参考所附附图,以更加充分的描述本发明的实施例。然而,所附附图仅用于说明和阐述,并不构成对本发明范围的限制。
图1为本发明一种基于哈希节点的终端设备信息统计的方法中对上行数据包统计流程示意图;
图2为本发明一种基于哈希节点的终端设备信息统计的方法中 对下行数据包统计流程示意图;
图3为本发明一种基于哈希节点的终端设备信息统计的方法中对哈希表老化处理的流程示意图;
图4为本发明一种基于哈希节点的终端设备信息统计的方法中提取流量信息的流程示意图;
图5为本发明一种基于哈希节点的终端设备信息统计的装置中的结构示意图一;
图6为本发明一种基于哈希节点的终端设备信息统计的装置中的结构示意图二;
图7为本发明一种基于哈希节点的终端设备信息统计的装置中的结构示意图三;
图8为本发明一种基于哈希节点的终端设备信息统计的装置中的结构示意图四。
具体实施方式
下面结合附图和具体实施例对本发明一种基于哈希节点的终端设备信息统计的方法及装置进行详细说明。
实施例一
一种基于哈希节点的终端设备信息统计的方法,应用于连接有多个终端设备的路由器,如图1所述,包括步骤:
S11、于经过内核协议栈的数据包为上行数据包时,获取源IP地址;
S12、查找哈希表中是否存在该源IP地址对应的哈希节点;
S13、若不存在,根据该源IP地址建立新的哈希节点,解析该上行数据包的物理地址,并将该物理地址添加到该上行数据包的源IP地址对应的哈希节点的统计信息中,将该哈希节点插入哈希表,执行S14;若存在,直接执行S14;
S14、根据上行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。
此外,如图2所示,该方法还包括步骤:
S21、于经过内核协议栈的数据包为下行数据包时,获取目标IP地址;
S22、根据目标IP地址查找是否存在对应的哈希节点;
S23、若存在,根据下行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中;若不存在,不处理。
具体来说,在本实施例提供的基于哈希节点的终端设备信息统计的方法中,分别对上行数据包以及下行数据包的对应的IP地址的流量信息进行统计存储,以便于后续的管理。在这个过程中,提供了一个哈希表,该哈希表包括多个哈希节点。因为在统计过程中,主要是对内网终端设备的流量信息进行统计,所以在路由器中,上行数据包均是由内网的终端设备发送来的,所以需要对上行数据包均进行统计。
在统计上行数据包的过程中,首先要查找该上行数据包的IP地址,并分析哈希表中是否存在该IP地址相对应的哈希节点,若存在, 在根据该上行数据包在该哈希节点中存储该IP地址相应的流量信息;若不存在,需要先在哈希表上建立一与该IP地址相对应的哈希节点,并将该上行数据包在该哈希节点中存储该IP地址相应的流量信息。值得指出的是,流量信息指的是实时流量信息和累计流量信息。此外,还需要在该上行数据包的源IP地址对应的哈希节点中添加该上行数据包中的物理地址,即发送该上行数据包的终端设备的物理地址。通过建立由多个与IP地址一一对应的哈希节点构成的哈希表,并不断的分析上行数据包的IP地址,根据上行数据包统计相应的IP地址的流量信息,并将统计结构存储在相应的哈希节点中。这种方式实现了对所有上行数据的分类统计,完成了对所有IP地址对应的内网终端的行为数据的统计。
除此之外,对于下行数据包,首先要获取该下行数据包的目的IP地址,根据该目的IP地址查找哈希表中是否有对应的哈希节点。若有,则说明该下行数据包是内网的终端设备的;否则,则说明该下行数据包是外网设备的。所以,为了防止外网的洪泛攻击,造成对内网资源的滥用,不对下行数据包进行哈希节点的建立动作,只可进行查找动作。
近一步来讲,因为在实际应用中,如果某个终端设备已经离线很长时间,但是若还能看到其统计信息,这显然是不合理的,所以需要提供一个针对哈希节点的老化处理方法。即在方法中,如图3所示,还包括步骤:
定时删除老化的哈希节点。
具体来说,定时删除老化的哈希节点的过程包括步骤:
S31、提供一时间周期;
S32、从哈希表中删除在时间周内没有流量经过协议栈的IP地址对应的哈希节点。
具体来说,可以根据实际的业务需要,设定一时间周期。在路由器启动时,每达到一时间周期就会执行一到期函数,该到期函数会对时间周期内没有流量经协议栈的IP地址对应的哈希节点从哈希表中删除。这种方式有利于用户读取设备信息时,获取的总是相对实时的信息。值得指出的是,IP地址包括上行数据包的源IP地址和下行数据包的目标IP地址。
近一步来讲,如图4所示,本实施例提供的方法还包括步骤:
S41、提供一文件系统,将哈希表中的数据逐条写入该文件系统中;
S42、读取该文件系统,以获取流量信息。
近一步来讲,该文件系统是proc文件系统。
具体来讲,在实际应用中,Linux内核提供了一套和应用层通信的机制,即proc文件系统。当应用层通过标准的读文件操作读取指定的proc文件时,因为内核已经将哈希表中的数据逐条的写入到该文件中了,所以此时读取的是终端设备的流量信息。
此外,在获取了流量信息后,用户可以根据这些流量信息指定相应的防火墙规则,进而实现针对某些设备进行防蹭网的处理等。
因为终端设备不管通过什么方式(如DHCP、静态IP)连接到路 由器,通过路由器上网时,数据包都会通过内核的协议栈。所以,在本方法中,利用该特点,在数据包流经的地方对数据包进行解析,并根据解析出的IP地址建立哈希表,即每个终端设备对应一个哈希节点。同时,将解析出的物理地址作为哈希节点统计信息的一部分,也可以根据需要对某个IP地址的上下行流量进行统计,包括累计流量和每秒钟的实时流量,并将这些统计信息保存到对应的哈希节点中。应用层根据需要,从系统文件中读取这些内核的统计信息,用于后续的管理。
本实施例提供的方法,避免了单纯通过应用层获取信息的信息不足和实效性差的问题,同时避免了对冗余信息的收集对用户产生的困扰。此外,能够比较全面的统计各种连接方式的终端设备信息,同时不会带来冗余信息。最后,该方法还能够比较实时的对设备的流量信息进行统计。
实施例二
根据上述实施例提出的一种基于哈希节点的终端设备信息统计的方法,本实施例提出了一种基于哈希节点的终端设备信息统计的装置。
一种基于哈希节点的终端设备信息统计的装置,应用于连接有多个终端设备的路由器,如图5所示,包括:
源IP地址获取单元11,用以于经过路由器的内核协议栈的数据包为上行数据包时,获取上行数据包的源IP地址;
第一查找单元12,与源IP地址获取单元11相连,用以查找哈希 表中是否存在源IP地址对应的哈希节点;
插入单元13,与第一查找单元12相连,用以于哈希表中不存在该源IP地址对应的哈希节点时,根据源IP地址建立新的哈希节点并插入至哈希表中;
第一统计单元14,分别与第一查找单元12以及插入单元13相连,用以根据上行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。
具体来说,在本实施例提供的装置中,当经过路由器的内核协议栈的数据包为上行数据包时,通过源IP地址获取单元11获取该上行数据包的源IP地址。之后,由第一查找单元12从哈希表中查找该源IP地址是否存在有对应的哈希节点,若没有,则需要利用插入单元13根据该源IP地址建立新的哈希节点并插入至该哈希表中。最后,利用第一统计单元14,根据上行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。
进一步来讲,本实施例提供的装置还包括:
解析单元15,与插入单元13相连,用以于哈希表中不存在该源IP地址对应的哈希节点时,解析该源IP地址对应的上行数据包的物理地址,并将该物理地址添加到该上行数据包的源IP地址对应的哈希节点中。
进一步来讲,如图6所示,本实施例提供的装置还包括:
目标IP地址获取单元21,用以于数据包为下行数据包时,用以获取下行数据包的目标IP地址;
第二查找单元22,与目标IP地址获取单元21相连,用以根据目标IP地址查找哈希表中是否存在对应的哈希节点;
第二统计单元23,与第二查找单元22相连,用以于目标IP地址在哈希表中存在对应的哈希节点时,根据下行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。
具体来说,对于下行数据包,首先要通过第二查找单元22获取该下行数据包的目的IP地址,并根据该目的IP地址查找哈希表中是否有对应的哈希节点。若有,则说明该下行数据包是内网的终端设备的;否则,则说明该下行数据包是外网设备的。所以,为了防止外网的洪泛攻击,造成对内网资源的滥用,不对下行数据包进行哈希节点的建立动作,只可进行查找动作。最后,利用第二统计单元23根据下行数据包统计源IP地址的流量信息,并将流量信息保存至源IP地址对应的哈希节点中。
进一步来讲,流量信息包括实时流量信息和累计流量信息。
进一步来讲,如图7所示,本实施例提供的装置还包括:
定时单元31,用以提供一时间周期;
删除单元32,与定时单元31相连,用以从哈希表中删除在时间周期内没有流量经过协议栈的IP地址对应的哈希节点。
具体来说,可以根据实际的业务需要,通过定时单元31设定一时间周期。在路由器启动时,删除单元32定时的进行删除动作,即删除单元32会对时间周期内没有流量经协议栈的IP地址对应的哈希节点从哈希表中删除。这种方式有利于用户读取设备信息时,获取的 总是相对实时的信息。值得指出的是,IP地址包括上行数据包的源IP地址和下行数据包的目标IP地址。
进一步来讲,如图8所示,本实施例提供的装置还包括:
写入单元41,用以将哈希表中的数据逐条写入文件系统中;
读取单元42,与写入单元41相连,用以读取文件系统,以获取流量信息。
近一步来讲,该文件系统是proc文件系统。
具体来讲,在实际应用中,Linux内核提供了一套和应用层通信的机制,即proc文件系统。当读取单元42通过标准的读文件操作读取指定的proc文件时,因为写入单元41已经将哈希表中的数据逐条的写入到该文件中了,所以此时读取的是终端设备的流量信息。
对于本领域的技术人员而言,阅读上述说明后,各种变化和修正无疑将显而易见。因此,所附的权利要求书应看作是涵盖本发明的真实意图和范围的全部变化和修正。在权利要求书范围内任何和所有等价的范围与内容,都应认为仍属本发明的意图和范围内。

Claims (11)

  1. 一种基于哈希节点的终端设备信息统计的方法,应用于连接有多个所述终端设备的路由器,其特征在于,提供一哈希表,所述方法还包括步骤:
    于经过所述路由器的内核协议栈的数据包为上行数据包时,获取所述上行数据包的源IP地址;
    查找所述哈希表中是否存在所述源IP地址对应的哈希节点;
    若不存在,根据所述源IP地址建立新的哈希节点并插入至所述哈希表中;若存在,不做处理;
    根据所述上行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中。
  2. 根据权利要求1所述的基于哈希节点的终端设备信息统计的方法,其特征在于,在将新建的所述哈希节点并插入至所述哈希表中时,所述方法还包括步骤:
    解析所述上行数据包的物理地址,将所述物理地址添加到所述上行数据包的源IP地址对应的所述哈希节点中。
  3. 根据权利要求1所述的基于哈希节点的终端设备信息统计的方法,其特征在于,所述方法还包括步骤:
    于所述数据包为下行数据包时,获取所述下行数据包的目标IP地址;
    根据所述目标IP地址查找所述哈希表中是否存在对应的哈希节点;
    若存在,根据所述下行数据包统计所述源IP地址的流量信息, 并将所述流量信息保存至所述源IP地址对应的所述哈希节点中;若不存在,不做处理。
  4. 根据权利要求3所述的基于哈希节点的终端设备信息统计的方法,其特征在于,所述方法还包括步骤:
    提供一时间周期;
    从所述哈希表中删除于所述时间周期内没有流量经过所述协议栈的IP地址对应的哈希节点;
    其中,所述IP地址包括所述上行数据包的所述源IP地址和所述下行数据包的所述目标IP地址。
  5. 根据权利要求3所述的基于哈希节点的终端设备信息统计的方法,其特征在于,所述方法还包括步骤:
    提供一文件系统,将所述哈希表中的数据逐条写入所述文件系统中;
    读取所述文件系统,以获取所述流量信息。
  6. 根据权利要求5所述的基于哈希节点的终端设备信息统计的方法,其特征在于,所述文件系统为proc文件系统。
  7. 根据权利要求5所述的基于哈希节点的终端设备信息统计的方法,其特征在于,所述流量信息包括实时流量信息和累计流量信息。
  8. 一种基于哈希节点的终端设备信息统计的装置,应用于连接有多个所述终端设备的路由器,其特征在于,所述装置包括:
    源IP地址获取单元(11),用以于经过所述路由器的内核协议栈的数据包为上行数据包时,获取所述上行数据包的源IP地址;
    第一查找单元(12),与所述源IP地址获取单元(11)相连,用以查找哈希表中是否存在所述源IP地址对应的哈希节点;
    插入单元(13),与所述第一查找单元(12)相连,根据所述源IP地址建立新的哈希节点并插入至所述哈希表中;
    解析单元(15),与所述插入单元(13)相连,用以于所述哈希表中不存在所述源IP地址对应的哈希节点时,解析所述源IP地址对应的所述上行数据包的物理地址,并将所述物理地址添加到所述上行数据包的源IP地址对应的所述哈希节点中;
    第一统计单元(14),分别与所述第一查找单元(12)以及所述插入单元(13)相连,用以根据所述上行数据包统计所述源IP地址的流量信息,并将所述流量信息保存至所述源IP地址对应的所述哈希节点中。
  9. 根据权利要求8所述的基于哈希节点的终端设备信息统计的装置,其特征在于,所述装置还包括:
    目标IP地址获取单元(21),用以于所述数据包为下行数据包时,获取所述下行数据包的目标IP地址;
    第二查找单元(22),与所述目标IP地址获取单元(21)相连,用以根据所述目标IP地址查找所述哈希表中是否存在对应的哈希节点;
    第二统计单元(23),与所述第二查找单元(22)相连,用以于所述目标IP地址在所述哈希表中存在对应的所述哈希节点时,根据所述下行数据包统计所述源IP地址的流量信息,并将所述流量信息 保存至所述源IP地址对应的所述哈希节点中。
  10. 根据权利要求9所述的基于哈希节点的终端设备信息统计的装置,其特征在于,所述装置还包括:
    定时单元(31),用以提供一时间周期;
    删除单元(32),与定时单元(31)相连,用以从所述哈希表中删除在所述时间周期内没有流量经过所述协议栈的IP地址对应的所述哈希节点;
    其中,所述IP地址包括所述上行数据的所述源IP地址和所述习性数据包的所述目标IP地址。
  11. 根据权利要求8或9所述的基于哈希节点的终端设备信息统计的装置,其特征在于,所述装置还包括:
    写入单元(41),用以将所述哈希表中的数据逐条写入文件系统中;
    读取单元(42),与所述写入单元(41)相连,用以读取所述文件系统,以获取所述流量信息。
PCT/CN2017/077416 2016-04-26 2017-03-21 一种基于哈希节点的终端设备信息统计的方法及装置 WO2017185912A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610266058.XA CN105978748A (zh) 2016-04-26 2016-04-26 一种基于哈希节点的终端设备信息统计的方法及装置
CN201610266058.X 2016-04-26

Publications (1)

Publication Number Publication Date
WO2017185912A1 true WO2017185912A1 (zh) 2017-11-02

Family

ID=56993595

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/077416 WO2017185912A1 (zh) 2016-04-26 2017-03-21 一种基于哈希节点的终端设备信息统计的方法及装置

Country Status (2)

Country Link
CN (1) CN105978748A (zh)
WO (1) WO2017185912A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105978748A (zh) * 2016-04-26 2016-09-28 上海斐讯数据通信技术有限公司 一种基于哈希节点的终端设备信息统计的方法及装置
CN106844233A (zh) * 2016-12-07 2017-06-13 深圳市德传技术有限公司 一种基于哈希表的路由器运行数据缓存方法及系统
CN107133294A (zh) * 2017-04-26 2017-09-05 上海斐讯数据通信技术有限公司 数据包信息存储方法及系统
CN107682913A (zh) * 2017-09-21 2018-02-09 烽火通信科技股份有限公司 采集无线信号范围内终端设备信息的方法及系统
CN108111422B (zh) * 2017-12-29 2020-11-27 北京明朝万达科技股份有限公司 一种基于dpdk的数据高速多路转发方法及装置
CN111031567B (zh) * 2020-01-14 2022-06-24 南通先进通信技术研究院有限公司 一种核心网设备的流量统计方法
CN115022226A (zh) * 2022-06-01 2022-09-06 浙江航芯科技有限公司 获取路由器在线终端列表的方法、装置、设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1905491A (zh) * 2006-08-11 2007-01-31 杭州华为三康技术有限公司 一种流量统计方法及流量采集器
CN103763154A (zh) * 2014-01-11 2014-04-30 浪潮电子信息产业股份有限公司 一种网络流量检测方法
CN105515919A (zh) * 2016-01-20 2016-04-20 中国电子科技集团公司第五十四研究所 一种基于哈希压缩算法的网络流量监控方法
CN105978748A (zh) * 2016-04-26 2016-09-28 上海斐讯数据通信技术有限公司 一种基于哈希节点的终端设备信息统计的方法及装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6928054B1 (en) * 2000-09-20 2005-08-09 Nortel Networks Limited Apparatus, method, media and signals for connection-class parameter control of packet flow
CN100542094C (zh) * 2003-05-07 2009-09-16 华为技术有限公司 一种网际协议报文的统计方法
CN103581044A (zh) * 2013-11-04 2014-02-12 汉柏科技有限公司 一种流量统计方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1905491A (zh) * 2006-08-11 2007-01-31 杭州华为三康技术有限公司 一种流量统计方法及流量采集器
CN103763154A (zh) * 2014-01-11 2014-04-30 浪潮电子信息产业股份有限公司 一种网络流量检测方法
CN105515919A (zh) * 2016-01-20 2016-04-20 中国电子科技集团公司第五十四研究所 一种基于哈希压缩算法的网络流量监控方法
CN105978748A (zh) * 2016-04-26 2016-09-28 上海斐讯数据通信技术有限公司 一种基于哈希节点的终端设备信息统计的方法及装置

Also Published As

Publication number Publication date
CN105978748A (zh) 2016-09-28

Similar Documents

Publication Publication Date Title
WO2017185912A1 (zh) 一种基于哈希节点的终端设备信息统计的方法及装置
JP4471554B2 (ja) ネットワーク使用監視装置及びそれに関連する方法
CN110113345B (zh) 一种基于物联网流量的资产自动发现的方法
US10263868B1 (en) User-specific policy enforcement based on network traffic fingerprinting
US8843627B1 (en) System and method for extracting signatures from seeded flow groups to classify network traffic
US9088598B1 (en) Systematic mining of associated server herds for uncovering malware and attack campaigns
US8949418B2 (en) Firewall event reduction for rule use counting
WO2018121331A1 (zh) 攻击请求的确定方法、装置及服务器
US20150350154A1 (en) Using Distributed Network Elements to Send Authoritative DNS Responses
CN102724317A (zh) 一种网络数据流量分类方法和装置
CN104639391A (zh) 一种生成网络流量记录的方法及相应的流量检测设备
US10931688B2 (en) Malicious website discovery using web analytics identifiers
CN111314301A (zh) 一种基于dns解析的网站访问控制方法及装置
US20210344589A1 (en) Method, server, and system for data stream redirecting
US10419351B1 (en) System and method for extracting signatures from controlled execution of applications and application codes retrieved from an application source
CN109302406B (zh) 一种分布式网页取证的方法及系统
WO2016201780A1 (zh) 网关管理方法及装置
EP3800833B1 (en) Deep packet inspection application classification systems and methods
US11005806B1 (en) Methods and apparatus for deep packet inspection to identify intermediate network devices
CN111371917B (zh) 一种域名检测方法及系统
CN110300193B (zh) 一种获取实体域名的方法和装置
CN105591836B (zh) 数据流检测方法和装置
CN111143743B (zh) 一种自动扩充应用识别库的方法及装置
CN108737291B (zh) 一种网络流量表示的方法及装置
CN111371915B (zh) Ip地址列表维护方法和装置及网关设备

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17788565

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17788565

Country of ref document: EP

Kind code of ref document: A1