WO2016201843A1 - 一种mac地址学习的控制方法和装置 - Google Patents

一种mac地址学习的控制方法和装置 Download PDF

Info

Publication number
WO2016201843A1
WO2016201843A1 PCT/CN2015/092442 CN2015092442W WO2016201843A1 WO 2016201843 A1 WO2016201843 A1 WO 2016201843A1 CN 2015092442 W CN2015092442 W CN 2015092442W WO 2016201843 A1 WO2016201843 A1 WO 2016201843A1
Authority
WO
WIPO (PCT)
Prior art keywords
mac address
packet
address table
usage
deleted
Prior art date
Application number
PCT/CN2015/092442
Other languages
English (en)
French (fr)
Inventor
许煜芝
吴波
马兴睿
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016201843A1 publication Critical patent/WO2016201843A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing

Definitions

  • This document relates to, but is not limited to, the field of communication technologies, and in particular, to a method and apparatus for controlling MAC address learning.
  • each network device learns the MAC address information of the corresponding message and according to MAC (Media Access Control, media).
  • the access control) address information is forwarded to implement the communication function between multiple devices. Therefore, the MAC address is the basis for communication between each device in the network.
  • MAC address learning is also an indispensable function of each device.
  • the principle of MAC address learning is to learn the source MAC address information of the received packet, and then find the corresponding port according to the destination MAC address information of the received packet, so as to send the packet to the corresponding port.
  • the network device learns a lot of meaningless MAC address information and occupies a limited MAC address resource of the network device. The waste of resources affects the forwarding of normal messages.
  • the network device can limit the number of MAC address learning of the corresponding port. This method can ensure that the MAC address capacity of the network device is not full, but it also affects the MAC address of the normal port of the corresponding port. Learn.
  • the embodiment of the invention provides a method and a device for controlling MAC address learning to solve the technical problem of how to prevent an invalid MAC address from occupying device resources.
  • the embodiment of the invention provides a method for controlling MAC address learning, and the method includes:
  • control method further includes the following features:
  • determining the MAC address usage in the MAC address table of the device according to the destination media access control MAC address of the packet including:
  • the destination MAC address of the packet After receiving the packet, if the destination MAC address of the packet is in the device MAC address table, it is determined that the MAC address corresponding to the destination MAC address in the device MAC address table is used.
  • control method further includes the following features:
  • the MAC address For each scanned MAC address, if the MAC address is already used, the MAC address is reset to be unused, and if the MAC address is not used, when the MAC address satisfies the deletion condition, The entry corresponding to the MAC address is deleted in the MAC address table.
  • control method further includes the following features:
  • the aging process of the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device further includes:
  • control method further includes the following features:
  • the control method further includes:
  • the source MAC address of the packet After receiving the packet, if the source MAC address of the packet is in the yellow list, the source MAC address of the packet is not learned.
  • control method further includes the following features:
  • the control method further includes:
  • the MAC address entries in the yellow list are periodically cleared.
  • control method further includes the following features:
  • the deletion condition includes: the MAC address has never been used within a preset time.
  • control method further includes the following features:
  • the embodiment of the invention provides a device for controlling MAC address learning, including:
  • the address usage record module is configured to determine, after receiving the message, the use of the MAC address in the MAC address table of the device according to the destination media access control MAC address of the packet;
  • the address aging processing module is configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device.
  • control device further includes the following features:
  • the address usage record module is configured to determine the use of the MAC address in the MAC address table of the device according to the destination media access control MAC address of the packet after receiving the message as follows:
  • the destination MAC address of the packet After receiving the packet, if the destination MAC address of the packet is in the device MAC address table, it is determined that the MAC address corresponding to the destination MAC address in the device MAC address table is used.
  • control device further includes the following features:
  • the address aging processing module is configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device in the following manner:
  • the MAC address For each scanned MAC address, if the MAC address is already used, the MAC address is reset to be unused, and if the MAC address is not used, when the MAC address satisfies the deletion condition, The entry corresponding to the MAC address is deleted in the MAC address table.
  • control device further includes the following features:
  • the address aging processing module is further configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the device MAC address table by:
  • the deleted MAC address is added to the yellow list.
  • control device further includes the following features:
  • the control device further includes:
  • the MAC address learning module is configured to: after receiving the message, if the source MAC address of the packet is in the yellow list, the source MAC address of the packet is not learned.
  • control device further includes the following features:
  • the control device further includes:
  • the yellow list recovery module is configured to periodically clear the MAC address entries in the yellow list.
  • control device further includes the following features:
  • the deletion condition includes: the MAC address has never been used within a preset time.
  • control device further includes the following features:
  • the yellow list condition includes: deleting the MAC address multiple times from the device MAC address table and the number of times reaches a threshold within a preset time.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the above method.
  • the method and device for controlling MAC address learning learns the source MAC address of the packet, and determines whether the learned MAC address information is in use according to the destination MAC address of the packet. If the learned MAC address is not in use, the MAC address information is quickly deleted from the device MAC address table. If a MAC address is deleted because it is not used multiple times, the address can be added to the yellow address. In the list, the MAC address is directly filtered out during the learning of the MAC address. This prevents the MAC address of the device from being affected by invalid packets, ensuring the MAC address learning of normal forwarding packets, and ensuring the performance and resources of the device.
  • FIG. 1 is a flowchart of a method for controlling MAC address learning according to an embodiment of the present invention.
  • FIG. 2 is a schematic structural diagram of a device for controlling MAC address learning according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a MAC address learning process in an application example of the present invention.
  • FIG. 4 is a schematic diagram of a MAC address detection process in an application example of the present invention.
  • the essential purpose of the network device to learn the MAC address is to find the destination port of the packet to ensure that the packet can be forwarded correctly. If the learned MAC address does not have a corresponding forwarding packet, it is meaningless to continue learning.
  • the embodiment of the present invention learns the MAC address information according to the source MAC address of the packet, and determines whether the learned address information is used according to the destination MAC of the packet. If the learned MAC address is not in use, the The MAC address information is deleted. If a MAC address is deleted multiple times because it is not used, then the place will be deleted. The address is added to the yellow list. The MAC address is directly filtered during learning. This prevents the MAC address of the device from being affected by invalid packets and ensures the performance and resources of the device.
  • the method of the embodiment of the present invention includes: a MAC address learning process and a MAC address detection process;
  • the identifier is used to record whether the MAC address has forwarded the packet (it can be set to 1 when the packet is forwarded each time).
  • the network device Detecting whether the MAC address learned by the network device forwards the packet, and periodically scans the identifier corresponding to the MAC address, and restores the identifier of the corresponding MAC address after scanning (the identifier may be set to 0);
  • the MAC address information may be deleted;
  • the MAC address can be added to the yellow list.
  • the MAC address learning process does not learn the MAC address for a period of time, thus reducing the impact of such MAC addresses on network devices.
  • the MAC address of the yellowlist has an aging policy. That is, the MAC address in the yellowlist is deleted after a period of time.
  • the network device filters the MAC address in the yellow list to avoid the MAC address capacity of the MAC device.
  • the network device queries the MAC address that has been learned but has not forwarded the packet, and deletes the MAC address in advance to ensure that there are enough resources to learn the required MAC address.
  • the embodiments of the present invention may be used in various scenarios and devices.
  • the mechanism of the embodiment of the present invention may be adopted for the entire device, and the mechanism of the embodiment of the present invention may be adopted for some ports of the device.
  • the devices connected to the user-side interface are limited, and all are home devices. Under normal circumstances, packet attacks do not occur, and the network side may be easily due to the complexity of the upper-layer network. If there are a lot of invalid messages, the content of the embodiment of the present invention can be enabled on the network side port for the home gateway device, thereby avoiding the impact of invalid messages on the home gateway device.
  • the content of the embodiment of the present invention can be used on each port of the device, thereby avoiding invalidation of each port.
  • the device can also dynamically enable the content of the embodiment of the present invention.
  • the original learning address can be used when the number of addresses is sufficient. After the number of addresses reaches a certain number, the content of the embodiment of the present invention is used.
  • the embodiment of the present invention can also determine whether to add invalid MAC addresses to the yellow list according to the records deleted by the invalid MAC address, so that the invalid MAC addresses are not learned during the address learning, thereby further reducing the impact on the device. And there is an aging mechanism for the yellow list to prevent these MAC addresses from being invalid.
  • the embodiment of the present invention does not limit the number of invalid MAC address deletion records and the aging time. These may be configured according to different values of devices in different network environments.
  • an embodiment of the present invention provides a method for controlling MAC address learning, which is applied to a MAC address learning control device, and the method includes:
  • S20 Perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device.
  • the control method may further include the following features:
  • determining, according to the destination media access control MAC address of the packet, the use of the MAC address in the MAC address table of the device including:
  • determining that the MAC address corresponding to the destination MAC address in the device MAC address table is used including:
  • the main idea of the embodiment of the present invention is to determine whether the MAC address is to be deleted or retained according to whether the learned MAC address is forwarded, and does not limit the manner in which the information is obtained, and the query uses the identifier to know whether the MAC address is obtained. Being used is just one way.
  • aging the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device including:
  • the MAC address For each scanned MAC address, if the MAC address is already used, the MAC address is reset to be unused, and if the MAC address is not used, when the MAC address satisfies the deletion condition, Deleting an entry corresponding to the MAC address in the MAC address table;
  • aging the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device further includes:
  • the deleted MAC address is added to the yellow list.
  • the method further includes:
  • the source MAC address of the packet After receiving the packet, if the source MAC address of the packet is in the yellow list, the source MAC address of the packet is not learned;
  • the method further includes:
  • the MAC address entry in the yellow list includes: a MAC address, or a MAC address, and a virtual local area network VLAN identifier;
  • the embodiment of the present invention does not limit whether the learning address is a pure MAC mode or a MAC+VLAN mode, mainly whether the learned address information is used to determine whether to delete In addition to the corresponding address information. If the entry in the MAC address table uses the pure MAC address mode, the entry in the yellow list uses the pure MAC address mode. If the entry in the MAC address table uses the MAC address + VLAN identifier, the entry in the yellow list uses the MAC address. +VLAN identification method.
  • the deleting condition includes:
  • the MAC address has never been used within a preset time
  • the yellow list condition includes:
  • the MAC address is deleted from the device MAC address table multiple times and the number of times reaches a threshold value within a preset time;
  • the device MAC address table is aged according to the usage of the MAC address in the device MAC address table.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the above method.
  • an embodiment of the present invention provides a MAC address learning control apparatus, including:
  • the address usage record module is configured to determine, after receiving the message, the use of the MAC address in the MAC address table of the device according to the destination media access control MAC address of the packet;
  • the address aging processing module is configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the MAC address table of the device.
  • the control device may further include the following features:
  • the address usage record module is configured to: after the received message is implemented, determine the MAC address table of the device according to the destination media access control MAC address of the packet.
  • MAC address usage :
  • the destination MAC address of the packet After receiving the packet, if the destination MAC address of the packet is in the device MAC address table, it is determined that the MAC address corresponding to the destination MAC address in the device MAC address table is used.
  • the address aging processing module is configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the device MAC address table by:
  • the MAC address For each scanned MAC address, if the MAC address is already used, the MAC address is reset to be unused, and if the MAC address is not used, when the MAC address satisfies the deletion condition, The entry corresponding to the MAC address is deleted in the MAC address table.
  • the address aging processing module is configured to perform aging processing on the MAC address in the MAC address table of the device according to the usage of the MAC address in the device MAC address table by:
  • the deleted MAC address is added to the yellow list.
  • control device further includes:
  • the MAC address learning module is configured to: after receiving the message, if the source MAC address of the packet is in the yellow list, the source MAC address of the packet is not learned.
  • control device further includes:
  • the yellow list recovery module is configured to periodically clear the MAC address entries in the yellow list.
  • the deleting condition includes: the MAC address has never been used within a preset time.
  • the yellowlist condition includes: deleting the MAC address multiple times from the device MAC address table and the number of times reaches a threshold within a preset time.
  • the MAC address learning process will be further described in detail below with reference to FIG.
  • S101 Receive a packet, and parse the source MAC address and the destination MAC address of the packet.
  • step S102 determining whether the source MAC address is in the yellow list or in the device MAC address table, if yes, proceeding to step S104, if no, proceeding to step S103;
  • S103 learn the source MAC address, that is, add the MAC address to the device MAC address table.
  • S104 Find a device MAC address table according to the destination MAC address information.
  • step S105 determining whether the destination MAC address is in the device MAC address table, if yes, proceeding to step S106, if not, the MAC address learning process ends;
  • S106 Set the usage identifier of the MAC address in the device MAC address table corresponding to the destination MAC address (for example, set to "1" to indicate that it has been used).
  • the MAC address detection procedure will be further described in detail below with reference to FIG.
  • step S202 determining, for any MAC address that is scanned, whether the usage identifier of the MAC address indicates that it has been used, if yes, proceeding to step S203, if no, proceeding to step S204;
  • step S203 reset the usage identifier of the MAC address to indicate that it is not used, so that the usage status of the MAC address can be correctly determined in the next polling, and then proceeds to step S201 to poll the next MAC address.
  • step S204 Determine whether the MAC address meets the deletion policy. If the process proceeds to step S205, if not, proceed to step S201 to poll the next MAC address.
  • the specific deletion policy may be set by the specific device according to the scenario (such as a time policy, and the MAC address may be deleted if it is not used for a period of time);
  • step S206 Determine whether the deleted MAC address satisfies the yellow list policy. If the yellow list policy is satisfied, go to step S207. If not, go to step S201 to poll the next MAC address.
  • the specific yellow list policy can be set by the device according to a specific scenario, such as a MAC.
  • the address is deleted multiple times within a preset time;
  • step S207 Add the MAC address to the yellow list, and then proceed to step S201 to poll the next MAC address.
  • the MAC address learning process will not learn the MAC address, thereby reducing the impact of the MAC address on the device.
  • the method and device for controlling MAC address learning provided by the foregoing embodiment are to learn the source MAC address of the packet, and determine whether the learned MAC address information is used according to the destination MAC address of the packet, if the learned MAC address is used. If it is not in use, it will quickly delete the MAC address information from the device MAC address table. If a MAC address is deleted because it is not used for many times, you can add the address to the yellow list and learn at the MAC address. The MAC address is directly filtered out, so that the MAC address of the device is protected from invalid packets, and the MAC address learning of the packets is forwarded. This ensures the performance and resources of the device.
  • all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
  • the devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
  • Each device/function module/function unit in the above embodiment is implemented in the form of a software function module. And when sold or used as a stand-alone product, it can be stored on a computer readable storage medium.
  • the above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
  • the foregoing technical solution can prevent the MAC address resource of the device from being affected by the invalid packet, ensure the MAC address learning of the normal forwarding packet, and ensure the performance and resources of the device.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种MAC地址学习的控制方法和装置,其中,该方法包括:接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。上述技术方案能够防止无效MAC地址占用设备资源。

