Embodiment
The invention provides the method and apparatus that a kind of mac frame is transmitted, be used for the forwarding of network mac frame.Whether the port by relatively receiving mac frame is consistent with the source MAC corresponding port in the mac address forwarding table, if it is inconsistent by target MAC (Media Access Control) address corresponding port forwarding mac frame, stop the circulation of data in the network intermediate ring road to be transmitted, avoid causing network congestion.
Seeing also Fig. 1 is that the method that mac frame provided by the invention is transmitted is implemented illustration.
The source MAC that the mac frame that step 101, parsing are received carries;
After the networking is got up, have the data packet transmission that the user sends in the network, the transmission of packet is not between two equipment, can be through the transmission of intermediate equipment.After the equipment in the network is received the mac frame of other equipment transmissions, resolve the source MAC that this mac frame carries; Mac frame is generally data and the control data in the network (as the CCM frame) that the user sends in the network.
Step 102, query source MAC Address;
The source MAC that carries in the inquiry mac frame in mac address forwarding table then enters step 103 if inquire; Then do not enter step 108 if inquire; In addition, if the query source MAC Address then directly abandons the mac frame of receiving for the mac frame of the equipment of reception mac frame.
Step 103, extraction source MAC Address and the port that receives mac frame;
Extract the source MAC that parsing obtains in 101 steps, the port that receives mac frame with equipment is corresponding.
Step 104, comparison port;
Whether the forwarding port that source MAC is corresponding in the port that relatively receives mac frame and the mac address forwarding table is consistent, if inconsistent entering in the step 105; If unanimity then enters step 109;
Another possibility of this step: if relatively port is inconsistent, relatively receive port forwarding port which optimum corresponding of mac frame with source MAC in the mac address forwarding table, if receive the port optimum of mac frame, then this port is replaced in mac address forwarding table and the source MAC corresponding port, entered step 109.Relatively port can carry out the comparison of path optimum according to different strategies, such as carrying out port flow relatively to determine optimum port, selects the port of the little port of flow as optimum.
Step 105, parsing target MAC (Media Access Control) address;
The target MAC (Media Access Control) address that the mac frame that parsing is received carries.
Step 106, search purposes MAC Address;
The described target MAC (Media Access Control) address of inquiry then enters step 108 if inquire in mac address forwarding table, does not then abandon the mac frame of receiving if inquire.
Step 107, mac frame is forwarded to the forwarding port of target MAC (Media Access Control) address correspondence in the mac address forwarding table.
Step 108, study source MAC and the port that receives mac frame;
MAC Address of learning and the port correspondence that receives mac frame are write in the mac address forwarding table.
Step 109, parsing target MAC (Media Access Control) address are transmitted mac frame;
Difference according to the target MAC (Media Access Control) address of frame in the network can be divided into Frame: broadcasting, multicast and clean culture; Broadcasting as destination address is all device addresses in the whole network; Multicast is that destination address is a group address; Clean culture is that destination address has only one.
In this step, the repeating process of broadcasting is that mac frame is forwarded to other all of the ports except that the port that receives this MAC.
The forwarding of clean culture is inquired about mac address forwarding table with target MAC (Media Access Control) address, then mac frame is forwarded to target MAC (Media Access Control) address corresponding port in the list item if inquire, and then this mac frame is not forwarded to other all of the ports that remove the port that receives this mac frame if inquire.
The forwarding of multicast is inquired about mac address forwarding table with target MAC (Media Access Control) address, then mac frame is forwarded to target MAC (Media Access Control) address corresponding port in the list item if inquire, and then this mac frame is not forwarded to other all of the ports that remove the port that receives this mac frame if inquire.
So far, the repeating process of mac frame finishes in a network equipment.
From the foregoing description as can be seen, the invention provides after equipment is received mac frame, is the MAC Address that receives the equipment of mac frame if resolve source MAC, then abandons this mac frame, prevents that effectively the circulation of packet in the loop from transmitting, and avoids network congestion.
Further, the present invention also provides if do not inquire the port that source MAC is then learnt source MAC and received this mac frame in mac address forwarding table, avoids the packet of the list item that do not occur in the mac address forwarding table to be dropped.
Further, the invention provides the relatively more optimum step of port, can reasonably distribute port flow according to current network conditions.
Optionally, when the invention provides network and breaking down, by the CCM forwards with faulty equipment or/and the corresponding MAC Address of port that faulty line connects, deletion with faulty equipment or/and the corresponding mac address forwarding table item of port that faulty line connects, and delete in the described mac address forwarding table with described receiving and carry in the described mac address forwarding table with faulty equipment or/and the corresponding mac address forwarding table item of receiving port of the CCM of the corresponding MAC Address of the port that faulty link is connected ensures the smooth and easy forwarding of packet when network breaks down.
Seeing also Fig. 2 is the method figure that CCM frame provided by the invention is transmitted.
The Ethernet fault detect, each equipment can send connectivity check messages (CCM by other equipment in network, Continuity Check Message), the invention provides equipment by CCM other device forwards equipment faults and/or line fault method in other networks.
Step 10, with in the mac address forwarding table with faulty equipment or/and the corresponding MAC Address of port that faulty link connects be filled among the TLV among the CCM;
Type lengths values (TLV, Type Length Value) is field in the CCM frame.
According to specific circumstances, select for use the type that is not used among the TLV to insert MAC Address, the present invention uses Reserved for definition by IEEE 802.1 types to fill in MAC Address, and those skilled in the art can select to insert the type of MAC Address according to specific circumstances.
Step 11, CCM is forwarded to not with faulty equipment or/and the port that faulty line is connected;
To carry in the mac address forwarding table port that faulty link is connected or/and the CCM of the corresponding MAC Address of the port that faulty link connects is forwarded to not with faulty equipment with faulty equipment, promptly be forwarded to except that with faulty equipment or/and other ports of the port that faulty line is connected.
Mac address forwarding table item in step 12, the deletion mac address forwarding table;
In the deletion mac address forwarding table with faulty equipment or/and the corresponding mac address forwarding table item of port that faulty link connects.
If this equipment is received the CCM message of other device forwards, enter step 13.
Whether carry MAC Address among the TLV among step 13, the parsing CCM;
Whether carry among the TLV among the CCM that parsing is received that other equipment send with faulty equipment or/and the corresponding MAC Address of port that faulty line connects, if enter step 14, then no longer do not carry out following step if carry MAC Address among the TLV among the parsing CCM, jump out this process.
Step 14, in mac address forwarding table, inquire about port;
Whether the MAC Address corresponding port that query steps 13 inquires in MAC transmits is the port that equipment receives CCM, if then enter step 15, if not then disregard.
The mac address forwarding table item that CCM carries in step 15, the deletion mac address forwarding table;
The mac address forwarding table item that CCM carries in the deletion mac address forwarding table, this MAC Address corresponding port are the port that equipment receives CCM.
Need to prove, in the process that process supporter's mac frame that above-mentioned CCM frame is transmitted is transmitted, do not rely on the process that mac frame transmits and exist; The process that the CCM frame is transmitted reaches inaccessible mac frame forwarding circuit and/or equipment in the deletion mac address forwarding table, makes that the forwarding of mac frame is more effective and smooth and easy.
Seeing also Fig. 3 is the equipment structure chart that mac frame provided by the invention is transmitted.
MAC Address resolution unit 201 is used to resolve the MAC Address that the mac frame that receives carries;
MAC Address query unit 202 is used for the MAC Address that is resolved in mac address forwarding table inquiry MAC Address resolution unit;
Source MAC extraction unit 203 is used in the MAC Address query unit after mac address forwarding table inquires source MAC, extracts source MAC that carries in the described mac frame and the port that receives mac frame;
Port comparing unit 204, whether the forwarding port that the port that is used for relatively receiving described mac frame and described mac address forwarding table source MAC are corresponding is consistent;
Mac frame retransmission unit 205, be used for when the port of the port comparing unit reception mac frame relatively forwarding port corresponding with described mac address forwarding table source MAC is inconsistent, mac frame is forwarded to the MAC Address query unit in mac address forwarding table, inquires about the target MAC (Media Access Control) address corresponding port that is resolved in the MAC Address resolution unit, if in described mac address forwarding table, do not inquire the MAC Address that is resolved in the described MAC Address resolution unit, then abandon described mac frame; When the forwarding port that source MAC is corresponding in the port of described port comparing unit described reception mac frame relatively and the mac address forwarding table is consistent, mac frame is forwarded to described MAC Address query unit in mac address forwarding table, inquires about the MAC Address corresponding port that is resolved in the MAC Address resolution unit, when the MAC Address query unit did not inquire the target MAC (Media Access Control) address that mac frame that the MAC Address resolution unit is resolved to carries, mac frame was forwarded to the port that does not receive mac frame.
The invention provides in addition after equipment is received mac frame, is the MAC Address that receives the equipment of mac frame if resolve source MAC, then abandons this mac frame, prevents that effectively the circulation of packet in the loop from transmitting, and avoids network congestion.Therefore, on the basis of above-mentioned mac frame forwarding unit scheme, MAC Address query unit 202 is used to also to inquire about whether the source MAC that the MAC Address resolution unit resolves is the MAC Address that receives the equipment of mac frame, if then notify the mac frame retransmission unit to abandon described mac frame.
On the basis of above-mentioned mac frame forwarding unit scheme,, the invention provides the study MAC Address in mac address forwarding table in mac address forwarding table if the MAC Address of carrying in the mac frame is not inquired about.This moment, the mac frame forwarding unit also comprised:
MAC address learning unit 206, be used in described MAC Address query unit when described mac address forwarding table does not inquire source MAC, source MAC and the port that receives described mac frame are filled in the mac address forwarding table, and notify described mac frame retransmission unit to transmit described mac frame.。
On the basis of above-mentioned mac frame forwarding unit scheme, if the port comparing unit relatively receives the MAC Address corresponding port of carrying in the mac frame in the port of mac frame and the mac address forwarding table, receive the port optimum of mac frame, reasonably distribute port flow according to current network conditions.This moment, the mac frame forwarding unit also comprised:
Optimum port is replaced unit 207, be used for relatively receiving the port of the mac frame forwarding port corresponding when inconsistent with the mac address forwarding table source MAC at the port comparing unit, whether relatively receive the port of the mac frame forwarding port corresponding with source MAC in the mac address forwarding table optimum, if the port optimum of described reception mac frame, the port that then will receive mac frame is replaced the forwarding port of source MAC correspondence in the mac address forwarding table.
The Ethernet fault detect, each mac frame forwarding unit can send connectivity check messages (CCM by other equipment in network, Continuity Check Message), the invention provides the device that equipment is transmitted by the CCM frame of CCM other device forwards equipment faults and/or line fault in other networks, when network breaks down, ensure the smooth and easy forwarding of packet.
MAC Address is inserted unit 301, be used for when network breaks down, with in the mac address forwarding table with described faulty equipment or/and the corresponding MAC Address of port that faulty line connects be filled among the TLV among the described CCM;
Mac address forwarding table entry deletion unit 302, be used for deleting mac address forwarding table with described faulty equipment or/and the corresponding mac address forwarding table item of port that faulty line connects.
Based on the device that above-mentioned CCM frame is transmitted, the device that the CCM frame is transmitted also comprises:
CCM resolution unit 303, be used for resolving whether the CCM that receives carries in the mac address forwarding table with faulty equipment or/and the corresponding MAC Address of port that faulty link connects, then notify the MAC Address query unit in mac address forwarding table, inquire about in the mac address forwarding table that carries with faulty equipment or/and the corresponding MAC Address of port of faulty link connection if carry;
MAC Address corresponding to port that faulty link connects if the MAC Address query unit inquires in mac address forwarding table in the mac address forwarding table that carries among the CCM with faulty equipment; Then the MAC Address unit further the described port corresponding with MAC Address of inquiry whether be that reception is carried in the mac address forwarding table with faulty equipment or/and the port of the CCM of MAC Address corresponding to the port that faulty link is connected, if then notify in the mac address forwarding table entry deletion element deletion mac address forwarding table with carrying in the mac address forwarding table with faulty equipment of receiving or/and mac address forwarding table item corresponding to port of the CCM of MAC Address corresponding to the port that faulty link is connected.
The present invention can be applied in the datacycle of avoiding loop to cause in the networking arbitrarily and transmit, such as being applied in the horizontal splitting scheme.
More than the method and apparatus transmitted of method and apparatus that mac frame provided by the present invention is transmitted and CCM frame be described in detail, used specific case herein principle of the present invention and execution mode are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.