A method for vlan traversal test of a switch
By automatically configuring VLAN parameters and comparing them with web page information through PC-side scripts, and combining this with network card IP address analysis, automated testing of switch VLANs is achieved. This solves the problems of time-consuming and costly VLAN traversal testing of switches, enabling fast and low-cost comprehensive testing.
Patent Information
- Application Number
- CN202211299511.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-21
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2042-10-21
AI Technical Summary
Existing technologies for VLAN traversal testing of switches are time-consuming, labor-intensive, and risky due to random sampling testing, and cannot fully cover all 4094 VLANs.
By running a PC-based script to automatically configure VLAN parameters, comparing the parameter information obtained from the web interface with the expected values, and automatically obtaining IP addresses using the network card to determine the validity of the DHCP server, automated testing of switch VLANs is achieved.
It enables rapid and automated testing of switch VLANs, saving manpower and resources, reducing costs, improving testing efficiency, and avoiding the risks of manual random sampling testing.
Smart Images

Figure CN115604096B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to switch testing methods, and more particularly to a method for VLAN traversal testing of a switch. Background Technology
[0002] Currently, manually traversing all 4094 VLANs when testing switch VLANs is an extremely wasteful labor cost. Therefore, in actual project testing, not all VLANs are traversed. Generally, a small number of VLANs are randomly selected manually for traversal. However, this results in an incomplete test and poses a significant risk.
[0003] However, traversing all VLANs presents several problems: excessive data volume and time-consuming manual statistics. For example, creating a VLAN, opening a Layer 3 virtual interface, and checking the correctness of parameters displayed on the web interface and the validity of the DHCP server for that interface typically takes two minutes. Therefore, traversing all 4094 VLANs would require 17 working days to complete this task. This is excessively time-consuming, inefficient, and labor-intensive. Summary of the Invention
[0004] To address the problems in existing technologies, this invention provides a method for VLAN traversal testing of a switch. By running a PC-side script, VLAN parameters are automatically configured. Then, the parameter information obtained from the web interface is compared with the expected values to complete the webpage display information check. PC network card 2 continuously releases / renews to obtain IP addresses. After obtaining an IP address, network card 2 checks whether the IP address is within the address pool range and verifies the validity of the DHCP Server function. This completes the automated testing of the switch's VLANs. The testing method is simple, fast, saves manpower and resources, and is low-cost. It solves the problems of high risk in manual random sampling testing and high cost and time-consuming manual comprehensive testing in existing technologies.
[0005] A method for VLAN traversal testing of a switch according to the present invention includes the following steps:
[0006] Step 1: Set up the hardware test environment, set the VLAN 1 management address of the switch, connect network card 1 to port 1 of the switch through a static address, connect network card 2 to port 2 of the switch through a dynamic IP address, and connect the console port of the switch to the USB port of the PC.
[0007] Step 2: Configure 4094 switch VLANs, define custom variables i, m, and n, assign initial values i=m=n=1, create a standard data file to store the expected values, enter the command vlan 1-4094 in the globally configured VLAN data file, and turn on the global DHCP Server switch;
[0008] Step 3: Configure VLAN and address pool parameters, create a Layer 3 VLAN interface with VLAN ID=i, add an address pool configuration, configure the DNS server, address pool range, subnet mask and gateway, and store the Layer 3 VLAN interface parameters and address pool parameters to a standard data file;
[0009] Step 4: Repeat step 3 to traverse VLAN i, where 1 ≤ i ≤ 4094 and i is a positive integer;
[0010] Step 5: Set VLAN ID = m, enable the DHCP Server on the Layer 3 interface of VLAN m, traverse VLAN m, save the configuration, 1 ≤ m ≤ 4094, where m is a positive integer;
[0011] Step 6: Read each Layer 3 interface parameter and compare it with the expected value in the standard data file to determine whether it conforms to the standard;
[0012] Step 7: When the Layer 3 interface parameters of the switch VLAN are compared with the expected values in the standard data file and it is determined that they conform to the standard, check the validity of the Layer 3 interface DHCP Server, set port 2 to VLAN ID = n, 1≤n≤4094, where n is a positive integer, network card 2 obtains an IP address and determines whether the IP address is within the address pool range;
[0013] Step 8: Test each VLAN n one by one. If network card 2 obtains an IP address and all IP addresses are within the address pool range, the test passes and the test is completed. Otherwise, the test fails and the program terminates.
[0014] The present invention is further improved in that, in step 1, the PC is pre-installed with PyCharm and SecureCRT software and has a USB port, network card 1 and network card 2. The switch has switch port 1, switch port 2 and switch console port. The VLAN 1 management address of the switch is 192.0.0.1 / 24. The static address of network card 1 is 192.0.0.2 / 24. Network card 1 is connected to switch port 1 through the static address. Network card 2 is connected to switch port 2 by obtaining a dynamic IP address. The USB port is connected to the switch console port through a serial cable.
[0015] The present invention is further improved in that, in step 2, the standard data file is an Excel file, and the expected value is the range of data values that can be theoretically obtained when testing the VLAN of the switch.
[0016] In a further improvement to this invention, in step 3, the IP address of the VLAN interface is 192.BC1 / 24, 1≤B≤255, 1≤C≤255, and B and C are positive integers.
[0017] The present invention is further improved in that, in step 3, the DNS server is configured as 8.8.8.8, the address pool range is 192.BC1-192.BC100, the subnet mask is 255.255.255.0, and the gateway is configured as 192.BC1.
[0018] The present invention is further improved in that, in step 3, all parameters other than the Layer 3 VLAN interface parameters and address pool parameters are also stored in the standard data file, including the expected value of the DHCP Server interface enable switch state being enabled.
[0019] In a further improvement to this invention, in step 6, the Layer 3 interface parameters are displayed on the web page of the PC. The Layer 3 interface parameters include VLAN ID, IP address, subnet mask, and DHCP Server interface enable / disable status.
[0020] The present invention is further improved in that, in step 6, when the Layer 3 interface parameters of the switch VLAN are compared with the expected values of the standard data file and it is determined that they do not meet the standard, the switch VLAN parameter information of the unsuccessful comparison is output, the program is terminated, and the administrator is prompted to handle it.
[0021] In a further improvement to this invention, in step 7, network card 2 obtains an IP address through the release and renew commands. When network card 2 fails to obtain an IP address or the obtained IP address is not within the address pool range, it outputs a failure message, records relevant parameter information, terminates the program, and prompts the administrator for processing.
[0022] The present invention is further improved in that, in step 1, the switch can be replaced with various models of Layer 3 switches under test for testing, and all operations on the switch are performed using CLI commands.
[0023] The beneficial effects of this invention are as follows: This invention provides a method for VLAN traversal testing of a switch. By running a PC-side script, VLAN parameters are automatically configured, and then the parameter information obtained from the web interface is compared with the expected values to complete the web page display information check. PC network card 2 continuously releases / renews to obtain IP addresses. After obtaining an IP address, network card 2 determines whether the IP address is within the address pool range and checks the validity of the DHCP Server function, thereby completing the automated testing of the switch VLANs. Through the automated VLAN traversal testing method, the boundary values of switch VLANs and the validity of the Layer 3 VLAN interface DHCP Server can be tested, realizing tests that are extremely difficult to complete manually. The testing method is simple, fast, saves manpower and material resources, and has low cost. It solves the problems of high risk in manual random sampling testing and high cost in manual comprehensive testing in the prior art. Attached Figure Description
[0024] Figure 1 This is a flowchart of a method for testing VLAN traversal on a switch according to the present invention. Detailed Implementation
[0025] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.
[0026] Please see Figure 1 The present invention provides a method for VLAN traversal testing of a switch, comprising the following steps:
[0027] Step 1: Set up the hardware test environment. Set the VLAN 1 management address of the switch to 192.0.0.1 / 24 and the static address of NIC 1 to 192.0.0.2 / 24. NIC 1 is connected to port 1 of the switch through the static address, and NIC 2 is connected to port 2 of the switch through obtaining a dynamic IP address. Connect the console port of the switch to the USB port of the PC using a serial cable. In this step, you need to prepare a PC with two wired network cards (PCs, i.e., personal computers) with PyCharm and SecureCRT software installed, and a Layer 3 switch to be tested. The PC has a USB port, network card 1, and network card 2. The switch has switch port 1, switch port 2, and switch console port. Network card 1 is connected to switch port 1, network card 2 is connected to switch port 2, and the USB port is connected to the switch console port via a serial cable. The console port is the main control interface of the switch. In this embodiment, the PC USB port is the COM3 interface, which is the communication port 3 of the PC's RS232 serial port. The switch can be replaced with various models of Layer 3 switches to be tested. All operations on the switch are performed using CLI commands.
[0028] VLAN (Virtual Local Area Network) is a logical group of devices and users that are not limited by physical location. They can be organized according to function, department, and application, and their communication is as if they were in the same network segment, hence the name "virtual LAN." VLAN is a relatively new technology that operates at layers 2 and 3 of the OSI reference model. A VLAN is a broadcast domain, and communication between VLANs is accomplished through layer 3 routers. Compared to traditional LAN technologies, VLAN technology is more flexible, offering advantages such as reduced management overhead for moving, adding, and modifying network devices, control of broadcast activities, and improved network security. In this embodiment, the switch VLANs are the objects being traversed and tested.
[0029] In this embodiment, PyCharm is a Python IDE (Integrated Development Environment) with a complete set of tools to help users improve their efficiency when developing with the Python language, such as debugging, syntax highlighting, project management, code navigation, intelligent suggestions, auto-completion, unit testing, and version control. In addition, this IDE provides some advanced features to support professional web development under the Django framework. SecureCRT is a terminal emulation program that supports SSH (SSH1 and SSH2). Simply put, it is software for logging into UNIX or Linux server hosts under Windows. SecureCRT software supports protocols including SSH1, SSH2, Telnet, Telnet / TLS, RLogin, Serial, TAPI, and Raw protocols.
[0030] This embodiment uses the Serial protocol. Serial ATA employs a point-to-point transmission protocol, where each hard drive has its own dedicated channel for communication with the host. All hard drives in the system are equal, therefore, there is no distinction between "master" and "slave" drives in Serial ATA, and users no longer need to configure hard drive jumpers. Another advantage of Serial ATA's point-to-point transmission mode is that each hard drive can exclusively enjoy channel bandwidth, which improves transmission performance. Since Serial ATA is incompatible with traditional parallel ATA, this issue has been carefully considered in the design of Serial ATA. Current Serial ATA can be used compatiblely with existing parallel ATA systems through converters. These converters can convert the motherboard's parallel ATA signals into serial ATA signals for use by Serial ATA hard drives, or convert the motherboard's Serial ATA signals into parallel ATA signals that can be received by ordinary parallel ATA hard drives. Moreover, the use of such converters is very flexible. In this embodiment, PyCharm and SecureCRT are used to build the test environment for switch VLAN traversal testing.
[0031] In this embodiment, CLI stands for Command Line Interface. The CLI interface is the interface provided by all routers, TM (Termination Multi-IPlexer), CM (Cable Modem), and other products such as Cisco, Lucent, Arris, and Huawei. It is a standard for router products. Using CLI has advantages such as low usage requirements (only a serial port is needed), ease of use, and convenient function expansion. Especially when configuring many (e.g., 10) router devices, the COPY / PASTE function can quickly complete the configuration of all routers, eliminating the need to configure them one by one via Internet Explorer. In this embodiment, all operations on the switch use CLI commands, making operation simple and convenient.
[0032] Step 2: Configure 4094 switch VLANs, define custom variables i, m, and n, and assign initial values i = m = n = 1. Create a standard data file to store expected values. In this embodiment, the standard data file is an Excel file named "Configuration.xlsx". The expected values are the theoretically obtainable range of data values when testing switch VLANs. Enter the command vlan 1-4094 in the globally configured VLAN data file to turn on the global DHCP Server switch. Although VLAN 1 already exists and its IP address has been configured, creating and configuring the IP address again will not have any impact. The purpose of creating VLAN 1 and configuring the IP address again is to reduce the amount of code and make the code more concise. Here, DHCP Server refers to a computer that manages the DHCP standard in a specific network. The responsibility of the DHCP server is to assign IP addresses when workstations log in and to ensure that the IP address assigned to each workstation is different. The DHCP server greatly simplifies some network management tasks that previously needed to be done manually.
[0033] Step 3: Configure VLAN and address pool parameters. Create a Layer 3 VLAN interface with VLAN ID = i and IP address = 192.BC1 / 24, where 1 ≤ B ≤ 255 and 1 ≤ C ≤ 255, where B and C are positive integers. Add an address pool configuration, setting the DNS server to 8.8.8.8, the address pool range to 192.BC1-192.BC100, the subnet mask to 255.255.255.0, and the gateway to 192.BC1. Store the Layer 3 VLAN interface parameters and address pool parameters in a standard data file. All other parameters besides the Layer 3 VLAN interface parameters and address pool parameters are also stored in the standard data file, including the expected value for the DHCP Server interface enable switch status: enabled. In this embodiment, the expected value can be a range or a specific value, used to determine whether the target data being compared is within the expected value range or is the same as the expected value, i.e., to determine whether the switch VLAN traversal test is successful. DNS server is an abbreviation for Domain Name System or Domain Name Service. It consists of domain name resolvers and domain name servers. A domain name server is a server that stores the domain names and corresponding IP addresses of all hosts in the network and has the function of converting domain names into IP addresses. A domain name must correspond to an IP address, but an IP address does not necessarily have a domain name. The domain name system adopts a hierarchical structure similar to a directory tree. The domain name server is the server side in the client / server model. It mainly has two forms: primary server and forwarding server. The process of mapping a domain name to an IP address is called "domain name resolution".
[0034] In this embodiment, the IP addresses of the VLAN interfaces are configured as follows: VLAN 1: 192.0.0.1 / 24, VLAN 2: 192.0.1.1 / 24, VLAN 3: 192.0.2.1 / 24... VLAN 256: 192.0.255.1 / 24, VLAN 257: 192.1.0.1 / 24, VLAN 258: 192.1.1.1 / 24... The code for retrieving values B and C uses an if statement to determine the values.
[0035] If C < 255
[0036] {C = C + 1;}
[0037] Else
[0038] {C = 0; B = B + 1;}
[0039] 4094 VLANs require 4094 IP addresses. When B=16, C can take values from 0 to 255, a total of 256 numbers, which gives 16*256=4096 IP addresses, which can meet the requirements. Therefore, B only needs to be incremented by 1.
[0040] Step 4: Repeat step 3 to traverse VLAN i, where 1 ≤ i ≤ 4094 and i is a positive integer.
[0041] Step 5: Set VLAN ID to m, enable the DHCP Server on the Layer 3 interface of VLAN m, iterate through VLAN m, and save the configuration. 1 ≤ m ≤ 4094, where m is a positive integer.
[0042] Step 6: Read each Layer 3 interface parameter and compare it with the expected value in the standard data file to determine if it conforms to the standard. The Layer 3 interface parameters are displayed on the PC's web interface and include VLAN ID, IP address, subnet mask, and DHCP Server interface enable / disable status. When the Layer 3 interface parameters of the switch VLAN do not conform to the expected value in the standard data file, output the switch VLAN parameter information of the unsuccessful comparison, terminate the program, and prompt the administrator for handling.
[0043] Step 7: When the Layer 3 interface parameters of the switch VLAN are compared with the expected values in the standard data file and are deemed to conform to the standard, the validity of the Layer 3 interface DHCP Server is checked. Port 2 is set to VLAN ID = n, 1 ≤ n ≤ 4094, where n is a positive integer. Network interface card 2 obtains an IP address and checks if the IP address is within the address pool range. Network interface card 2 obtains an IP address using the `release` and `renew` commands. The `release` command releases an existing IP address, while the `renew` command requests an IP address from the DHCP server and leases one. If network interface card 2 fails to obtain an IP address or the obtained IP address is not within the address pool range, a failure message is output, relevant parameter information is recorded, the program is terminated, and administrators are prompted for further action.
[0044] Step 8: Test each VLAN n one by one. If network card 2 obtains an IP address and all IP addresses are within the address pool range, the test passes and the test is completed. Otherwise, the test fails and the program terminates.
[0045] As can be seen from the above, the beneficial effects of the present invention are as follows: The present invention provides a method for VLAN traversal testing of a switch. By running a PC-side script, VLAN parameters are automatically configured, and then the parameter information obtained from the web interface is compared with the expected value to complete the web page display information check. The PC network card 2 continuously releases / renews to obtain IP addresses. After obtaining the IP address, the network card 2 determines whether the IP address is within the address pool range and checks the validity of the DHCP Server function, thereby completing the automated testing of the switch VLANs. Through the automated VLAN traversal testing method, the boundary values of the switch VLANs and the validity of the Layer 3 VLAN interface DHCP Server can be tested, realizing the testing that is extremely difficult to complete manually. The testing method is simple, the testing speed is fast, saves manpower and material resources, and has low cost. It solves the problems of high risk of manual random sampling testing and high cost of manual comprehensive testing in the prior art.
[0046] The specific embodiments described above are preferred embodiments of the present invention and are not intended to limit the specific scope of the present invention. The scope of the present invention includes, but is not limited to, these specific embodiments. All equivalent changes made in accordance with the present invention are within the protection scope of the present invention.
Claims
1. A method for VLAN traversal testing of a switch, characterized in that, Includes the following steps, Step 1: Set up the hardware test environment, set the VLAN 1 management address of the switch, connect network card 1 to port 1 of the switch through a static address, connect network card 2 to port 2 of the switch through a dynamic IP address, and connect the console port of the switch to the USB port of the PC. Step 2: Configure 4094 switch VLANs, define custom variables i, m, and n, assign initial values i=m=n=1, create a standard data file to store the expected values, enter the command vlan 1-4094 in the globally configured VLAN data file, and turn on the global DHCP Server switch; Step 3: Configure VLAN and address pool parameters, create a Layer 3 VLAN interface with vlanID=i, add a new address pool configuration, configure the DNS server, address pool range, subnet mask and gateway, and store the Layer 3 VLAN interface parameters and address pool parameters to a standard data file; Step 4: Repeat step 3 to traverse VLAN i, where 1 ≤ i ≤ 4094 and i is a positive integer; Step 5: Set VLAN ID = m, enable the DHCP Server on the Layer 3 interface of VLAN m, traverse VLAN m, save the configuration, 1 ≤ m ≤ 4094, where m is a positive integer; Step 6: Read each Layer 3 interface parameter and compare it with the expected value in the standard data file to determine whether it conforms to the standard; Step 7: When the Layer 3 interface parameters of the switch VLAN are compared with the expected values in the standard data file and it is determined that they conform to the standard, check the validity of the Layer 3 interface DHCP Server, set port 2 to VLAN ID = n, 1≤n≤4094, where n is a positive integer, network card 2 obtains an IP address and determines whether the IP address is within the address pool range; Step 8: Test each VLAN n one by one. If network card 2 obtains an IP address and all IP addresses are within the address pool range, the test passes and the test is completed. Otherwise, the test fails and the program terminates.
2. The method for VLAN traversal testing of a switch as described in claim 1, characterized in that: In step 1, the PC is pre-installed with PyCharm and SecureCRT software and has a USB port, network card 1, and network card 2. The switch has switch port 1, switch port 2, and switch console port. The management address of the switch VLAN 1 is 192.0.0.1 / 24, and the static address of network card 1 is 192.0.0.2 / 24. Network card 1 is connected to switch port 1 through the static address, and network card 2 is connected to switch port 2 by obtaining a dynamic IP address. The USB port is connected to the switch console port through a serial cable.
3. The method for VLAN traversal testing of a switch as described in claim 2, characterized in that: In step 2, the standard data file is an Excel file, and the expected value is the theoretically obtainable range of data values when testing the VLAN of the switch.
4. The method for VLAN traversal testing of a switch as described in claim 3, characterized in that: In step 3, the IP address of the VLAN interface is 192.BC1 / 24, 1≤B≤255, 1≤C≤255, where B and C are positive integers.
5. The method for VLAN traversal testing of a switch as described in claim 4, characterized in that: In step 3, the DNS server is configured as 8.8.8.8, the address pool range is 192.BC1-192.BC100, the subnet mask is 255.255.255.0, and the gateway is configured as 192.BC1.
6. The method for VLAN traversal testing of a switch as described in claim 5, characterized in that: In step 3, all parameters except for the Layer 3 VLAN interface parameters and address pool parameters are also stored in the standard data file, including the expected value of the DHCPServer interface enable switch status being enabled.
7. The method for VLAN traversal testing of a switch as described in claim 6, characterized in that: In step 6, the Layer 3 interface parameters are displayed on the PC's web interface. The Layer 3 interface parameters include VLAN ID, IP address, subnet mask, and DHCP Server interface enable / disable status.
8. The method for VLAN traversal testing of a switch as described in claim 7, characterized in that: In step 6, if the Layer 3 interface parameters of the switch VLAN do not meet the expected values in the standard data file, the switch VLAN parameter information of the unsuccessful comparison is output, the program is terminated, and the administrator is prompted to handle the issue.
9. The method for VLAN traversal testing of a switch as described in claim 8, characterized in that: In step 7, network card 2 obtains an IP address through the release and renew commands. When network card 2 fails to obtain an IP address or the obtained IP address is not within the address pool range, it outputs a failure message, records relevant parameter information, terminates the program, and prompts the administrator for processing.
10. The method for VLAN traversal testing of a switch as described in claim 9, characterized in that: In step 1, the switch can be replaced with various models of Layer 3 switches under test for testing, and all operations on the switch are performed using CLI commands.
Citation Information
Patent Citations
Automatic testing tool and testing method for vlan function of ONU (Optical Network Unit)
CN103684581A
Automated testing method and equipment based on dynamic vlan (Virtual Local Area Network)
CN105306308A