Description

一种MAC地址学习的控制方法和装置 技术领域
本文涉及但不限于通信技术领域,尤其涉及的是一种MAC地址学习的控制方法和装置。
背景技术
随着网络通信的发展,网络已经成为人们日常生活和工作不可缺少的元素,在网络传输的过程中,每个网络设备都会学习对应报文的MAC地址信息,并根据MAC(Media Access Control,媒体访问控制)地址信息对报文进行转发,从而实现多个设备之间的通信功能,所以MAC地址是网络中每个设备进行通信的基础,MAC地址学习也是每个设备必不可少的功能。
MAC地址学习的原理是学习接收报文的源MAC地址信息,然后根据接收报文目的MAC地址信息查找到对应的端口,从而将报文发送到对应的端口。但是由于现实网络中存在大量的杂包(网络设备不关心的广播报文或者其它报文),从而导致网络设备学习到了很多无意义的MAC地址信息,占用了网络设备有限的MAC地址资源,造成了资源的浪费,并且影响到正常报文的转发。
目前网络设备针对这种情况,可以将对应端口的MAC地址学习数量进行限制,这种方式虽然能够保证网络设备总体的MAC地址容量不被占满,但是也影响了对应端口正常报文的MAC地址学习。
目前网络设备针对这种情况的另外一种方式就是在MAC地址学习的时候判断报文的VLAN(Virtual Local Area Network,虚拟局域网)信息,只有端口允许的VLAN才会进行学习,但这种方式仅仅能够解决不在端口允许的VLAN中的报文对于设备的冲击,对于在端口允许的VLAN中的报文对于设备的冲击,无法进行防护。
因此,如何防止无效MAC地址占用设备资源,是需要解决的问题。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
本发明实施例提供了一种MAC地址学习的控制方法和装置,以解决如何能够防止无效MAC地址占用设备资源的技术问题。
本发明实施例提供了一种MAC地址学习的控制方法,该方法包括:
接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
可选地,该控制方法还包括下述特点:
接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况,包括:
接收到报文后,如所述报文的目的MAC地址在所述设备MAC地址表中,则确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用。
可选地,该控制方法还包括下述特点:
根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,包括:
定期扫描所述设备MAC地址表中每个MAC地址的使用情况;
对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目。
可选地,该控制方法还包括下述特点:
根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,还包括:
从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的 MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中。
可选地,该控制方法还包括下述特点:
所述控制方法还包括:
接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址。
可选地,该控制方法还包括下述特点:
所述控制方法还包括:
定期清除所述黄名单中的MAC地址条目。
可选地,该控制方法还包括下述特点:
所述删除条件包括:在预设时间内所述MAC地址从未使用过。
可选地,该控制方法还包括下述特点:
所述黄名单条件包括:在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值。
本发明实施例提供了一种MAC地址学习的控制装置,包括:
地址使用情况记录模块,设置为接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
地址老化处理模块,设置为根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
可选地,该控制装置还包括下述特点:
地址使用情况记录模块,是设置为通过如下方式实现接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况:
接收到报文后,如所述报文的目的MAC地址在所述设备MAC地址表中,则确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用。
可选地,该控制装置还包括下述特点:
地址老化处理模块,是设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
定期扫描设备MAC地址表中每个MAC地址的使用情况;
对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目。
可选地,该控制装置还包括下述特点:
地址老化处理模块,还设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中。
可选地,该控制装置还包括下述特点:
所述控制装置还包括:
MAC地址学习模块,设置为接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址。
可选地,该控制装置还包括下述特点:
所述控制装置还包括:
黄名单恢复模块,设置为定期清除所述黄名单中的MAC地址条目。
可选地,该控制装置还包括下述特点:
所述删除条件包括:在预设时间内所述MAC地址从未使用过。
可选地,该控制装置还包括下述特点:
所述黄名单条件包括:在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值。
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行上述的方法。
与相关技术相比,本发明实施例提供的一种MAC地址学习的控制方法和装置,学习报文的源MAC地址,并根据报文的目的MAC地址来判断学习到的MAC地址信息是否在使用,如果学习到的MAC地址没有在使用,那么就会快速将该MAC地址信息从设备MAC地址表中删除,如果某个MAC地址多次因为未使用而被删除,那么可以将该地址加入到黄名单中,在MAC地址学习时直接过滤掉该MAC地址,从而能够避免设备的MAC地址资源受到无效报文的冲击,保障正常转发报文的MAC地址学习,保证了设备的性能和资源。
在阅读并理解了附图和详细描述后,可以明白其他方面。
附图概述
图1为本发明实施例的一种MAC地址学习的控制方法的流程图。
图2为本发明实施例的一种MAC地址学习的控制装置的结构示意图。
图3为本发明应用示例中MAC地址学习流程的示意图。
图4为本发明应用示例中MAC地址检测流程的示意图。
本发明的实施方式
下文中将结合附图对本发明的实施例进行详细说明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。
网络设备学习MAC地址的本质目的是为了查找到转发报文的目的端口,保证报文能够正确地转发,如果学习到的MAC地址没有对应的转发报文,即使能够持续学习到也是没有意义的。本发明实施例根据报文的源MAC来学习MAC地址信息,并根据报文的目的MAC来判断学习到的地址信息是否在使用,如果学习到的MAC地址没有在使用,那么就会快速将该MAC地址信息删除,如果某个MAC地址多次因为未使用而被删除,那么就会将该地 址加入到黄名单中,在学习时直接过滤该MAC地址,从而避免设备的MAC地址资源受到无效报文的冲击,保证了设备的性能和资源。
本发明实施例的方法包括:MAC地址学习流程和MAC地址检测流程;
(1)MAC地址学习流程:
判断是否需要对报文中的源MAC进行学习,对于不需要学习的报文将直接转发,而对于需要学习的报文将针对源MAC进行学习,并对每个学习到的MAC地址条目增加一个标识用于记录该MAC地址是否转发过报文(可以当每次转发过报文即将标识置1)。
(2)MAC地址检测流程:
检测网络设备学习到的MAC地址是否转发过报文,可以定时扫描MAC地址对应的标识,一旦扫描后就恢复对应MAC地址的标识(可以将标识置0);
如果在一定策略内(可以是一段时间)某个MAC地址对应的标识始终为0,为了防止设备MAC地址表条目被占满,可以删除该MAC地址信息;
如果一个MAC地址多次发生上述删除操作,那么可以将该MAC地址加入黄名单,MAC地址学习流程在一段时间内不会学习该MAC地址,从而减少这类MAC地址对网络设备的影响;
为了保证后续黄名单中MAC地址变为正常的MAC地址,对黄名单中的MAC地址有对应的老化策略,即一段时间之后会删除黄名单中的MAC地址。
本发明实施例通过上述两个流程的配合,在保证网络设备正常进行MAC地址学习的同时,与相关技术相比有以下几个特点和优势:
1)网络设备会针对黄名单中的MAC地址进行过滤,避免这类MAC冲击网络设备的MAC地址容量;
2)网络设备会对学习到但未转发过报文的MAC地址进行查询,并将这类MAC提前删除,保证有足够的资源学习需要的MAC地址;
本发明实施例可以用于多种场景和设备中,可以针对整个设备采用本发明实施例的机制,也可以针对设备某些端口采用本发明实施例的机制。
对于家庭网关设备,由于使用场景比较固定,在用户侧接口接入的设备有限,都是家庭设备,正常情况下不会出现报文的冲击,而对于网络侧可能由于上层网络的复杂性很容易出现很多无效报文,那么针对家庭网关类设备可以在网络侧端口启用本发明实施例的内容,从而避免了无效报文对于家庭网关设备的冲击。
对于交换机等设备,由于使用场景不固定,在每个端口都有可能存在无效报文,那么针对这类设备可以在设备每个端口都使用本发明实施例的内容,从而避免每个端口无效报文对于交换等设备的冲击。
设备也可以动态使能本发明实施例的内容,可以在地址数目比较充足的时候采用原有的学习地址的方式,在地址数量达到一定数量后再采用本发明实施例的内容。
本发明实施例还可以根据无效MAC地址删除的记录,从而决定是否将无效的MAC地址加入到黄名单中,从而在地址学习时就对这些无效MAC地址不学习,从而进一步减少对设备的冲击,并且可以针对黄名单有老化的机制,防止这些MAC地址一直无效。本发明实施例并不限定无效MAC地址删除记录的数量和老化的时间,这些可以根据设备在不同网络环境下配置不同的值。
如图1所示,本发明实施例提供了一种MAC地址学习的控制方法,该方法应用于MAC地址学习的控制装置,该方法包括:
S10,接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
S20,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
所述控制方法还可以包括下述特点:
可选地,接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况,包括:
接收到报文后,如所述报文的目的MAC地址在设备MAC地址表中,则 确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用;
可选地,确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用,包括:
将所述目的MAC地址对应的MAC地址的使用标识设置为表示已使用;
本发明实施例的主要思想是根据学习到的MAC地址是否转发过报文从而来决定其是否要被删除还是保留,并不限定使用何种方式来得到这个信息,查询使用标识来获知MAC地址是否被使用只是其中一种方式。
可选地,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,包括:
定期扫描设备MAC地址表中每个MAC地址的使用情况;
对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目;
可选地,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,还包括:
从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中;
可选地,所述方法还包括:
接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址;
可选地,所述方法还包括:
定期清除所述黄名单中的MAC地址条目;
可选地,所述黄名单中的MAC地址条目,包括:MAC地址、或MAC地址与虚拟局域网VLAN标识;
本发明实施例并不限定学习地址的方式是纯MAC方式,还是使用MAC+VLAN方式,主要是看学习到的地址信息是否在使用来决定是否来删 除对应的地址信息。如果MAC地址表中的条目使用纯MAC地址方式,则黄名单中的条目使用纯MAC地址方式,如果MAC地址表中的条目使用MAC地址+VLAN标识的方式,则黄名单中的条目使用MAC地址+VLAN标识的方式。
可选地,所述删除条件包括:
在预设时间内所述MAC地址从未使用过;
可选地,所述黄名单条件包括:
在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值;
可选地,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,包括:
在设备的MAC地址表中的MAC地址条目达到阈值后,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表进行老化处理。
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行上述的方法。
如图2所示,本发明实施例提供了一种MAC地址学习的控制装置,包括:
地址使用情况记录模块,设置为接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
地址老化处理模块,设置为根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
所述控制装置还可以包括下述特征:
可选地,地址使用情况记录模块,是设置为通过如下方式实现接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中 MAC地址的使用情况:
接收到报文后,如所述报文的目的MAC地址在设备MAC地址表中,则确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用。
可选地,地址老化处理模块,是设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
定期扫描设备MAC地址表中每个MAC地址的使用情况;
对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目。
可选地,地址老化处理模块,是设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中。
可选地,所述控制装置还包括:
MAC地址学习模块,设置为接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址。
可选地,所述控制装置还包括:
黄名单恢复模块,设置为定期清除所述黄名单中的MAC地址条目。
可选地,所述删除条件包括:在预设时间内所述MAC地址从未使用过。
可选地,所述黄名单条件包括:在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值。
应用示例
下面结合附图3对MAC地址学习流程作进一步的详细说明。
S101:接收到报文,解析出报文的源MAC地址和目的MAC地址信息;
S102:判断源MAC地址是否在黄名单中或设备MAC地址表中,是则进入步骤S104,否,则进入步骤S103;
S103:学习该源MAC地址,也即,将该MAC地址添加到设备MAC地址表中;
S104:根据目的MAC地址信息查找设备MAC地址表;
S105:判断目的MAC地址是否在设备MAC地址表中,如果在则进入步骤S106,如果不在,则MAC地址学习流程结束;
S106:将目的MAC地址对应的设备MAC地址表中的MAC地址的使用标识置位(比如,置为“1”用于表示已使用)。
下面结合附图4对MAC地址检测流程作进一步的详细说明。
S201:轮询设备MAC地址表中的MAC地址的使用情况;
S202:对扫描到的任一MAC地址,判断该MAC地址的使用标识是否表示已使用,如果是则进入步骤S203,否,则进入步骤S204;
S203:重新设置所述MAC地址的使用标识为表示未使用,以便下次轮询时能够正确判断该MAC地址的使用状态,然后进入步骤S201,轮询下一个MAC地址;
S204:判断该MAC地址是否满足删除策略,如果满足进入步骤S205,如果不满足,进入步骤S201,轮询下一个MAC地址;
其中,具体删除策略可以由具体设备根据场景来设定(如时间策略,该MAC地址在一段时间内没有使用即可以删除);
S205:在设备MAC地址表中删除该MAC地址对应的条目;
S206:判断所述被删除的MAC地址是否满足黄名单策略,如果满足黄名单策略,则进入步骤S207,如果不满足,进入步骤S201,轮询下一个MAC地址;
其中,具体黄名单策略,可以由设备根据具体场景来设定,如一个MAC 地址在预设时间内发生多次删除等;
S207:将该MAC地址加入到黄名单中,然后进入步骤S201,轮询下一个MAC地址。
其中,一个MAC地址一旦加入黄名单,则MAC地址学习流程中将不会学习该MAC地址,从而减少该MAC地址对设备的冲击。
上述实施例提供的一种MAC地址学习的控制方法和装置,学习报文的源MAC地址,并根据报文的目的MAC地址来判断学习到的MAC地址信息是否在使用,如果学习到的MAC地址没有在使用,那么就会快速将该MAC地址信息从设备MAC地址表中删除,如果某个MAC地址多次因为未使用而被删除,那么可以将该地址加入到黄名单中,在MAC地址学习时直接过滤掉该MAC地址,从而能够避免设备的MAC地址资源受到无效报文的冲击,保障正常转发报文的MAC地址学习,保证了设备的性能和资源。
以上内容是结合具体的实施方式对本发明所作的进一步详细说明,不能认定本发明的具体实施只局限于这些说明。
本领域普通技术人员可以理解上述实施例的全部或部分步骤可以使用计算机程序流程来实现,所述计算机程序可以存储于一计算机可读存储介质中,所述计算机程序在相应的硬件平台上(如系统、设备、装置、器件等)执行,在执行时,包括方法实施例的步骤之一或其组合。
可选地,上述实施例的全部或部分步骤也可以使用集成电路来实现,这些步骤可以被分别制作成一个个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。
上述实施例中的各装置/功能模块/功能单元可以采用通用的计算装置来实现,它们可以集中在单个的计算装置上,也可以分布在多个计算装置所组成的网络上。
上述实施例中的各装置/功能模块/功能单元以软件功能模块的形式实现 并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。上述提到的计算机可读取存储介质可以是只读存储器,磁盘或光盘等。
工业实用性
上述技术方案能够避免设备的MAC地址资源受到无效报文的冲击,保障正常转发报文的MAC地址学习,保证了设备的性能和资源。

