WO2012162964A1 - Method and device for learning media access control address - Google Patents

Method and device for learning media access control address Download PDF

Info

Publication number
WO2012162964A1
WO2012162964A1 PCT/CN2011/078923 CN2011078923W WO2012162964A1 WO 2012162964 A1 WO2012162964 A1 WO 2012162964A1 CN 2011078923 W CN2011078923 W CN 2011078923W WO 2012162964 A1 WO2012162964 A1 WO 2012162964A1
Authority
WO
WIPO (PCT)
Prior art keywords
mac address
priority
entry
service
storage space
Prior art date
Application number
PCT/CN2011/078923
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Priority to CN2011800016466A priority Critical patent/CN102356607A/en
Priority to PCT/CN2011/078923 priority patent/WO2012162964A1/en
Publication of WO2012162964A1 publication Critical patent/WO2012162964A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4604LAN interconnection over a backbone network, e.g. Internet, Frame Relay
    • H04L12/462LAN interconnection over a bridge based backbone
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4604LAN interconnection over a backbone network, e.g. Internet, Frame Relay
    • H04L12/462LAN interconnection over a bridge based backbone
    • H04L12/4625Single bridge functionality, e.g. connection of two networks over a single bridge

Definitions

  • the present invention relates to the field of data communications, and more particularly to a method and apparatus for learning media access control addresses.
  • the Ethernet switching device forwards according to the MAC address at the MAC (Media Acces s Cont rol) layer.
  • the packet 1 enters the device 3 through the ingress port, and the device 3 first checks the validity of the packet. If it is legal, the source MAC address is learned (writing the MAC address table). Then, look up the MAC entry corresponding to the destination MAC address, find the MAC address table, read the port corresponding to the MAC address table, and forward the message from the port. This completes a message forwarding.
  • the MAC address table resource is limited. If the MAC address table is full, if the MAC address is not aged or deleted, the new MAC address (with the new MAC address) cannot learn the new MAC address. If the MAC address entry is not found in the packet, the broadcast will be caused. The device will generally suppress the traffic caused by the unknown unicast. Therefore, the quality of the service without learning the MAC address cannot be guaranteed.
  • the embodiment of the present invention can solve the problem that the new MAC address cannot be learned when the MAC address table resource is exhausted, thereby affecting the service quality.
  • an embodiment of the present invention provides a method for learning a MAC address, including: receiving a message containing a source MAC address;
  • an embodiment of the present invention provides an apparatus for learning a MAC address, including: a message receiving unit, configured to receive a message including a source MAC address;
  • a priority determining unit configured to determine a MAC address priority P of the source MAC address according to information included in the packet or information of a service to which the packet belongs;
  • An idle judging unit configured to determine whether there is free storage space in the MAC address table
  • a preemption unit if there is no free storage space in the MAC address table, used to determine, according to the P and the MAC address priority of each entry in the MAC address table, an entry in the MAC address table is occupied.
  • the storage space, the MAC address priority of the one entry is not equal to the P; the storage unit is configured to store an entry including the source MAC address by using a storage space occupied by the one entry.
  • a new MAC address can be learned by using the already occupied storage space when the storage resource of the MAC address table is exhausted, thereby improving the service quality of the service.
  • Figure 1 is a schematic diagram of packet forwarding
  • FIG. 2 is a schematic flowchart of a method for learning a MAC address according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of data of a MAC address entry according to an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a strict priority learning policy according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a proportional priority learning policy according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of an apparatus for learning a MAC address according to an embodiment of the present invention.
  • IP telephony VO IP, Vo i ce on IP
  • BTV Broadband TV
  • HI S high-speed Internet service
  • H i gh Speed Interne t The priority can be from high to low.
  • An embodiment of the present invention provides a method for learning a MAC address, as shown in FIG. 2, including: Step 201: Receive a message containing a source MAC address;
  • Step 203 If there is no free storage space in the MAC address table, determine one of the MAC address tables according to the MAC address priority P of the source MAC address and the MAC address priority of each entry in the MAC address table.
  • the storage space occupied by the entry, the MAC address priority of the one entry is not equal to the P, and the P is determined according to the information contained in the packet or the information of the service to which the packet belongs;
  • Step 205 Store, by using the storage space occupied by the one entry, an entry that includes the source MAC address.
  • the MAC address priority of this entry is the P.
  • the system stores the MAC address priority data of each entry in the MAC address table, and the MAC address priority of the entry is also the MAC address of the entry.
  • MAC address priority For example, as shown in Figure 3, the MAC address priority data can be directly stored in the MAC address entry of the MAC address table. Of course, the MAC address priority data may not be stored in the MAC address table.
  • the priority of the service is different.
  • the value of the priority is also different. It can be based on the information contained in the received message or
  • the information of the service to which the message belongs is determined by the MAC address priority of the source MAC address.
  • the MAC address priority of the source MAC address can be determined in the following ways:
  • the priority of the packet included in the packet is obtained, and the MAC address priority P of the source MAC address is determined according to the packet priority and the mapping from the packet priority to the MAC address priority.
  • the received packet priority field can be the priority field of 802. lp, the priority field of the IP header, and the multi-protocol label switching (MPLS, Mul t i-Pro toco l Labe l Swi t ching ) Priority field of the message, custom priority field, etc.
  • MPLS multi-protocol label switching
  • the mapping from the priority of the message to the priority of the MAC address can be directly used.
  • the priority of 802. lp is stored as a MAC address priority for service processing.
  • the mapping from the packet priority to the MAC address priority may be stored and processed as the MAC address priority with the highest 3 b i t of the priority field.
  • the service identification information such as the VLAN ID, the port number, the encapsulation type, etc.
  • the service to which the message belongs is determined according to the service identification information, thereby obtaining the service of the service.
  • a service flow can be used to represent a service, and a service flow can be identified by using a user VLAN, a user's encapsulation type (such as PPPoE type), one or more ports, a PVC, etc., and this service flow is usually Both have business priority attributes.
  • the service packet is matched with the service flow, the service belongs to the service according to the priority of the service flow.
  • the service has the service priority, and the source MAC address is determined according to the mapping from the service priority to the MAC address. MAC address priority.
  • the MAC address priority P of the source MAC address is equal to the MAC address priority corresponding to the service in the configuration data.
  • the specific service to which the packet belongs is determined according to the service identification information, and the configuration data includes the MAC address priority of the source MAC address included in the specific service.
  • the MAC address priority has four levels from 0 to 3, and a service is configured, the service is based on port 0/1/0, and the MAC address priority of the service is set to 3, for the service belonging to the service. All 4 messages, that is, all packets entering from the port, the MAC address priority of the source MAC address contained in these messages is 3.
  • the MAC address priority has 4 levels from 0 to 3, and the traffic priority is prioritized. Level, that is, the service priority has 8 levels from 0 to 7.
  • the MAC address priority is not configured, and the other is port 0/2/0 vpiO vci 36.
  • the MAC address priority of the service flow is 2. After the device enters port 0/2/0, it first determines the service flow to which the message belongs.
  • the priority of the service flow needs to be mapped because the MAC address priority is not configured.
  • 4 bar traffic priority 0 to 1 can be mapped to 0 of the MAC address priority, 2 to 3 are mapped to 1, and so on.
  • other methods can also be used for mapping, such as mapping 6 to 7 to 0, 4 to 5 to 1, and so on.
  • mapping 6 to 7 to 0, 4 to 5 to 1, and so on If the MAC address priority of the vpi 0 vci 35 is mapped to 3, the MAC address priority of the source MAC address included in all the entries from the vpi 0 vci 35 of the port is 3.
  • the MAC address priority of the message is set to 2.
  • the MAC address priority has 4 levels from 0 to 3, and the service flow priority, that is, the service priority has 8 levels from 0 to 7, and two service flows are configured: one is port 0. /3/0 vlan50, the traffic priority is 5, the MAC address priority is not configured, and the other is port 0/3/0 vlan 60, and the MAC address priority of the service flow is set to 1.
  • the priority 1 of the service is mapped to the MAC address priority
  • the service flow priority 5 of the packet with the vlan of 50 on the port is mapped to the MAC address priority
  • the MAC address priority is determined in a hybrid manner, and the MAC address priority mapping may be determined in part according to the packet self-giving priority field (the first mode above), and the MAC address priority is based on the MAC address priority.
  • the mapping relationship of the address priority determines the MAC address priority (the second mode above), and the partial configuration determines the MAC address priority corresponding to the service (the third mode above). For example, the service to which the packet belongs is determined, and the MAC address priority of the service configuration is checked. If the MAC precedence is configured, no mapping is required, and the MAC address priority is directly processed. If the MAC precedence is not configured, but the configuration is configured. If the service priority is configured, the service priority is mapped to the MAC address priority.
  • the priority field of the packet can be mapped to the MAC address priority.
  • the priority of the processing may be from high to low: the configured MAC priority, the service priority mapping to the MAC address priority, and the packet priority field mapping to the MAC address priority. With this processing sequence, the MAC address priority can be reflected as much as possible in the priority order of the service, thereby providing better differentiated services for different services.
  • the priority occupied learning policy may be used to preempt the space occupied by an address entry from the used storage space to store the address entry containing the source MAC address, so as to avoid The MAC address table resource cannot be used to learn a new MAC address, thereby improving the service quality of the service.
  • the storage space occupied by one entry in the MAC address table is specifically a storage space occupied by an entry in the MAC address table with a priority of the MAC address, wherein the Pi
  • the MAC address priority is lower than the MAC address priority of the P.
  • the one address entry may be the entry with the lowest priority of the MAC address in the entry with the lower priority of the MAC address.
  • a threshold can be configured for each MAC address priority. For example, a threshold is configured for each MAC address priority in descending order, and the high priority configuration threshold is not less than the low priority threshold.
  • the MAC address table resource is 1000. If 2 bi ts are used to represent 4 MAC address priorities, the weighting of the 4 priority thresholds may be 40%, 30%, 20%, 10%. , that is, the thresholds of four priorities are 400, 300, 200, 100. If 3 priorities are used to represent 8 priority levels, the threshold can be configured to 30%, 20%, 10%, 10%, 8%, 8%, 7%, 7%.
  • the idle entry can be used directly, regardless of whether the number of MAC address entries of a certain MAC address priority is less than the threshold corresponding to the priority. Do not consider the configured threshold. For example, if there are 1000 MAC address entries, the lowest priority configuration with a priority of 0 has a threshold of 100. After the 0 priority has occupied 100 entries, if there are still idle entries, you can continue to learn the priority. A MAC address of 0. When there are no free entries, you can consider the thresholds for different MAC address priorities.
  • the storage space occupied by an entry with the MAC address priority of the MAC address table in the MAC address table may be determined to be preempted. For example, if there are a total of 4 MAC address priorities with a priority of 0 to 3, the MAC address priority is 0 and 1 when there is no free storage space and the source MAC address with the MAC address priority of 3 needs to be preempted. If the entries exceed the thresholds assigned to the 0 and 1 priorities, you can determine an entry from the two entries to preempt.
  • the one entry may be an entry whose MAC address priority is the lowest priority of the MAC address in the entry that satisfies the condition that the priority of the MAC address is lower than P and the number of entries of the priority is greater than the threshold. .
  • an entry with priority 0 is determined among the 0 and 1 priority entries to be preempted. Because the resources occupied by the low-priority MAC address can be preempted, the high-priority service can be provided with a higher processing priority than the low-priority service. For the preferred solution, the service with lower priority can be preempted as much as possible, so as to achieve better differentiated services. The above situation determines that an MAC address has a lower priority than an entry of the P.
  • the priority of Q is higher than P, and the number of Q is greater than the threshold, and the number of Ps in the MAC address table is less than the threshold, it may be determined that an entry in the MAC address table with a MAC address priority of Q is occupied.
  • Storage space for preemption For example, when there are 8 priority priorities of 0 to 7 in which the priority of the MAC address is increased, when the source MAC address whose MAC address priority is Q needs to occupy the MAC address table resource learning MAC address, the MAC address in the MAC address table The number of entries with the priority of Q has not reached the allocated threshold, but the remaining MAC address table resources have been exhausted by the entries with the MAC address priority of 6 and 7, and the MAC addresses have priority of 6 and 7.
  • the one entry may be the entry with the lowest MAC address priority among all the entries satisfying the condition.
  • the low-priority MAC address can reclaim the allocated quota, ensuring that the low-priority service will not be starved.
  • the service with lower priority can be preempted as much as possible, so as to achieve better differentiated services.
  • a specific case of determining the storage space occupied by an entry in the MAC address table is as follows: determining a storage space occupied by an entry whose MAC address priority is Q in the MAC address table.
  • the MAC address priority of the Q is greater than the MAC address priority of the P, and the MAC address priority in the MAC address table is that the number of entries of the P is less than the threshold configured for the P.
  • the number of entries with the MAC address priority being the Q is greater than the threshold configured for the P 2 .
  • the storage space of the entry with the MAC address priority of Q cannot be preempted; If the priority of the entry is higher than P, and the number of Qs is less than or equal to the threshold, the storage space of the entry with the MAC address priority of Q cannot be preempted.
  • the low priority is If the number of the primary entries is less than or equal to the assigned threshold, there is no resource that can be preempted, and the source MAC address is not learned. If the number of the priority MAC entries is less than the assigned threshold. The total number of other priority entries exceeds the threshold configured for the priority. Therefore, the MAC entries of the other priorities can be preempted. An entry is preempted.
  • MAC address table resources of the device are limited, in order to ensure the priority of some services, MAC address table resources can be separately allocated to various services. For example, the service flow (a port may have multiple service flows), the port, and the number of MAC address resources of the vlan may be separately restricted. At this time, the foregoing method for learning the MAC address may be applied based on the separately allocated MAC address table resources. A finer-grained priority-based MAC address learning can be achieved. For example, if 10 MAC address table resources are allocated for a service flow, the MAC address priority learning policy can be configured on the service flow, and the packet priority of the packet can be mapped to the MAC address priority. Strict priority is used.
  • the MAC address priority corresponding to the MAC entry needs to be saved.
  • the storage field of the priority can be added to the MAC entry.
  • the MAC address priority data of the entry in the MAC address table can be used to determine whether there is a preempted entry in the MAC address table.
  • the MAC address priority is recorded in the entry.
  • Figure 4 shows a specific embodiment employing a strict priority learning strategy.
  • the MAC address priority ranges from 1 to n, and n priority priorities are sequentially increased, and n is an integer greater than 1.
  • the learning counter of the corresponding priority is incremented by one.
  • the counter corresponding to the corresponding priority is decremented by one. Through the counter, it can be more directly judged whether there is an entry resource that can be preempted.
  • This embodiment includes the following steps: Step 401: Receive a packet including a source MAC address.
  • Step 403 Determine that the MAC address priority of the message is m, m is less than or equal to n, and is greater than or equal to 1.
  • the MAC address priority of the message can be determined by the method described above.
  • Step 405 Determine whether the sum of the respective counters is smaller than the total number of resources of the MAC address table. If the sum of the counters is equal to the total number of resources in the MAC address table, that is, there is no free entry in the MAC address table, go to 407. If it is less than, there is still idle. Entry, go to 417.
  • Step 407 Determine that the counter to be checked this time is the counter i.
  • Counter 1 is the first counter to be checked, and the next one to check is the i + 1 counter.
  • Step 409 Determine whether i is equal to m, if yes, go to 415, if not, go to 411;
  • Step 411 Determine if the value of counter i is not equal to 0, if yes, execute 413, if not, execute 407. By determining whether the value of the counter i is not equal to 0, it is determined whether there is an entry that can be preempted in the MAC address table.
  • Step 413 Use the storage space of the entry with the MAC address priority i in the MAC address table to generate an entry containing the source MAC address, set the priority of the entry to m, the counter m plus 1, and the counter i to decrease by 1.
  • Step 415 The low-priority entry that cannot be preempted does not learn the source MAC address.
  • Step 417 Generate an entry containing the source MAC address by using a storage space of a free entry of the MAC address table, and set the The MAC address priority of the entry is m, and the counter m is incremented by 1.
  • Figure 5 shows a specific embodiment of a proportional priority learning strategy.
  • the MAC address priority ranges from 1 to n, and n priority priorities are sequentially increased, and n is an integer greater than 1.
  • the priority threshold is set for each MAC address priority, and the threshold of the MAC address with priority k is Q K . This embodiment includes the following steps:
  • Step 501 Receive a packet containing a source MAC address.
  • Step 503 Determine that the MAC address priority of the message is m, m is less than or equal to n, and is greater than or equal to 1.
  • the MAC address priority of the message can be determined by the method described above.
  • Step 505 Determine whether the sum of the respective counters is smaller than the total number of resources of the MAC address table. If the sum of the respective counters is not less than the total number of resources of the MAC address table, that is, there is no idle entry in the MAC address table, go to 507, if it is less, then there is For free entries, go to 525.
  • Step 507 Determine whether the value of the counter m is less than Q m . If it is greater than or equal to 0, try to preempt a low priority entry. If it is less than, go to 519 and retrieve an entry.
  • Step 509 It is determined that the counter to be checked this time is the counter i, the counter 1 is the first counter to be checked, and the next one to be checked is the i+1 counter. Check in order of priority from small to large to find the lowest priority entry that can be preempted.
  • Step 511 Determine whether i is equal to m, if yes, go to 517, if not, go to 513;
  • Step 513 Determine whether the value of counter i is greater than Q m , if yes, execute 515, if no, go to 509;
  • Step 515 Generate an entry containing the source MAC address in the storage space of the entry with the MAC address priority i in the MAC address table, set the MAC address priority of the entry to m, increment the counter m by 1, and reduce the counter i. 1 ;
  • Step 517 There is no low priority entry that can be preempted, and the source MAC address is not learned.
  • Step 519 It is determined that the counter to be checked this time is the counter i, and the counter 1 is the first checked counter, and the next one is to be checked. For the i + 1 counter. Check in order of priority from small to large to find the lowest priority entry that can be preempted.
  • Step 521 Determine whether the value of the counter i is greater than, if yes, the number of entries of the priority i in the MAC address table exceeds the threshold of the priority i, and continue to perform 523 to grab an entry resource; if not, Indicates that the threshold has not been exceeded, go to 519 and continue to check the next counter.
  • Step 523 Generate an entry containing the source MAC address in the storage space of the entry with the MAC address priority i in the MAC address table, set the MAC address priority of the entry to m, increment the counter m by 1, and reduce the counter i. 1 ;
  • Step 525 Generate an entry including the source MAC address by using a storage space of a free entry of the MAC address table, and set a MAC address priority of the entry to be m, and increment the counter m by 1.
  • An embodiment of the present invention provides a device for learning a MAC address, as shown in FIG. 600: The message receiving unit 601 receives a message including a source MAC address.
  • the priority determining unit 603 determines the MAC address priority P of the source MAC address according to the information contained in the message or the information of the service to which the message belongs;
  • the idle determination unit 605 determines whether there is a free storage space in the MAC address table 607. If there is no free entry in the MAC address table 607, the preemption unit 609 according to the P and the MAC address priority of each entry in the MAC address table, Determining a storage space occupied by an entry in the MAC address table 607, where the MAC address priority of the one entry is not equal to the P;
  • the storage unit 611 uses the storage space occupied by an entry determined by the preemption unit 609 to store an entry containing the source MAC address.
  • the non-preemption unit 613 uses the free storage space to store an entry including the source MAC address, and the MAC address priority of the entry including the source MAC address. For the P.
  • the preemption unit 609 determines the storage space occupied by an entry in the MAC address table, which may be specifically: determining a storage space occupied by an entry in the entry of the MAC address priority table in the MAC address table, where The MAC address priority of the Pi is lower than the MAC address priority of the P. Further, the MAC address priority in the MAC address table is that the number of the entries is greater than a threshold configured for the Pi.
  • Preemption unit 609 determines the storage space occupied by an entry in the MAC address table may specifically be: determining the MAC address in the MAC address table memory space a priority entry occupies two entries in P, wherein MAC address of the P 2 priority higher than the priority P of the MAC address, the MAC address in the MAC address table priority less than the threshold value P is configured for the number of entries of the P, and The number of entries with the MAC address priority being the P 2 is greater than the threshold configured for the P 2 .
  • Each of the above units can be implemented by using a general-purpose processor and a memory in conjunction with a software program, and the MAC address table can be a piece of memory.
  • the above units can also be implemented by hardware such as programmable logic or AS IC chip.
  • the MAC address table can be implemented by programmable logic, or hardware such as ASIC chip. Now.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

