Disclosure of Invention
In view of this, the present invention provides a mac address processing method and apparatus, so as to solve the problem that the protection port needs to relearn the mac address table after the working link fails. The technical scheme is as follows:
a mac address processing method is applied to communication equipment and comprises the following steps:
redefining a super port under the condition that the virtual local area network access lists of a working port and a protection port are the same, wherein the super port is composed of the working port, the protection port and the virtual local area network access list;
generating a media access control mac address table, wherein a virtual local area network access list corresponding to the super port and a mac address of a super port of an opposite end corresponding to the super port are recorded in the mac address table;
under the condition that the super port receives a first data frame carrying a target mac address, judging whether the target mac address exists in a mac address of a super port of an opposite end corresponding to the super port;
if yes, determining an active port from the working port and the protection port, determining a target opposite-end super port corresponding to the target mac address based on the virtual local area network access list, and controlling the active port to forward the first data frame to the target opposite-end super port.
Preferably, the generating the mac address table includes:
if the working port or the protection port is detected to receive a second data frame carrying an active media access control mac address, determining the source mac address as the mac address of the opposite-end super port of the super port;
and generating a mac address table corresponding to the super port according to the mac address of the super port of the opposite end corresponding to the super port and the virtual local area network access list.
Preferably, the determining an active port from the working port and the protection port includes:
selecting a port for storing service data from the working port and the protection port;
and determining the selected port as an active port.
Preferably, the method further comprises the following steps:
and under the condition that the change event of the active port is detected, the active port identification of the active port is sent to the target opposite-end super port.
Preferably, the port type of the working port is a common port or a link aggregation group.
Preferably, the protection port type is a normal port or a link aggregation group.
A mac address processing apparatus, comprising: the device comprises a redefining module, a generating module, a judging module and a control module;
the redefinition module is used for redefining a super port under the condition that the virtual local area network access lists of a working port and a protection port are the same, and the super port is composed of the working port, the protection port and the virtual local area network access list;
the generation module is configured to generate a mac address table for media access control, where a virtual local area network access list corresponding to the super port and a mac address of the super port of the opposite end corresponding to the super port are recorded in the mac address table;
the judging module is used for judging whether the target mac address exists in the mac address of the opposite-end super port corresponding to the super port or not under the condition that the super port receives a first data frame carrying the target mac address; if yes, triggering the control module;
the control module is configured to determine an active port from the working port and the protection port, determine a target peer super port corresponding to the target mac address based on the virtual local area network access list, and control the active port to forward the first data frame to the target peer super port.
Preferably, the generating module is specifically configured to:
if the working port or the protection port is detected to receive a second data frame carrying an active media access control mac address, determining the source mac address as the mac address of the opposite-end super port of the super port; and generating a mac address table corresponding to the super port according to the mac address of the super port of the opposite end corresponding to the super port and the virtual local area network access list.
Preferably, the determining module is specifically configured to:
selecting a port for storing service data from the working port and the protection port; and determining the selected port as an active port.
Preferably, the control module is further configured to:
and under the condition that the change event of the active port is detected, the active port identification of the active port is sent to the target opposite-end super port.
Compared with the prior art, the invention has the following beneficial effects:
the method is applied to communication equipment, defines a working port, a protection port and a virtual local area network access list with the same working port and protection port as a super port, and completes forwarding by using the super port and a learned mac address table. Therefore, mac address updating can be skipped in the link switching process, and only the active port needs to be determined, so that the data forwarding time of the communication equipment is greatly shortened.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
VLAN technology: ethernet is a data network communication technology based on CSMA/CD (Carrier Sense Multiple Access/Collision detection) shared communication medium, and when the number of hosts is large, the problems of serious Collision, broadcast flooding, significant performance degradation, and even network unavailability may occur. Implementing LAN interconnection through communication devices such as switches or routers, while solving the serious problem of Collision (Collision), still does not isolate the broadcast messages. In this case, a Virtual Local Area Network (VLAN) technology is available, which can divide a LAN into a plurality of logical LANs, each VLAN being a broadcast domain, and the communication between hosts in the VLAN is the same as in a LAN, but the VLANs cannot be directly intercommunicated, so that the broadcast messages are limited to a VLAN.
The VLAN is divided without physical location restrictions: hosts not in the same physical location range may belong to the same VLAN; a VLAN contains subscribers that may be connected to the same switch, may span switches, or may even span routers.
Based on the above VLAN technology, an embodiment of the present invention provides a mac address processing method, where the method is applied to communication devices, where the communication devices include, but are not limited to, switches and routers, and a flowchart of the method is shown in fig. 1, and includes the following steps:
s10, redefining a super port for the communication equipment under the condition that the virtual local area network access lists of the working port and the protection port are the same, wherein the super port is composed of the working port, the protection port and the virtual local area network access list;
in this embodiment, a virtual local area network access list VLAN list records multiple VLAN identifiers, and the VLAN identifiers and mac addresses of hosts having access rights under the VLAN have a corresponding relationship.
The port type of the working port may be a common port, and may also be a link aggregation group lag (link aggregation group), where the link aggregation group lag is formed by aggregating a plurality of common port. And the port type of the protection port may also be port or lag. Thus, a super port consists of two members, a working port and a protection port, each member being either port + vlan list or lag + vlan list.
S20, generating a media access control mac address table, wherein the mac address table records a virtual local area network access list corresponding to the super port and a mac address of the super port of the opposite end corresponding to the super port;
in this embodiment, the mac address table of the communication device is learned based on the source mac address of the data frame. The following illustrates the procedure for learning the mac address table by the super-oral part in the communication device:
if a data frame sent by the opposite-end super port is received from the working port or the protection port, the communication device analyzes a SOURCE MAC address (assumed as MAC-SOURCE) of the data frame, and adds the MAC-SOURCE as a MAC address of the opposite-end super port corresponding to the super port into a MAC address table. Of course, in this process, if it is detected that the MAC-SOURCE already exists in the MAC address table, it may not be added.
In addition, the number of the super ports corresponding to the communication device may be one or more, and identifiers, such as super port numbers, may be added to the super ports in the mac address table to distinguish mac addresses and virtual local area network access lists of opposite super ports corresponding to the super ports.
In this process, of course, the communication device may also learn the mac address sent by the common port or the link aggregation group lag, so that when the working port or the protection port receives a data frame carrying such a mac address, the working port or the protection port directly sends the data frame to the connected opposite port.
In a specific implementation process, the step S20 of "generating a mac address table of media access control" may specifically adopt the following steps, and a flowchart of the method is shown in fig. 2:
s201, if it is detected that the working port or the protection port receives a second data frame carrying an active media access control mac address, determining the source mac address as the mac address of the opposite super port corresponding to the super port;
s202, according to the mac address of the opposite super port corresponding to the super port and the virtual local area network access list, a mac address table corresponding to the super port is generated.
S30, under the condition that the super port receives the first data frame carrying the target mac address, judging whether the target mac address exists in the mac address of the super port of the opposite end corresponding to the super port; if yes, go to step S40;
in this embodiment, if the target mac address does not exist in the mac address of the opposite-end super port corresponding to the super port, the communication device executes any operation.
S40, determining an active port from the working port and the protection port, determining a target opposite-end super port corresponding to the target mac address based on the virtual local area network access list, and controlling the active port to forward the first data frame to the target opposite-end super port;
in this embodiment, in the working process of the working link, only the working port forwards the data frame, so that the working port has service data. Otherwise, when detecting the working link failure, the communication device will automatically switch to the protection link, and at this time, only the protection port forwards the data frame, so that the service data exists at the protection port. It can be seen that the communication device can determine the active port by selecting the port where the service data exists.
And in the process that the active port forwards the first data frame to the target opposite-end super port, firstly determining a forwarding mode of the first data frame, if the first data frame is in a unicast mode, directly forwarding the first data frame to the target opposite-end super port, and if the first data frame is in a broadcast mode, forwarding the first data frame to all ports including the target opposite-end super port in a broadcast mode.
In addition, in order to ensure that the peer communication device switches to the port corresponding to the active port in time, in some other embodiments, the method further includes the following steps, and a flowchart of the method is shown in fig. 3:
and S50, when detecting that the active port has a change event, sending the active port identification of the active port to the target opposite-end super port.
The active port identification may be a port number of the active port, etc. may be used to uniquely identify the active port identification.
The above steps S201 to S202 are only one preferred implementation of the "generating the mac address table" process in step S20 disclosed in the embodiment of the present application, and the specific implementation of this process may be arbitrarily set according to its own requirements, and is not limited herein.
The mac address processing method provided by the embodiment of the invention is applied to communication equipment, defines a working port, a protection port and a virtual local area network access list with the same working port and protection port as a super port, and completes forwarding by using the super port and a learned mac address list. Therefore, mac address updating can be skipped in the link switching process, and only the active port needs to be determined, so that the data forwarding time of the communication equipment is greatly shortened.
Based on the mac address processing method provided in the foregoing embodiment, an embodiment of the present invention correspondingly provides an apparatus for executing the mac address processing method, where a schematic structural diagram is shown in fig. 4, and the apparatus includes: a redefinition module 10, a generation module 20, a judgment module 30 and a control module 40;
a redefining module 10, configured to redefine a super port when the virtual local area network access lists of the working port and the protection port are the same, where the super port is composed of the working port, the protection port, and the virtual local area network access list;
a generating module 20, configured to generate a mac address table for media access control, where a virtual local area network access list corresponding to an extra port and a mac address of an opposite-end extra port corresponding to the extra port are recorded in the mac address table;
a determining module 30, configured to determine, when the super port receives the first data frame carrying the target mac address, whether the target mac address exists in a mac address of a super port of an opposite end corresponding to the super port; if yes, triggering the control module 40;
the control module 40 is configured to determine an active port from the working port and the protection port, determine a target opposite-end superport corresponding to the target mac address based on the virtual local area network access list, and control the active port to forward the first data frame to the target opposite-end superport.
In some other embodiments, the generating module 20 is specifically configured to:
if the working port or the protection port is detected to receive a second data frame carrying an active medium access control mac address, determining the source mac address as the mac address of the opposite-end super port of the super port; and generating a mac address table corresponding to the super port according to the mac address of the super port of the opposite end corresponding to the super port and the virtual local area network access list.
In some other embodiments, the determining module 40 is specifically configured to:
selecting a port storing service data from the working port and the protection port; and determining the selected port as an active port.
In some other embodiments, the control module 40 is further configured to:
and under the condition that the change event of the active port is detected, the active port identification of the active port is sent to the target opposite-end super port.
The mac address processing device provided by the embodiment of the invention skips mac address updating in the link switching process, and only needs to determine the active port, thereby greatly reducing the data forwarding time of the switch.
The mac address processing method and apparatus provided by the present invention are described in detail above, and a specific example is applied in the text to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include or include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.