MAC address drift test method and device, equipment and storage medium
By using the first network card and the second network card in the network to send address resolution protocol messages and set interface priority and port mode, detecting MAC address drift, the problems of inefficiency and low degree of automation in the existing technology are solved, and the problem of inefficiency and low degree of automation is realized. Efficient and accurate detection of MAC address drift ensures network stability and security.
Patent Information
- Application Number
- CN202410933998.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-29
AI Technical Summary
The prior art is inefficient in detecting MAC address drift, is prone to errors and is not highly automated, making it difficult to cope with the monitoring needs of large-scale network environments.
The address resolution protocol message is sent to the switch through the first network card and the second network card. After setting different interface priority and port modes, log in to the switch and comprehensively evaluate the test results to determine whether the overall performance and functions of the network equipment meet expectations.
It improves the efficiency and accuracy of MAC address drift testing, ensures the correctness, security and stability of network configuration, and is suitable for large-scale network environments.
Smart Images

Figure CN119052129A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to a method, device, equipment and storage medium for testing MAC address drift. Background Art
[0002] In modern network management, MAC address drift may cause a variety of network security and management problems, such as network device authentication failure, network attacks and resource allocation errors. In order to ensure the stability and security of the network, accurately detecting and tracking MAC address drift has become an important task for network administrators.
[0003] Currently, MAC addresses are usually monitored and recorded through network protocol analysis tools. A common method is to use multiple network cards to send ARP packets to the switch and record the switch's response to detect changes in MAC addresses. These test processes usually include multiple manual operations and logging into the switch to query and record test results.
[0004] Although this method can detect MAC address drift, it has the problem of low efficiency. Manually setting the priority and port mode of the network card, sending ARP packets one by one and recording the response information is time-consuming and labor-intensive. At the same time, due to the complex operation and easy errors, the test results are inaccurate or incomplete. In addition, the existing method has a low degree of automation and is difficult to cope with the needs of MAC address drift monitoring in large-scale network environments. Therefore, how to improve the test efficiency of MAC address drift has become an urgent problem to be solved.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The purpose of the present application is to provide a method, device, equipment and storage medium for testing MAC address drift, aiming to solve the technical problem of how to improve the testing efficiency of MAC address drift.
[0007] To achieve the above object, the present application proposes a method for testing MAC address drift, the method comprising:
[0008] Sending an address resolution protocol message to the switch through the first network card and the second network card, and querying the drift record of the MAC address to obtain a first test result;
[0009] In the case of setting the interface priorities of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a second test result;
[0010] In the case of setting the port mode and the port priority of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a third test result;
[0011] A final test result is obtained according to the first test result, the second test result and the third test result, and the test is completed.
[0012] In one embodiment, the step of sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain the second test result when the interface priorities of the first network card and the second network card are set includes:
[0013] When the interface priorities of the first network card and the second network card are set to be the same, continuously sending the address resolution protocol message to the switch through the second network card within a preset time period;
[0014] During the packet sending period of the second network card, logging into the switch through the first network card to obtain a first login result;
[0015] After the second network card stops sending packets, logging into the switch through the first network card to obtain a second login result;
[0016] In a case where the interface priority of the second network card is set to be greater than the interface priority of the first network card, the address resolution protocol message is sent through the second network card, and after the sending is completed, the switch is logged in through the first network card to obtain a third login result;
[0017] When the first login result is a login failure, the second login result is a login success, and the third login result is a login failure, the second test result is a pass, otherwise it is a fail.
[0018] In one embodiment, the step of sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain the third test result when the port mode and the port priority of the first network card and the second network card are set includes:
[0019] When the port mode of the first network card is set to the exit mode and the port priority of the first network card is set to be lower than the port priority of the second network card, the address resolution protocol message is sent to the switch through the second network card, and the switch is logged in through the first network card to obtain a fourth login result;
[0020] Log in to the switch through the second network card to check the port status of the first network card, and obtain a first checking result;
[0021] When the port mode of the first network card is set to the shutdown mode, the address resolution protocol message is sent to the switch through the second network card, and the port status of the first network card is checked by logging into the switch through the second network card to obtain a second checking result;
[0022] When the fourth login result is login failure, the first check result is VLAN0, and the second check result is closed, the third test result is passed, otherwise it is failed.
[0023] In one embodiment, the step of sending an address resolution protocol message to a switch through the first network card and the second network card, and querying a MAC address drift record to obtain a first test result includes:
[0024] Constructing an address resolution protocol message of the first network card;
[0025] Sending the address resolution protocol message to the switch through the second network card;
[0026] Querying the drift record of the MAC address through the first network card;
[0027] When the drift record is that the port connected to the first network card drifts to the port connected to the second network card, the first test result is passed; otherwise, it is failed.
[0028] In one embodiment, the step of querying the drift record of the MAC address through the first network card includes:
[0029] Capturing all the address resolution protocol messages passing through the first network card;
[0030] Analyze the address resolution protocol message to obtain multiple IP addresses and a MAC address corresponding to each IP address;
[0031] Record the change of the MAC address corresponding to the IP address to obtain the drift record of the MAC address.
[0032] In one embodiment, the step of obtaining a final test result according to the first test result, the second test result and the third test result comprises:
[0033] When the first test result, the second test result and the third test result are all passed, the final test result is passed, otherwise it is failed.
[0034] In one embodiment, after the step of obtaining the final test result according to the first test result, the second test result and the third test result, the method further includes:
[0035] When the final test result is passed, the final test result is saved in a preset table;
[0036] When the final test result is a failure, the final test result is saved in a preset table, and the first test result, the second test result, and the third test result are recorded.
[0037] In addition, to achieve the above purpose, the present application also proposes a MAC address drift testing device, the device comprising:
[0038] A first test module is used to send an address resolution protocol message to the switch through the first network card and the second network card, and query the drift record of the MAC address to obtain a first test result;
[0039] A second test module is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a second test result when the interface priorities of the first network card and the second network card are set;
[0040] A third test module is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a third test result when the port mode and port priority of the first network card and the second network card are set;
[0041] The result acquisition module is used to obtain the final test result according to the first test result, the second test result and the third test result to complete the test.
[0042] In addition, to achieve the above-mentioned purpose, the present application also proposes a MAC address drift testing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the MAC address drift testing method as described above.
[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the MAC address drift testing method described above are implemented.
[0044] One or more technical solutions proposed in this application have at least the following technical effects:
[0045] An address resolution protocol message is sent to the switch through the first network card and the second network card, and the drift record of the MAC address is queried to obtain a first test result; under the condition that the interface priority of the first network card and the second network card is set, the address resolution protocol message is sent to the switch through the first network card and the second network card and the switch is logged in to obtain a second test result; under the condition that the port mode and port priority of the first network card and the second network card are set, the address resolution protocol message is sent to the switch through the first network card and the second network card and the switch is logged in to obtain a third test result; a final test result is obtained according to the first test result, the second test result and the third test result, and the test is completed. Send Address Resolution Protocol (ARP) packets to the switch through the first and second network cards, and query the MAC address drift record. The main purpose of this step is to verify the MAC address drift between devices (such as computers or other devices) from one port to another in the network. This helps to confirm whether the network device can correctly update and record its MAC address table when receiving data packets from different ports to ensure that the data packets are correctly forwarded to the target device; after setting the interface priority of the first and second network cards, send ARP packets to the switch through these two network cards, and try to log in to the switch. The purpose of this step is to verify the impact of setting interface priority on device login and communication. This test can Determine whether the device can log in in the expected order or refuse to log in after setting different priorities, so as to test and verify the access control policy in the network; after setting the port mode and priority of the first and second network cards, send ARP packets to the switch through the two network cards again and try to log in. The purpose of this step is to verify the impact of setting the port mode and priority on the behavior and response of the device in the network. Through this test, you can check how the device handles MAC address conflicts, port status, and how to prioritize or refuse the forwarding of data packets; the final test result is obtained by comprehensive evaluation based on the first, second and third test results. The role of this step is to comprehensively consider the results of all previous tests to determine whether the overall performance and function of the network device meet expectations. If all test results pass, the final test result is passed; otherwise, it is failed. This helps to determine the correctness, security and stability of the network configuration, and provides directions for further adjustment and improvement, ensuring the stability and security of the network and improving the efficiency of testing MAC address drift. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A flowchart of the first embodiment of the MAC address drift testing method of the present application is provided;
[0049] Figure 2 A flowchart of the second embodiment of the MAC address drift testing method of the present application is provided;
[0050] Figure 3 This is a schematic diagram of the module structure of a testing device for MAC address drift according to an embodiment of the present application;
[0051] Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the MAC address drift testing method in the embodiment of the present application.
[0052] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0054] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0055] The current MAC address monitoring method relies on network protocol analysis tools to detect MAC address changes by manually sending ARP packets and recording switch responses. However, this process is inefficient, error-prone, and has a low degree of automation, making it difficult to adapt to the monitoring needs of large-scale network environments.
[0056] The main solution of the embodiment of the present application is: first, by sending an Address Resolution Protocol (ARP) message and querying the drift record of the MAC address, confirm that the device can correctly update and manage the MAC address table to ensure that the data packet can be effectively forwarded to the target device. Secondly, set different interface priorities and verify their impact on device login and communication to evaluate the effectiveness of the network access control policy. Furthermore, set the port mode and priority to test the performance of the device when dealing with MAC address conflicts and port status, and how it prioritizes data packet forwarding. Finally, comprehensively evaluate all test results to determine whether the overall performance and functionality of the network device meet expectations, and provide directions for further improvement and adjustment. These steps not only help to ensure the correctness, security and stability of the network configuration, but also improve the efficiency and accuracy of testing MAC address drift and network device behavior.
[0057] It should be noted that the execution subject of the embodiments of the present application may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a server, etc. capable of realizing the above functions. The present embodiment and the following embodiments are described below using a computer as an example.
[0058] Based on this, the present application embodiment provides a method for testing MAC address drift, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the MAC address drift testing method of the present application.
[0059] In this embodiment, the MAC address drift testing method includes steps S10 to S40:
[0060] Step S10, sending an address resolution protocol message to the switch through the first network card and the second network card, and querying the drift record of the MAC address to obtain a first test result;
[0061] It should be noted that the first network card is a network interface card on a computer or server, which is used to connect to the switch and send and receive network traffic. In this embodiment, the first network card is used to connect to the switch command line through the Secure Shell (SSH) protocol. The second network card is a network interface card on a different computer or server, which is used to send a constructed Address Resolution Protocol (ARP) message to the switch. In this embodiment, the second network card is mainly used to simulate the ARP message of the first network card and send it to the switch. The ARP message is used to resolve the correspondence between the Internet Protocol (IP) address and the Media Access Control (MAC) address in the network. Specifically, the ARP request is to inquire about the MAC address corresponding to a certain IP address, and the ARP response provides the MAC address of the IP address. In this embodiment, the second network card will construct and send the ARP message of the first network card to test the drift of the MAC address. The switch is a network hardware that connects multiple network devices and is used to receive and forward data frames. In this embodiment, the switch will receive ARP messages from the first network card and the second network card, and record their MAC address information. MAC address drift refers to the phenomenon that the same MAC address moves from one switch port to another. In this embodiment, the test is performed by observing the MAC address table of the switch to check whether the MAC address of the first network card has drifted from the port connected to the first network card to the port connected to the second network card. The first test result is a preliminary result of the test, which is used to determine whether the first phase of the test has passed. Specifically, the test result is the drift record of the MAC address queried through the switch command line. If the MAC address of the first network card is found in the MAC address table of the switch to have drifted from the port of the first network card to the port of the second network card, the test is passed; otherwise, the test fails.
[0062] It can be understood that a connection is established between the first network card and the switch command line interface, and the second network card is used to send a simulated ARP message of the first network card to the switch, and then the MAC address table is queried in the switch command line to check whether the MAC address of the first network card drifts from its original connection port to the connection port of the second network card, thereby obtaining the first test result.
[0063] As an example, an address resolution protocol message is sent to a switch through a first network card and a second network card, and a drift record of a MAC address is queried, and the steps of obtaining a first test result include: constructing an address resolution protocol message of the first network card; sending the address resolution protocol message to the switch through the second network card; querying the drift record of the MAC address through the first network card; when the drift record is that the port connected to the first network card drifts to the port connected to the second network card, the first test result is passed, otherwise it is failed.
[0064] First, construct an ARP request message containing the MAC address of the first network card and the target IP address, which usually involves the following steps: set the sender MAC address of the ARP request to the MAC address of the first network card, the sender IP address to the IP address of the first network card, the target MAC address to all zeros or a broadcast address, and the target IP address to the IP address of the switch. Then, send the ARP message to the switch through the second network card; then, log in to the command line interface of the switch through the first network card, execute the command to query the MAC address table of the switch, and check whether there is a record of the MAC address of the first network card drifting from the port to which it is connected to the port to which the second network card is connected; if the query result shows that the MAC address drift occurs, the test result is passed, otherwise it is failed.
[0065] As an example, the step of querying the drift record of the MAC address through the first network card includes: capturing all the address resolution protocol messages passing through the first network card; analyzing the address resolution protocol messages to obtain multiple IP addresses and the MAC address corresponding to each IP address; recording the changes of the MAC address corresponding to the IP address to obtain the drift record of the MAC address.
[0066] IP address refers to the Internet Protocol address of a device in the network, which identifies the location of each device in the network. For example, the first network card and the switch will have their own IP addresses. MAC address refers to the physical address of a device, also known as the media access control address, which is a unique identifier of a device in the network. For example, the first network card and the second network card each have a unique MAC address. First, capture all ARP packets passing through the first network card. These packets contain the IP address and MAC address information of each device in the network; then analyze these ARP packets to extract each IP address and its corresponding MAC address; then monitor and record the changes in the MAC addresses corresponding to these IP addresses. If the MAC address of a certain IP address changes from one value to another, this change is recorded; finally, obtain the drift record of the MAC address through these change records.
[0067] Step S20, in the case of setting the interface priorities of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a second test result;
[0068] It should be noted that the interface priority refers to the priority setting of the switch interface, which is used to determine which interface has a higher priority when the same MAC address appears on multiple interfaces. The port with a higher priority will be selected first to learn and record the MAC address, and the interface with a lower priority may be ignored or specific measures may be taken (such as port shutdown or virtual local area network (VLAN) exit mode). The second test result refers to the test result obtained after the interface priority is set, after sending ARP packets to the switch through the first network card and the second network card and trying to log in to the switch. Specifically, if the switch correctly processes the MAC address according to the port priority, the test passes; otherwise, the test fails. For example, the expected result may be that the high-priority port successfully learns the MAC address and allows login, while the low-priority port cannot log in or is set to a specific mode.
[0069] It can be understood that after setting the interface priorities of the first network card and the second network card, ARP packets are sent to the switch through the first network card and the second network card, and then attempts are made to log in to the switch through the two network cards respectively to observe whether the switch correctly handles MAC address learning according to the set interface priorities, thereby obtaining the second test result, that is, determining whether the high-priority port successfully learns the MAC address and allows login, and whether the low-priority port cannot log in or is placed in a specific mode.
[0070] Step S30, in the case of setting the port mode and the port priority of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a third test result;
[0071] It should be noted that port mode refers to the working mode setting of the switch port, including different operating states, such as port shutdown mode and VLAN exit mode. In port shutdown mode, the port is disabled and cannot forward data. In VLAN exit mode, the port is removed from the original VLAN, making it unable to forward data. Port priority refers to the priority setting of the switch port, which is used to determine which port has a higher priority when the same MAC address appears on multiple ports. The port with a higher priority will first learn and record the MAC address, while the port with a lower priority may be ignored or take other measures. The third test result refers to the test result obtained after setting the port mode and port priority of the first network card and the second network card, sending ARP packets to the switch through these two network cards and trying to log in to the switch. Specifically, this result determines whether the switch correctly handles the MAC address conflict according to the set port mode and priority. For example, the high-priority port successfully learns the MAC address and allows login, while the low-priority port is disabled or removed from the VLAN.
[0072] It can be understood that after setting the port mode (such as port shutdown mode or VLAN exit mode) and port priority (high priority or low priority) of the first network card and the second network card, ARP packets are sent to the switch through the first network card and the second network card respectively, and then attempts are made to log in to the switch through the two network cards respectively, and observe and record whether the switch handles the learning and conflict of MAC addresses according to the configured port mode and priority, specifically including: checking whether the high-priority port successfully learns the MAC address and allows login, and whether the low-priority port is disabled or removed from the VLAN, thereby obtaining the third test result.
[0073] As an example, when the port mode and port priority of the first network card and the second network card are set, the address resolution protocol message is sent to the switch through the first network card and the second network card and the switch is logged in to obtain the third test result. The steps include: when the port mode of the first network card is set to exit mode and the port priority of the first network card is set lower than the port priority of the second network card, the address resolution protocol message is sent to the switch through the second network card, and the switch is logged in through the first network card to obtain a fourth login result; the port status of the first network card is checked by logging in to the switch through the second network card to obtain a first viewing result; when the port mode of the first network card is set to shutdown mode, the address resolution protocol message is sent to the switch through the second network card, and the port status of the first network card is logged in to the switch through the second network card to obtain a second viewing result; when the fourth login result is login failure, the first viewing result is VLAN0 and the second viewing result is closed, the third test result is passed, otherwise it is failed.
[0074] Exit mode refers to a working mode of the port, in which the port is removed from the original VLAN (virtual local area network) so that it cannot forward data; the fourth login result refers to the login status obtained after trying to log in to the switch through the first network card. If the login fails, this is the fourth login result; port status refers to the current operating status of the switch port, such as on (VLAN1) or off (VLAN0). VLAN0 means that the port is removed from its original VLAN and is in the default VLAN state; shutdown mode means that the port is set to disabled and cannot transmit data; the second view result refers to checking the status of the port connected to the first network card after logging in to the switch through the second network card; if the status is displayed as off, this is the second view result. When the first network card is set to exit mode and its port priority is lower than that of the second network card, an ARP message is sent to the switch through the second network card, and an attempt is made to log in to the switch through the first network card, and whether the login is successful is recorded to obtain a fourth login result; then, the switch is logged in through the second network card and the port status of the first network card is checked, and its status is recorded whether it is VLAN0, to obtain a first viewing result; then, the port mode of the first network card is set to shutdown mode, and an ARP message is sent to the switch through the second network card again, and the switch is logged in to the switch through the second network card to check the port status of the first network card, and its status is recorded whether it is closed, to obtain a second viewing result; finally, when the fourth login result shows that the login of the first network card failed, the first viewing result shows that the port status of the first network card is VLAN0, and the second viewing result shows that the port status of the first network card is closed, the third test result is passed, otherwise it is failed.
[0075] Step S40, obtaining a final test result according to the first test result, the second test result and the third test result, and completing the test.
[0076] It should be noted that the final test result refers to the overall test conclusion obtained after comprehensive evaluation of the first test result, the second test result and the third test result. This result indicates whether all test steps are successful, and it can be used to determine whether the overall function and performance of the device and configuration meet expectations.
[0077] It can be understood that, first, the first test result is reviewed to check whether the MAC address drifts correctly by sending ARP packets and querying the MAC address drift record; secondly, the second test result is reviewed to check whether the switch can correctly handle the MAC address and allow or deny login according to the priority after setting the interface priority; finally, the third test result is reviewed to check whether the switch can correctly handle the MAC address conflict and port status after setting the port mode and priority; by comprehensively analyzing these results, the final test result is obtained, thereby completing the entire test process.
[0078] As an example, the step of obtaining the final test result according to the first test result, the second test result and the third test result includes: when the first test result, the second test result and the third test result are all passed, the final test result is passed, otherwise it is failed.
[0079] First, check the first test result to confirm whether the ARP packet and MAC address drift verification test passed; then, check the second test result to confirm whether the switch correctly processed the MAC address and performed login processing according to the priority after setting the interface priority; then, check the third test result to confirm whether the switch correctly handled the MAC address conflict and port status after setting the port mode and priority; finally, comprehensively evaluate the three test results. When all test results are passed, the final test result is passed; if any of the test results is failed, the final test result is failed.
[0080] As an example, after the step of obtaining the final test result according to the first test result, the second test result and the third test result, it also includes: when the final test result is passed, saving the final test result to a preset table; when the final test result is failed, saving the final test result to a preset table, and recording the first test result, the second test result and the third test result.
[0081] A preset table refers to a table file that is defined and prepared in advance for recording and storing test results. This table is usually in Excel format or a similar spreadsheet format, containing specific columns and rows, and is used to systematically record the various test results and related information. First, check all test results and evaluate them comprehensively to get the final test result; then, if the final test result is passed, record and save the final test result to the preset spreadsheet; if the final test result is not passed, record and save the final test result to the preset spreadsheet, and record and save the first test result, the second test result, and the third test result in detail for subsequent analysis and problem tracking; these records help to systematically archive the test process and its results, ensuring that each step of the test can be traced back and checked when necessary.
[0082] This embodiment provides a method for testing MAC address drift, which includes sending an address resolution protocol message to a switch through a first network card and a second network card, and querying a drift record of a MAC address to obtain a first test result; in the case of setting the interface priority of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a second test result; in the case of setting the port mode and port priority of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a third test result; and obtaining a final test result according to the first test result, the second test result, and the third test result to complete the test. Send Address Resolution Protocol (ARP) packets to the switch through the first and second network cards, and query the MAC address drift record. The main purpose of this step is to verify the MAC address drift between devices (such as computers or other devices) from one port to another in the network. This helps to confirm whether the network device can correctly update and record its MAC address table when receiving data packets from different ports to ensure that the data packets are correctly forwarded to the target device; after setting the interface priority of the first and second network cards, send ARP packets to the switch through these two network cards, and try to log in to the switch. The purpose of this step is to verify the impact of setting interface priority on device login and communication. This test can Determine whether the device can log in in the expected order or refuse to log in after setting different priorities, so as to test and verify the access control policy in the network; after setting the port mode and priority of the first network card and the second network card, send ARP packets to the switch through the two network cards again and try to log in. The purpose of this step is to verify the impact of setting the port mode and priority on the behavior and response of the device in the network. Through this test, it can be checked how the device handles MAC address conflicts, port status, and how to prioritize or refuse the forwarding of data packets; the final test result is obtained by comprehensive evaluation based on the first, second and third test results. The role of this step is to comprehensively consider the results of all previous tests to determine whether the overall performance and function of the network device meet expectations. If all test results pass, the final test result is passed; otherwise, it is failed. This helps to determine the correctness, security and stability of the network configuration, and provides a direction for further adjustment and improvement, ensuring the stability and security of the network. This embodiment performs automated testing through this method to improve the test efficiency of MAC address drift.
[0083] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 2 , Figure 2This is a flow chart of a second embodiment of a method for testing MAC address drift of the present application. Step S20 of the method for testing MAC address drift includes steps S21 to S25:
[0084] Step S21, when the interface priorities of the first network card and the second network card are set to be the same, continuously sending the address resolution protocol message to the switch through the second network card within a preset time period;
[0085] It should be noted that the preset duration refers to the preset time length for continuously sending ARP (Address Resolution Protocol) messages. This time period can be any predetermined duration period, such as 5 minutes, and is usually used to test how the device handles continuous ARP requests or data packet traffic over a period of time.
[0086] It can be understood that when the interface priorities of the first network card and the second network card are set to the same, the Address Resolution Protocol (ARP) message is continuously sent to the switch through the second network card within a preset time (i.e., a preset duration, such as 10 seconds or 1 minute). The purpose of this step is to test the performance and behavior of the switch when processing continuous ARP traffic under the same priority conditions. By continuously sending ARP messages, it is possible to observe how the switch manages the processing of ARP requests, the updating of the MAC address table, and the stability and responsiveness under high traffic or attack conditions. This helps to ensure that the switch can effectively handle frequent ARP traffic and potential network attacks in an actual network environment, and verify its robustness and reliability under the same priority conditions.
[0087] Step S22, during the packet sending period of the second network card, logging into the switch through the first network card to obtain a first login result;
[0088] It should be noted that the first login result refers to the result of attempting to log in to the switch through the first network card during the period when the second network card continues to send ARP packets. This result can be a successful login or a failed login, which specifically indicates the switch's responsiveness and processing priority for different ports under high traffic or specific network conditions. By evaluating the first login result, you can understand whether the switch can correctly manage login requests and maintain the normal operation of the network when facing continuous ARP traffic.
[0089] It is understandable that during the period when the second network card continues to send ARP packets, the first network card is used to try to log in to the switch, and the login result at this time is recorded. This result is called the first login result. The detailed purpose of this step is to test whether the switch can correctly respond to and allow login requests from different ports when processing continuous ARP traffic. By evaluating the first login result, the performance, responsiveness and priority processing mechanism of the switch under high load conditions can be understood, and its stability and reliability in the face of continuous network traffic can be verified.
[0090] Step S23, after the second network card stops sending packets, logging into the switch through the first network card to obtain a second login result;
[0091] It should be noted that the second login result refers to the result of attempting to log in to the switch through the first network card after the second network card stops sending ARP packets. This result can be a successful login or a failed login. It is specifically used to evaluate whether the switch can resume normal operation and respond to login requests after stopping processing high-traffic ARP requests. By analyzing the second login result, you can understand the processing capacity and stability of the switch after the traffic returns to normal.
[0092] It is understandable that after the second network card stops sending ARP packets, the first network card is used to try to log in to the switch, and the login result at this time is recorded, which is called the second login result. The specific steps include: stopping the ARP packet sending operation of the second network card; trying to access the management interface or command line interface of the switch using the login credentials through the first network card; observing and recording whether the login is successful, the time required, and the response of the switch. The purpose of this step is to evaluate whether the switch can quickly recover and respond normally to new login requests after processing the high-load ARP traffic, thereby verifying the switch's operating capabilities, response speed, and overall stability after the traffic returns to normal, which helps to confirm whether the switch can continue to provide reliable network management and control functions after the load pressure is relieved.
[0093] Step S24, when the interface priority of the second network card is set to be greater than the interface priority of the first network card, the address resolution protocol message is sent through the second network card, and after the sending is completed, the switch is logged in through the first network card to obtain a third login result;
[0094] It should be noted that the third login result refers to the result of sending an ARP packet through the second network card and attempting to log in to the switch through the first network card after the interface priority of the second network card is set to be higher than the interface priority of the first network card. This result can be a successful login or a failed login, which is specifically used to evaluate the response and processing mechanism of the switch to the login request after setting different interface priorities.
[0095] It can be understood that by analyzing the third login result, it is possible to understand whether the switch can correctly manage and respond to login requests from low-priority interfaces after giving priority to high-priority interface traffic, thereby verifying the impact of the switch's priority configuration on its performance and stability.
[0096] Step S25, when the first login result is login failure, the second login result is login success and the third login result is login failure, the second test result is passed, otherwise it is failed.
[0097] It is understandable that when the first login result is a login failure (indicating that the first network card cannot log in to the switch when the second network card continues to send ARP packets), the second login result is a login success (indicating that the first network card can successfully log in to the switch after the second network card stops sending ARP packets), and the third login result is a login failure (indicating that the interface priority of the second network card is higher than that of the first network card, and after sending ARP packets, the first network card cannot log in to the switch), the second test result is judged to be passed; otherwise, the second test result is judged to be failed. The detailed purpose of this step is to verify whether the switch can perform traffic management and priority processing as expected in the face of continuous traffic and priority configuration through login results under different conditions, thereby confirming the correctness and stability of the switch under these specific network configurations and stress conditions. Through the analysis of these login results, the reliability and performance of the switch in actual applications can be ensured.
[0098] In this embodiment, when the interface priorities of the first network card and the second network card are set to be the same, the address resolution protocol message is continuously sent to the switch through the second network card within a preset time period; during the packet sending period of the second network card, the switch is logged in through the first network card to obtain a first login result; after the second network card stops sending packets, the switch is logged in through the first network card to obtain a second login result; when the interface priority of the second network card is set to be greater than the interface priority of the first network card, the address resolution protocol message is sent through the second network card, and after the sending is completed, the switch is logged in through the first network card to obtain a third login result; when the first login result is a login failure, the second login result is a login success, and the third login result is a login failure, the second test result is a pass, otherwise it is a fail. This embodiment simulates a high-traffic environment to evaluate the performance and stability of the switch when processing a large number of ARP packets; evaluates whether the switch can correctly process and respond to login requests from different ports in a high-traffic environment, thereby testing its load management capability; verifies whether the switch can quickly resume normal operation and correctly respond to login requests after removing the high-traffic load, thereby testing its recovery capability and stability; evaluates whether the switch can correctly manage and respond to login requests from low-priority interfaces after processing high-priority interface traffic, thereby testing its priority processing mechanism; and comprehensively evaluates login results under different test conditions to confirm whether the switch performs as expected in a high-traffic environment, recovery state, and priority configuration. Through these results, the load processing capability, recovery capability, and priority management capability of the switch can be verified, ensuring its reliability and performance in an actual network environment.
[0099] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the test method for MAC address drift of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0100] This application also provides a MAC address drift test device, please refer to Figure 3 , the MAC address drift testing device comprises:
[0101] The first test module 10 is used to send an address resolution protocol message to the switch through the first network card and the second network card, and query the drift record of the MAC address to obtain a first test result;
[0102] A second test module 20 is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a second test result when the interface priorities of the first network card and the second network card are set;
[0103] A third test module 30 is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a third test result when the port mode and port priority of the first network card and the second network card are set;
[0104] The result acquisition module 40 is used to obtain a final test result according to the first test result, the second test result and the third test result to complete the test.
[0105] The MAC address drift test device provided by the present application adopts the MAC address drift test method in the above embodiment, which can solve the technical problem of how to improve the test efficiency of MAC address drift. Compared with the prior art, the beneficial effect of the MAC address drift test device provided by the present application is the same as the beneficial effect of the MAC address drift test method provided by the above embodiment, and other technical features in the MAC address drift test device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0106] The present application provides a MAC address drift testing device, the MAC address drift testing device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the MAC address drift testing method in the above-mentioned embodiment 1.
[0107] Reference below Figure 4 , which shows a schematic diagram of the structure of a test device for MAC address drift suitable for implementing the embodiment of the present application. The test device for MAC address drift in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The MAC address drift test device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0108] like Figure 4As shown, the test device for MAC address drift may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the test device for MAC address drift are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the test device for MAC address drift to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a test device for MAC address drift with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.
[0109] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0110] The MAC address drift test device provided by the present application adopts the MAC address drift test method in the above embodiment, which can solve the technical problem of how to improve the test efficiency of MAC address drift. Compared with the prior art, the beneficial effect of the MAC address drift test device provided by the present application is the same as the beneficial effect of the MAC address drift test method provided by the above embodiment, and other technical features in the MAC address drift test device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0111] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0112] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0113] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the MAC address drift testing method in the above-mentioned embodiment.
[0114] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0115] The computer-readable storage medium may be included in the MAC address drift test device; or may exist independently without being assembled into the MAC address drift test device.
[0116] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the MAC address drift test device, the MAC address drift test device: sends an address resolution protocol message to the switch through the first network card and the second network card, and queries the MAC address drift record to obtain a first test result; while setting the interface priority of the first network card and the second network card, sends the address resolution protocol message to the switch through the first network card and the second network card and logs in to the switch to obtain a second test result; while setting the port mode and port priority of the first network card and the second network card, sends the address resolution protocol message to the switch through the first network card and the second network card and logs in to the switch to obtain a third test result; obtains a final test result according to the first test result, the second test result and the third test result, and completes the test.
[0117] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0118] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0119] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0120] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned MAC address drift test method, and can solve the technical problem of how to improve the test efficiency of MAC address drift. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the MAC address drift test method provided by the above-mentioned embodiment, and will not be repeated here.
[0121] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned MAC address drift testing method when executed by a processor.
[0122] The computer program product provided by the present application can solve the technical problem of how to improve the efficiency of testing MAC address drift. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the testing method for MAC address drift provided by the above embodiment, which will not be repeated here.
[0123] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for testing MAC address drift, characterized in that: The MAC address drift testing method is applied to a testing device, wherein the testing device includes a plurality of network cards, and each network card is respectively connected to a switch to be tested for communication. The method includes: Sending an address resolution protocol message to the switch through the first network card and the second network card, and querying the drift record of the MAC address to obtain a first test result; In the case of setting the interface priorities of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a second test result; In the case of setting the port mode and the port priority of the first network card and the second network card, sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain a third test result; A final test result is obtained according to the first test result, the second test result and the third test result, and the test is completed.
2. The method according to claim 1, characterized in that The step of sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain the second test result when the interface priorities of the first network card and the second network card are set includes: When the interface priorities of the first network card and the second network card are set to be the same, continuously sending the address resolution protocol message to the switch through the second network card within a preset time period; During the packet sending period of the second network card, logging into the switch through the first network card to obtain a first login result; After the second network card stops sending packets, logging into the switch through the first network card to obtain a second login result; In a case where the interface priority of the second network card is set to be greater than the interface priority of the first network card, the address resolution protocol message is sent through the second network card, and after the sending is completed, the switch is logged in through the first network card to obtain a third login result; When the first login result is a login failure, the second login result is a login success, and the third login result is a login failure, the second test result is a pass, otherwise it is a fail.
3. The method according to claim 1, characterized in that The step of sending the address resolution protocol message to the switch through the first network card and the second network card and logging into the switch to obtain the third test result under the condition that the port mode and the port priority of the first network card and the second network card are set includes: When the port mode of the first network card is set to the exit mode and the port priority of the first network card is set to be lower than the port priority of the second network card, the address resolution protocol message is sent to the switch through the second network card, and the switch is logged in through the first network card to obtain a fourth login result; Log in to the switch through the second network card to check the port status of the first network card, and obtain a first checking result; When the port mode of the first network card is set to the shutdown mode, the address resolution protocol message is sent to the switch through the second network card, and the port status of the first network card is checked by logging into the switch through the second network card to obtain a second checking result; When the fourth login result is login failure, the first check result is VLAN0, and the second check result is closed, the third test result is passed, otherwise it is failed.
4. The method according to claim 1, characterized in that The step of sending an address resolution protocol message to the switch through the first network card and the second network card, and querying the drift record of the MAC address to obtain the first test result includes: Constructing an address resolution protocol message of the first network card; Sending the address resolution protocol message to the switch through the second network card; Querying the drift record of the MAC address through the first network card; When the drift record is that the port connected to the first network card drifts to the port connected to the second network card, the first test result is passed, otherwise it is failed.
5. The method according to claim 4, characterized in that The step of querying the drift record of the MAC address through the first network card includes: Capturing all the address resolution protocol messages passing through the first network card; Analyze the address resolution protocol message to obtain multiple IP addresses and a MAC address corresponding to each IP address; Record the change of the MAC address corresponding to the IP address to obtain the drift record of the MAC address.
6. The method according to claim 1, characterized in that The step of obtaining a final test result according to the first test result, the second test result and the third test result comprises: When the first test result, the second test result and the third test result are all passed, the final test result is passed, otherwise it is failed.
7. The method according to claim 1, characterized in that After the step of obtaining the final test result according to the first test result, the second test result and the third test result, the method further includes: When the final test result is passed, the final test result is saved in a preset table; When the final test result is a failure, the final test result is saved in a preset table, and the first test result, the second test result, and the third test result are recorded.
8. A MAC address drift testing device, characterized in that: The device comprises: A first test module is used to send an address resolution protocol message to the switch through the first network card and the second network card, and query the drift record of the MAC address to obtain a first test result; A second test module is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a second test result when the interface priorities of the first network card and the second network card are set; A third test module is used to send the address resolution protocol message to the switch through the first network card and the second network card and log in to the switch to obtain a third test result when the port mode and port priority of the first network card and the second network card are set; The result acquisition module is used to obtain the final test result according to the first test result, the second test result and the third test result to complete the test.
9. A MAC address drift test device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the method for testing MAC address drift according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the method for testing MAC address drift according to any one of claims 1 to 7 are implemented.
