Method, apparatus, member device, system and storage medium for mac address allocation
By determining the base MAC address and demand in the stacked system, the MAC address allocation of virtual machines is optimized, solving the problem of resource waste in the prior art and improving resource utilization.
Patent Information
- Application Number
- CN202310120215.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2043-02-15
AI Technical Summary
Existing technologies for MAC address allocation in stacked systems lead to resource waste, requiring the reservation of a large number of MAC addresses, especially in virtual machine environments where resource utilization efficiency is low.
By determining the base MAC address and demand in the stacking system, the range of MAC addresses for each virtual machine is obtained from the local database and determined accordingly, reducing the number of reserved addresses, and allocating based on the base MAC address and the base MAC address demand.
This effectively reduces the number of reserved MAC addresses, avoids resource waste, and improves resource utilization.
Smart Images

Figure CN116366599B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data communication, in particular to a MAC address allocation method, device, member device, system and storage medium. BACKGROUND
[0002] At present, the MAC address allocation mode of the second layer physical port, the second layer logical port and the third layer port under the stacking system is as follows: a range of MAC addresses is planned in advance for the stacking system, that is, when the stacking system is established, the range of MAC addresses required by the stacking system is calculated according to the "stacking system starting MAC address and stacking domain", and then the MAC addresses are allocated for the second layer physical port, the second layer logical port and the third layer port.
[0003] For the virtual machine under the stacking system, "the number of virtual machines × the number of stacking domains × the number of MAC addresses required by each virtual machine" MAC addresses need to be reserved, for example, the number of virtual machines in the stacking system is 7, the number of stacking domains is 255, and the number of MAC addresses required by each virtual machine is 5, so 8925 MAC addresses need to be reserved, obviously this reservation mode is a waste of resources. SUMMARY
[0004] In order to overcome the shortcomings of the prior art, the embodiments of the present application provide a MAC address allocation method, device, member device, system and storage medium, which can reduce the number of MAC addresses to be reserved and avoid resource waste.
[0005] The technical scheme of the embodiments of the present application can be implemented as follows:
[0006] In a first aspect, the embodiments of the present application provide a MAC address allocation method applied to a member device in a stacking system, the member device running a virtual machine, and the method comprising:
[0007] obtaining a pre-acquired basic MAC address and a basic MAC address requirement from a local database, wherein the basic MAC address is a starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacking system, and the basic MAC address requirement is the number of MAC addresses used by each virtual machine running on the member device as the master device in the stacking system;
[0008] determining the MAC address range allocated to each virtual machine of the self device based on the basic MAC address and the basic MAC address requirement.
[0009] Optionally, the MAC address range comprises a start MAC address and an end MAC address, and the step of determining the MAC address range allocated to each virtual machine of the self device based on the base MAC address and the base MAC address requirement quantity comprises:
[0010] For any virtual machine of the self device, an address offset quantity is obtained according to a preset number of the virtual machine and the base MAC address requirement quantity;
[0011] The start MAC address is determined according to the base MAC address and the address offset quantity;
[0012] The end MAC address is determined according to the start MAC address and the base MAC address requirement quantity;
[0013] The MAC address range allocated to the virtual machine is determined according to the start MAC address and the end MAC address.
[0014] Optionally, the step of obtaining the address offset quantity according to the preset number of the virtual machine and the base MAC address requirement quantity comprises:
[0015] The product of the preset number of the virtual machine and the base MAC address requirement quantity is taken as the address offset quantity.
[0016] Optionally, before the step of taking the pre-acquired base MAC address and base requirement quantity from the local database, the method further comprises:
[0017] When the stacking system is built, a preset MAC address start value and a preset MAC address requirement quantity stored in the local database and corresponding to the self device are encapsulated into a management packet;
[0018] The management packet is broadcasted to other member devices in the stacking system, so that other member devices in the stacking system determine the base MAC address and the base MAC address requirement quantity according to the preset MAC address start value and the preset MAC address requirement quantity carried in the management packet when the stacking system is built.
[0019] Optionally, before the step of encapsulating the preset MAC address start value and the preset MAC address requirement quantity stored in the local database and corresponding to the self device into the management packet, the method further comprises:
[0020] reading chassis information of the member device, storing preset MAC address start value and preset MAC address requirement for the member device in the chassis information in a local database, so that when the stacking system is built, the base MAC address and the base MAC address requirement are determined according to the preset MAC address start value and the preset MAC address requirement for the member device stored in the local database.
[0021] Optionally, the method further comprises:
[0022] receiving a management packet broadcasted by other member devices in the stacking system when the stacking system is built;
[0023] storing preset MAC address start value and preset MAC address requirement for the other member devices carried in the management packet in a local database, so that when the stacking system is built, the base MAC address and the base MAC address requirement are determined according to the preset MAC address start value and the preset MAC address requirement for the other member devices stored in the local database.
[0024] In a second aspect, an embodiment of the present application provides a MAC address allocation apparatus applied to a member device in a stacking system, wherein the member device runs a virtual machine, and the apparatus comprises:
[0025] an obtaining module, configured to obtain a base MAC address and a base MAC address requirement obtained in advance from a local database, wherein the base MAC address is a start value of a MAC address used by a virtual machine running on a member device serving as a master device in the stacking system, and the base MAC address requirement is a number of MAC addresses used by each virtual machine running on the member device serving as the master device in the stacking system;
[0026] a determining module, configured to determine a MAC address range of each virtual machine of the member device based on the base MAC address and the base MAC address requirement.
[0027] In a third aspect, an embodiment of the present application provides a member device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the MAC address allocation method in the first aspect.
[0028] In a fourth aspect, an embodiment of the present application provides a stacking system, comprising a plurality of member devices in the third aspect.
[0029] In a fifth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the MAC address allocation method in the first aspect.
[0030] Compared with the prior art, the MAC address allocation method applied to the member device running the virtual machine in the stacking system provided by the embodiment of the present application firstly takes out the pre-acquired basic MAC address and basic MAC address demand from the local database, wherein the basic MAC address is the starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacking system, and the basic MAC address demand is the number of the MAC addresses used by the virtual machine running on the member device as the master device in the stacking system; then, the MAC address range of each virtual machine allocated to the self device is determined based on the basic MAC address and the basic MAC address demand. Since the starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacking system and the number of the MAC addresses used by the virtual machine are taken as the basis for allocating the MAC address to each virtual machine running on each member device, the number of the reserved MAC addresses is reduced, and resource waste is avoided. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation on the scope, and for those of ordinary skill in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0032] Figure 1 A structural schematic diagram of the stacking system provided by the embodiment of the present application;
[0033] Figure 2 A flowchart of the MAC address allocation method provided by the embodiment of the present application Figure 1 ;
[0034] Figure 3 A flowchart of the MAC address allocation method provided by the embodiment of the present application Figure 2 ;
[0035] Figure 4 A MAC address allocation process example diagram provided by the embodiment of the present application;
[0036] Figure 5 A functional unit block diagram of the MAC address allocation device provided by the embodiment of the present application;
[0037] Figure 6 A structural schematic block diagram of the member device provided by the embodiment of the present application.
[0038] Icons: 100-MAC address allocation device; 101-Acquisition module; 102-Determination module; 103-Broadcast module; 104-Reading module; 105-Receiving module; 200-Member device; 210-Memory; 220-Processor. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0040] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0041] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0042] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0043] like Figure 1 As shown, a stacking system connects multiple network devices via stacking links using virtual switching technology, presenting them externally as a single, larger virtual device. This simplifies network topology, reduces user costs, multiplies bandwidth, and improves device reliability. These network devices in a stacking system are collectively referred to as member devices. Among the multiple member devices participating in the stacking, one member device is the master device, and the others are slave devices. The master device is in an active state, acting as the manager and controller, while the other member devices are in a standby state.
[0044] With the continuous development of Internet, the data volume presents explosive growth, in the face of massive data, the performance of processing data of each member device is also improved, and even the resource surplus condition appears. In order to fully improve the resource utilization of the member device, the virtualization technology is widely used for the member device, therefore, the virtual machine application technology of the stacking system is also born. Generally, at least one virtual machine is enabled on each member device in the stacking system, and the virtual machine of the member device as the master device is in the active state, and the virtual machine of the member device as the slave device is in the standby state.
[0045] At present, in the stacking system, the allocation mode of the MAC address of the two-layer physical port, the two-layer logical port and the three-layer port is that a certain range of MAC addresses is planned in advance for the stacking system, that is, the MAC address managed by the stacking system is calculated according to the "stacking system starting MAC address and stacking domain" when the stacking system is established, and then is allocated for the two-layer physical port, the two-layer logical port and the three-layer port.
[0046] The virtual machine in the stacking system must have a MAC address to run the protocol control plane, and the virtual machine can run as an independent logical device, and the MAC address allocation of the virtual machine in the stacking system is also in the above-mentioned mode, that is, at least one virtual machine is created on each member device after the stacking system is established, in order to allocate the MAC address for the two-layer physical port, the two-layer logical port and the three-layer port in the virtual machine, it is necessary to reserve "the number of virtual machines × the number of stacking domains × the number of MAC addresses required by each virtual machine" MAC addresses, for example, the number of virtual machines created in the stacking system is 7, the number of stacking domains is 255, and the number of MAC addresses required by each virtual machine is 5, so 7 × 255 × 5 = 8925 MAC addresses need to be reserved, obviously, this reservation mode is a waste of resources.
[0047] In order to reduce the number of MAC address reservations and avoid resource waste, the embodiment of the present application provides a MAC address allocation method for a member device running a virtual machine in a stacking system as shown in the figure. Figure 1 The MAC address allocation method will be described in detail below.
[0048] Please refer to Figure 2 , the MAC address allocation method includes steps S101-S102.
[0049] S101, the pre-acquired basic MAC address and the basic MAC address requirement are taken out from the local database.
[0050] Among them, the basic MAC address is the starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacking system, and the basic MAC address requirement is the number of MAC addresses used by the virtual machine running on the member device as the master device in the stacking system.
[0051] S102, determining a MAC address range of each virtual machine allocated to the self device based on the base MAC address and the base MAC address requirement.
[0052] The MAC address range comprises a start MAC address and an end MAC address.
[0053] As a possible implementation, the step S102 can comprise sub-steps S102-1-S02-4.
[0054] S102-1, obtaining an address offset of any virtual machine of the self device according to the preset number of the virtual machine and the base MAC address requirement.
[0055] The address offset represents a distance between the start MAC address and the base MAC address.
[0056] In the embodiment of the application, the product of the preset number of each virtual machine and the base MAC address requirement can be taken as the corresponding address offset of each virtual machine.
[0057] Exemplarily, assuming that the preset number of a virtual machine is 1 and the base MAC address requirement is 5, the address offset obtained by multiplication calculation is 1x5=5.
[0058] S102-2, determining the start MAC address according to the base MAC address and the address offset.
[0059] In the embodiment of the application, the start MAC address=base MAC address+address offset.
[0060] Exemplarily, assuming that the address offset obtained according to the preset number of the virtual machine and the base MAC address requirement is 5 and the base MAC address is 0033.0000.0010, the sum of the two, i.e. 0033.0000.0015, is the start MAC address.
[0061] S102-3, determining the end MAC address according to the start MAC address and the base MAC address requirement.
[0062] In the embodiment of the application, the end MAC address=start MAC address+base MAC address requirement-1.
[0063] Exemplarily, assuming that the base MAC address requirement is 5 and the start MAC address obtained by the foregoing steps S102-1-S102-2 is 0033.0000.0015, the end MAC address can be calculated as 0033.0000.0019.
[0064] S102-4, determining the MAC address range allocated to the virtual machine according to the start MAC address and the end MAC address.
[0065] Exemplarily, assuming that the start MAC address is 0033.0000.0015 and the end MAC address is 0033.0000.0019 obtained by adopting the foregoing steps S102-1 to S102-3, the MAC address range allocated to the virtual machine numbered 1 is 0033.0000.0015-0033.0000.0019, i.e. including 0033.0000.0015, 0033.0000.0016, 0033.0000.0017, 0033.0000.0018 and 0033.0000.0019.
[0066] For the entire stacking system, the number of reserved MAC addresses is "the number of virtual machines x the basic MAC address requirement", which can save resources compared to the existing way of reserving "the number of virtual machines x the number of stacking domains x the number of MAC addresses required by the virtual machine". The MAC addresses reserved by each member device of the stacking system are the same.
[0067] From the foregoing, it can be seen that the MAC address allocation of the virtual machine is based on the basic MAC address and the basic MAC address requirement pre-acquired and stored in the local database of the member device running the virtual machine. Therefore, how to make the local database of the member device store the basic MAC address and the basic MAC address requirement will be described in detail below.
[0068] Before performing step S101, refer to Figure 3 Steps S103 to S104 also need to be performed first.
[0069] S103, when the stacking system is built, encapsulating the preset MAC address start value and the preset MAC address requirement stored in the local database for itself into a management packet.
[0070] The preset MAC address start value stored in the local database of each member device for itself is different, and the preset MAC address requirement can be the same or different.
[0071] S104, broadcasting the management packet to other member devices in the stacking system, so that other member devices in the stacking system determine the basic MAC address and the basic MAC address requirement according to the preset MAC address start value and the preset MAC address requirement carried in the management packet when the stacking system is built.
[0072] Since the base MAC address is related to the base MAC address demand, and the member device which will be the master device is not determined during the building of the stacking system, and the local database of each member device only stores the preset MAC address start value and the preset MAC address demand of itself, the preset MAC address start value and the preset MAC address demand of itself of any member device need to be encapsulated into a management message and broadcast to other member devices.
[0073] Please refer to Figure 3 The MAC address allocation method further comprises steps S105-S106 which are executed in parallel with steps S103-S104.
[0074] S105, during the building of the stacking system, receiving the management message broadcast by other member devices in the stacking system.
[0075] It can be understood that each member device is also receiving the management message broadcast by other member devices while it is broadcasting the management message to other member devices.
[0076] S106, storing the preset MAC address start value and the preset MAC address demand of other member devices carried in the management message into the local database, so that the base MAC address and the base MAC address demand can be determined according to the preset MAC address start value and the preset MAC address demand of other member devices stored in the local database when the building of the stacking system is completed.
[0077] In the embodiment of the application, through the above steps S103-S104 and steps S105-S106, the local database of any member device stores not only the preset MAC address start value and the preset MAC address demand of itself, but also the preset MAC address start value and the preset MAC address demand of each other member device.
[0078] After the building of the stacking system is completed and the member device which will be the master device is selected, each member device can directly use the preset MAC address start value of the master device stored in its local database as the base MAC address, and use the preset MAC address demand as the base MAC address demand.
[0079] The following will introduce how to make the local database of each member device store the preset MAC address start value and the preset MAC address demand of itself.
[0080] Before the execution of the procedures of steps S103-S104 and steps S105-S106, please refer to Figure 3 Step S107 also needs to be executed first.
[0081] S107, reading the chassis information of the self, storing the preset MAC address start value and the preset MAC address demand for the self written in the chassis information into the local database, so that when the stacking system is built, the base MAC address and the base MAC address demand are determined according to the preset MAC address start value and the preset MAC address demand for the self stored in the local database.
[0082] In the embodiment of the application, the chassis information of each member device in the stacking system is written with the preset MAC address start value and the preset MAC address demand for the self before leaving the factory.
[0083] When each member device is powered on to load the operating system, the preset MAC address start value and the preset MAC address demand in the chassis of the self are read and written into the local database.
[0084] The implementation principle of the MAC address allocation method will be further described below by using the following example.
[0085] As shown in Figure 4 , it is assumed that the stacking system is composed of four member devices, namely, member device 1, member device 2, member device 3 and member device 4.
[0086] The chassis information of each member device in the stacking system is written with the preset MAC address start value and the preset MAC address demand for the self before leaving the factory, wherein the preset MAC address start values written in the chassis information of the member device 1, the member device 2, the member device 3 and the member device 4 are address A, address B, address C and address D respectively, and the preset MAC address demands written in the chassis information of the member device 1, the member device 2, the member device 3 and the member device 4 are x, y, z and k respectively, wherein the preset MAC address demand in the application is the MAC address demand of a single virtual machine running on the member device.
[0087] When each member device is powered on to load the operating system, the preset MAC address start value and the preset MAC address demand for the self are read from the chassis information of the self and written into the local database.
[0088] When the stacking system is built, each member device in the stacking domain encapsulates the preset MAC address start value and the preset MAC address demand for the self into a management packet and broadcasts the management packet to all other member devices.
[0089] Each member device receives the management packet of the other member device, and writes the preset MAC address start value and the preset MAC address demand of the other member device taken from the management packet into the local database, so that the address A, the address B, the address C and the address D and the MAC address demands x, y, z and k are obtained in the local database of each member device.
[0090] When the stack system is built, a member device in the stack domain is elected as the master device of the stack system. After a virtual machine is created on the master device, the master device informs other member devices to create the virtual machine synchronously, so that each member device in the stack system creates the same number and the same number of virtual machines.
[0091] Suppose that the member device 1 is the master device, and the preset MAC address start value and the preset MAC address requirement of the member device 1 are used as the basis of the virtual machine MAC address allocation in the stack system, that is, the basis MAC address is address A, and the basis MAC address requirement is x.
[0092] Suppose that the virtual machines created on each member device in the stack system are 4, and the numbers are 0, 1, 2 and 3 respectively. Since the basis MAC address is address A and the basis MAC address requirement is x, suppose that the address A is 0033.0000.0010 and x is 5. Since the basis MAC address requirement is 5, which is the MAC address requirement of a single virtual machine, the MAC addresses of the 4 virtual machines need to be allocated respectively, and the specific allocation process is as follows:
[0093] The MAC address allocation process of the virtual machine 0: the number 0 multiplied by the basis MAC address requirement 5 obtains the address offset 0; according to the sum of the basis MAC address 0033.0000.0010 and the address offset 0, the start MAC address is 0033.0000.0010; according to the sum of the start MAC address 0033.0000.0010 and the basis MAC address requirement 5 minus 1, the end MAC address is 0033.0000.0014, and it is determined that the MAC address range allocated to the virtual machine is: 0033.0000.0010-0033.0000.0014.
[0094] The MAC address allocation process of the virtual machine 1: the number 1 multiplied by the basis MAC address requirement 5 obtains the address offset 5; according to the sum of the basis MAC address 0033.0000.0010 and the address offset 5, the start MAC address is 0033.0000.0015; according to the sum of the start MAC address 0033.0000.0015 and the basis MAC address requirement 5 minus 1, the end MAC address is 0033.0000.0019, and it is determined that the MAC address range allocated to the virtual machine is: 0033.0000.0015-0033.0000.0019.
[0095] The MAC address allocation process of the virtual machine 2: the number 2 multiplied by the base MAC address requirement 5 obtains an address offset 10; according to the sum of the base MAC address 0033.0000.0010 and the address offset 10, the start MAC address is 0033.0000.002a; according to the sum of the start MAC address 0033.0000.002a and the base MAC address requirement 5 minus 1, the end MAC address is 0033.0000.002e, and it is determined that the MAC address range allocated to the virtual machine is: 0033.0000.002a-0033.0000.002e.
[0096] The MAC address allocation process of the virtual machine 3: the number 3 multiplied by the base MAC address requirement 5 obtains an address offset 15; according to the sum of the base MAC address 0033.0000.0010 and the address offset 15, the start MAC address is 0033.0000.002f; according to the sum of the start MAC address 0033.0000.002f and the base MAC address requirement 5 minus 1, the end MAC address is 0033.0000.0033, and it is determined that the MAC address range allocated to the virtual machine is: 0033.0000.002f-0033.0000.0033.
[0097] Therefore, according to the base MAC address 0033.0000.0010 of the host device and the base MAC address requirement 5, the MAC address range allocated to each virtual machine on the member device is shown in the following table:
[0098] Virtual machine number Allocated MAC address range 0 0033.0000.0010-0033.0000.0014 1 0033.0000.0015-0033.0000.0019 2 0033.0000.002a - 0033.0000.002e 3 0033.0000.002f-0033.0000.0033
[0099] It should be noted that the MAC address allocation process of each virtual machine of the host device or other member device of the stacked system adopts the above steps. In order to perform the corresponding steps in the above method embodiments and various possible implementation manners, an implementation manner of a MAC address allocation apparatus 100 applied to any member device in the stacked system is given below.
[0100] Please refer to Figure 5 The MAC address allocation apparatus 100 includes an acquisition module 101, a determination module 102, a broadcast module 103, a reading module 104, and a receiving module 105.
[0101] The obtaining module 101 is configured to obtain a pre-obtained base MAC address and a base MAC address requirement quantity from a local database, wherein the base MAC address is a starting value of a MAC address used by a virtual machine running on a member device serving as a master device in a stacking system, and the base MAC address requirement quantity is a number of MAC addresses used by each virtual machine running on the member device serving as the master device in the stacking system.
[0102] The determining module 102 is configured to determine a MAC address range of each virtual machine assigned to the self device based on the base MAC address and the base MAC address requirement quantity.
[0103] Optionally, the MAC address range comprises a starting MAC address and an ending MAC address, and the determining module 102, when determining the MAC address range of each virtual machine assigned to the self device based on the base MAC address and the base MAC address requirement quantity, is specifically configured to, for any virtual machine of the self device, obtain an address offset quantity according to a preset number of the virtual machine and the base MAC address requirement quantity, determine the starting MAC address according to the base MAC address and the address offset quantity, determine the ending MAC address according to the starting MAC address and the base MAC address requirement quantity, and determine the MAC address range of the virtual machine according to the starting MAC address and the ending MAC address.
[0104] Optionally, the determining module 102, when obtaining the address offset quantity according to the preset number of the virtual machine and the base MAC address requirement quantity, is specifically configured to take a product of the preset number of the virtual machine and the base MAC address requirement quantity as the address offset quantity.
[0105] Optionally, the broadcasting module 103 is configured to encapsulate the preset MAC address starting value and the preset MAC address requirement quantity of the self device stored in the local database into a management packet when the stacking system is built, and broadcast the management packet to other member devices in the stacking system, so that the other member devices in the stacking system determine the base MAC address and the base MAC address requirement quantity according to the preset MAC address starting value and the preset MAC address requirement quantity carried in the management packet when the stacking system is built.
[0106] Optionally, the reading module 104 is configured to read chassis information of the self device, store a preset MAC address starting value and a preset MAC address requirement quantity of the self device pre-written in the chassis information into the local database, so that the base MAC address and the base MAC address requirement quantity are determined according to the preset MAC address starting value and the preset MAC address requirement quantity of the self device stored in the local database when the stacking system is built.
[0107] Optionally, the receiving module 105 is configured to receive a management packet broadcast by other member devices in the stacking system during the building of the stacking system, and store preset MAC address start values and preset MAC address requirements for the other member devices carried in the management packet into a local database, so that the base MAC address and the base MAC address requirement are determined according to the preset MAC address start values and the preset MAC address requirements for the other member devices stored in the local database when the building of the stacking system is completed.
[0108] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the MAC address allocation apparatus 100 described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0109] Further, the embodiment of the present application also provides a member device 200, please refer to Figure 6 The member device 200 can include a memory 210 and a processor 220.
[0110] The processor 220 can be a general central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the MAC address allocation method provided by the foregoing method embodiments.
[0111] The memory 210 can be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, and can also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but not limited to this. The memory 210 can exist independently and be connected to the processor 220 through a communication bus. The memory 210 can also be integrated with the processor 220. The memory 210 is configured to store machine executable instructions for executing the scheme of the present application. The processor 220 is configured to execute the machine executable instructions stored in the memory 210 to implement the foregoing method embodiments.
[0112] The embodiment of the present application further provides a computer readable storage medium comprising a computer program, which, when executed, can be used to perform the related operations in the MAC address allocation method provided by the method embodiment.
[0113] To sum up, the MAC address allocation method, device, member device, system and storage medium provided by the embodiment of the present application firstly take out the pre-acquired basic MAC address and basic MAC address demand from the local database, wherein the basic MAC address is the starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacked system, and the basic MAC address demand is the number of MAC addresses used by each virtual machine running on the member device as the master device in the stacked system; then, based on the basic MAC address and the basic MAC address demand, the MAC address range allocated to each virtual machine of the self device is determined. Since the starting value of the MAC address used by the virtual machine running on the member device as the master device in the stacked system and the number of MAC addresses used are used as the basis for allocating the MAC address to each virtual machine running on each member device, the number of reserved MAC addresses is reduced, and resource waste is avoided.
[0114] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method of MAC address allocation, characterized by, The method is applied to a member device in a stacking system, the member device runs a virtual machine, and the method comprises the following steps: When the stacking system is built, a preset MAC address start value and a preset MAC address requirement amount stored in a local database for the member device are encapsulated into a management packet; The management packet is broadcasted to other member devices in the stacking system, so that other member devices in the stacking system determine a base MAC address and a base MAC address requirement amount according to the preset MAC address start value and the preset MAC address requirement amount carried in the management packet when the stacking system is built; The base MAC address and the base MAC address requirement amount obtained in advance are taken out from the local database, wherein the base MAC address is a start value of a MAC address used by the virtual machine running on the member device serving as the master device in the stacking system, and the base MAC address requirement amount is a number of MAC addresses used by each virtual machine running on the member device serving as the master device in the stacking system; Based on the base MAC address and the base MAC address requirement amount, a MAC address range of each virtual machine allocated to the member device is determined.
2. The method of claim 1, wherein, The MAC address range comprises a start MAC address and an end MAC address, and the step of determining the MAC address range of each virtual machine allocated to the member device based on the base MAC address and the base MAC address requirement amount comprises the following steps: For any virtual machine of the member device, an address offset is obtained according to a preset number of the virtual machine and the base MAC address requirement amount; The start MAC address is determined according to the base MAC address and the address offset; The end MAC address is determined according to the start MAC address and the base MAC address requirement amount; The MAC address range allocated to the virtual machine is determined according to the start MAC address and the end MAC address.
3. The method of claim 2, wherein, The step of obtaining the address offset according to the preset number of the virtual machine and the base MAC address requirement amount comprises the following step: The product of the preset number of the virtual machine and the base MAC address requirement amount is taken as the address offset.
4. The method of claim 1, wherein, Before the step of encapsulating the preset MAC address start value and the preset MAC address requirement amount stored in the local database for the member device into the management packet, the method further comprises the following step: The chassis information of the member device is read, and the preset MAC address start value and the preset MAC address requirement amount written in advance in the chassis information for the member device are stored in the local database, so that the base MAC address and the base MAC address requirement amount are determined according to the preset MAC address start value and the preset MAC address requirement amount stored in the local database for the member device when the stacking system is built.
5. The method of claim 1, wherein, The method further comprises the following steps: When the stacking system is built, the management packet broadcasted by other member devices in the stacking system is received; The base MAC address and the base MAC address requirement amount are determined according to the preset MAC address start value and the preset MAC address requirement amount carried in the management packet; The preset MAC address start value and the preset MAC address requirement quantity for other member devices carried in the management packet are stored in the local database, so that when the stack system is built, the base MAC address and the base MAC address requirement quantity are determined according to the preset MAC address start value and the preset MAC address requirement quantity for other member devices stored in the local database.
6. A MAC address allocation apparatus characterized by comprising: The member device is applied to a stack system, and a virtual machine runs on the member device. The broadcast module is configured to encapsulate the preset MAC address start value and the preset MAC address requirement quantity for the member device stored in the local database into a management packet when the stack system is built, and broadcast the management packet to other member devices in the stack system, so that other member devices in the stack system determine the base MAC address and the base MAC address requirement quantity according to the preset MAC address start value and the preset MAC address requirement quantity carried in the management packet when the stack system is built. The acquisition module is configured to acquire the base MAC address and the base MAC address requirement quantity from the local database, wherein the base MAC address is a start value of a MAC address used by a virtual machine running on a member device serving as a master device in the stack system, and the base MAC address requirement quantity is a number of MAC addresses used by each virtual machine running on the member device serving as the master device in the stack system. The determination module is configured to determine a MAC address range of each virtual machine allocated to the member device based on the base MAC address and the base MAC address requirement quantity.
7. A member device, characterized by The stack system comprises a plurality of member devices as claimed in claim 7.
8. A stacking system characterized by, The stack system comprises a plurality of member devices as claimed in claim 7.
9. A computer-readable storage medium, characterized in that, The stack system comprises a plurality of member devices as claimed in claim 7.
Citation Information
Patent Citations
MAC address burning method and system
CN110471676A