Claims (17)

  1. 一种媒体访问控制MAC地址学习的控制方法,该方法包括:
    接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
    根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
  2. 如权利要求1所述的控制方法,其中,接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况,包括:
    接收到报文后,如所述报文的目的MAC地址在所述设备MAC地址表中,则确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用。
  3. 如权利要求2所述的控制方法,其中,根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,包括:
    定期扫描所述设备MAC地址表中每个MAC地址的使用情况;
    对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目。
  4. 如权利要求3所述的控制方法,所述根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理,还包括:
    从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中。
  5. 如权利要求4所述的控制方法,还包括:
    接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址。
  6. 如权利要求5所述的控制方法,还包括:
    定期清除所述黄名单中的MAC地址条目。
  7. 如权利要求3所述的控制方法,其中,所述删除条件包括:
    在预设时间内所述MAC地址从未使用过。
  8. 如权利要求4所述的控制方法,其中,所述黄名单条件包括:
    在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值。
  9. 一种媒体访问控制MAC地址学习的控制装置,包括:
    地址使用情况记录模块,设置为接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况;
    地址老化处理模块,设置为根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理。
  10. 如权利要求9所述的控制装置,其中:
    地址使用情况记录模块,是设置为通过如下方式实现接收到报文后,根据所述报文的目的媒体访问控制MAC地址确定设备MAC地址表中MAC地址的使用情况:
    接收到报文后,如所述报文的目的MAC地址在所述设备MAC地址表中,则确定所述设备MAC地址表中所述目的MAC地址对应的MAC地址已使用。
  11. 如权利要求10所述的控制装置,其中:
    地址老化处理模块,是设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
    定期扫描设备MAC地址表中每个MAC地址的使用情况;
    对每一个扫描到的MAC地址,如所述MAC地址已使用,则重新设置所述MAC地址为未使用,如所述MAC地址未使用过,则在所述MAC地址满足删除条件时,从所述MAC地址表中删除所述MAC地址对应的条目。
  12. 如权利要求11所述的控制装置,
    地址老化处理模块,还设置为通过如下方式实现根据所述设备MAC地址表中MAC地址的使用情况对所述设备MAC地址表中的MAC地址进行老化处理:
    从所述MAC地址表中删除所述MAC地址对应的条目后,如被删除的MAC地址条目满足黄名单条件,则将所述被删除的MAC地址添加到所述黄名单中。
  13. 如权利要求12所述的控制装置,还包括:
    MAC地址学习模块,设置为接收到报文后,如所述报文的源MAC地址在所述黄名单中,则不学习所述报文的源MAC地址。
  14. 如权利要求13所述的控制装置,还包括:
    黄名单恢复模块,设置为定期清除所述黄名单中的MAC地址条目。
  15. 如权利要求11所述的控制装置,其中,所述删除条件包括:
    在预设时间内所述MAC地址从未使用过。
  16. 如权利要求12所述的控制装置,其中,所述黄名单条件包括:
    在预设时间内所述MAC地址多次被从所述设备MAC地址表中删除且次数达到阈值。
  17. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1~8中任一项所述的方法。
