Address generation method and device, computer readable storage medium and electronic equipment
By generating virtual MAC addresses based on the number of startups and real MAC addresses in the device, and updating them when the board is replaced, the problem of changes and conflicts of virtual MAC addresses is solved, and the stability and uniqueness of virtual MAC addresses are achieved, improving the stability and uniqueness of virtual MAC addresses Maintainability of equipment.
Patent Information
- Application Number
- CN202411432705.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-07
AI Technical Summary
In the prior art, the virtual MAC address is prone to change and conflicts with the virtual MAC addresses of other devices, affecting the maintainability and address management of the device.
By receiving the device's startup request, sending a startup signal to the target board, obtaining the virtual MAC address generated in the target board based on the number of device startup times and the real MAC address, and storing it as the device's virtual MAC address to ensure that the virtual MAC address is in The device remains unchanged when it is constantly powered, and is sent to the corresponding board when the board is replaced.
The uniqueness and stability of the virtual MAC address is realized, and the conflicts with the virtual MAC address with other devices are avoided, address management is facilitated, and the maintenance of the device is improved.
Smart Images

Figure CN119276830A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of address management technology, and in particular to an address generation method, device, computer-readable storage medium and electronic device. Background Art
[0002] There are currently two methods for generating virtual MAC addresses. Solution 1: The main control board and the backup control board each keep their own MAC addresses. When the main control board is working, the MAC address displayed by the device is the MAC address of the main control board. The backup control board reads the MAC address of the main control board and stores it. When the main control board is abnormal, the backup control board works and displays the MAC address it reads from the main control board to ensure that the MAC address will not change. Solution 2: The MAC address is not stored in the control board, but is stored on the backplane, which is not pluggable. When the prototype is working, the main control board reads the MAC address on the backplane. When the main control board is abnormal, the backup control board also reads the MAC address on the backplane. In this way, the MAC address of the device is always the MAC address on the backplane, thereby ensuring that the MAC address will not change.
[0003] However, there are some problems with the above two solutions. Solution 1: When the prototype is started for the first time, the MAC address of its main control board can be used as the MAC address of the entire device. If all control boards are unplugged and then reinserted with a new control board, the MAC address of the device will change. If only one control board is replaced at a time, its MAC address will not change. Solution 2: To store the MAC address on the backplane, it is necessary to place a storage device on the backplane, which will reduce the reliability of the backplane. When other boards have abnormalities, you can simply unplug and replace the board. The backplane is not pluggable. If the backplane device has an abnormality, the device is damaged and can only be repaired, which reduces the maintainability of the device. Moreover, the backplane stores the MAC. When one board is reading and writing, plugging in and out of another board will affect the reading and writing results. Other measures are needed to ensure the correctness of the reading and writing.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] Embodiments of the present invention provide an address generation method, apparatus, computer-readable storage medium, and electronic device to at least solve the technical problem that the virtual MAC address of a current device is prone to change and conflicts with the virtual MAC addresses of other devices.
[0006] According to one aspect of an embodiment of the present invention, an address generation method is provided, including: receiving a startup request of a device; sending a startup signal to a target board in the device based on the startup request; acquiring a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; and storing the virtual MAC address as the virtual MAC address of the device.
[0007] Optionally, the method further includes sending the virtual MAC address to other boards in the device except the target board and the main control board for storage.
[0008] Optionally, the method further includes: when a first board in the device is replaced and the device is not restarted, sending the virtual MAC address to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
[0009] Optionally, when a main control board in the device is replaced, it also includes: obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; determining whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; if the virtual MAC addresses stored in other boards except the replaced main control board are the same, storing the virtual MAC address in the replaced main control board.
[0010] Optionally, when the virtual MAC addresses stored in other boards except the replaced main control board are different, obtain the check code corresponding to the virtual MAC address stored in the other boards; based on the check code, correct the virtual MAC address stored in the other boards to obtain the target virtual MAC address; store the target virtual MAC address in the replaced main control board.
[0011] Optionally, the target board is a power board in the device.
[0012] Optionally, the method further includes: when there are multiple power boards in the device, based on the priorities of the multiple power boards, selecting the power board with the highest priority as the target board.
[0013] According to another aspect of the present invention, an address generating device is provided, comprising: a receiving module for receiving a startup request of a device; a sending module for sending a startup signal to a target board in the device based on the startup request; an acquiring module for acquiring a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; and a storing module for storing the virtual MAC address as the virtual MAC address of the device.
[0014] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned address generation methods.
[0015] According to another aspect of the present invention, there is provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein any one of the above-mentioned address generation methods is executed when the program is run.
[0016] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned address generation methods are implemented.
[0017] In the embodiment of the present invention, an address generation method is adopted to achieve the purpose that the virtual MAC address of the device will not change when the device is powered on, thereby achieving the technical effect of facilitating address management, and further solving the technical problem that the virtual MAC address of the current device is prone to change and conflicts with the virtual MAC address of other devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0019] Figure 1 is a flow chart of an address generation method provided according to an embodiment of the present invention;
[0020] Figure 2 is a schematic diagram of board-card interaction in an address generation method provided in an optional embodiment of the present invention;
[0021] Figure 3 is a structural block diagram of an address generating device provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0025] A virtual MAC address is a MAC address used in a virtualized environment to represent a virtual device or network interface.
[0026] The real MAC address (Media Access Control Address) is a unique identifier for a network interface card or device used for network communications. It is a unique set of 12 hexadecimal digits (48 bits in total) assigned by the device manufacturer during the production process and embedded in the hardware.
[0027] Chassis refers to a box or frame used to carry and organize multiple hardware components. It is widely used in various computing, storage and network devices. The main function of a chassis is to provide a structured environment for installing, managing and maintaining multiple modules or boards.
[0028] For any electronic device, a unique MAC address is required as the identification code of the device. During the operation of the device, the MAC address cannot be changed, otherwise the management and business will be interrupted. For general equipment, the MAC address of the prototype can be guaranteed not to change during use, and for frame equipment, there are generally two control boards, which can be plugged in and out, and can be used as redundant backups. When the main control board is abnormal, switch to the spare control board to take over the entire frame, replace the main control board, and the MAC address of the entire device will change. In response to the above technical problems, the present invention provides an embodiment of an address generation method. According to an embodiment of the present invention, a method embodiment of an address generation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0029] Figure 1 is a flow chart of an address generation method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0030] Step S102: receiving a startup request of a device.
[0031] Optionally, the execution subject of the method of this embodiment can be a main control board in the device, wherein the device can be a frame device, and the frame device generally has multiple control boards, multiple service boards, multiple fan boards, multiple power boards and other boards, which are inserted into the card slots of the frame device. Because the boards in the frame device can be plugged in and out at will, the virtual MAC address of the frame device is prone to change. Among them, the main control board is the main control board in the device, which is responsible for handling the main control, management and processing tasks of the device. Usually, there will be a spare control board in the frame device. When the main control board is abnormal, the spare control board can take over the work of the main control board.
[0032] When the device is started, that is, when the device is powered on, the main control board in the device will receive a startup request. Usually when the device is started, there will be a startup sequence, which is controlled by the main control board in the chassis. In most cases, when the power is turned on and the device starts to start, the main control board will receive the startup request and then send a startup signal to other boards. This startup signal can be transmitted through the backplane bus inside the chassis or other internal communication mechanisms to ensure that all boards can receive the startup request and perform the corresponding initialization operations.
[0033] Step S104: Based on the start request, a start signal is sent to a target board in the device.
[0034] After receiving the startup request, the main control board will send the startup signal to other boards, including the target board, which can be any board with a real MAC address in the device. This is because the virtual MAC address of the device needs to be generated based on the real MAC address of the target board.
[0035] Step S106, obtaining a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board after receiving the startup signal based on the number of device startups and the real MAC address of the target board.
[0036] After receiving the startup signal, the target board will generate a virtual MAC address based on the number of times the device is started and its own real MAC address. The number of times the device is started will be updated after each restart, while the real MAC address of the target board will not change. During the production process of the board, the real MAC address will be written into the board as the unique identifier of the board. Therefore, even if the number of startups is the same in different devices, the real MAC addresses corresponding to the boards are different, and the virtual MAC addresses generated are also different, avoiding the phenomenon of virtual MAC address conflicts and achieving the technical effect of convenient address management.
[0037] When the device is powered on, the main control board will receive the startup request and send a startup signal to other boards. The target board will update the device startup count based on the startup signal. That is, after the device is powered on, the device startup count will be accumulated. Each time the device is started, the startup count will increase by one. The device startup count is stored in the target board, which makes it easy for the target board to read the startup count and generate a virtual MAC address. Then, the virtual MAC address is generated based on the updated device startup count and the real MAC address.
[0038] There are many methods for generating a virtual MAC address in the target board based on the number of device startups and its own real MAC address. For example, the real MAC address can be directly added or subtracted from the number of device startups as the virtual MAC address; or an intermediate value can be generated based on the number of device startups, and then the virtual MAC address is obtained based on the sum of the intermediate value and the real MAC address.
[0039] The target board can be multiple boards, that is, a virtual MAC address is generated based on one or more real MAC addresses combined with the number of startups. For example, the difference between the real MAC addresses corresponding to the two boards and the sum of the number of startups can be used as the virtual MAC address of the entire device. Because the real MAC address is the unique identifier of each board, and the number of startups will be updated according to the device startup, it is guaranteed that the virtual MAC address will not change as long as the device is not restarted, and it is difficult to be the same as the virtual MAC address of other devices, which facilitates address management. Based on the real MAC address, and distinguishing the differences between each power-on of the device, a virtual MAC address is generated to ensure the uniqueness of the generated virtual MAC address.
[0040] In this way, even if different boards are plugged in and out, the device's virtual MAC address will not change if the device is powered on. When the device is powered off and restarted, the virtual MAC address will change, that is, the virtual MAC address will be different each time it is powered on. This ensures the uniqueness of the virtual MAC address, reduces the probability of duplication of virtual MAC addresses with other devices, and facilitates address management.
[0041] The number of startups may also be based on other criteria for determining whether the device is restarted. For example, if a light turns on each time the device is started, the number of startups recorded here may also be the number of times the light turns on.
[0042] The main control board obtains the virtual MAC address stored in the target board, and the main control board can be set. The place where the virtual MAC address is stored in the target board is queried continuously or at a certain frequency within a preset period of time after the device is started, until the virtual MAC address generated by the target board is obtained. The target board can also be configured to generate a prompt signal after the virtual MAC address is generated and sent to the main control board to prompt the main control board that the virtual MAC address can be obtained. Among them, obtaining the virtual MAC address, that is, data transmission between boards in the frame device can include a variety of methods, such as a backplane bus, and the boards communicate through a dedicated bus on the backplane. These buses can be standard buses or dedicated bus designs. There is also a point-to-point connection, where data is transmitted between boards through a dedicated point-to-point connection line. This method is usually used for high-speed and low-latency communication requirements.
[0043] Step S108: The virtual MAC address is used as the virtual MAC address of the device and stored.
[0044] After the device is powered on, the virtual MAC addresses of all boards in the device are empty, so the main control board needs to obtain the virtual MAC address generated in the target board and store it as the virtual MAC address of the device.
[0045] Through the above steps, the purpose of ensuring that the virtual MAC address of the device does not change when the device is powered on is achieved, thereby achieving the technical effect of facilitating address management, and further solving the technical problem that the virtual MAC address of the current device is prone to change and conflicts with the virtual MAC address of other devices.
[0046] As an optional embodiment, the virtual MAC address is sent to other boards in the device except the target board and the main control board for storage.
[0047] The main control board can send the virtual MAC address to the board in the device that does not have a virtual MAC address yet, that is, each board in the device stores the virtual MAC address generated in the target board in the virtual MAC address of its own board, and the virtual MAC address displayed by the device to the outside is also the virtual MAC address. Saving the virtual MAC address to all boards facilitates the management of virtual MAC addresses when plugging and unplugging boards, that is, when replacing boards, as long as there are still boards that have not been replaced, the virtual MAC address can be saved in the replaced boards. In this way, as long as the device is powered on, the virtual MAC address will not change, which is convenient for address management.
[0048] As an optional embodiment, when a first board in the device is replaced and the device is not restarted, the virtual MAC address is sent to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
[0049] When the device is in operation, the first board in the device is replaced, that is, when the board in the device is replaced but not restarted, the main control board can send the stored virtual MAC address to the replaced board, and the replaced board will save the virtual MAC address as its own virtual MAC address. In this way, the virtual MAC address can still be kept unified.
[0050] If you only replace the target board in the device with the target board in another device, the replaced target boards will receive the virtual MAC addresses issued by the main control boards in their respective devices, and there will be no duplication of virtual MAC addresses. After the device is restarted, a new virtual MAC address can be regenerated based on the real MAC address of the replaced target board.
[0051] For example, when the first board is the target board, the current device is used as the first device, if the target board is changed from the first device to the second device to work. A new target board is replaced in the first device, and the virtual MAC address is sent to the new target board, and the unity of the virtual MAC address can still be maintained. In the second device, if the second device is restarted, the number of device startups stored in the target board in the second device will be updated, so that the virtual MAC address corresponding to the second device is generated by the updated number of device startups and the real MAC address of the target board, because the number of device startups is different from the number of startups when the target board is in the first device, the generated virtual MAC addresses are different. That is, although the virtual MAC addresses of the first device and the second device are both generated based on the real MAC address of the target board, due to the different number of startups, the virtual MAC addresses of the two devices are also different, avoiding the phenomenon of repeated virtual MAC addresses, and facilitating address management. If the second device is not restarted, the target board in the second device will receive the virtual MAC address sent by the main control board in the second device, which can still ensure that the virtual MAC addresses of the first device and the second device are different, avoiding the phenomenon of repeated virtual MAC addresses.
[0052] For another example, when the first board in the device has an abnormality, the board needs to be replaced. The main control board directly sends the virtual MAC address to the replaced board, which can ensure the unification of the virtual MAC addresses in the device and facilitate address management.
[0053] In addition to the main control board sending the virtual MAC address to the replaced first board, because the generated virtual MAC address is also stored in other boards except the main control board, the replaced first board can also determine its own virtual MAC address based on the virtual MAC addresses of other boards.
[0054] As an optional embodiment, when the main control board in the device is replaced, it also includes: obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; judging whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; if the virtual MAC addresses stored in other boards except the replaced main control board are the same, storing the virtual MAC address in the replaced main control board. If the virtual MAC addresses stored in other boards except the replaced main control board are different, obtaining the check code corresponding to the virtual MAC address stored in other boards; based on the check code, correcting the virtual MAC addresses stored in other boards to obtain the target virtual MAC address; storing the target virtual MAC address in the replaced main control board.
[0055] When the main control board is replaced due to an abnormality, the replaced main control board can read the virtual MAC addresses of all other boards and verify them. It is determined whether the virtual MAC addresses of other boards except the replaced main control board are the same. If they are the same, it is considered that the virtual MAC address is the virtual MAC address of the device, and the replaced main control board can save the virtual MAC address. If the obtained virtual MAC address is different, it can be determined whether an abnormality occurred in the acquisition process or in the storage. At this time, a corresponding prompt message can be generated to prompt the relevant operator to restart the device to generate a new virtual MAC address.
[0056] When performing address verification, you can also use the verification code method to verify. The use of the verification code (or verification value) can ensure the consistency and accuracy of the MAC address. When the main control board reads the MAC address of other boards, especially the virtual MAC address, for verification, it can use the following methods:
[0057] CRC check: Cyclic Redundancy Check is a commonly used checksum generation and verification method. When generating a virtual MAC address, a checksum calculated based on the CRC algorithm can be added to the address and then stored. When the main control board reads the MAC address of other boards, it also performs CRC calculation on the address and compares it with the checksum stored on the board. If they are consistent, the address is considered correct, otherwise it is considered incorrect.
[0058] Parity check: This is a relatively simple verification method that determines the integrity of the address by calculating the odd or even number of binary bits in the MAC address. When the MAC address is generated, a parity bit is added. When the address is read, the parity is calculated again and compared with the stored check bit to determine whether the address has been tampered with or damaged.
[0059] Hash check: Use the hash function to calculate the MAC address and generate a check value (hash value) of a fixed length. This value is stored on the board. When verification is required, the main control board performs a hash calculation on the read MAC address again and compares the hash value to confirm the correctness of the address.
[0060] Digital signature: If the security level requirement is high, digital signature technology can be used. When generating a MAC address, use the private key to encrypt it to generate a digital signature, which is stored on the board. After the main control board reads the MAC address, it uses the public key to decrypt the address and signature, and compares the decryption results to verify the source and integrity of the address.
[0061] In specific implementation, the generation and verification of the check code should ensure efficiency while taking into account resource consumption and security requirements, and select the most suitable verification method. For example, for environments with high real-time and resource constraints, CRC or parity check may be preferred, while for occasions with higher security requirements, digital signatures or a combination of multiple verification methods may be selected to improve the reliability of verification.
[0062] When it is detected that the virtual MAC addresses stored in other boards except the main control board are inconsistent, the check code of the virtual MAC address stored in other boards can be obtained. Based on the check code, the address can be corrected to obtain the correct virtual MAC address, that is, the target virtual MAC address. In data communication and storage systems, check codes (such as CRC, parity check, Hamming code, etc.) can be used to detect errors that may occur during data transmission or storage. When an error is detected, if a code that can correct the error (such as Hamming code) is used, the address or data can be corrected by the check code. For example, Hamming code is a linear error correction code that can detect and correct single bit errors. The construction of Hamming code is based on interweaving data bits and check bits, so that each check bit can check a part of the data bits, realizing coverage verification of data. When the target board generates a virtual MAC address, the check bit value can be calculated according to the rules of the Hamming code, and added to the data bit to form a Hamming code word, which is sent to the main control board as a virtual MAC address, and then sent to other boards by the main control board. In this way, after the main control board is replaced, the virtual MAC addresses of other boards obtained include the addresses of the check code. After obtaining the virtual MAC addresses of other boards, the replaced main control board can recalculate the check bit value and compare it with the received check bit. If the received check bit does not match the calculated check bit, it means that an error occurred during the data transmission process. By comparing the received check bit with the calculated check bit, the position of the erroneous bit can be determined by using the characteristics of the Hamming code. The Hamming code can correct single-bit errors, so the position where the calculated check bit is different from the received check bit can indicate the position of the erroneous bit. After determining the position of the erroneous bit, its value can be flipped (0 becomes 1, 1 becomes 0) to correct the error. For address correction, if a bit in the address is found to be wrong, this bit is corrected to ensure the correctness of the address.
[0063] As an optional embodiment, the target board is a power board in the device.
[0064] Because the power board is an indispensable board in the device, and the device cannot be started without the power board, the power board is selected as the target board. When the power board is unplugged from the device and inserted into the new device, the startup times will be updated after the new device is started because the power board is inserted into the new device. Even if the virtual MAC address is generated according to the real MAC address of the power board and the startup times of the device, the virtual MAC address in the new device will be different from the virtual MAC address generated in the previous device because the startup times have changed. Therefore, the virtual MAC addresses of the two devices are different, which is convenient for address management.
[0065] Optionally, the number of times the device is started is stored in the power board, so that the number of times the device is started can correspond to the power board. Because there may be multiple power boards in a device, the number of times the device is started is stored in the power board, and the number of times the device is started will move with the movement of the power board. Even if the power board of the device is unplugged and plugged into another device to start, when the new device starts, the virtual MAC address generated will be different due to the change in the number of times the power board is started, ensuring that the MAC addresses of the two frames are different. In this way, after the power board is inserted into the new device and the new device is started, the number of times the power board is started will be updated based on the previously stored number of times the power board is started, reducing the probability of duplication of the virtual MAC address with the original device.
[0066] As an optional embodiment, when there are multiple power boards in the device, based on the priorities of the multiple power boards, a power board with the highest priority is selected as the target board.
[0067] Normally, there are multiple power boards in a device, so that even if one or some of the power boards fail, the other power boards can still provide enough power to ensure the continuous operation of the system, that is, the system will not stop working due to power outages. For example, the main power board can be given the highest priority, and the backup battery board can be given a lower priority. The battery board with the highest priority can be considered a more important battery board, that is, the probability of replacement is lower. Therefore, the real MAC address corresponding to the battery board with the highest priority is used to generate a virtual MAC address. Based on the real MAC address and distinguishing the differences between each time the device is powered on, a virtual MAC address is generated, which can ensure the uniqueness of the generated virtual MAC address.
[0068] As an optional embodiment, a power-off instruction of a device is received; based on the power-off instruction, the virtual MAC addresses stored in all boards in the device are deleted.
[0069] When the main control board receives the power-off command, the device is ready to shut down. The main control board will delete the virtual MAC addresses stored in all boards in the device to facilitate the regeneration of virtual MAC addresses after the next startup. If it is not cleared, address duplication is likely to occur, affecting address management. However, the location where the startup times are stored is not cleared, because the startup times need to be accumulated, so only the location where the virtual MAC address is stored is cleared. After the device is started, the main control board will obtain the virtual MAC address stored in the target board. If the virtual MAC address is not cleared at this time, it is easy to duplicate the previous virtual MAC address, and thus the uniqueness of the generated virtual MAC address cannot be guaranteed, and it is also easy to conflict with the virtual MAC address of other devices.
[0070] A specific implementation method is given below, taking a frame device as an example, and taking a power board as a target board to generate an address. Figure 2 is a schematic diagram of board-card interaction in an address generation method provided in an optional embodiment of the present invention, such as Figure 2 As shown, Figure 2 The power board in the system is the highest priority board. Figure 2 The other boards in the frame device are the boards other than the main control board and the power board with the highest priority. Figure 2 I won’t show them one by one.
[0071] 1. Before the device is powered on, the virtual MAC addresses of all boards are empty, the real MAC address of the power board has data, and the number of startups has data.
[0072] 2. After the device is powered on, the main control board will receive the device startup request, and generate a startup signal based on the startup request and send it to other boards in the device. All power boards will refresh the startup count based on the startup signal and add 1. The power board with the highest priority will read the real MAC address and the startup count, generate a new MAC address based on these two data, and store the MAC address in the virtual MAC address. At this time, the virtual MAC address of the main control board is empty. The power board with the highest priority can generate a prompt signal and send it to the main control board to prompt the main control board that the main control board can read the virtual MAC address. The main control board will read the virtual MAC address stored in the power board with the highest priority based on the prompt signal and store it. After the main control board reads the virtual MAC address of the power board, it will send the MAC address to all boards, and each board will store the MAC address in its own virtual MAC address. The MAC address displayed by the device to the outside is also the MAC address.
[0073] 3. When a board is abnormal, replace it with a new board. If the board is not the main control board, the main control board will send its stored virtual MAC address to the new board and store it in its virtual MAC address. If the replaced board is the main control board, the main control board will read the virtual MAC addresses of all other boards and verify them. If the virtual MAC addresses of all boards are the same, the newly inserted main control board will store the MAC address as its own virtual MAC address.
[0074] 4. Even if the power board of the device is unplugged and another chassis device is inserted to start, when the new device starts, the virtual MAC address generated will be different due to the change in the startup number of the power board, ensuring that the MAC addresses of the two chassis devices are different.
[0075] 5. After the device is powered off, the virtual addresses of all boards are cleared.
[0076] Figure 3 is a structural block diagram of an address generation device provided according to an embodiment of the present invention, such as Figure 3As shown, according to an embodiment of the present invention, an address generation device is provided, including a receiving module 32, an updating module 34, an acquiring module 36 and a storing module 38, wherein:
[0077] The receiving module 32 is used to receive a startup request of a device.
[0078] The sending module 34 is connected to the receiving module 32 and is used to send a start signal to a target board in the device based on the start request.
[0079] The acquisition module 36 is connected to the update module 34 and is used to acquire the virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal.
[0080] The storage module 38 is connected to the acquisition module 36 and is used to store the virtual MAC address as the virtual MAC address of the device.
[0081] Optionally, the above-mentioned device also includes a sending module for sending the virtual MAC address to other boards in the device except the target board and the main control board for storage.
[0082] Optionally, the above-mentioned device also includes: when a first board in the device is replaced and the device is not restarted, sending the virtual MAC address to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
[0083] Optionally, when the main control board in the device is replaced, the above-mentioned device also includes: obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; judging whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; when the virtual MAC addresses stored in other boards except the replaced main control board are the same, storing the virtual MAC address in the replaced main control board.
[0084] Optionally, when the virtual MAC addresses stored in other boards except the replaced main control board are different, obtain the check code corresponding to the virtual MAC address stored in the other boards; based on the check code, correct the virtual MAC address stored in the other boards to obtain the target virtual MAC address; store the target virtual MAC address in the replaced main control board.
[0085] Optionally, the target board is a power board in the device.
[0086] Optionally, the apparatus further comprises: a selection module for selecting a power board with the highest priority as a target board based on the priorities of the multiple power boards when there are multiple power boards in the device.
[0087] According to an embodiment of the present invention, a computer-readable storage medium is provided, and the computer-readable storage medium includes: receiving a startup request of a device; sending a startup signal to a target board in the device based on the startup request; obtaining a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; and storing the virtual MAC address as the virtual MAC address of the device.
[0088] Optionally, the method further includes sending the virtual MAC address to other boards in the device except the target board and the main control board for storage.
[0089] Optionally, it also includes: when a first board in the device is replaced and the device is not restarted, sending the virtual MAC address to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
[0090] Optionally, when a main control board in the device is replaced, it also includes: obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; determining whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; if the virtual MAC addresses stored in other boards except the replaced main control board are the same, storing the virtual MAC address in the replaced main control board.
[0091] Optionally, when the virtual MAC addresses stored in other boards except the replaced main control board are different, obtain the check code corresponding to the virtual MAC address stored in the other boards; based on the check code, correct the virtual MAC address stored in the other boards to obtain the target virtual MAC address; store the target virtual MAC address in the replaced main control board.
[0092] Optionally, the target board is a power board in the device.
[0093] Optionally, the method further includes: when there are multiple power boards in the device, based on the priorities of the multiple power boards, selecting the power board with the highest priority as the target board.
[0094] According to an embodiment of the present invention, there is provided an electronic device, including:
[0095] A memory storing an executable program;
[0096] A processor is used to run the program, wherein any one of the above-mentioned address generation methods is executed when the program is run.
[0097] According to an embodiment of the present invention, a computer program product is provided, including a computer program, which, when executed by a processor, implements receiving a startup request of a device; based on the startup request, sending a startup signal to a target board in the device; obtaining a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; and storing the virtual MAC address as the virtual MAC address of the device.
[0098] Optionally, the method further includes sending the virtual MAC address to other boards in the device except the target board and the main control board for storage.
[0099] Optionally, it also includes: when a first board in the device is replaced and the device is not restarted, sending the virtual MAC address to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
[0100] Optionally, when a main control board in the device is replaced, it also includes: obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; determining whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; if the virtual MAC addresses stored in other boards except the replaced main control board are the same, storing the virtual MAC address in the replaced main control board.
[0101] Optionally, when the virtual MAC addresses stored in other boards except the replaced main control board are different, obtain the check code corresponding to the virtual MAC address stored in the other boards; based on the check code, correct the virtual MAC address stored in the other boards to obtain the target virtual MAC address; store the target virtual MAC address in the replaced main control board.
[0102] Optionally, the target board is a power board in the device.
[0103] Optionally, the method further includes: when there are multiple power boards in the device, based on the priorities of the multiple power boards, selecting a power board with the highest priority as the target board.
[0104] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0105] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0106] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0107] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0108] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0109] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0110] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for generating an address, characterized in that: include: Receive a startup request from a device; Based on the startup request, sending a startup signal to a target board in the device; Acquire a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; The virtual MAC address is used as the virtual MAC address of the device and stored.
2. The method according to claim 1, characterized in that Also includes: The virtual MAC address is sent to other boards in the device except the target board and the main control board for storage.
3. The method according to claim 2, characterized in that Also includes: When a first board in the device is replaced and the device is not restarted, the virtual MAC address is sent to the replaced first board for storage, wherein the first board is a board other than the main control board in the device.
4. The method according to claim 1, characterized in that: In the case where the main control board in the device is replaced, the device further comprises: Obtaining virtual MAC addresses stored in other boards in the device except the replaced main control board; Determine whether the virtual MAC addresses stored in other boards except the replaced main control board are the same; In the case that the virtual MAC addresses stored in other boards except the replaced main control board are the same, the virtual MAC address is stored in the replaced main control board.
5. The method according to claim 4, characterized in that Also includes: When the virtual MAC addresses stored in the boards other than the replaced main control board are different, obtaining the verification code corresponding to the virtual MAC addresses stored in the other boards; Based on the verification code, correct the virtual MAC address stored in the other board to obtain the target virtual MAC address; The target virtual MAC address is stored in the replaced main control board.
6. The method according to claim 1, characterized in that The target board is a power board in the device.
7. The method according to claim 6, characterized in that Also includes: In the case that there are multiple power boards in the device, based on the priorities of the multiple power boards, a power board with the highest priority is selected as the target board.
8. An address generating device, characterized in that: include: A receiving module, used for receiving a startup request of a device; A sending module, used for sending a start signal to a target board in the device based on the start request; An acquisition module, used for acquiring a virtual MAC address stored in the target board, wherein the virtual MAC address is generated by the target board based on the number of device startups and the real MAC address of the target board after receiving the startup signal; The storage module is used to use the virtual MAC address as the virtual MAC address of the device and store it.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute the address generation method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program, when running, executes the address generation method described in any one of claims 1 to 7.