Summary of the invention
The shortcoming of prior art, the object of the present invention is to provide a kind of method and network analyzer of testing the MAC address aging time of switch in view of the above, tests the larger problem of methodical error of MAC address aging time for solving prior art.
For achieving the above object and other relevant objects, the invention provides a kind of method of testing the MAC address aging time of switch, be applied to the switch that comprises three ports and the test environment that the network analyzer being connected with each port forms, comprise: described network analyzer contains the learning frame of source MAC and target MAC (Media Access Control) address by the first port broadcast packet of described switch; When described network analyzer is exported described learning frame at second, third port that monitors described switch, with the frequency preset, to described the second port, send and take the source MAC of described learning frame the first port as target MAC (Media Access Control) address, the target MAC (Media Access Control) address of described learning frame of the take unicast data frames that is source MAC to described switch, and the quantity of the unicast data frames that sends of record, monitor the output of the 3rd port simultaneously; Described network analyzer when monitoring described the 3rd port and export described switch and be flooded to the unicast data frames of described the 3rd port, the quantity of the unicast data frames that record receives; Described network analyzer calculates the MAC address aging time of described switch according to formula (a1-a2)/f, wherein, a1 is the quantity of the unicast data frames that sends of described the second port, a2 is the quantity that described switch is flooded to the unicast data frames of described the 3rd port, and f is described frequency.
Preferably, also comprise: described network analyzer is shown sent learning frame, unicast data frames and the quantity that records.
Preferably, also comprise: when described network analyzer is exported described learning frame at second, third port that monitors described switch, utilize and send the record that shown learning frame is removed in first unicast data frames gap before.
Preferably, described frequency is fixed value and sets according to the required precision of switch mac address ageing time that will test and the system bandwidth of switch.
Preferably, described frequency is 1 unicast data frames/second.
Based on above-mentioned purpose, the present invention also provides a kind of network analyzer, for the MAC address aging time of testing switch, wherein, described switch comprises three ports, described network analyzer is connected with each port, it comprises: on-air testing module, and for the learning frame containing source MAC and target MAC (Media Access Control) address by described the first port broadcast packet, and described second, third port of monitoring, and second, third port is exported described learning frame described in monitoring, output clean culture sends instruction, the clean culture test module being connected with described on-air testing module, for when receiving described clean culture transmission instruction, with the frequency preset, to described the second port, send and take the source MAC of described learning frame as target MAC (Media Access Control) address, the unicast data frames that the target MAC (Media Access Control) address of described learning frame of take is source MAC is to the first port of described switch, the quantity of the unicast data frames that record sends, and monitor the output of the 3rd port, when monitoring described the 3rd port and export described switch and be flooded to the unicast data frames of described the 3rd port, the quantity of the unicast data frames that record receives, the data processing module being connected with described clean culture test module, for the MAC address aging time of calculating described switch according to formula (a1-a2)/f, wherein, a1 is the quantity of the unicast data frames that sends of described the second port, a2 is the quantity that described switch is flooded to the unicast data frames of described the 3rd port, and f is described frequency.
Preferably, described network analyzer also comprises display screen; Described on-air testing module is transported to described display screen by sent learning frame and is shown; Described clean culture test module is transported to described display screen by sent unicast data frames with the quantity recording and is shown.
Preferably, described clean culture test module also, for when receiving described clean culture transmission instruction, utilizes and sends the record that shown learning frame is removed in first unicast data frames gap before.
Preferably, described frequency is fixed value and sets according to the required precision of switch mac address ageing time that will test and the system bandwidth of switch.
Preferably, described frequency is 1 unicast data frames/second.
As mentioned above, method and the network analyzer of the MAC address aging time of test switch of the present invention, there is following beneficial effect: utilize the quantity of the unicast data frames that sends predeterminated frequency and the difference and the predeterminated frequency that receive the quantity of described unicast data frames to calculate ageing time, can effectively avoid directly monitoring the error that two time points bring.
Embodiment
Below, by specific instantiation explanation embodiments of the present invention, those skilled in the art can understand other advantages of the present invention and effect easily by the disclosed content of this specification.The present invention can also be implemented or be applied by other different embodiment, and the every details in this specification also can be based on different viewpoints and application, carries out various modifications or change not deviating under spirit of the present invention.It should be noted that, in the situation that not conflicting, the feature in following examples and embodiment can combine mutually.
Refer to Fig. 1, the invention provides a kind of method of testing the MAC address aging time of switch, the test environment that the switch that is applied to comprise three ports forms with the network analyzer being connected with each port.It should be noted that, the present invention is also applicable to comprise the more test of the switch of multiport.
Wherein, do not preserve the dynamic address forwarding table of the source MAC-target MAC (Media Access Control) address-port that will test in described switch, described method of testing is mainly carried out by described network analyzer.Wherein, described network analyzer can be independent analytical instrument, also can be for the computer equipment of network analysis software is installed.
In step S1, described network analyzer contains the learning frame of source MAC and target MAC (Media Access Control) address by the first port broadcast packet of described switch.
Particularly, described network analyzer first contains the learning frame of source MAC and target MAC (Media Access Control) address to the first port broadcast packet of described switch, it can be also a plurality of that the quantity of the learning frame of broadcasting can be one, the all of the port of said interchanger is set up the corresponding relation of described source MAC-target MAC (Media Access Control) address-the first port according to broadcasted learning frame, wherein, because described network analyzer sends learning frame to described the first port, described switch is set up the corresponding relation of the first port and described source MAC, and second, the 3rd port forwards described learning frame.
In step S2, when described network analyzer is exported described learning frame at second, third port that monitors described switch, with the frequency preset, to described the second port, send and take the source MAC of described learning frame the first port as target MAC (Media Access Control) address, the target MAC (Media Access Control) address of described learning frame of the take unicast data frames that is source MAC to described switch, and the quantity of the unicast data frames that sends of record, monitor the output of the 3rd port simultaneously.Wherein, for convenience of calculation, described frequency is fixed value and sets according to the required precision of switch mac address ageing time that will test and the system bandwidth of switch, and for example, described frequency is 1 unicast data frames/second.
Particularly, described network analyzer is monitoring second of described switch, when the 3rd port is exported described learning frame, second of described switch is described, three ports have been set up the corresponding relation of source MAC-port, now start to calculate the ageing time of the MAC Address of described switch, described network analyzer stops broadcasting described learning frame again, but send and take the source MAC of described learning frame as target MAC (Media Access Control) address to the second port with described frequency, the unicast data frames that the target MAC (Media Access Control) address of described learning frame of take is source MAC, described switch is according to the corresponding relation of preserved source MAC-target MAC (Media Access Control) address-the first port, and the target MAC (Media Access Control) address in described unicast data frames, described unicast data frames is gone to the first port output, simultaneously, the quantity of the unicast data frames that described network analyzer record sends, and monitor the output of the 3rd port.
Because MAC address aging time of described switch not yet finishes, described switch can't go to described unicast data frames described the 3rd port, and therefore, described network analyzer can not receive the unicast data frames from the 3rd port.Meanwhile, described network analyzer sends unicast data frames with the frequency of presetting, as long as the quantity of the unicast data frames that record sends can be learnt the duration that sends unicast data frames.
In step S3, described network analyzer when monitoring described the 3rd port and export described switch and be flooded to the unicast data frames of described the 3rd port, the quantity of the unicast data frames that record receives.
Particularly, described network analyzer is when monitoring described the 3rd port and export described unicast data frames, the MAC address aging of described switch is described, and time is up, in described switch, deleted the corresponding relation of source MAC-the first port, and flood to all of the port, forward described unicast data frames.At this moment, described network analyzer starts to record the quantity of described the 3rd port output unicast data frames.
In step S4, described network analyzer calculates the MAC address aging time of described switch according to formula (a1-a2)/f, and wherein, a1 is the quantity of sent unicast data frames, and a2 is the quantity of received unicast data frames, and f is described frequency.
Particularly, described network analyzer stops sending unicast data frames under technical staff's operation, according to above-mentioned formula, calculates the MAC address aging time of described switch.
As a kind of preferred version, described network analyzer is also provided with display screen, and described method of testing also comprises: described network analyzer is shown sent learning frame, unicast data frames and the quantity that records, so that technical staff's observation test process.
For example, described network analyzer is presented at sent learning frame, unicast data frames and the quantity that records in display screen with form.
More preferably, when described network analyzer is exported described learning frame at second, third port that monitors described switch, utilize and send the record that shown learning frame is removed in first unicast data frames gap before.
Particularly, when described network analyzer is exported described learning frame at second, third port that monitors described switch, beginning is exported described unicast data frames according to default frequency, in time cycle before unicast data frames described in exporting first, described network analyzer is first removed the record of shown learning frame.So, can allow technical staff clearly observe the test process of MAC address aging time, also can not cause interference opportunity to the transmission of unicast data frames.
As shown in Figure 2, the present invention also provides a kind of network analyzer.For the MAC address aging time of testing switch, wherein, described switch 2 comprises three ports, and described network analyzer 1 is connected with each port.Particularly, described network analyzer 1 comprises three interfaces, first interface 11 is connected with the first port 21 of described switch 2, the second interface 12 is connected with the second port 22 of described switch 2, the 3rd interface 13 is connected with the 3rd port 23 of described switch 2, and described network analyzer 1 also comprises on-air testing module 14, clean culture test module 15 and data processing module 16.
Described on-air testing module 14 is for the learning frame containing source MAC and target MAC (Media Access Control) address by described the first port 21 broadcast packets, and described second, third port 22,23 of monitoring, and monitoring the described learning frame of described second, third port 22,23 output, output clean culture sends instruction.In the present embodiment, described on-air testing module 14 comprises network interface card, CPU, memory, the bus being connected with three and software.Described on-air testing module 14 is also connected with described first, second, and third interface 11,12,13 by described network interface card, to export/to receive described learning frame.
Particularly, described on-air testing module 14 first contains the learning frame of source MAC and target MAC (Media Access Control) address to the first port 21 broadcast packets of described switch 2, it can be also a plurality of that the quantity of the learning frame of broadcasting can be one, the all of the port of said interchanger is set up the corresponding relation of described source MAC-target MAC (Media Access Control) address-the first port 21 according to broadcasted learning frame, wherein, because described network analyzer 1 sends learning frame to described the first port 21, described switch 2 is set up the corresponding relation of described source MAC-target MAC (Media Access Control) address-the first port 21, and second, the 3rd port 22, 23 forward described learning frame.Described on-air testing module 14 is when listening to the described learning frame of described second, third port 22,23 output, and output clean culture sends instruction to described clean culture test module 15.
Described clean culture test module 15 is for when receiving described clean culture transmission instruction, with the frequency preset, to described the second port 22, send and take the source MAC of described learning frame as target MAC (Media Access Control) address, the unicast data frames that the target MAC (Media Access Control) address of described learning frame of take is source MAC is to the first port 21 of described switch, the quantity of the unicast data frames that record sends, and monitor the output of the 3rd port 23, when monitoring the described switch of described the 3rd port 23 output and be flooded to the unicast data frames of described the 3rd port 23, the quantity of the unicast data frames that record receives.In the present embodiment, described clean culture test module 15 comprises network interface card, CPU, memory, the bus being connected with three and software.Described clean culture test module 15 is also connected with the 3rd interface 12,13 with described second by described network interface card, to export/to receive described unicast data frames.Wherein, for convenience of calculation, described frequency is fixed value and sets according to the required precision of switch mac address ageing time that will test and the system bandwidth of switch, and for example, described frequency is 1 unicast data frames/second.
Particularly, described clean culture test module 15 is monitoring second of described switch 2, the 3rd port 22, during the described learning frame of 23 output, second of described switch 2 is described, three ports 22, 23 have set up the corresponding relation of source MAC-target MAC (Media Access Control) address-the first port 21, now start to calculate the ageing time of the MAC Address of described switch 2, described clean culture test module 15 stops broadcasting described learning frame again, but send and take the source MAC of described learning frame as target MAC (Media Access Control) address to the second port 22 with described frequency, the unicast data frames that the target MAC (Media Access Control) address of described learning frame of take is source MAC, described switch 2 is according to the corresponding relation of preserved source MAC-the first port 21, and the target MAC (Media Access Control) address in described unicast data frames, described unicast data frames is gone to the first port 21 outputs, simultaneously, the quantity of the unicast data frames that described clean culture test module 15 records send, and monitor the output of the 3rd port 23.
Because MAC address aging time of described switch 2 not yet finishes, described switch 2 can't go to described unicast data frames described the 3rd port 23, and therefore, described clean culture test module 15 can not receive the unicast data frames from the 3rd port 23.Meanwhile, described clean culture test module 15 sends unicast data frames with the frequency of presetting, as long as the quantity of the unicast data frames that record sends can be learnt the duration that sends unicast data frames.
Then, described clean culture test module 15 is when monitoring the described switch of described the 3rd port 23 output and be flooded to the unicast data frames of described the 3rd port 23, the MAC address aging of described switch 2 is described, and time is up, in described switch 2, deleted the corresponding relation of source MAC-the first port 21, and flood to all of the port, forward described unicast data frames.At this moment, described clean culture test module 15 starts to record the quantity of described the 3rd port 23 output unicast data frames.
Described data processing module 16 is connected with described clean culture test module 15, for the MAC address aging time of calculating described switch 2 according to formula (a1-a2)/f, wherein, a1 is the quantity of the unicast data frames that sends of described the second port 22, a2 is the quantity (quantity of the unicast data frames that namely described the 3rd port 23 receives) that described switch is flooded to the unicast data frames of described the 3rd port 23, and f is described frequency.
Particularly, described network analyzer 1 stops sending unicast data frames under technical staff's operation, and described data processing module 16 calculates the MAC address aging time of described switch 2 according to above-mentioned formula.
As a kind of preferred version, described network analyzer 1 is also provided with display screen (not giving diagram), and described network analyzer 1 also comprises display screen; Described on-air testing module 14 is transported to described display screen by sent learning frame and is shown; Described clean culture test module 15 is transported to described display screen by sent unicast data frames with the quantity recording and is shown.
For example, described on-air testing module 14 and clean culture test module 15 are presented at sent learning frame, unicast data frames and the quantity that records in display screen with form.
More preferably, described clean culture test module 15, when receiving described clean culture transmission instruction, utilizes and sends the record that shown learning frame is removed in first unicast data frames gap before.
Particularly, described clean culture test module 15 is when monitoring the described learning frame of second, third port 23 output of described switch 2, beginning is exported described unicast data frames according to default frequency, in time cycle before unicast data frames described in exporting first, described clean culture test module 15 is first removed the record of shown learning frame.So, can allow technical staff clearly observe the test process of MAC address aging time, also can not cause interference opportunity to the transmission of unicast data frames.
In sum, method and the network analyzer of the MAC address aging time of test switch of the present invention, utilize the quantity of the unicast data frames that sends predeterminated frequency to calculate ageing time with the difference and the predeterminated frequency that receive the quantity of described unicast data frames, can effectively avoid directly monitoring the error that two time points bring; In addition, by institute's sending/receiving to each Frame, quantity be presented in display screen and can help technical staff to observe test process; In addition, before showing the unicast data frames of adding up, recording of learning frame is clear, can help technical staff to observe test process.So the present invention has effectively overcome various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all can, under spirit of the present invention and category, modify or change above-described embodiment.Therefore, such as in affiliated technical field, have and conventionally know that the knowledgeable, not departing from all equivalence modifications that complete under disclosed spirit and technological thought or changing, must be contained by claim of the present invention.