PCT/CN2015/092442 2015-06-18 2015-10-21 一种mac地址学习的控制方法和装置 WO2016201843A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510342608.7A CN106330712B (zh) 2015-06-18 2015-06-18 一种mac地址学习的控制方法和装置
CN201510342608.7 2015-06-18

Publications (1)

Publication Number Publication Date
WO2016201843A1 true WO2016201843A1 (zh) 2016-12-22

Family

ID=57544807

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/092442 WO2016201843A1 (zh) 2015-06-18 2015-10-21 一种mac地址学习的控制方法和装置

Country Status (2)

Country Link
CN (1) CN106330712B (zh)
WO (1) WO2016201843A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113542130A (zh) * 2021-07-22 2021-10-22 新华三信息安全技术有限公司 地址表项的处理方法及装置

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108347494B (zh) * 2017-01-25 2022-03-11 中兴通讯股份有限公司 Mac地址老化处理方法、网络处理器芯片及通信设备
CN109451087B (zh) * 2018-10-26 2022-05-31 新华三技术有限公司 Mac表项老化处理方法和装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101958938A (zh) * 2010-06-01 2011-01-26 福建星网锐捷网络有限公司 基于网络处理器的mac地址表的学习方法及装置
US8249065B2 (en) * 2008-03-18 2012-08-21 Cisco Technology, Inc. Destination MAC aging of entries in a Layer 2 (L2) forwarding table
CN103581022A (zh) * 2013-10-23 2014-02-12 福建星网锐捷网络有限公司 Mac地址的查找转发方法和装置
CN104333520A (zh) * 2014-11-28 2015-02-04 上海斐讯数据通信技术有限公司 一种交换机mac地址表双老化时间控制方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100435528C (zh) * 2005-08-29 2008-11-19 杭州华三通信技术有限公司 减少网络内媒体接入控制地址学习的方法
CN101043433B (zh) * 2006-06-24 2011-03-30 华为技术有限公司 一种桥模式弹性分组环mac地址学习表的老化方法
CN101488899B (zh) * 2008-01-17 2011-11-23 中兴通讯股份有限公司 用于1:1vlan接入网的mac地址学习限制方法和装置
CN102035721B (zh) * 2009-09-30 2012-09-26 中兴通讯股份有限公司 介质访问控制表项老化处理的方法及装置
CN103428091A (zh) * 2012-05-15 2013-12-04 中兴通讯股份有限公司 Mac地址学习的控制方法及转发设备
CN103595638B (zh) * 2013-11-04 2016-09-28 北京星网锐捷网络技术有限公司 一种mac地址学习方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8249065B2 (en) * 2008-03-18 2012-08-21 Cisco Technology, Inc. Destination MAC aging of entries in a Layer 2 (L2) forwarding table
CN101958938A (zh) * 2010-06-01 2011-01-26 福建星网锐捷网络有限公司 基于网络处理器的mac地址表的学习方法及装置
CN103581022A (zh) * 2013-10-23 2014-02-12 福建星网锐捷网络有限公司 Mac地址的查找转发方法和装置
CN104333520A (zh) * 2014-11-28 2015-02-04 上海斐讯数据通信技术有限公司 一种交换机mac地址表双老化时间控制方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113542130A (zh) * 2021-07-22 2021-10-22 新华三信息安全技术有限公司 地址表项的处理方法及装置

