Method for identifying cascade information and direct connection equipment information of switch and access system
Obtain switch information through the SNMP protocol, filter and analyze traffic connection information, identify switch cascade relationships and directly connected devices, solve identification problems in existing technologies, and improve the efficiency and reliability of network management and security control.
Patent Information
- Application Number
- CN202310334125.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
AI Technical Summary
The existing technology is difficult to accurately identify the cascade relationship between switches and directly connected device information, affecting the efficiency of network management and security control.
Obtain the routing table and interface table information of the switch through the SNMP protocol, filter the traffic connection information between switches, establish the switch connection relationship table, determine the sequence tag according to the traffic direction, and identify the cascade relationship and directly connected devices of the switch.
The network topology is constructed, the efficiency of network management and the reliability of security control are improved, and changes in network structure and equipment are grasped in a timely manner.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network access and security control, and in particular relates to a method for acquiring switch cascade information and directly connected device information and an access system applying the method. Background Art
[0002] In device management, the switch is connected to each device that needs to be managed through a network cable. The connection status of each port of the switch and the information of the devices and hosts connected to the ports are important ways for administrators to manage the devices. The SNMP protocol can be used to obtain basic switch information, such as the switch port information, the connection status of each port, the upload and download traffic of the port, the IP / MAC of the device connected to each port, etc., which improves the accuracy of information identification and provides convenience for administrators to manage hosts.
[0003] When it is known that the device is a switch, the SNMP protocol is used to analyze the routing table, interface table and other related variables in the MIB library to obtain the basic information needed to draw the network topology. After summarizing the characteristics of the existing information, the information of the specific connected devices of each port of the switch is obtained, which can provide basic data support for drawing the network topology. In practice, it is necessary to accurately obtain from the basic information of the switch whether the device under each port is directly connected, and the cascade relationship between each switch. Summary of the invention
[0004] Based on the above technical background, the technical solution of the present invention aims to propose a method for identifying switch cascade relationships and switch directly connected devices and a network access system using the identification method. The specific technical contents are as follows: In a first aspect, a method for identifying a switch cascade relationship is provided, comprising: Get the information of each switch in the network and the device information of each port; According to the switch IP, the connection information including only the traffic between switches is filtered out from the port device information, and a switch connection relationship table is established; The sequence mark of each piece of data in the switch connection relationship table is determined according to the switch flow direction, and the cascade relationship of each switch is determined according to the sequence mark.
[0005] The obtaining of information of each switch in the network and device information under each port thereof includes, when it is known that the device is a switch, obtaining using the SNMP protocol: a switch details table including the IP of the first switch and its corresponding MAC; a port device table including the IP of the third switch, the ID of the third port and the corresponding relationship between the MAC of the third device connected thereto and the device IP.
[0006] Preferably, a switch connection relationship table is established, including: Take out all the first switch IPs in the switch details table and add them to the second switch IP list. According to the second switch IP, traverse the port device table, take out all data that meets the first condition and store them in the switch connection relationship table. The first condition includes that the third switch IP = the second switch IP and the corresponding device IP = the first switch IP. When the above data is stored in the switch connection relationship table, it is stipulated that: destination IP = third switch IP, destination port = third port ID, start IP = third device IP.
[0007] Preferably, the sequence mark of each piece of data in the switch connection relationship table is determined according to the switch traffic direction, including: The switch connection relationship table is read cyclically, and the data with the same destination port is taken out. If the list is not empty after filtering out the data with the destination IP as the core switch, each piece of data is traversed: If the starting IP of the first data is not a core switch, obtain the second data whose destination IP and starting IP are swapped with the first data, and obtain the third data whose destination IP and destination port are the same as the second data; if there is only one piece of the third data that meets the condition, add the first state mark to the first data and add the second state mark to the second data; if there is more than one piece of the third data that meets the condition, add the second state mark to the first data and the second data respectively; If the starting IP of the first data is a core switch, a second status mark is added to the first data and the second data respectively.
[0008] Preferably, the above-mentioned determining the cascade relationship of each switch according to the sequence tag includes: Query the data with the first status mark added to the switch connection relationship table, obtain the first data list with the starting IP as the core switch, and set the sequence mark of each data to 1; Use the destination IP of the first data list as the starting IP of the next query condition, query the data with a sequence mark of empty, and set the sequence mark of each data to 2; If the current query results in more than one piece of data, traverse each piece of data, use the destination IP as the starting IP of the next query condition, query the data that has been marked with the first status and has a sequence mark of empty, and set the sequence mark of each piece of data to 3; If only one piece of data is found, the destination IP of the data is used as the starting IP of the next query condition, and the data with the first status mark added and the sequence mark is empty are queried, and the sequence mark of each piece of data is set to 3; Continue to query according to the above steps until no matching data is found in the switch connection relationship table; Finally, the cascade relationship of each switch is determined according to the sequence mark, including that the sequence mark of each piece of data indicates the level of a group of cascade relationships represented by the piece of data.
[0009] In a second aspect, a method for identifying a switch directly connected device is provided, the method comprising the above-mentioned switch details table, port device table and switch connection relationship table; The process of obtaining the switch directly connected device includes: Add a third status mark to the data in the port device table that meets the following conditions: the third device MAC belongs to the first switch MAC in the switch details table; Take out the data with the largest sequence mark in the switch connection relationship table as the first data list: Add a third status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID = the destination port ID in the first data list, Add a fourth status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID ≠ the destination port ID in the first data list, Query the data without adding the status mark, if the third switch IP corresponding to the MAC of the data is ≠ the current switch IP in the first data list, then add the third status mark to the data; According to the sequence mark, the data in the switch connection relationship table are taken out in order from large to small, and the state mark is added to the port device table according to the above process until all the data are marked; the device marked as the fourth state is the device directly connected to the switch.
[0010] In a third aspect, a device for identifying a switch cascade relationship and a directly connected device is provided, the device comprising: The switch basic information acquisition module is used to obtain the information of each switch in the network and the device information of each port using the SNMP protocol; An information extraction module is used to filter out connection information including only traffic between switches from port device information according to the switch IP, and establish a switch connection relationship table; The information analysis module is used to determine the sequence mark of each data in the switch connection relationship table according to the switch flow direction, determine the cascade relationship of each switch according to the sequence mark, and filter out the device information directly connected to the switch from the port device table according to the sequence mark.
[0011] Preferably, the information extraction module establishes a switch details table, a port device table and a switch connection information table according to the above method.
[0012] Preferably, the information analysis module determines the cascade relationship of each switch and identifies the directly connected device of the switch according to the above method.
[0013] In a fourth aspect, a network access system is also provided, comprising a terminal and an access server, wherein the server comprises the identification device as described above.
[0014] The present invention adopting the above technical solution has at least the following beneficial effects: obtaining the routing table and interface table information of the switch through the SNMP protocol; then performing feature analysis on the obtained information to obtain the cascade information between switches; and finally determining the IP / MAC of the device directly connected to each switch port based on the cascade information and interface table information. Using this information, the topology of the network can be constructed, and the efficiency of network management can be improved, especially in terms of network access and security control, timely grasping and discovering changes in network structure and equipment, which has positive significance for improving the effectiveness of access and the reliability of security protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a schematic diagram of the overall process of an embodiment of the switch cascade relationship identification method of the present invention; Figure 2 This is a schematic diagram of a process of establishing a switch connection relationship table in accordance with an embodiment of a method for identifying a switch cascade relationship of the present invention; Figure 3 This is a schematic diagram of a data screening process in accordance with an embodiment of a method for identifying a cascade relationship of switches of the present invention; Figure 4 This is a schematic diagram of a network topology structure based on switches obtained in the embodiment of the switch cascade relationship identification method of the present invention; Figure 5 This is a schematic diagram of the module composition of the switch cascade relationship and direct-connected device identification device of the present invention. Implementation
[0016] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant contents of the present application, rather than to limit the application. It is also necessary to explain that, for ease of description, only the parts related to the application are shown in the accompanying drawings.
[0017] For ease of understanding, the terms involved in the embodiments of the present invention are first explained: Switches mainly work at the physical layer and data link layer of the OSI model, providing transparent bridging and switching between Ethernets, and forwarding Ethernet data frames between ports based on the MAC address of the link layer. They can be used to isolate collision domains. In the OSI reference model, the second layer where the switch is located is used for addressing. The addressing here refers to the MAC address, and the switch forwards the MAC address. In each switch, there is a MAC address table, which is automatically learned by the switch. It can be seen that one of the main functions of the switch is MAC-based addressing and forwarding, while the router addressing is based on the IP address, which is one of the main differences between the two.
[0018] Network and device administrators can obtain data from devices through SNMP read operations (GET) and perform setting operations on devices through SNMP write operations (SET). Devices can notify administrators of important status change events of devices through SNMP trap operations (alarms).
[0019] The basic idea of SNMP is to define a unified interface and protocol for devices of different types, manufacturers, and models, so that administrators can manage these network management devices through a unified appearance, improve the efficiency of network management, and simplify the work of network administrators. SNMP is designed on the TCP / IP protocol family and works based on the TCP / IP protocol to manage devices in the network that support the SNMP protocol.
[0020] In terms of specific implementation, SNMP provides administrators with a network management platform NMS, which is responsible for issuing network management commands, data storage, and data analysis. The SNMP agent runs on the supervised device, and the agent implements SNMP communication between the device and the network management. The network management and the agent are interfaced through MIB. MIB defines the managed objects in the device. Both the network management and the agent implement the corresponding MIB objects, so that both parties can identify each other's data and achieve communication. The network management applies to the agent for the data defined in the MIB. After the agent recognizes it, it converts the relevant status or parameters provided by the device into the format defined by the MIB and responds to the network management to complete a management operation.
[0021] The technical solution of the present invention includes a method for identifying a switch cascade relationship, a method for identifying a directly connected device, and a network access system applying the method.
[0022] like Figure 1 The method for identifying the cascade relationship of switches generally comprises the following steps: S101, obtaining information of each switch in the network and device information of each port thereof.
[0023] S102, filtering out connection information including only traffic between switches from port device information according to the switch IP, and establishing a switch connection relationship table.
[0024] S103, determining the sequence mark of each piece of data in the switch connection relationship table according to the switch traffic direction.
[0025] S104, determining the cascade relationship of each switch according to the sequence tag.
[0026] The following is a detailed description of each step: In S101, basic switch information is obtained from the routing table, interface table, etc. of the switch through commands of the SNMP protocol, such as: (1) Obtain the switch device name, port number, port information, and switch continuous operation time; (2) Obtain basic information about the switch - device model, device manufacturer; (3) Get the switch port list - name, online status, total upload traffic, total download traffic (byte), upload speed, download speed, and the number of connections corresponding to the port; (4) Obtain the device list corresponding to the switch port, ①IP address list, ②IP / MAC list, ③The port number of the connection corresponding to the MAC address; ①+②get the IP-MAC correspondence relationship; convert each bit of the MAC address into decimal, and correspond to ③ information to obtain the device IP list corresponding to each port of the switch.
[0027] It should be noted here that the "first", "second", etc. mentioned below are just formal distinctions made for the convenience of describing the same subject data in different tables, and do not constitute a limitation on the technical features.
[0028] When the device is known to be a switch, the basic switch information obtained above can be used to obtain a switch details table including the first switch IP and its corresponding MAC, and a port device table including the third switch IP, the third port ID and the corresponding relationship between the third device MAC connected to it and the device IP.
[0029] The switch details table format described above can be shown in Table 1: Table 1 tb_interchanger Serial number ip (switch ip) mac (switch mac) vlan (vlan of the switch) 1 The above port device table can be shown in Table 2: Table 2 tb_ip_mac_list Serial number Ethernet _ip (Switch IP) Ethernet_id (switch port) mac (device mac) ip (device ip) vlan (switch vlan) status (whether it is directly connected) 1 In S102, Figure 2 As shown, Take out all the first switch IPs in the switch details table (Table 1) and add them to the second switch IP list. According to the second switch IP, traverse the port device table (Table 2) or directly traverse the first switch IP. Take out all the data that meets the first condition and store them in the switch connection relationship table. The first condition includes that the third switch IP = the second switch IP and the corresponding device IP = the first switch IP. When storing the above filtered data into the switch connection relationship table, it is stipulated that: destination IP = third switch IP, destination port = third port ID, start IP = third device IP.
[0030] Combined with the above table format, a switch connection relationship table is established, including: reading the information in the tb_interchanger table, counting the switch IP list, traversing the switch list, obtaining the ethernet_ip in the tb_ip_mac_list as the currently traversed switch IP, and the device IP belongs to the switch information, and storing it in the tb_connected table.
[0031] In S103, the sequence mark of each piece of data in the switch connection relationship table is determined according to the switch traffic direction, including two steps of data screening and sequence marking.
[0032] The first step, such as Figure 3 Filter the data as shown.
[0033] The switch connection relationship table is read cyclically, and the data with the same destination port is taken out. If the list is not empty after filtering out the data with the destination IP as the core switch, each piece of data is traversed: If the starting IP of the first data is not a core switch, obtain the second data whose destination IP and starting IP are swapped with the first data, and obtain the third data whose destination IP and destination port are the same as the second data; if there is only one piece of the third data that meets the condition, add the first state mark to the first data and add the second state mark to the second data; if there is more than one piece of the third data that meets the condition, add the second state mark to the first data and the second data respectively; If the starting IP of the first data is a core switch, a second status mark is added to the first data and the second data respectively.
[0034] The second step is to sequence label the filtered data.
[0035] Query the data with the first status mark added to the switch connection relationship table, obtain the first data list with the starting IP as the core switch, and set the sequence mark of each data to 1; Use the destination IP of the first data list as the starting IP of the next query condition, query the data with a sequence mark of empty, and set the sequence mark of each data to 2; If the current query results in more than one piece of data, iterate through each piece of data, use the destination IP as the starting IP for the next query condition, query the data that has been marked with the first status and whose sequence mark is empty, and set the sequence mark of each piece of data to 3. If only one piece of data is found, the destination IP of the data is used as the starting IP of the next query condition, and the data with the first status mark added and the sequence mark is empty are queried, and the sequence mark of each piece of data is set to 3; Continue to query according to the above steps until no data that meets the conditions is found in the switch connection relationship table.
[0036] In S104, the cascade relationship of each switch is determined according to the sequence mark, including that the sequence mark of each piece of data indicates the level of a group of cascade relationships represented by the piece of data.
[0037] Based on the data in the switch details table, the port device list and the switch connection relationship table, an embodiment of a method for identifying a switch directly connected device is proposed.
[0038] The process of obtaining the switch directly connected device includes: Add a third status mark to the data in the port device table that meets the following conditions: the third device MAC belongs to the first switch MAC in the switch details table; Take out the data with the largest sequence mark in the switch connection relationship table as the first data list: Add a third status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID = the destination port ID in the first data list, Add a fourth status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID ≠ the destination port ID in the first data list, Query the data without adding the status mark, if the third switch IP corresponding to the MAC of the data is ≠ the current switch IP in the first data list, then add the third status mark to the data; According to the sequence mark, the data in the switch connection relationship table are taken out in order from large to small, and the state mark is added to the port device table according to the above process until all the data are marked; the device marked as the fourth state is the device directly connected to the switch.
[0039] The following describes the identification method of the switch cascade relationship and the directly connected device, and the corresponding device for implementing the identification method, through specific embodiments. Embodiment 1
[0040] This embodiment provides a process for identifying a switch cascade relationship. For example, there is a switch connection relationship table and data to be processed as shown in the following table, that is, Table (1): id ip_start(destination IP) ethernet_id_start(destination port) ip_end (starting IP) ethernet_id_end(starting port) status (status flag) 1 10.0.11.254 5 10.0.11.209 2 10.0.11.254 5 10.0.11.207 3 10.0.11.254 5 10.0.11.252 4 10.0.11.254 5 10.0.11.205 5 10.0.11.252 7 10.0.11.254 6 10.0.11.252 13 10.0.11.207 7 10.0.11.252 15 10.0.11.209 8 10.0.11.252 12 10.0.11.205 9 10.0.11.207 4 10.0.11.254 10 10.0.11.207 6 10.0.11.252 11 10.0.11.207 8 10.0.11.205 12 10.0.11.207 3 10.0.11.209 13 10.0.11.205 13 10.0.11.254 14 10.0.11.205 13 10.0.11.252 15 10.0.11.205 13 10.0.11.207 16 10.0.11.205 13 10.0.11.209 17 10.0.11.209 4 10.0.11.254 18 10.0.11.209 4 10.0.11.252 19 10.0.11.209 4 10.0.11.207 20 10.0.11.209 4 10.0.11.205 (1) The unprocessed data in the list is obtained, and the core switch IP is known to be 10.0.11.254.
[0041] (2) Take out the data with the same ethernet_id_start as in (1) and filter out the data with ip_start as the core switch, that is, filter out the data with ip_start as 10.0.11.254. The resulting list is not empty, that is, we get Table (2): id ip_start ethernet_id_start ip_end ethernet_id_end status 13 10.0.11.205 13 10.0.11.254 14 10.0.11.205 13 10.0.11.252 15 10.0.11.205 13 10.0.11.207 16 10.0.11.205 13 10.0.11.209 17 10.0.11.209 4 10.0.11.254 18 10.0.11.209 4 10.0.11.252 19 10.0.11.209 4 10.0.11.207 20 10.0.11.209 4 10.0.11.205 (3) Traverse the data in table (2): It should be noted here that Connected1, Connected2, etc. described below represent different data.
[0042] If ip_end is a core switch, the status of the data is set to -1, and the status of the data in Table (1) that meets "Connected2.ip_start=Connected1.ip_end and Connected2.ip_end=Connected1.ip_start" is set to -1.
[0043] id ip_start ethernet_id_start ip_end ethernet_id_end status 14 10.0.11.205 13 10.0.11.252 -1
[0044] (3-1) If ip_end is not a core switch, query the data list in table (1) that uses the data Connected1.ip_end as Connected2.ip_start, Connected1.ip_start as Connected2.ip_end and status is not equal to -1.
[0045] id ip_start ethernet_id_start ip_end ethernet_id_end status 8 10.0.11.252 12 10.0.11.205 -1
[0046] (3-2) Query table (1) to obtain the following data that meet the conditions: Connected2.ipstart=Connected3.ipStart, The data list of Connected2.ethernetIdStart=Connected3.ethernetIdStart. If there is only one data, set the status of Connected1 to 1 and the status of Connected2 to -1; if there are multiple data, set the status of Connected1 and Connected2 to -1 respectively.
[0047] 6 10.0.11.252 13 10.0.11.207 7 10.0.11.252 15 10.0.11.209
[0048] (3-3) Repeat the above steps until the data traversal is completed.
[0049] (4) After the traversal is completed, the data with status 1 is valid data, and the next step is to add sequence markers.
[0050] The process of adding sequence markers to data is illustrated with the following data as an example: ip_start ip_end sequence 10.0.11.252 10.0.11.254 10.0.11.203 10.0.11.252 10.0.11.207 10.0.11.252 10.0.11.209 10.0.11.207 10.0.11.205 10.0.11.207 10.0.11.201 10.0.11.209 Get the data list of the core switch with ip_end, that is ip_start ip_end sequence 10.0.11.252 10.0.11.254 Indicates that the data in this list is the root node, and sets the sequence to 1. ip_start ip_end sequence 10.0.11.252 10.0.11.254 1 And determine the length of the list. If the length of the list = 1, then directly use this ip_start as the ip_end of the next query condition, and the data list with sequence as empty, as follows: ip_start ip_end sequence 10.0.11.203 10.0.11.252 10.0.11.207 10.0.11.252 Indicates that the data in this list are nodes under the root node, and the sequence is set to 2. ip_start ip_end sequence 10.0.11.203 10.0.11.252 2 10.0.11.207 10.0.11.252 2 Determine the length of the list. If the length of the list is > 1, traverse the list and take the ip_start of the data in the list as the ip_end of the next query condition, as well as the data list where the sequence is empty, as follows: ip_start ip_end sequence 10.0.11.209 10.0.11.207 10.0.11.205 10.0.11.207 Indicates that the data in this list is the node under the previous node, and sets the sequence to 3. ip_start ip_end sequence 10.0.11.209 10.0.11.207 3 10.0.11.205 10.0.11.207 3 Determine the length of the list. If the length of the list is > 1, traverse the list and take the ip_start of the data in the list as the ip_end of the next query condition, as well as the data list where the sequence is empty, as follows: ip_start ip_end sequence 10.0.11.201 10.0.11.209 Set sequence to 4, ip_start ip_end sequence 10.0.11.201 10.0.11.209 4 Determine the length of the list. If the length of the list = 1, traverse the list and take the ip_start of the data in the list as the ip_end of the next query condition. If there is no data, the data processing ends.
[0051] The table after the above process is completed is as follows: ip_start ip_end sequence 10.0.11.252 10.0.11.254 1 10.0.11.203 10.0.11.252 2 10.0.11.207 10.0.11.252 2 10.0.11.209 10.0.11.207 3 10.0.11.205 10.0.11.207 3 10.0.11.201 10.0.11.209 4 The sequence tag (i.e., sequence) indicates the level of the cascade relationship consisting of the "ip_end" and "ip_start" pairs. Based on the connection direction, the network topology based on the switch can be obtained (e.g. Figure 4 as shown). Embodiment 2
[0052] How to identify devices directly connected to a switch. The operation is the tb_ip_mac_list table Step 1: Remove the information about switches connecting to each other Find the switch mac list according to the tb_interchanger table Query the data in tb_ip_mac_list and tb_ethernet whose mac belongs to the switch and whose status is empty, and set the status of all these data to -1 (that is, these correspondences are all correspondences between switches and do not need to be displayed when displaying the relationship between switch ports and devices).
[0053] Step 2: Determine the device directly connected to the switch According to the switch cascading sequence obtained in Example 1, find the data list with the largest sequence; Determine if sequence is greater than 0 and the size of the data list is greater than 0 and then traverse the list (connected data list) (2-1) Query the data in the ip_mac_list table where ethernet_ip is equal to ip_start in the connected data, ethernet_id is equal to ethernet_id_start in the connected data, and the status field in the ip_mac_list table is empty. The data of these devices are all read from the ports connected to the switch, so the status field is set to -1, indicating that these devices are not directly connected to the switch.
[0054] (2-2) Query the data list in the ip_mac_list table where ethernet_ip is equal to ip_start in the connected data, and ethernet_id is not equal to ethernet_id_start in the connected data, and the status field in the ip_mac_list table is empty, and traverse this list.
[0055] (2-2-1) Set the status of this data to 1, indicating that the device is directly connected to this switch.
[0056] (2-2-2) Query the data list where the mac of the data is not the current switch IP and the status is empty, and set all the states of these data to -1. (Because these devices are connected to the switch at the bottom layer, the data read in other switches are read between switches, so the status is set to -1).
[0057] Set sequence = sequence - 1, query the switch data list (connected data list) corresponding to the current sequence, jump to (2), and continue processing the switch device information.
[0058] Finally, find the device whose status is 1, which is the device directly connected to the switch. Embodiment 3
[0059] like Figure 5 As shown, a device for identifying a switch cascade relationship and a directly connected device includes: The basic information acquisition module is used to obtain the information of each switch in the network and the device information under each port using the SNMP protocol; An information extraction module is used to filter out connection information including only traffic between switches from port device information according to the switch IP, and establish a switch connection relationship table; The information analysis module is used to determine the sequence mark of each data in the switch connection relationship table according to the switch flow direction, determine the cascade relationship of each switch according to the sequence mark, and filter out the device information directly connected to the switch from the port device table according to the sequence mark.
[0060] Preferably, the information extraction module establishes a switch details table, a port device table and a switch connection information table according to the above method.
[0061] Preferably, the information analysis module determines the cascade relationship of each switch and identifies the directly connected device of the switch according to the above method.
[0062] A person skilled in the art will appreciate that all or part of the steps in the above-mentioned embodiment method may also be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc.
[0063] The above description of the above disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will conform to the broadest scope consistent with the principles disclosed herein.
Claims
1. A method for identifying a switch cascade relationship, characterized in that: include: Get the information of each switch in the network and the device information of each port; According to the switch IP, the connection information including only the traffic between switches is filtered out from the port device information, and a switch connection relationship table is established; The sequence mark of each piece of data in the switch connection relationship table is determined according to the switch flow direction, and the cascade relationship of each switch is determined according to the sequence mark.
2. The method according to claim 1, characterized in that The obtaining of information of each switch in the network and device information under each port thereof includes, when the known device is a switch, obtaining using the SNMP protocol: a switch details table including an IP address of a first switch and a corresponding MAC address of the first switch; A port device table including the third switch IP, the third port ID and the corresponding relationship between the third device MAC connected thereto and the device IP.
3. The method according to claim 2, characterized in that Establish a switch connection relationship table, including: Take out all the first switch IPs in the switch details table and add them to the second switch IP list. According to the second switch IP, traverse the port device table, take out all data that meets the first condition and store them in the switch connection relationship table. The first condition includes that the third switch IP = the second switch IP and the corresponding device IP = the first switch IP. When the data is stored in the switch connection relationship table, it is stipulated that: destination IP=third switch IP, destination port=third port ID, start IP=third device IP.
4. The method according to claim 3, characterized in that The sequence mark of each piece of data in the switch connection relationship table is determined according to the switch traffic direction, including: The switch connection relationship table is read cyclically, and the data with the same destination port is taken out. If the list is not empty after filtering out the data with the destination IP as the core switch, each piece of data is traversed: If the starting IP of the first data is not a core switch, obtain the second data whose destination IP and starting IP are swapped with the first data, and obtain the third data whose destination IP and destination port are the same as the second data; if there is only one piece of the third data that meets the condition, add the first state mark to the first data and add the second state mark to the second data; if there is more than one piece of the third data that meets the condition, add the second state mark to the first data and the second data respectively; If the starting IP of the first data is a core switch, a second status mark is added to the first data and the second data respectively.
5. The method according to claim 4, characterized in that The cascade relationship of each switch is determined according to the sequence tag, including: Query the data with the first status mark added to the switch connection relationship table, obtain the first data list with the starting IP as the core switch, and set the sequence mark of each data to 1; Use the destination IP of the first data list as the starting IP of the next query condition, query the data with a sequence mark of empty, and set the sequence mark of each data to 2; If the current query results in more than one piece of data, traverse each piece of data, use the destination IP as the starting IP of the next query condition, query the data that has been marked with the first status and has a sequence mark of empty, and set the sequence mark of each piece of data to 3; If only one piece of data is found, the destination IP of the data is used as the starting IP of the next query condition, and the data with the first status mark added and the sequence mark is empty are queried, and the sequence mark of each piece of data is set to 3; Continue to query according to the above steps until no matching data is found in the switch connection relationship table; Finally, the cascade relationship of each switch is determined according to the sequence mark, including that the sequence mark of each piece of data indicates the level of a group of cascade relationships represented by the piece of data.
6. A method for identifying a switch directly connected device, characterized in that: The method comprises the switch details table, the port device table and the switch connection relationship table as described in any one of claims 2 to 5; The process of obtaining the switch directly connected device includes: Add a third status mark to the data in the port device table that meets the following conditions: the third device MAC belongs to the first switch MAC in the switch details table; Take out the data with the largest sequence mark in the switch connection relationship table as the first data list: Add a third status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID = the destination port ID in the first data list, Add a fourth status mark to the data in the port device table that meets the following conditions: the third switch IP = the destination IP in the first data list, and the third port ID ≠ the destination port ID in the first data list, Query the data without adding the status mark, if the third switch IP corresponding to the MAC of the data is ≠ the current switch IP in the first data list, then add the third status mark to the data; According to the sequence mark, the data in the switch connection relationship table are taken out in order from large to small, and the state mark is added to the port device table according to the above process until all the data are marked; the device marked as the fourth state is the device directly connected to the switch.
7. A device for identifying switch cascade relationships and directly connected devices, characterized in that: The device comprises: The switch basic information acquisition module is used to obtain the information of each switch in the network and the device information of each port using the SNMP protocol; An information extraction module is used to filter out connection information including only traffic between switches from port device information according to the switch IP, and establish a switch connection relationship table; The information analysis module is used to determine the sequence mark of each data in the switch connection relationship table according to the switch flow direction, determine the cascade relationship of each switch according to the sequence mark, and filter out the device information directly connected to the switch from the port device table according to the sequence mark.
8. The device according to claim 7, characterized in that The information extraction module establishes a switch details table, a port device table and a switch connection information table according to the method of claim 2 or 3.
9. The device according to claim 7, characterized in that The information analysis module determines the cascade relationship of each switch according to the method of claim 4 or 5, and identifies the directly connected device of the switch according to the method of claim 6.
10. A network access system, characterized in that: The system includes a terminal and an access server, and the server includes the device as described in any one of claims 7 or 9.
