A kind of system and method testing switch mac address study
Technical field
The present invention relates to switch technology field, especially relate to a kind of system and method testing switch mac address study.
Background technology
Under initial condition, switch mac (MediaAccessControl or MediumAccessControl, media interviews control, or physical address, hardware address) address table is empty, in order to realize fast-forwarding, must set up mac address table.Meanwhile, due to the finite capacity of mac address table, and network equipment variation is relatively more frequent, and switch is wanted to delete old mac address table timely, upgrades the mac address table changed.The dynamic mac address table study of switch is exactly that when passing through switch port accepts to packet, exchange opportunity analyzes source mac and vlanid of this packet to carry out interpolation and the deletion of mac address.Switch forwards unicast message according to mac address table.The pace of learning of MAC Address and mac address table specification affect the forwarding performance of switch greatly.MAC address learning is excessively slow, a large amount of mac address short time gives out a contract for a project, may leak and learn some MAC, the bag that returns of this hourglass MAC Address is just thought DLF (DestinationLookupFailure) message by switch, thus affects switch forwarding performance.Equally, mac address table specification is too little, and mac address table is write completely, and other MAC Address messages just can only select broadcast mode to forward, and affect switch performance too.Therefore, in test process, need the specification of testing a large amount of mac address learning performance and mac address table, the method for testing that tradition is commonly used has:
Scheme one: single port single sends the message (as 10000) of fixed qty MAC Address alternation, then checks switch soft or hard mac address table number, contrasts with transmission MAC number.In time sending number and be more, the method seems very inconvenient, the words seen one by one trouble very, and whether correct brush screen also quickly, can only carry out comparing result according to statistics number.
Scheme one can detect switch mac address table size and chip MAC concurrent capability (by adjustment packet sending speed) really, but switch general requirements has 16K or 32KMAC address capability at present, core switch even reaches 128K capacity, simply to check and to contrast soft or hard mac address table workload huge, bottom hardware mac address table brush screen has tens minutes, makes us dazzled.Manually carry out searching the situation contrasting and be easy to occur having leaked, accurate testing degree neither be very high.
Scheme two: dual-port continues and the message of alternation (as: 5000<--->5000) corresponding to order MAC Address of sending out source a large amount of, after a period of time, judge whether message all have received from the speed whether sent with opposite end to the speed of message according to two port accepts is identical, have received message, mac study i.e. normal.
The method of testing of scheme two is relatively simple, message corresponding to many group mac is sent by two-port, check the message whether port all receives opposite end and send, whether the method does not need contrast soft or hard mac address table equal, as long as the contrary multiple alternation data flow of continuation air exercise source order mac, send the speed of message according to port accepts to Peer-Port and number judges whether mac learns normal.This method also can send out by repeatedly revising the mac address table specification that alternation source MAC quantity detects switch, but so also bring some problems, the ability of switch short time study mac can not be tested out, because message continues to send, some message MAC first time may be had normally not write mac address table, but second time or third time are when sending this message, this MAC just normally writes in mac address table, and we also have no way of learning that whether the MAC concurrent capability of switch is up to standard like this.
Summary of the invention
The technical problem that the present invention mainly solves is to provide a kind of system and method testing switch mac address study, can test out the learning ability of switch accurately.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: provide a kind of method of testing switch mac address study, and wherein, switch comprises the first transmitting-receiving port and the second transmitting-receiving port, and the method comprises:
Send broadcasting packet to the first transmitting-receiving port, wherein, broadcasting packet includes source MAC, makes switch that the source MAC of broadcasting packet and first are received and dispatched port association;
Unicast message is sent to the second transmitting-receiving port, wherein, the quantity of unicast message is not more than the quantity of broadcasting packet, and unicast message comprises destination-mac address, destination-mac address is identical with the source MAC of broadcasting packet, sends from the first transmitting-receiving port to indicate unicast message;
Detect unicast message whether all to be sent by the first transmitting-receiving port, if the result detected is no, then judge that switch mac address study is abnormal, if the result detected is yes, then judge that switch mac address study is normal.
Wherein, method also comprises: synchronous adjustment sends quantity and the speed of broadcasting packet to the first transmitting-receiving port and receives and dispatches to second quantity and the speed that port sends unicast message gradually.
Wherein, the step that whether detection unicast message is all sent by the first transmitting-receiving port comprises:
First quantity of the unicast message of statistics second transmitting-receiving port accepts, further statistics first receives and dispatches the second quantity of the transmission unicast message of port, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port.
Wherein, the quantity of unicast message equals the quantity of broadcasting packet;
The step whether detection unicast message is all sent by the first transmitting-receiving port comprises:
Add up the first transmitting-receiving port respectively send the first quantity of broadcasting packet and send the second quantity of unicast message, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port.
Wherein, switch comprises the 3rd transmitting-receiving port further, and the quantity of unicast message equals the quantity of broadcasting packet;
The step whether detection unicast message is all sent by the first transmitting-receiving port comprises:
When the second transmitting-receiving port accepts unicast message, detect the 3rd transmitting-receiving port and whether receive unicast message, if receive unicast message, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if do not receive unicast message, be then judged as that unicast message is all sent by the first transmitting-receiving port.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: provide a kind of system of testing switch mac address study, this system comprises:
Switch, comprises the first transmitting-receiving port and the second transmitting-receiving port;
Message sends instrument, comprising:
First transmit port, for sending broadcasting packet to the first transmitting-receiving port, wherein, broadcasting packet includes source MAC, makes switch that the source MAC of broadcasting packet and first are received and dispatched port association;
Second transmit port, for sending unicast message to the second transmitting-receiving port, wherein, the quantity of unicast message is not more than the quantity of broadcasting packet, unicast message comprises destination-mac address, destination-mac address is identical with the source MAC of broadcasting packet, sends from the first transmitting-receiving port to indicate unicast message;
Whether controller, all being sent by the first transmitting-receiving port for detecting unicast message, if the result detected is no, then judging that switch mac address study is abnormal, if the result detected is yes, then judging that switch mac address study is normal.
Wherein, controller also further gradually synchronous adjustment first transmit port send to the first transmitting-receiving port the quantity of broadcasting packet and speed and the second transmit port to send quantity from unicast message to the second transmitting-receiving port and speed.
Wherein, the first quantity of the unicast message of the second transmitting-receiving port accepts added up further by controller, and add up the second quantity of the transmission unicast message of the first transmitting-receiving port, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port.
Wherein, the quantity of unicast message equals the quantity of broadcasting packet;
Controller is added up the first transmitting-receiving port further respectively and is sent the first quantity of broadcasting packet and send the second quantity of unicast message, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port.
Wherein, switch comprises the 3rd transmitting-receiving port further, and message sends instrument and comprises the 3rd transmit port received and dispatched port with the 3rd and be connected further, and the quantity of unicast message equals the quantity of broadcasting packet;
When the second transmitting-receiving port accepts unicast message, controller detects the 3rd transmit port further and whether receives unicast message, if receive unicast message, then be judged as that unicast message is not all sent by the first transmitting-receiving port, if do not receive unicast message, be then judged as that unicast message is all sent by the first transmitting-receiving port.
The invention has the beneficial effects as follows: the situation being different from prior art, the invention provides a kind of method of testing switch mac address study, the method is first send broadcasting packet to the first transmitting-receiving port of switch, wherein, broadcasting packet includes source MAC, make switch that the source MAC of broadcasting packet and first are received and dispatched port association, then the second transmitting-receiving port to switch sends unicast message, wherein, the quantity of unicast message is not more than the quantity of broadcasting packet, unicast message comprises destination-mac address, destination-mac address is identical with the source MAC of broadcasting packet, send from the first transmitting-receiving port to indicate unicast message, finally detect unicast message whether all to be sent by the first transmitting-receiving port, if the result detected is no, then judge that switch mac address study is abnormal, if the result detected is yes, then judge that switch mac address study is normal.Therefore, the present invention can test out the performance of switch accurately.
Accompanying drawing explanation
Fig. 1 is a kind of flow chart testing the method for switch mac address study that the embodiment of the present invention provides;
Fig. 2 is a kind of structural representation testing the system of switch mac address study that the embodiment of the present invention provides.
Embodiment
Refer to Fig. 1, Fig. 1 is a kind of flow chart testing the method for switch mac address study that the embodiment of the present invention provides.Wherein, switch comprises the first transmitting-receiving port and the second transmitting-receiving port, and as shown in Figure 1, the method comprises the following steps:
Step S1: send broadcasting packet to the first transmitting-receiving port, wherein, broadcasting packet includes source MAC, after making first of switch the transmitting-receiving port receive this broadcasting packet, learn this source MAC, by in the source MAC of this broadcasting packet write mac address table, source MAC and first is made to receive and dispatch port association.
Step S2: send unicast message to the second transmitting-receiving port, wherein, the quantity of unicast message is not more than the quantity of broadcasting packet, and unicast message comprises destination-mac address, destination-mac address is identical with the source MAC of broadcasting packet, sends from the first transmitting-receiving port to indicate unicast message.It should be noted that the source MAC of unicast message is any, destination-mac address is identical with the source MAC of broadcasting packet, is equivalent to unicast message needs that the second transmitting-receiving port receives and receives and dispatches port by first and send.
Step S3: detect unicast message and whether all sent by the first transmitting-receiving port.
In this step, if the result detected is yes, then jump to step S4, if the result detected is no, then jump to step S5.
Wherein, the method that this step detects comprises following three kinds:
The first detection method: the first quantity of the unicast message that statistics second transmitting-receiving port receives, the second quantity of the transmission unicast message of statistics first transmitting-receiving port further.Whether the value then comparing the first quantity and the second quantity is equal, if do not think, then illustrate that the unicast message of the second transmitting-receiving port accepts does not all send out from the first transmitting-receiving port, so be judged as that unicast message is not all sent by the first transmitting-receiving port, if equal, then illustrate that the unicast message that the second transmitting-receiving port receives all has sent out from the first transmitting-receiving port, so be judged as that unicast message is all sent by the first transmitting-receiving port.
It should be noted that the first detection method is all applicable when the quantity of unicast message is less than or equal to the quantity of broadcasting packet.
Wherein, the condition of the second detection method below introduced and the third detection method is: the quantity to the unicast message of the first transmitting-receiving port transmission equals the quantity of the broadcasting packet sent to the second transmitting-receiving port.
The second detection method: add up the first transmitting-receiving first quantity of broadcasting packet of port accepts and the second quantity of the unicast message of transmission respectively, whether the value comparing the first quantity and the second quantity is equal.If unequal, then illustrate that the unicast message that the second transmitting-receiving port receives does not have all to send from the first transmitting-receiving port, be therefore judged as that unicast message is not all sent by the first transmitting-receiving port.Now, the difference of the first quantity and the second quantity is the number of the first transmitting-receiving port learning MAC address failure.If equal, then illustrate that the unicast message that the second transmitting-receiving port receives all sends from the first transmitting-receiving port, be therefore judged as that unicast message is all sent by the first transmitting-receiving port.This detection method detects the first transmitting-receiving port accepts simultaneously and sends the quantity of message, convenient and simple, not easily makes mistakes.
Should understand, the message received due to the first transmitting-receiving port is broadcasting packet, then when the first transmitting-receiving port receives this broadcasting packet, second transmitting-receiving port also receives this broadcasting packet, therefore, the quantity and second that the second detection method also can add up the first transmitting-receiving port transmission unicast message respectively receives and dispatches the quantity that port receives broadcasting packet, then two quantity is compared, principle is identical with previously described, does not repeat them here.
The third detection method: switch comprises the 3rd transmitting-receiving port further, wherein the 3rd transmitting-receiving port is policing port.When the second transmitting-receiving port accepts unicast message, detect the 3rd transmitting-receiving port and whether receive this unicast message, if receive this unicast message, then illustrate that the unicast message that the second transmitting-receiving port receives does not have all to send from the first transmitting-receiving port, be therefore judged as that unicast message is not all sent by the first transmitting-receiving port.These are leaked by switch the MAC Address learned can be thought DLF (DestinationLookupFailure by switch, object looking up the fault) message, be broadcast to all transmitting-receiving ports, such policing port also just can receive these and leak the message learning MAC Address.If do not receive unicast message, then explanation first transmitting-receiving port all have sent the unicast message that the second transmitting-receiving port receives, and is therefore judged as that unicast message is all sent by the first transmitting-receiving port.
In like manner, for the second detection method, the message received due to the first transmitting-receiving port is broadcasting packet, then when the first transmitting-receiving port receives this broadcasting packet, the 3rd transmitting-receiving port can receive this broadcasting packet equally, therefore, the quantity and the 3rd that the second detection method also can add up the first transmitting-receiving port transmission unicast message respectively receives and dispatches the quantity that port receives broadcasting packet, then two quantity compared, principle is identical with previously described, does not repeat them here.
Step S4: judge that switch mac address study is normal.
Step S5: judge that switch mac address study is abnormal.
In the present embodiment, synchronous adjustment sends quantity and the speed of broadcasting packet to the first transmitting-receiving port and receives and dispatches to second quantity and the speed that port sends unicast message gradually.
For example, the source MAC alternation of the broadcasting packet that the first transmitting-receiving port receives 8000 times, send total number 8000, transmission rate is that initial rate carries out increasing and reducing with 800pps; The source MAC of unicast message that second transmitting-receiving port receives is any, does not need alternation, and it is consistent that the source MAC rule change that port receives is received and dispatched in destination-mac address change and first, total number 8000.
Each change sends quantity and the speed of message, all carries out once previously described step S1-S3, so just can test out the concurrent learning ability of MAC Address of switch and total specification number according to the result of test.
Therefore, the present invention can send the speed of MAC message by simple adjustment, whether the concurrent learning performance of MAC testing out switch is up to standard.And the number of MAC Address is sent by simple adjustment, the mac address table specification testing out switch is how many.
The embodiment of the present invention additionally provides a kind of system of testing switch mac address study, and this system is applicable to previously described method.Specifically refer to Fig. 2, Fig. 2 is a kind of structural representation testing the system of switch mac address study that the embodiment of the present invention provides.
As shown in Figure 2, the system 10 of the embodiment of the present invention comprises switch 11, message sends instrument 12 and controller 13.Wherein, controller 13 connects switch 11 by serial ports, and connects message transmission instrument 12 by wire jumper, sends message bag to control message transmission instrument 12.Switch 11 comprises the first transmitting-receiving port 111 and the second transmitting-receiving port 112.Message sends instrument 12 and comprises the first transmit port 121 and the second transmit port 122.First transmitting-receiving port 111 is connected with the first transmit port 121, and the second transmitting-receiving port 112 is connected with the second transmit port 122.
In the present embodiment, the first transmit port 121 is for sending broadcasting packet to the first transmitting-receiving port 111, and wherein, broadcasting packet includes source MAC, makes switch that the source MAC of broadcasting packet and first are received and dispatched port association.
Second transmit port 122 is for sending unicast message to the second transmitting-receiving port 112, wherein, the quantity of unicast message is not more than the quantity of broadcasting packet, unicast message comprises destination-mac address, destination-mac address is identical with the source MAC of broadcasting packet, sends from the first transmitting-receiving port to indicate unicast message.
Whether controller 13 is all sent by described first transmitting-receiving port 111 for detecting unicast message, if the result detected is no, then judges that switch 11 learns abnormal, if the result detected is yes, then judges that switch 11 learns normally.
Specifically, the first quantity of the unicast message that port 112 receives received and dispatched by controller 13 further statistics second, and add up the second quantity of the transmission unicast message of the first transmitting-receiving port 111, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port 111, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port 111.
Or when the quantity that the quantity of the broadcasting packet that the first transmit port 121 sends to the first transmitting-receiving port 111 equals the unicast message that the second transmit port 122 sends to the second transmitting-receiving port 112 is equal.Controller 13 is added up the first transmitting-receiving port 111 further respectively and is received the first quantity of broadcasting packet and send the second quantity of unicast message, relatively whether the value of the first quantity and the second quantity is equal, if unequal, then be judged as that unicast message is not all sent by the first transmitting-receiving port 111, if equal, be then judged as that unicast message is all sent by the first transmitting-receiving port 111.
Or switch 11 comprises the 3rd transmitting-receiving port 113 further, message sends instrument 12 and comprises the 3rd transmit port 123 received and dispatched port 113 with the 3rd and be connected further.When the second transmitting-receiving port 112 receives unicast message, controller 13 detects the 3rd transmit port 113 further and whether receives unicast message, if receive unicast message, then be judged as that unicast message is not all sent by the first transmitting-receiving port 111, if do not receive unicast message, be then judged as that unicast message is all sent by the first transmitting-receiving port 111.
Wherein, controller 13 also gradually synchronous adjustment first transmit port 121 send to the first transmitting-receiving port 111 quantity of broadcasting packet and speed and the second transmit port 122 to send quantity from unicast message to the second transmitting-receiving port 112 and speed.
For example, the source MAC alternation of the broadcasting packet that the first transmitting-receiving port 111 receives 8000 times, send total number 8000, transmission rate is that initial rate carries out increasing and reducing with 800pps; The source MAC of unicast message that second transmitting-receiving port 112 receives is any, does not need alternation, and it is consistent that the source MAC rule change that port 111 receives is received and dispatched in destination-mac address change and first, total number 8000.
Each change sends quantity and the speed of message, all carries out once previously described detection, so just can test out the concurrent learning ability of MAC Address of switch 12 and total specification number according to the result of test.
The foregoing is only embodiments of the invention; not thereby the scope of the claims of the present invention is limited; every utilize specification of the present invention and accompanying drawing content to do equivalent structure or equivalent flow process conversion; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.