Also Published As

Publication number Publication date
CN106330712B (zh) 2019-05-24
CN106330712A (zh) 2017-01-11

Similar Documents

Publication Publication Date Title
US7684339B2 (en) Communication control system
EP1779605B1 (en) Forwarding database in a network switch device
CN107547243B (zh) 一种报文转发方法及装置
WO2015188579A1 (zh) 分布式虚拟防火墙装置、方法及防火墙控制器
JP2006270839A (ja) レイヤ2機器の設定制御装置
JP2007006054A (ja) パケット中継装置及びパケット中継システム
CN106789865B (zh) 一种基于gre网络结合sdn技术和蜜罐技术的网络安全防护方法
US7707312B2 (en) Printer discovery protocol system and method
US9325613B2 (en) Communication device and address learning method
JP5134141B2 (ja) 不正アクセス遮断制御方法
WO2014114196A1 (en) Keeping a terminal access location record alive
WO2016201843A1 (zh) 一种mac地址学习的控制方法和装置
WO2015079284A1 (en) Methods and systems for processing internet protocol packets
EP2218214B1 (en) Network location service
CN102202004B (zh) 路由错误处理方法、装置和路由设备
RU2602333C2 (ru) Сетевая система, способ обработки пакетов и носитель записи
JP6086020B2 (ja) 通信装置、アドレス学習方法及びアドレス学習プログラム
WO2016138845A1 (zh) 一种实现协议报文上送cpu的方法和装置
JP2010239591A (ja) ネットワークシステム、中継装置、およびネットワーク制御方法
JP2003152806A (ja) 通信路のスイッチ接続制御システム
JP7156310B2 (ja) 通信装置、通信システム、通信制御方法、プログラム
CN107517111A (zh) 一种动态虚拟局域网管理方法及其装置、网络设备
CN105591920B (zh) 基于irdp的ra报文处理方法及装置
TW201436509A (zh) 網路交換器與資料更新方法
WO2017156979A1 (zh) 一种媒体接入控制mac地址处理方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15895412

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15895412

Country of ref document: EP

Kind code of ref document: A1