A method and a device for learning a media access control (MAC) address. The method comprises: receiving a packet comprising a source MAC address; if a MAC address table does not have any vacant storage space, determining, according to the MAC address priority P of the source MAC address and the MAC address priority of each entry in the MAC address table, a storage space occupied by an entry in the MAC address table, the MAC address priority of the entry being not equal to P, and P being determined according to information comprised in the packet or information of the service of the packet; using the storage space occupied by the entry to store the entry comprising the source MAC address. Through the embodiments of the present invention, when storage resources of a MAC address table are used up, an occupied storage space may be used for learning a new MAC address, thereby improving the quality of service of services.

Description

学习媒 ^入控制地址的方法和装置  Method and device for learning medium control address
技术领域 Technical field
本发明涉及数据通讯领域, 具体地说, 涉及学习媒体接入控制地址的方 法和装置。  The present invention relates to the field of data communications, and more particularly to a method and apparatus for learning media access control addresses.
背景技术 Background technique
以太网交换设备在媒体接入控制 (MAC , Media Acces s Cont rol )层根据 MAC地址进行转发。  The Ethernet switching device forwards according to the MAC address at the MAC (Media Acces s Cont rol) layer.
如图 1所示的 MAC地址学习过程, 报文 1从设备 1通过入端口, 进入设 备 3 ,设备 3首先进行报文合法性检查,如果合法,则进行源 MAC地址学习(写 入 MAC地址表 ), 然后查找目的 MAC地址对应的 MAC表项, 找到 MAC地址表, 读出该 MAC地址表对应的端口, 艮文从该端口转发出去。 这样就完成了一次 报文转发。  As shown in Figure 1 of the MAC address learning process, the packet 1 enters the device 3 through the ingress port, and the device 3 first checks the validity of the packet. If it is legal, the source MAC address is learned (writing the MAC address table). Then, look up the MAC entry corresponding to the destination MAC address, find the MAC address table, read the port corresponding to the MAC address table, and forward the message from the port. This completes a message forwarding.
然而, MAC地址表资源是有限的, 如果 MAC地址表学习满后, 在没有老化 或者删除 MAC地址的情况下, 新来的 ^艮文(带有新 MAC地址)就不能学习新 MAC地址, 回来的报文找不到 MAC表项, 就会造成广播, 设备一般都会对未知 单播造成的广播进行流量抑制, 从而不能保证没有学习到 MAC地址的业务的 质量。  However, the MAC address table resource is limited. If the MAC address table is full, if the MAC address is not aged or deleted, the new MAC address (with the new MAC address) cannot learn the new MAC address. If the MAC address entry is not found in the packet, the broadcast will be caused. The device will generally suppress the traffic caused by the unknown unicast. Therefore, the quality of the service without learning the MAC address cannot be guaranteed.
发明内容 Summary of the invention
本发明的实施例可以解决在 MAC地址表资源耗尽的情况下不能学习新 MAC 地址, 从而影响业务质量的问题。  The embodiment of the present invention can solve the problem that the new MAC address cannot be learned when the MAC address table resource is exhausted, thereby affecting the service quality.
一方面, 本发明的实施例提供了一种学习 MAC地址的方法, 包括: 接收包含源 MAC地址的 ^艮文;  In one aspect, an embodiment of the present invention provides a method for learning a MAC address, including: receiving a message containing a source MAC address;
如果 MAC地址表中没有空闲存储空间, 根据所述源 MAC地址的 MAC地址 优先级 P以及所述 MAC地址表中各个表项的 MAC地址优先级, 确定所述 MAC 地址表中的一个表项占用的存储空间, 所述一个表项的 MAC地址优先级不等 于所述 P,所述 P系根据所述报文包含的信息或所述报文所属的业务的信息确 定; 使用所述一个表项占用的存储空间存储包含所述源 MAC地址的表项。 另一方面, 本发明的实施例提供了一种学习 MAC地址的装置, 包括: 报文接收单元, 用于接收包含源 MAC地址的报文; If there is no free storage space in the MAC address table, determine an entry in the MAC address table according to the MAC address priority P of the source MAC address and the MAC address priority of each entry in the MAC address table. The storage space, the MAC address priority of the one entry is not equal to the P, and the P is determined according to the information contained in the packet or the information of the service to which the packet belongs; The storage space occupied by the one entry is used to store an entry that includes the source MAC address. On the other hand, an embodiment of the present invention provides an apparatus for learning a MAC address, including: a message receiving unit, configured to receive a message including a source MAC address;
优先级确定单元, 用于根据所述报文包含的信息或所述报文所属的业务 的信息确定所述源 MAC地址的 MAC地址优先级 P;  a priority determining unit, configured to determine a MAC address priority P of the source MAC address according to information included in the packet or information of a service to which the packet belongs;
空闲判断单元, 用于判断 MAC地址表中是否有空闲存储空间;  An idle judging unit, configured to determine whether there is free storage space in the MAC address table;
抢占单元, 如果所述 MAC 地址表中没有空闲存储空间, 用于根据所述 P 以及所述 MAC地址表中各个表项的 MAC地址优先级, 确定所述 MAC地址表中 的一个表项占用的存储空间, 所述一个表项的 MAC地址优先级不等于所述 P; 保存单元, 用于使用所述一个表项占用的存储空间存储包含所述源 MAC 地址的表项。  a preemption unit, if there is no free storage space in the MAC address table, used to determine, according to the P and the MAC address priority of each entry in the MAC address table, an entry in the MAC address table is occupied. The storage space, the MAC address priority of the one entry is not equal to the P; the storage unit is configured to store an entry including the source MAC address by using a storage space occupied by the one entry.
通过实施本发明的实施例, 可以在 MAC地址表存储资源用完的情况下, 使用已经被占用的存储空间学习新的 MAC地址, 从而提升业务的服务质量。 附图说明  By implementing the embodiment of the present invention, a new MAC address can be learned by using the already occupied storage space when the storage resource of the MAC address table is exhausted, thereby improving the service quality of the service. DRAWINGS
为了更清楚地说明本发明实施例的技术方案, 下面将对实施例描述中所 需要使用的附图作一筒单地介绍, 显而易见地, 下面描述中的附图仅仅是本 发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。  In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings may be obtained based on these drawings without any creative work.
图 1为报文转发示意图;  Figure 1 is a schematic diagram of packet forwarding;
图 2为本发明实施例的学习 MAC地址的方法流程示意图;  2 is a schematic flowchart of a method for learning a MAC address according to an embodiment of the present invention;
图 3为本发明实施例的 MAC地址表项数据示意图;  3 is a schematic diagram of data of a MAC address entry according to an embodiment of the present invention;
图 4为本发明实施例的严格优先级学习策略的流程示意图;  4 is a schematic flowchart of a strict priority learning policy according to an embodiment of the present invention;
图 5为本发明实施例的比例优先级学习策略的流程示意图;  FIG. 5 is a schematic flowchart of a proportional priority learning policy according to an embodiment of the present invention; FIG.
图 6为本发明实施例的学习 MAC地址的装置示意图。  FIG. 6 is a schematic diagram of an apparatus for learning a MAC address according to an embodiment of the present invention.
具体实施方式 detailed description
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而 不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做 出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。 The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying 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 embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without departing from the inventive scope are the scope of the present invention.
各种业务可以有不同的业务优先级, 比如 IP电话 ( VO IP , Vo i ce on IP )、 宽带电视(BTV , Broadband TV )、高速因特网服务( HI S , H i gh Speed Interne t ) 等业务的优先级可以是从高到低的顺序。  Various services can have different business priorities, such as IP telephony (VO IP, Vo i ce on IP), broadband TV (BTV, Broadband TV), high-speed Internet service (HI S, H i gh Speed Interne t ) The priority can be from high to low.
本发明的实施例提供了一种学习 MAC地址的方法, 如图 2所示, 包括: 步骤 201 : 接收包含源 MAC地址的 ^艮文;  An embodiment of the present invention provides a method for learning a MAC address, as shown in FIG. 2, including: Step 201: Receive a message containing a source MAC address;
步骤 203: 如果 MAC地址表中没有空闲存储空间,根据所述源 MAC地址的 MAC地址优先级 P以及所述 MAC地址表中各个表项的 MAC地址优先级,确定所 述 MAC地址表中的一个表项占用的存储空间, 所述一个表项的 MAC地址优先 级不等于所述 P ,所述 P系根据所述报文包含的信息或所述报文所属的业务的 信息确定;  Step 203: If there is no free storage space in the MAC address table, determine one of the MAC address tables according to the MAC address priority P of the source MAC address and the MAC address priority of each entry in the MAC address table. The storage space occupied by the entry, the MAC address priority of the one entry is not equal to the P, and the P is determined according to the information contained in the packet or the information of the service to which the packet belongs;
步骤 205 :使用所述一个表项占用的存储空间存储包含所述源 MAC地址的 表项。 该表项的 MAC地址优先级为所述 P。  Step 205: Store, by using the storage space occupied by the one entry, an entry that includes the source MAC address. The MAC address priority of this entry is the P.
为了根据 MAC地址优先级信息实施优先级学习策略, 系统中保存有 MAC 地址表中的每个表项的 MAC地址优先级数据, 该表项的 MAC地址优先级也就 是该表项的 MAC地址的 MAC地址优先级。 例如, 如图 3所示, MAC地址优先级 数据可以直接存储在 MAC地址表的 MAC表项中。 当然, MAC地址优先级数据也 可以不存储在 MAC地址表中。  In order to implement the priority learning policy according to the MAC address priority information, the system stores the MAC address priority data of each entry in the MAC address table, and the MAC address priority of the entry is also the MAC address of the entry. MAC address priority. For example, as shown in Figure 3, the MAC address priority data can be directly stored in the MAC address entry of the MAC address table. Of course, the MAC address priority data may not be stored in the MAC address table.
由于 MAC地址表资源有限, 不可能使用很长的字段来存储优先级, 而业 务的优先级各式各样, 优先级的取值也是大小不一, 可以根据接收到的报文 包含的信息或者该 ·^艮文所属业务的信息, 确定源 MAC地址的 MAC地址优先级。 可以采用如下几种方式确定源 MAC地址的 MAC地址优先级:  Due to the limited resources of the MAC address table, it is impossible to use a long field to store the priority. The priority of the service is different. The value of the priority is also different. It can be based on the information contained in the received message or The information of the service to which the message belongs is determined by the MAC address priority of the source MAC address. The MAC address priority of the source MAC address can be determined in the following ways:
1. 获取所述报文包含的报文优先级, 根据所述报文优先级以及报文优先 级到 MAC地址优先级的映射关系, 确定所述源 MAC地址的 MAC地址优先级 P。  1. The priority of the packet included in the packet is obtained, and the MAC address priority P of the source MAC address is determined according to the packet priority and the mapping from the packet priority to the MAC address priority.
收到的报文包含的报文优先级字段, 这些优先级字段可以是 802. l p的优 先级字段, IP头部的优先级字段, 多协议标签交换(MPLS , Mul t i-Pro toco l Labe l Swi t ching )报文的优先级字段, 自定义的优先级字段等。 The received packet priority field. The priority field can be the priority field of 802. lp, the priority field of the IP header, and the multi-protocol label switching (MPLS, Mul t i-Pro toco l Labe l Swi t ching ) Priority field of the message, custom priority field, etc.
例如, 使用 802. l p的报文优先级字段时, 如果在 MAC表项中用 3个比特 ( b i t )存储 MAC地址优先级, ^艮文优先级到 MAC地址优先级的映射关系可以 是直接用 802. l p的优先级作为 MAC地址优先级来存储并进行业务处理。 使用 IP报文优先级字段时, 报文优先级到 MAC地址优先级的映射关系可以是以优 先级字段的最高 3个 b i t作为作为 MAC地址优先级来存储和处理。  For example, when using the packet priority field of 802. lp, if the MAC address priority is stored in the MAC entry with 3 bits (bit), the mapping from the priority of the message to the priority of the MAC address can be directly used. The priority of 802. lp is stored as a MAC address priority for service processing. When the IP packet priority field is used, the mapping from the packet priority to the MAC address priority may be stored and processed as the MAC address priority with the highest 3 b i t of the priority field.
2. 确定报文所属的业务, 获取该业务的业务优先级, 根据业务优先级到 MAC地址优先级的映射关系, 确定所述源 MAC地址的 MAC地址优先级。  2. Determine the service to which the packet belongs, obtain the service priority of the service, and determine the MAC address priority of the source MAC address according to the mapping from the service priority to the MAC address priority.
为了确定 ·^艮文所属的业务,可以从 ·^艮文中提取业务识别信息,如 VLAN ID, 端口号、 封装类型等, 根据这些业务识别信息确定报文所属的业务, 进而获 得该业务的业务优先级。 也可以根据报文中未包含的信息, 如报文的来源端 口、 子端口、 PVC等信息确定报文所属的业务。  In order to determine the service to which the message belongs, the service identification information, such as the VLAN ID, the port number, the encapsulation type, etc., may be extracted from the message, and the service to which the message belongs is determined according to the service identification information, thereby obtaining the service of the service. priority. You can also determine the service to which the packet belongs based on the information that is not included in the packet, such as the source port, sub-port, and PVC of the packet.
例如,在接入网领域,可以使用业务流表示一种业务,可以使用用户 VLAN、 用户的封装类型 (如 PPPoE类型)、 一个或多个端口、 一个 PVC等标识一个业 务流, 这个业务流通常都具有业务优先级属性。 业务报文经过匹配业务流后, 根据业务流的优先级, 确定所述报文所属的业务, 该业务具有业务优先级, 才艮据业务优先级到 MAC地址的映射关系, 确定源 MAC地址的 MAC地址优先级。  For example, in the field of access networks, a service flow can be used to represent a service, and a service flow can be identified by using a user VLAN, a user's encapsulation type (such as PPPoE type), one or more ports, a PVC, etc., and this service flow is usually Both have business priority attributes. After the service packet is matched with the service flow, the service belongs to the service according to the priority of the service flow. The service has the service priority, and the source MAC address is determined according to the mapping from the service priority to the MAC address. MAC address priority.
3. 确定所述 ^艮文所属的业务, 所述源 MAC地址的 MAC地址优先级 P等于 配置数据中所述业务对应的 MAC地址优先级。  3. The MAC address priority P of the source MAC address is equal to the MAC address priority corresponding to the service in the configuration data.
根据业务识别信息确定报文所属的具体业务, 配置数据中包含了该具体 业务的 4艮文中包含的源 MAC地址的 MAC地址优先级。  The specific service to which the packet belongs is determined according to the service identification information, and the configuration data includes the MAC address priority of the source MAC address included in the specific service.
以下结合几个例子说明以上几种确定源 MAC地址优先级的方法。 在一个 实施例中, MAC地址优先级有 4个等级为从 0到 3 , 配置一个业务, 该业务基 于端口 0/ 1 / 0 , 配置该业务的 MAC地址优先级为 3 , 对于属于该业务的所有 4艮 文, 即从该端口进入的所有报文, 这些报文包含的源 MAC地址的 MAC地址优 先级都为 3。  The following several methods are used to illustrate the above methods for determining the priority of the source MAC address. In one embodiment, the MAC address priority has four levels from 0 to 3, and a service is configured, the service is based on port 0/1/0, and the MAC address priority of the service is set to 3, for the service belonging to the service. All 4 messages, that is, all packets entering from the port, the MAC address priority of the source MAC address contained in these messages is 3.
在另一个实施例中, MAC地址优先级有 4个等级为从 0到 3 , 业务流优先 级, 即业务优先级有 8个等级为从 0到 7, 配置两条业务流: 一条业务流为端 口 0/2/0虚路径标识 ( vpi, virtual path identifier ) 0虚通道标识 (vci, virtual channel identifier ) 35, 业务流优先级为 7, 没有配置 MAC地址优 先级; 另一条为端口 0/2/0 vpiO vci 36, 配置该业务流的 MAC地址优先级为 2。 4艮文进入设备端口 0/2/0后, 首先确定 ·^艮文所属的业务流, 对于 vpi 0 vci 35业务的报文, 由于没有配置 MAC地址优先级, 需要将业务流的优先级映射 到 MAC地址优先级, 可以 4巴业务流优先级 0到 1映射到 MAC地址优先级的 0, 2到 3映射到 1, 依此类推。 当然, 也可以采用其他方法进行映射, 例如将 6 到 7映射为 0, 4到 5映射为 1, 依此类推。 如果 vpi 0 vci 35上来的 ^艮文的 MAC地址优先级映射为 3, 从该端口的 vpi 0 vci 35进入的所有 ^艮文包含的 源 MAC地址的 MAC地址优先级为 3。 对于 vpi 0 vci 36上来的 ^艮文, 由于该 业务流配置了 MAC地址优先级, 则将该 ·^艮文的 MAC地址优先级为配置值 2。 In another embodiment, the MAC address priority has 4 levels from 0 to 3, and the traffic priority is prioritized. Level, that is, the service priority has 8 levels from 0 to 7. Configure two service flows: One service flow is port 0/2/0 virtual path identifier (vpi, virtual path identifier) 0 virtual channel identifier (vci, virtual The channel identifier is 35, the traffic priority is 7. The MAC address priority is not configured, and the other is port 0/2/0 vpiO vci 36. The MAC address priority of the service flow is 2. After the device enters port 0/2/0, it first determines the service flow to which the message belongs. For the packets of the vpi 0 vci 35 service, the priority of the service flow needs to be mapped because the MAC address priority is not configured. To the MAC address priority, 4 bar traffic priority 0 to 1 can be mapped to 0 of the MAC address priority, 2 to 3 are mapped to 1, and so on. Of course, other methods can also be used for mapping, such as mapping 6 to 7 to 0, 4 to 5 to 1, and so on. If the MAC address priority of the vpi 0 vci 35 is mapped to 3, the MAC address priority of the source MAC address included in all the entries from the vpi 0 vci 35 of the port is 3. For the vpi 0 vci 36, since the service flow is configured with the MAC address priority, the MAC address priority of the message is set to 2.
在另一个实施例中, MAC地址优先级有 4个等级为从 0到 3, 业务流优先 级,即业务优先级有 8个等级为从 0到 7,配置两条业务流:一条为端口 0/3/0 vlan50, 业务流优先级为 5, 没有配置 MAC地址优先级; 另一条为端口 0/3/0 vlan 60, 配置该业务流的 MAC地址优先级为 1。 ^艮文进入设备端口 0/3/0, 确定该报文为 vlan为 50的业务的报文, 由于没有配置 MAC地址优先级, 根 据业务优先级到 MAC地址优先级的映射关系, 例如, 和前一个实施例相同的 映射关系, 将业务的优先级 1映射到 MAC地址优先级, 将该端口上来的 vlan 为 50的报文的业务流优先级 5映射为 MAC地址优先级 2, 即从该端口进入的 所有 vlan为 50的报文的源 MAC地址在 MAC地址表中的 MAC地址优先级为 2。 对于该端口上来的所有 vlan为 60的 ·^艮文, 由于该业务流配置了 MAC地址优 先级, 则将该报文的 MAC地址表的优先级设置为 1。  In another embodiment, the MAC address priority has 4 levels from 0 to 3, and the service flow priority, that is, the service priority has 8 levels from 0 to 7, and two service flows are configured: one is port 0. /3/0 vlan50, the traffic priority is 5, the MAC address priority is not configured, and the other is port 0/3/0 vlan 60, and the MAC address priority of the service flow is set to 1.艮 进入 进入 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备 设备In the same mapping relationship of the previous embodiment, the priority 1 of the service is mapped to the MAC address priority, and the service flow priority 5 of the packet with the vlan of 50 on the port is mapped to the MAC address priority 2, that is, from the The source MAC address of all packets with the VLAN 50 being entered by the port has a MAC address priority of 2 in the MAC address table. If all the vlans on the port are 60, the priority of the MAC address table of the packet is set to 1 because the service flow is configured with the MAC address priority.
在另一个实施例中, 采用混合方式确定 MAC地址优先级, 可以部分才艮据 报文自带优先级字段确定 MAC地址优先级映射(上面的第 1种方式 ), 部分根 据业务优先级到 MAC地址优先级的映射关系确定 MAC地址优先级(上面的第 2 种方式),部分 ^据配置确定业务对应的 MAC地址优先级(上面的第 3种方式)。 例如, 确定报文所属的业务, 检查业务配置的 MAC地址优先级, 如果配置了 MAC优先级, 则不需要映射, 直接根据配置的 MAC优先级来处理, 如果没有配 置 MAC优先级, 但是配置了业务优先级, 则将业务优先级映射成 MAC地址优 先级来处理, 如果没有配置业务优先级, 则还可以将报文自带的优先级字段 映射为 MAC地址优先级。 处理的优先顺序从高到底可以是: 配置的 MAC优先 级、 业务优先级映射到 MAC地址优先级、 报文优先级字段映射到 MAC地址优 先级。 采用这种处理顺序, 可以使 MAC地址优先级尽可能反映业务的优先级 顺序, 从而为不同的业务提供更好的区别服务。 In another embodiment, the MAC address priority is determined in a hybrid manner, and the MAC address priority mapping may be determined in part according to the packet self-giving priority field (the first mode above), and the MAC address priority is based on the MAC address priority. The mapping relationship of the address priority determines the MAC address priority (the second mode above), and the partial configuration determines the MAC address priority corresponding to the service (the third mode above). For example, the service to which the packet belongs is determined, and the MAC address priority of the service configuration is checked. If the MAC precedence is configured, no mapping is required, and the MAC address priority is directly processed. If the MAC precedence is not configured, but the configuration is configured. If the service priority is configured, the service priority is mapped to the MAC address priority. If the service priority is not configured, the priority field of the packet can be mapped to the MAC address priority. The priority of the processing may be from high to low: the configured MAC priority, the service priority mapping to the MAC address priority, and the packet priority field mapping to the MAC address priority. With this processing sequence, the MAC address priority can be reflected as much as possible in the priority order of the service, thereby providing better differentiated services for different services.
步骤 203 中, 当没有空闲存储空间时, 可以通过采用优先级学习策略, 从已经被使用的存储空间中抢占一个地址表项占据的空间,以存储包含源 MAC 地址的地址表项, 避免因没有 MAC地址表资源而导致无法学习新的 MAC地址, 从而提升业务的服务质量。  In step 203, when there is no free storage space, the priority occupied learning policy may be used to preempt the space occupied by an address entry from the used storage space to store the address entry containing the source MAC address, so as to avoid The MAC address table resource cannot be used to learn a new MAC address, thereby improving the service quality of the service.
优先级学习策略可以包括:  Priority learning strategies can include:
1、 严格优先级策略  1. Strict priority strategy
基于严格优先级策略, 203确定所述 MAC地址表中的一个表项占用的存储 空间具体为确定所述 MAC地址表中 MAC地址优先级为 的一个表项占用的存 储空间, 其中, 所述 Pi的 MAC地址优先级低于所述 P的 MAC地址优先级。 优 选地, 该一个地址表项可以是所有 MAC地址优先级低于 P的表项中 MAC地址 优先级最低的表项。 在 MAC地址表资源耗尽的情况下, 高优先级的业务 MAC 地址学习可以抢占低优先级的 MAC表项资源, 只要 MAC地址表中有 MAC地址 优先级比正在学习的源 MAC地址的优先级低的表项资源, 就可以抢占。 如果 抢占优先级最低的表项, 可以实现更好的区别服务, 尽可能减小对较高优先 级服务的影响。 如果没有可被抢占的资源, 就不学习该源 MAC地址。 这种策 略使得高优先级业务比低优先级业务得到更好的优先处理。  Determining, by the strict priority policy, 203, that the storage space occupied by one entry in the MAC address table is specifically a storage space occupied by an entry in the MAC address table with a priority of the MAC address, wherein the Pi The MAC address priority is lower than the MAC address priority of the P. Preferably, the one address entry may be the entry with the lowest priority of the MAC address in the entry with the lower priority of the MAC address. When the MAC address table resource is exhausted, the high-priority service MAC address learning can preempt the low-priority MAC address entry resource, as long as the MAC address priority in the MAC address table is higher than the source MAC address being learned. Low entry resources can be preempted. If the lowest priority entry is preempted, a better differentiated service can be implemented to minimize the impact on higher priority services. If there is no resource that can be preempted, the source MAC address is not learned. This strategy allows high-priority services to be better prioritized than low-priority services.
2、 比例优先级策略  2. Proportional priority strategy
如果高优先级的业务非常多, 则高优先级业务可能会把 MAC表项资源抢 占完, 从而导致低优先级的业务无法学习 MAC地址, 从而导致低优先级的业 务饿死。 为了防止低优先级业务饿死, 同时又让高优先级业务得到相对更高 的处理优先级, 可以对每个 MAC地址优先级配置一个门限值。 例如, 按照从 高到低的顺序为每个 MAC地址优先级配置一个门限值, 高优先级的配置的门 限值不少于低优先级的门限值。 If the high-priority service is very high, the high-priority service may preempt the MAC entry. As a result, the low-priority service cannot learn the MAC address, resulting in a low-priority service. Starve to death. In order to prevent low-priority services from starving and at the same time giving high-priority services a relatively higher processing priority, a threshold can be configured for each MAC address priority. For example, a threshold is configured for each MAC address priority in descending order, and the high priority configuration threshold is not less than the low priority threshold.
例如, MAC地址表资源为 1000个, 如果使用 2个 bi t来表示 4个 MAC地 址优先级, 则 4个优先级的门限值的权重配置可以是 40%, 30%, 20%, 10%, 即 4个优先级的门限值为 400、 300、 200、 100。 如果用 3个 bi t表示 8个优 先级, 门限值可配置为 30% , 20% , 10% , 10%, 8% , 8%, 7%, 7%。  For example, the MAC address table resource is 1000. If 2 bi ts are used to represent 4 MAC address priorities, the weighting of the 4 priority thresholds may be 40%, 30%, 20%, 10%. , that is, the thresholds of four priorities are 400, 300, 200, 100. If 3 priorities are used to represent 8 priority levels, the threshold can be configured to 30%, 20%, 10%, 10%, 8%, 8%, 7%, 7%.
在学习 MAC的时候, 当 MAC地址表中有空闲表项的时候, 无论某个 MAC 地址优先级的 MAC地址表项数量是否小于该优先级对应的门限值, 都可以直 接使用空闲表项, 不用考虑配置的门限值。 例如, 1000个 MAC地址表项, 优 先级为 0的最低优先级配置的门限值为 100 , 在 0优先级占满 100个表项后, 如果还有空闲表项, 则可以继续学习优先级为 0的 MAC地址。 当没有空闲表 项的时候, 可以考虑配置给不同 MAC地址优先级的门限值。  When learning the MAC address, when there is a free entry in the MAC address table, the idle entry can be used directly, regardless of whether the number of MAC address entries of a certain MAC address priority is less than the threshold corresponding to the priority. Do not consider the configured threshold. For example, if there are 1000 MAC address entries, the lowest priority configuration with a priority of 0 has a threshold of 100. After the 0 priority has occupied 100 entries, if there are still idle entries, you can continue to learn the priority. A MAC address of 0. When there are no free entries, you can consider the thresholds for different MAC address priorities.
可以比较 MAC地址表中每个不等于 P的 MAC地址优先级 Q的表项的数量 和该 Q的门限值:  The number of entries of the MAC address priority Q that is not equal to P in the MAC address table and the threshold of the Q can be compared:
如果 Q的优先级低于 P, 且 Q的数量大于门限值, 则可以确定 MAC地址表 中 MAC地址优先级为 Q的一个表项占用的存储空间来进行抢占。 例如, 有 0 到 3优先级依次升高的共 4个 MAC地址优先级的情形, 当没有空闲存储空间, MAC地址优先级为 3的源 MAC地址需要抢占时, MAC地址优先级为 0和 1的表 项都超过了分别分配给 0和 1优先级的门限值, 则可以从这两种表项中确定 一个表项予以抢占。 优选地, 所述一个表项可以是 MAC地址优先级为所有满 足 MAC地址优先级低于 P且该优先级的表项数量大于门限值的条件的表项中 MAC地址优先级最低的表项。如前面的例子, 在 0和 1两种优先级表项中确定 一个优先级 0的表项予以抢占。 因为可以抢占到低优先级 MAC地址占用的资 源, 所以可以为高优先级业务提供比低优先级业务更高的处理优先级。 对于 优选方案, 可以尽可能抢占优先级低的业务, 从而实现更好的区别服务。 以上情况确定的是 MAC地址优先级低于所述 P的一个表项。 If the priority of the Q is lower than the P, and the number of Qs is greater than the threshold, the storage space occupied by an entry with the MAC address priority of the MAC address table in the MAC address table may be determined to be preempted. For example, if there are a total of 4 MAC address priorities with a priority of 0 to 3, the MAC address priority is 0 and 1 when there is no free storage space and the source MAC address with the MAC address priority of 3 needs to be preempted. If the entries exceed the thresholds assigned to the 0 and 1 priorities, you can determine an entry from the two entries to preempt. Preferably, the one entry may be an entry whose MAC address priority is the lowest priority of the MAC address in the entry that satisfies the condition that the priority of the MAC address is lower than P and the number of entries of the priority is greater than the threshold. . As in the previous example, an entry with priority 0 is determined among the 0 and 1 priority entries to be preempted. Because the resources occupied by the low-priority MAC address can be preempted, the high-priority service can be provided with a higher processing priority than the low-priority service. For the preferred solution, the service with lower priority can be preempted as much as possible, so as to achieve better differentiated services. The above situation determines that an MAC address has a lower priority than an entry of the P.
如果 Q的优先级低于 P, 且 Q的数量小于等于门限值, 则不能抢占 MAC地 址优先级为 Q的表项。  If the priority of Q is lower than P, and the number of Qs is less than or equal to the threshold, the entry with the MAC address priority of Q cannot be preempted.
如果 Q的优先级高于 P, 且 Q的数量大于门限值, 且 MAC地址表中 P的数 量小于门限值, 则可以确定 MAC地址表中 MAC地址优先级为 Q的一个表项占 用的存储空间来进行抢占。 例如, 有 0到 7共 8个优先级依次升高的 MAC地 址优先级的情形, 当 MAC地址优先级为 Q的源 MAC地址需要占用 MAC地址表 资源学习 MAC地址时, MAC地址表中 MAC地址优先级为 Q的表项的数量还未达 到分配的门限值, 但其余 MAC地址表资源已经都被 MAC地址优先级为 6和 7 的表项用完, 并且 MAC地址优先级为 6和 7的表项的数量都分别超过了各自 的门限值, 则可以从 6和 7 占用的表项中确定一个表项占据的存储空间予以 抢占。 优选地, 所述一个表项可以是所有满足条件的表项中 MAC地址优先级 最低的表项。 如前例, 可以抢占优先级为 6的表项。 当高优先级 MAC地址把 所有地址表资源都占用后, 低优先级 MAC地址可以抢回分配的配额, 保证了 低优先级业务不会被饿死。 对于优选方案, 可以尽可能抢占优先级低的业务, 从而实现更好的区别服务。 这种情况是 203所述的确定所述 MAC地址表中的 一个表项占用的存储空间的一种具体情形: 确定所述 MAC地址表中 MAC地址 优先级为 Q的一个表项占用的存储空间, 其中, 所述 Q的 MAC地址优先级大 于所述 P的 MAC地址优先级, 所述 MAC地址表中 MAC地址优先级为所述 P的 表项的数量小于为所述 P配置的门限值, 且 MAC地址优先级为所述 Q的表项 的数量大于为所述 P2配置的门限值。 If the priority of Q is higher than P, and the number of Q is greater than the threshold, and the number of Ps in the MAC address table is less than the threshold, it may be determined that an entry in the MAC address table with a MAC address priority of Q is occupied. Storage space for preemption. For example, when there are 8 priority priorities of 0 to 7 in which the priority of the MAC address is increased, when the source MAC address whose MAC address priority is Q needs to occupy the MAC address table resource learning MAC address, the MAC address in the MAC address table The number of entries with the priority of Q has not reached the allocated threshold, but the remaining MAC address table resources have been exhausted by the entries with the MAC address priority of 6 and 7, and the MAC addresses have priority of 6 and 7. If the number of entries exceeds the respective thresholds, you can determine the storage space occupied by one entry from the entries occupied by 6 and 7. Preferably, the one entry may be the entry with the lowest MAC address priority among all the entries satisfying the condition. As in the previous example, you can preempt the entry with the priority of 6. When the high-priority MAC address occupies all the address table resources, the low-priority MAC address can reclaim the allocated quota, ensuring that the low-priority service will not be starved. For the preferred solution, the service with lower priority can be preempted as much as possible, so as to achieve better differentiated services. In this case, a specific case of determining the storage space occupied by an entry in the MAC address table is as follows: determining a storage space occupied by an entry whose MAC address priority is Q in the MAC address table. The MAC address priority of the Q is greater than the MAC address priority of the P, and the MAC address priority in the MAC address table is that the number of entries of the P is less than the threshold configured for the P. And the number of entries with the MAC address priority being the Q is greater than the threshold configured for the P 2 .
如果 Q的优先级高于 P, 且 Q的数量大于门限值, 且 MAC地址表中 P的数 量大于等于门限值, 则不能抢占 MAC地址优先级为 Q的表项的存储空间; 如果 Q的优先级高于 P, 且 Q的数量小于等于门限值, 则不能抢占 MAC地 址优先级为 Q的表项的存储空间。  If the priority of Q is higher than P, and the number of Qs is greater than the threshold, and the number of Ps in the MAC address table is greater than or equal to the threshold, the storage space of the entry with the MAC address priority of Q cannot be preempted; If the priority of the entry is higher than P, and the number of Qs is less than or equal to the threshold, the storage space of the entry with the MAC address priority of Q cannot be preempted.
换言之, 当本优先级 MAC表项的数量大于等于分配的门限值时, 如果 MAC 地址表中不存在某个低优先级的表项, 或虽然存在低优先级的表项但是低优 先级的表项数量小于等于分配的门限值, 则没有可以抢占的资源, 无法抢占, 就不学习新来的源 MAC地址; 当本优先级 MAC表项的数量小于分配的门限值 时, 由于资源总数一定, 则存在某个其他优先级的表项数量超过了为该某个 优先级配置的门限值, 因此, 该其他优先级的 MAC表项是能被抢占的, 可以 从中选择一个表项进行抢占。 In other words, if the number of the priority MAC entries is greater than or equal to the assigned threshold, if there is no low priority entry in the MAC address table, or if there is a low priority entry, the low priority is If the number of the primary entries is less than or equal to the assigned threshold, there is no resource that can be preempted, and the source MAC address is not learned. If the number of the priority MAC entries is less than the assigned threshold. The total number of other priority entries exceeds the threshold configured for the priority. Therefore, the MAC entries of the other priorities can be preempted. An entry is preempted.
由于设备的 MAC地址表资源是有限的, 为了保障一些业务的优先性, 可 以给各种业务单独分配 MAC地址表资源。 例如, 可以单独限制业务流(一个 端口可能有多条业务流)、 端口、 vlan的 MAC地址资源数量, 此时, 可以基于 这些单独分配的 MAC地址表资源来应用前述的学习 MAC地址的方法, 可以达 到粒度更细的基于优先级的 MAC地址学习。 例如: 如果单独为一个业务流分 配了 10个 MAC地址表资源, 则可以在这条业务流上配置 MAC地址优先级学习 策略, 可以把报文包含的报文优先级映射到 MAC地址优先级, 采用严格优先 为了采用优先级学习策略, 需要保存 MAC表项对应的 MAC地址优先级, 例如可以在 MAC表项中增加优先级的存储字段。 可以利用 MAC地址表中的表 项的 MAC地址优先级数据, 来判断 MAC地址表中是否存在能被抢占的表项资 源。 向 MAC地址表中增加表项时, 在该表项中记录 MAC地址优先级。  Since the MAC address table resources of the device are limited, in order to ensure the priority of some services, MAC address table resources can be separately allocated to various services. For example, the service flow (a port may have multiple service flows), the port, and the number of MAC address resources of the vlan may be separately restricted. At this time, the foregoing method for learning the MAC address may be applied based on the separately allocated MAC address table resources. A finer-grained priority-based MAC address learning can be achieved. For example, if 10 MAC address table resources are allocated for a service flow, the MAC address priority learning policy can be configured on the service flow, and the packet priority of the packet can be mapped to the MAC address priority. Strict priority is used. In order to adopt the priority learning policy, the MAC address priority corresponding to the MAC entry needs to be saved. For example, the storage field of the priority can be added to the MAC entry. The MAC address priority data of the entry in the MAC address table can be used to determine whether there is a preempted entry in the MAC address table. When an entry is added to the MAC address table, the MAC address priority is recorded in the entry.
可以通过预先配置的方式确定是否采用优先级学习策略对 MAC地址进行 学习, 也可以通过预先配置的方式确定是采用严格优先级学习策略, 还是采 用比例优先级学习策略。  You can determine whether to use the priority learning policy to learn the MAC address in a pre-configured manner. You can also use a pre-configured method to determine whether to adopt a strict priority learning policy or a proportional priority learning strategy.
图 4所示的为采用严格优先级学习策略的一个具体实施例。 该实施例中, MAC地址优先级为 1到 n共 n个优先级依次升高的 MAC地址优先级, n为大于 1的整数。 使用 n个计数器, 其中, 第 k个计数器(计数器 k )记录 MAC地址 优先级为 k的 MAC地址使用的 MAC表项资源的数量, 其中, k = l , 2,. . .,n。 向 MAC地址表中增加表项时, 相应优先级的学习数计数器加 1 , 老化或者删除 该 MAC地址的时候, 相应优先级对应的计数器减 1。 通过计数器, 可以更直接 地判断是否存在能被抢占的表项资源。 该实施例包括以下步骤: 步骤 401: 收到一个包含源 MAC地址的报文; Figure 4 shows a specific embodiment employing a strict priority learning strategy. In this embodiment, the MAC address priority ranges from 1 to n, and n priority priorities are sequentially increased, and n is an integer greater than 1. N counters are used, wherein the kth counter (counter k) records the number of MAC entry resources used by the MAC address whose MAC address priority is k, where k = l , 2, . . . , n. When an entry is added to the MAC address table, the learning counter of the corresponding priority is incremented by one. When the MAC address is aged or deleted, the counter corresponding to the corresponding priority is decremented by one. Through the counter, it can be more directly judged whether there is an entry resource that can be preempted. This embodiment includes the following steps: Step 401: Receive a packet including a source MAC address.
步骤 403: 确定该 ·^艮文的 MAC地址优先级为 m, m小于等于 n且大于等于 1。 可以采用前文所述的方法确定该 4艮文的 MAC地址优先级。  Step 403: Determine that the MAC address priority of the message is m, m is less than or equal to n, and is greater than or equal to 1. The MAC address priority of the message can be determined by the method described above.
步骤 405: 判断各个计数器的和是否小于 MAC地址表资源总数, 如果各个 计数器的和等于 MAC地址表资源总数, 即 MAC地址表中已经没有空闲表项, 转至 407, 如果小于, 即还有空闲表项, 转至 417。  Step 405: Determine whether the sum of the respective counters is smaller than the total number of resources of the MAC address table. If the sum of the counters is equal to the total number of resources in the MAC address table, that is, there is no free entry in the MAC address table, go to 407. If it is less than, there is still idle. Entry, go to 417.
步骤 407: 确定本次要检查的计数器为计数器 i。 计数器 1是第一个被检 查的计数器, 下一个要检查的为第 i + 1个计数器。 按优先级从小到大的顺序 进行检查, 可以找到能被抢占的优先级最低的表项。  Step 407: Determine that the counter to be checked this time is the counter i. Counter 1 is the first counter to be checked, and the next one to check is the i + 1 counter. Check in order of priority from small to large to find the lowest priority entry that can be preempted.
步骤 409: 判断 i是否等于 m, 如果是, 转至 415, 如果不是, 转至 411; 步骤 411: 判断计数器 i的值是否不等于 0, 如果是, 执行 413, 如果不 是, 执行 407。 通过判断计数器 i的值是否不等于 0, 判断 MAC地址表中是否 存在能够被抢占的表项。  Step 409: Determine whether i is equal to m, if yes, go to 415, if not, go to 411; Step 411: Determine if the value of counter i is not equal to 0, if yes, execute 413, if not, execute 407. By determining whether the value of the counter i is not equal to 0, it is determined whether there is an entry that can be preempted in the MAC address table.
步骤 413:使用 MAC地址表中一个 MAC地址优先级为 i的表项的存储空间 生成包含源 MAC地址的表项, 设置该表项的优先级为 m, 计数器 m加 1, 计数 器 i减 1。  Step 413: Use the storage space of the entry with the MAC address priority i in the MAC address table to generate an entry containing the source MAC address, set the priority of the entry to m, the counter m plus 1, and the counter i to decrease by 1.
步骤 415: 没有能被抢占的低优先级的表项, 不学习该源 MAC地址; 步骤 417: 使用 MAC地址表的一个空闲表项的存储空间生成包含该源 MAC 地址的表项, 并设置该表项的 MAC地址优先级为 m, 计数器 m加 1。  Step 415: The low-priority entry that cannot be preempted does not learn the source MAC address. Step 417: Generate an entry containing the source MAC address by using a storage space of a free entry of the MAC address table, and set the The MAC address priority of the entry is m, and the counter m is incremented by 1.
图 5所示的为采用比例优先级学习策略的一个具体实施例。 该实施例中, MAC地址优先级为 1到 n共 n个优先级依次升高的 MAC地址优先级, n为大于 1的整数。 使用 n个计数器, 其中, 计数器 k记录 MAC地址优先级为 k的 MAC 地址使用的 MAC表项资源的数量。 其中, k = l, 2,...,n。 同时, 为每个 MAC 地址优先级设定该优先级的门限值, 优先级为 k的 MAC地址的门限值为 QK。 该实施例包括以下步骤: Figure 5 shows a specific embodiment of a proportional priority learning strategy. In this embodiment, the MAC address priority ranges from 1 to n, and n priority priorities are sequentially increased, and n is an integer greater than 1. The n counters are used, wherein the counter k records the number of MAC entry resources used by the MAC address whose MAC address priority is k. Where k = l, 2,...,n. At the same time, the priority threshold is set for each MAC address priority, and the threshold of the MAC address with priority k is Q K . This embodiment includes the following steps:
步骤 501: 收到一个包含源 MAC地址的报文;  Step 501: Receive a packet containing a source MAC address.
步骤 503: 确定该 ·^艮文的 MAC地址优先级为 m, m小于等于 n且大于等于 1。 可以采用前文所述的方法确定该 4艮文的 MAC地址优先级。 Step 503: Determine that the MAC address priority of the message is m, m is less than or equal to n, and is greater than or equal to 1. The MAC address priority of the message can be determined by the method described above.
步骤 505 : 判断各个计数器的和是否小于 MAC地址表资源总数, 如果各个 计数器的和不小于 MAC地址表资源总数, 即 MAC地址表中已经没有空闲表项, 转至 507 , 如果小于, 即还有空闲表项, 转至 525。  Step 505: Determine whether the sum of the respective counters is smaller than the total number of resources of the MAC address table. If the sum of the respective counters is not less than the total number of resources of the MAC address table, that is, there is no idle entry in the MAC address table, go to 507, if it is less, then there is For free entries, go to 525.
步骤 507: 判断计数器 m的值是否小于 Qm , 如果大于等于, 转至 509 , 尝 试抢占一个低优先级的表项, 如果小于, 转至 519 , 回抢一个表项。 Step 507: Determine whether the value of the counter m is less than Q m . If it is greater than or equal to 0, try to preempt a low priority entry. If it is less than, go to 519 and retrieve an entry.
步骤 509: 确定本次要检查的计数器为计数器 i , 计数器 1是第一个被检 查的计数器, 下一个要检查的为第 i + 1个计数器。 按优先级从小到大的顺序 进行检查, 可以找到能被抢占的优先级最低的表项。  Step 509: It is determined that the counter to be checked this time is the counter i, the counter 1 is the first counter to be checked, and the next one to be checked is the i+1 counter. Check in order of priority from small to large to find the lowest priority entry that can be preempted.
步骤 511 : 判断 i是否等于 m, 如果是, 转至 517 , 如果不是, 转至 513; 步骤 513: 判断计数器 i的值是否大于 Qm , 如果是, 执行 515 , 如果否, 转至 509; Step 511: Determine whether i is equal to m, if yes, go to 517, if not, go to 513; Step 513: Determine whether the value of counter i is greater than Q m , if yes, execute 515, if no, go to 509;
步骤 515 :使用 MAC地址表中一个 MAC地址优先级为 i的表项的存储空间 生成包含源 MAC地址的表项,设置该表项的 MAC地址优先级为 m, 计数器 m加 1 , 计数器 i减 1 ;  Step 515: Generate an entry containing the source MAC address in the storage space of the entry with the MAC address priority i in the MAC address table, set the MAC address priority of the entry to m, increment the counter m by 1, and reduce the counter i. 1 ;
步骤 517: 没有能被抢占的低优先级表项, 不学习该源 MAC地址; 步骤 519: 确定本次要检查的计数器为计数器 i , 计数器 1是第一个被检 查的计数器, 下一个要检查的为第 i + 1个计数器。 按优先级从小到大的顺序 进行检查, 可以找到能被抢占的优先级最低的表项。  Step 517: There is no low priority entry that can be preempted, and the source MAC address is not learned. Step 519: It is determined that the counter to be checked this time is the counter i, and the counter 1 is the first checked counter, and the next one is to be checked. For the i + 1 counter. Check in order of priority from small to large to find the lowest priority entry that can be preempted.
步骤 521 : 判断计数器 i的值是否大于 , 如果是, 表示 MAC地址表中优 先级 i的表项的数量超过了优先级 i的门限值, 继续执行 523回抢一个表项 资源; 如果否, 表示没有超过门限值, 转至 519 , 继续检查下一个计数器。  Step 521: Determine whether the value of the counter i is greater than, if yes, the number of entries of the priority i in the MAC address table exceeds the threshold of the priority i, and continue to perform 523 to grab an entry resource; if not, Indicates that the threshold has not been exceeded, go to 519 and continue to check the next counter.
步骤 523:使用 MAC地址表中一个 MAC地址优先级为 i的表项的存储空间 生成包含源 MAC地址的表项,设置该表项的 MAC地址优先级为 m, 计数器 m加 1 , 计数器 i减 1 ;  Step 523: Generate an entry containing the source MAC address in the storage space of the entry with the MAC address priority i in the MAC address table, set the MAC address priority of the entry to m, increment the counter m by 1, and reduce the counter i. 1 ;
步骤 525 : 使用 MAC地址表的一个空闲表项的存储空间生成包含该源 MAC 地址的表项, 并设置该表项的 MAC地址优先级为 m, 计数器 m加 1。 本发明的实施例提供了一种学习 MAC地址的装置, 如图 6中 600所示: 报文接收单元 601接收包含源 MAC地址的报文; Step 525: Generate an entry including the source MAC address by using a storage space of a free entry of the MAC address table, and set a MAC address priority of the entry to be m, and increment the counter m by 1. An embodiment of the present invention provides a device for learning a MAC address, as shown in FIG. 600: The message receiving unit 601 receives a message including a source MAC address.
收到该报文后, 优先级确定单元 603根据所述报文包含的信息或所述报 文所属的业务的信息确定所述源 MAC地址的 MAC地址优先级 P;  After receiving the message, the priority determining unit 603 determines the MAC address priority P of the source MAC address according to the information contained in the message or the information of the service to which the message belongs;
空闲判断单元 605判断 MAC地址表 607中是否有空闲存储空间; 如果 MAC地址表 607中没有空闲表项, 抢占单元 609根据所述 P以及所 述 MAC地址表中各个表项的 MAC地址优先级, 确定 MAC地址表 607中的一个 表项占用的存储空间, 所述一个表项的 MAC地址优先级不等于所述 P;  The idle determination unit 605 determines whether there is a free storage space in the MAC address table 607. If there is no free entry in the MAC address table 607, the preemption unit 609 according to the P and the MAC address priority of each entry in the MAC address table, Determining a storage space occupied by an entry in the MAC address table 607, where the MAC address priority of the one entry is not equal to the P;
保存单元 611使用抢占单元 609确定的一个表项占用的存储空间存储包 含所述源 MAC地址的表项。  The storage unit 611 uses the storage space occupied by an entry determined by the preemption unit 609 to store an entry containing the source MAC address.
进一步, 如果 MAC地址表 607中有空闲存储空间, 非抢占单元 613使用 所述空闲存储空间存储包含所述源 MAC地址的表项, 所述包含所述源 MAC地 址的表项的 MAC地址优先级为所述 P。  Further, if there is a free storage space in the MAC address table 607, the non-preemption unit 613 uses the free storage space to store an entry including the source MAC address, and the MAC address priority of the entry including the source MAC address. For the P.
抢占单元 609确定 MAC地址表中的一个表项占用的存储空间, 可以具体 为: 确定所述 MAC地址表中 MAC地址优先级为 的表项中的一个表项占用的 存储空间, 其中, 所述 Pi的 MAC地址优先级低于所述 P的 MAC地址优先级。 进一步, 所述 MAC地址表中 MAC地址优先级为所述 的表项的数量大于为所 述 Pi配置的门限值。  The preemption unit 609 determines the storage space occupied by an entry in the MAC address table, which may be specifically: determining a storage space occupied by an entry in the entry of the MAC address priority table in the MAC address table, where The MAC address priority of the Pi is lower than the MAC address priority of the P. Further, the MAC address priority in the MAC address table is that the number of the entries is greater than a threshold configured for the Pi.
抢占单元 609确定 MAC地址表中的一个表项占用的存储空间, 可以具体 为: 确定所述 MAC地址表中 MAC地址优先级为 P2的表项中的一个表项占用的 存储空间, 其中, 所述 P2的 MAC地址优先级大于所述 P的 MAC地址优先级, 所述 MAC地址表中 MAC地址优先级为所述 P的表项的数量小于为所述 P配置 的门限值, 且 MAC地址优先级为所述 P2的表项的数量大于为所述 P2配置的门 限值。 Preemption unit 609 determines the storage space occupied by an entry in the MAC address table may specifically be: determining the MAC address in the MAC address table memory space a priority entry occupies two entries in P, wherein MAC address of the P 2 priority higher than the priority P of the MAC address, the MAC address in the MAC address table priority less than the threshold value P is configured for the number of entries of the P, and The number of entries with the MAC address priority being the P 2 is greater than the threshold configured for the P 2 .
上述各个单元, 可以通过采用通用处理器和存储器, 配合软件程序实现, MAC地址表可以是一段内存。 上述各个单元也可以通过可编程逻辑, 或 AS IC 芯片等硬件实现, 例如 MAC地址表可以用可编程逻辑, 或 ASIC芯片等硬件实 现。 Each of the above units can be implemented by using a general-purpose processor and a memory in conjunction with a software program, and the MAC address table can be a piece of memory. The above units can also be implemented by hardware such as programmable logic or AS IC chip. For example, the MAC address table can be implemented by programmable logic, or hardware such as ASIC chip. Now.
通过以上的实施方式的描述, 本领域的技术人员可以清楚地了解到本发 明可借助软件加必需的硬件平台的方式来实现, 当然也可以全部通过硬件来 实施。 基于这样的理解, 本发明的技术方案对背景技术做出贡献的全部或者 部分可以以软件产品的形式体现出来, 该计算机软件产品可以存储在存储介 质中,如 R0M/RAM、磁碟、光盘等, 包括若干指令用以使得一台计算机设备(可 以是个人计算机, 服务器, 或者网络设备等)执行本发明各个实施例或者实 施例的某些部分所述的方法。  Through the description of the above embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary hardware platform, and of course, can also be implemented entirely by hardware. Based on such understanding, all or part of the technical solution of the present invention contributing to the background art may be embodied in the form of a software product, which may be stored in a storage medium such as a ROM/RAM, a magnetic disk, an optical disk, or the like. A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods described in various embodiments of the present invention or portions of the embodiments.
以上所述, 仅为本发明较佳的具体实施方式, 但本发明的保护范围并不 局限于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可 轻易想到的变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明 的保护范围应该以权利要求的保护范围为准。  The above is only a preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or within the technical scope disclosed by the present invention. Alternatives are intended to be covered by the scope of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

权利要求 书 Claim
1. 一种学习媒体接入控制 MAC地址的方法, 其特征在于, 包括:  A method for learning a media access control MAC address, comprising:
接收包含源 MAC地址的 ^艮文;  Receiving a message containing the source MAC address;
如果 MAC地址表中没有空闲存储空间, 才艮据所述源 MAC地址的 MAC地址优 先级 P以及所述 MAC地址表中各个表项的 MAC地址优先级, 确定所述 MAC地址 表中的一个表项占用的存储空间,所述一个表项的 MAC地址优先级不等于所述 P, 所述 P系根据所述报文包含的信息或所述报文所属的业务的信息确定;  Determining a table in the MAC address table according to the MAC address priority P of the source MAC address and the MAC address priority of each entry in the MAC address table, if there is no free storage space in the MAC address table. The storage space occupied by the item, the MAC address priority of the one entry is not equal to the P, and the P is determined according to the information contained in the packet or the information of the service to which the packet belongs;
使用所述一个表项占用的存储空间存储包含所述源 MAC地址的表项。  The storage space occupied by the one entry is used to store an entry that includes the source MAC address.
2. 如权利要求 1所述的方法, 其特征在于, 所述确定所述 MAC地址表中的 一个表项占用的存储空间, 具体包括:  The method of claim 1, wherein the determining the storage space occupied by one of the entries in the MAC address table comprises:
确定所述 MAC地址表中 MAC地址优先级为 的表项中的一个表项占用的存 储空间, 其中, 所述 Pi的 MAC地址优先级低于所述 P的 MAC地址优先级。  And determining, by the MAC address table, a storage space occupied by an entry in the entry with the priority of the MAC address, where the priority of the MAC address of the Pi is lower than the priority of the MAC address of the P.
3. 如权利要求 2所述的方法, 其特征在于, 所述 MAC地址表中 MAC地址优 先级为所述 的表项的数量大于为所述 配置的门限值。  The method according to claim 2, wherein the MAC address priority in the MAC address table is that the number of the entries is greater than a threshold value of the configuration.
4. 如权利要求 2或 3所述的方法, 其特征在于, 所述一个表项为所述 MAC 地址优先级为 Pi的表项中优先级最低的表项。  The method according to claim 2 or 3, wherein the one entry is the entry with the lowest priority among the entries with the priority of the MAC address being Pi.
5. 如权利要求 1所述的方法, 其特征在于, 所述确定所述 MAC地址表中的 一个表项占用的存储空间, 具体包括:  The method of claim 1, wherein the determining the storage space occupied by an entry in the MAC address table comprises:
确定所述 MAC地址表中 MAC地址优先级为 P2的表项中的一个表项占用的存 储空间, 其中, 所述 P2的 MAC地址优先级大于所述 P的 MAC地址优先级, 所述 且 MAC地址优先级为所述 P2的表项的数量大于为所述 P2配置的门限值。 Determining the MAC address table as the MAC address of the memory space a priority entry occupies P 2 in the entry, wherein the MAC address of the P 2 priority higher than the priority P of the MAC address, the The number of entries with the MAC address priority being the P 2 is greater than the threshold configured for the P 2 .
6. 如权利要求 5所述的方法, 其特征在于, 所述一个表项为所述 MAC地址 优先级为 P2的表项中优先级最低的表项。 6. The method according to claim 5, characterized in that the entry of a priority of the MAC address entry P 2 in the lowest priority entries.
7. 如权利要求 1 - 6任一所述的方法, 其特征在于, 进一步包括: 如果 MAC地址表中有空闲存储空间, 使用所述空闲存储空间存储包含所述 源 MAC地址的表项,所述包含所述源 MAC地址的表项的 MAC地址优先级为所述 P。 The method according to any one of claims 1 to 6, further comprising: if there is a free storage space in the MAC address table, using the free storage space to store an entry including the source MAC address, The MAC address priority of the entry containing the source MAC address is the P.
8. 如权利要求 1 - 7 任一所述的方法, 其特征在于, 所述根据所述报文包 含的信息或所述报文所属的业务的信息确定, 包括: The method according to any one of claims 1 to 7, wherein the determining according to the information contained in the packet or the information of the service to which the packet belongs includes:
获取所述报文包含的报文优先级, 根据所述报文优先级以及报文优先级到 MAC地址优先级的映射关系确定; 或者,  Obtaining the priority of the packet included in the packet, and determining the priority according to the packet priority and the priority of the packet to the MAC address priority; or
确定所述报文所属的业务, 获取所述业务的业务优先级, 根据业务优先级 到 MAC地址优先级的映射关系确定; 或者,  Determining the service to which the packet belongs, and obtaining the service priority of the service, and determining according to the mapping relationship between the service priority and the MAC address priority; or
确定所述报文所属的业务, 根据配置数据中所述业务对应的 MAC地址优先 级确定。  Determining the service to which the packet belongs is determined according to the priority of the MAC address corresponding to the service in the configuration data.
9. 如权利要求 1 - 8任一所述的方法, 其特征在于, 所述 MAC地址表中的 每个表项都包含该表项包含的 MAC地址的 MAC地址优先级。  The method according to any one of claims 1-8, wherein each entry in the MAC address table includes a MAC address priority of a MAC address included in the entry.
10. 一种学习媒体接入控制 MAC地址的装置, 其特征在于, 包括: 报文接收单元, 用于接收包含源 MAC地址的报文;  An apparatus for learning a medium access control MAC address, comprising: a message receiving unit, configured to receive a message including a source MAC address;
优先级确定单元, 用于确定所述源 MAC地址的 MAC地址优先级 P;  a priority determining unit, configured to determine a MAC address priority P of the source MAC address;
空闲判断单元, 用于判断 MAC地址表中是否有空闲存储空间;  An idle judging unit, configured to determine whether there is free storage space in the MAC address table;
抢占单元, 如果所述 MAC地址表中没有空闲存储空间, 用于根据所述 P 以 及所述 MAC地址表中各个表项的 MAC地址优先级, 确定所述 MAC地址表中的一 个表项占用的存储空间, 所述一个表项的 MAC地址优先级不等于所述 P;  a preemption unit, if there is no free storage space in the MAC address table, used to determine, according to the P and the MAC address priority of each entry in the MAC address table, an entry in the MAC address table is occupied. The storage space, the MAC address priority of the one entry is not equal to the P;
保存单元, 用于使用所述一个表项占用的存储空间存储包含所述源 MAC地 址的表项, 所述包含所述源 MAC地址的表项的 MAC地址优先级为所述 P。  And a storage unit, configured to store, by using the storage space occupied by the one entry, an entry that includes the source MAC address, and the MAC address priority of the entry that includes the source MAC address is the P.
11. 如权利要求 10所述的装置, 其特征在于, 进一步包括:  The device according to claim 10, further comprising:
非抢占单元, 如果 MAC地址表中有空闲存储空间, 用于使用所述空闲存储 空间存储包含所述源 MAC地址的表项, 所述包含所述源 MAC地址的表项的 MAC 地址优先级为所述 P。  a non-preemptive unit, if there is a free storage space in the MAC address table, for storing an entry containing the source MAC address, the MAC address priority of the entry containing the source MAC address is Said P.
PCT/CN2011/078923 2011-08-25 2011-08-25 Method and device for learning media access control address WO2012162964A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN2011800016466A CN102356607A (en) 2011-08-25 2011-08-25 Method and apparatus for learning media being accessed with control address
PCT/CN2011/078923 WO2012162964A1 (en) 2011-08-25 2011-08-25 Method and device for learning media access control address

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/078923 WO2012162964A1 (en) 2011-08-25 2011-08-25 Method and device for learning media access control address

Publications (1)

Publication Number Publication Date
WO2012162964A1 true WO2012162964A1 (en) 2012-12-06

Family

ID=45579287

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/078923 WO2012162964A1 (en) 2011-08-25 2011-08-25 Method and device for learning media access control address

Country Status (2)

Country Link
CN (1) CN102356607A (en)
WO (1) WO2012162964A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104184708A (en) * 2013-05-22 2014-12-03 杭州华三通信技术有限公司 Method of inhabiting MAC address attack in EVI (Ethernet Virtualization Interconnection) network and ED (edge device)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014094229A1 (en) * 2012-12-18 2014-06-26 Telefonaktiebolaget L M Ericsson (Publ) Method and apparatus for managing media access control addresses
CN106603736B (en) * 2015-10-20 2020-05-19 中兴通讯股份有限公司 MAC address processing method and device
CN109218458B (en) * 2017-07-07 2022-05-27 中兴通讯股份有限公司 Writing method and device of MAC address and computer readable storage medium
CN108647161B (en) * 2018-04-17 2020-07-14 北京控制工程研究所 Hardware monitoring circuit for recording access address history

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1980479A (en) * 2005-12-08 2007-06-13 株式会社Ntt都科摩 Call admission control device and call admission control method
CN101447933A (en) * 2008-12-30 2009-06-03 杭州华三通信技术有限公司 Assisting method and device, method and system as well as switch device for port safety protection
CN101834788A (en) * 2010-04-16 2010-09-15 福建星网锐捷网络有限公司 Storage operation method, device and equipment of media access control address table items
CN101431472B (en) * 2008-12-15 2011-05-25 中兴通讯股份有限公司 Processing method and apparatus for media access control clauses

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101047951B (en) * 2006-03-27 2010-06-16 中兴通讯股份有限公司 Media access control station transport method in radio communication system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1980479A (en) * 2005-12-08 2007-06-13 株式会社Ntt都科摩 Call admission control device and call admission control method
CN101431472B (en) * 2008-12-15 2011-05-25 中兴通讯股份有限公司 Processing method and apparatus for media access control clauses
CN101447933A (en) * 2008-12-30 2009-06-03 杭州华三通信技术有限公司 Assisting method and device, method and system as well as switch device for port safety protection
CN101834788A (en) * 2010-04-16 2010-09-15 福建星网锐捷网络有限公司 Storage operation method, device and equipment of media access control address table items

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104184708A (en) * 2013-05-22 2014-12-03 杭州华三通信技术有限公司 Method of inhabiting MAC address attack in EVI (Ethernet Virtualization Interconnection) network and ED (edge device)
CN104184708B (en) * 2013-05-22 2017-07-14 新华三技术有限公司 Suppress the method and edge device ED of MAC Address attack in EVI networks

Also Published As

Publication number Publication date
CN102356607A (en) 2012-02-15

Similar Documents

Publication Publication Date Title
EP1557007B1 (en) Multi- tiered virtual local area network (vlan) domain mapping mechanism
US7778254B2 (en) Method for managing congestion in a network switch
US6850521B1 (en) Network switch
US8230110B2 (en) Work-conserving packet scheduling in network devices
US8553543B2 (en) Traffic shaping method and device
US20040057437A1 (en) Methods and systems for providing differentiated quality of service in a communications system
US20050047411A1 (en) Network switch
CN100499529C (en) Jitter detection based congestion control method in city domain Ethernet
CN1913486A (en) Method and device for strengthening safety of protocol message
US11863459B2 (en) Packet processing method and apparatus
WO2012162964A1 (en) Method and device for learning media access control address
EP3188419B1 (en) Packet storing and forwarding method and circuit, and device
EP2939378B1 (en) Method and network element for packet job scheduler in data processing based on workload self-learning
GB2462060A (en) Emulated LAN (ELAN) including specifying ports of a service member set and flooding a packet to the permitted members of the set.
US8553539B2 (en) Method and system for packet traffic congestion management
US10764177B2 (en) Efficient implementation of complex network segmentation
JP4276094B2 (en) Communication apparatus and priority control method for performing priority control of packet
EP2107724B1 (en) Improved MAC address learning

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201180001646.6

Country of ref document: CN

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

Ref document number: 11866817

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: 11866817

Country of ref document: EP

Kind code of ref document: A1