Method for learning media access control address, network device, and system
First Claim
1. A method of learning a media access control (MAC) address for a network device, comprising:
- performing by the network device;
generating a key value according to a key field of a received packet, and obtaining an index value corresponding to the key value according to the key value;
performing a linear random iteration on the index value according to a preset number of iterations to obtain an iteration index value;
searching, according to the iteration index value obtained during a first iteration, in a MAC address pool for a MAC address corresponding to the iteration index value obtained during the first iteration;
if failing to find a MAC address corresponding to the iteration index value obtained during the first iteration in the MAC address pool, determining whether there is still an idle MAC address space in the MAC address pool, and continuing to perform another iteration; and
when number of iterations reach a preset maximum number of iterations, if still failing to find MAC addresses corresponding to iteration index values obtained during iterations and determining that there is still an idle MAC address space in the MAC address pool, learning a MAC address of the received packet at a position where a first idle MAC address space appears.
2 Assignments
0 Petitions
Accused Products
Abstract
Embodiments of the present invention provide a method for learning a media access control address, a network device and a system. The method includes: generating a key value according to a key field of a received packet, and obtaining an index value corresponding to the key value according to the key value; performing a linear random iteration on the index value according to a preset number of iterations; searching, according to an iteration index value obtained during a first iteration, in a MAC address pool for a MAC address corresponding to the iteration index value obtained during the first iteration; and learning a MAC address of the packet according to a search result. By using the embodiments of the present invention a media access control address space may be fully utilized, and the problem of media access control address conflicts may be solved to the greatest extent.
7 Citations
11 Claims
-
1. A method of learning a media access control (MAC) address for a network device, comprising:
performing by the network device; generating a key value according to a key field of a received packet, and obtaining an index value corresponding to the key value according to the key value; performing a linear random iteration on the index value according to a preset number of iterations to obtain an iteration index value; searching, according to the iteration index value obtained during a first iteration, in a MAC address pool for a MAC address corresponding to the iteration index value obtained during the first iteration; if failing to find a MAC address corresponding to the iteration index value obtained during the first iteration in the MAC address pool, determining whether there is still an idle MAC address space in the MAC address pool, and continuing to perform another iteration; and when number of iterations reach a preset maximum number of iterations, if still failing to find MAC addresses corresponding to iteration index values obtained during iterations and determining that there is still an idle MAC address space in the MAC address pool, learning a MAC address of the received packet at a position where a first idle MAC address space appears. - View Dependent Claims (2, 3, 4, 5)
-
6. A network device, comprising:
-
a non-transitory computer-readable medium to store computer program codes, and computer hardware configured, including configured by the programs, to implement; a generating module, configured to generate a key value according to a key field of a received packet; an obtaining module, configured to obtain an index value corresponding to the key value according to the key value generated by the generating module; an iteration module, configured to perform, according to a preset number of iterations, a linear random iteration on the index value obtained by the obtaining module to obtain an iteration index value; a searching module, configured to search, according to the iteration index value obtained during a first iteration, in a media access control (MAC) address pool for a MAC address corresponding to the iteration index value obtained during the first iteration; a determining module, configured to;
when the searching module does not find a MAC address corresponding to the iteration index value obtained during the first iteration in the MAC address pool, determine whether there is still an idle MAC address space in the MAC address pool, and instruct the iteration module to continue to perform another iteration; anda learning module, configured to;
when number of iterations reach a preset maximum number of iterations, if the searching module still fails to find MAC addresses corresponding to iteration index values obtained by the iteration module during iterations in the MAC address pool and the determining module determines that there is still an idle MAC address space in the MAC address pool, learn a MAC address of the received packet at a position where a first idle MAC address space appears in the MAC address pool. - View Dependent Claims (7, 8, 9, 10)
-
-
11. A non-transitory computer readable medium storing, comprising computer program code which when executed cause the computer to perform:
-
generating a key value according to a key field of a received packet, and obtaining an index value corresponding to the key value according to the key value; performing a linear random iteration on the index value according to a preset number of iterations to obtain an iteration index value; searching, according to the iteration index value obtained during a first iteration, in a MAC address pool for a MAC address corresponding to the iteration index value obtained during the first iteration; if failing to find a MAC address corresponding to the iteration index value obtained during the first iteration in the MAC address pool, determining whether there is still an idle MAC address space in the MAC address pool, and continuing to perform another iteration; and when number of iterations reach a preset maximum number of iterations, if still failing to find MAC addresses corresponding to iteration index values obtained during iterations and determining that there is still an idle MAC address space in the MAC address pool, learning a MAC address of the received packet at a position where a first idle MAC address space appears.
-
Specification