Disclosure of Invention
The embodiment of the application provides a link switching method and a link switching device, which are used for solving the problem that in the prior art, the stability of a server is poor due to the fact that a physical link between the server and a client is prone to damage.
In a first aspect, a link switching method provided in an embodiment of the present application is applied to a server, where the server includes at least two ports, each port is connected to one link interface, a plurality of network elements are included between the ports and the link interfaces, and the plurality of network elements form a physical link between the port and the link interface, and the method includes:
if the physical link between the first internet access currently used by the server and the first link interface is determined to meet the preset fault condition, starting a second internet access in the server;
determining a Media Access Control (MAC) address of the second network port according to a corresponding relation between the stored network port and the MAC address;
and sending a message for broadcasting the MAC address of the second internet access to each client through a physical link between the second internet access and a second link interface, so that each client switches to use the physical link between the second internet access and the second link interface to carry out conversation with the server according to the message.
In the embodiment of the application, if the physical link between the first internet access currently used by the server and the first link interface is determined to meet the preset fault condition, the second internet access in the server is started, determining the MAC address of the second network port according to the stored corresponding relation between the network port and the MAC address, sending a message for broadcasting the MAC address of the second internet access to each client through a physical link between the second internet access and the second link interface, so that each client switches to use the physical link between the second internet access and the second link interface to carry out conversation with the server according to the message, therefore, if the physical link between the first internet access and the first link interface which is currently used by the server fails, the session with each client can be switched to the session with the physical link between the second internet access and the second link interface, so that the influence on the client is small, and the stability of the server is good.
Optionally, the preset fault condition comprises any one or more of:
currently, no client carries out conversation with the server through the first internet access;
and N clients which are successfully accessed into the server through the first internet access recently can not ping, and no client successfully accesses into the server through the first internet access within a preset time, wherein N is an integer greater than zero.
Optionally, if it is determined that a physical link between a first internet access currently used by the server and the first link interface meets a preset fault condition, the method further includes:
and closing the first network port.
By adopting the scheme, when the physical link used by the server is switched, the network Protocol (IP) address of the server is kept unchanged, only the MAC address is switched, and the cost of IP resources is relatively low.
Optionally, the method further comprises:
reading state information of PHY chips connected with the first network port and the second network port in the server, wherein the state information is used for representing the state whether the first network port and the second network port are closed or not; and
before sending a message for broadcasting the MAC address of the second network port to each client via a physical link between the second network port and the second link interface, the method further includes:
and determining that the first internet access is in a closed state and the second internet access is in an open state according to the state information of the PHY chip.
Optionally, the server is a central unit CU in a fifth generation 5G mobile communication network, and each client is a distribution unit DU in the 5G mobile communication network;
the server is a time service server, and each client is a base station; alternatively, the first and second electrodes may be,
the server is an extension unit CP and each client is a remote unit DP.
In a second aspect, a link switching apparatus provided in an embodiment of the present application is applied to a server, where the server includes at least two ports, each port is connected to one link interface, a plurality of network elements are included between the port and the link interface, and the plurality of network elements form a physical link between the port and the link interface, and the apparatus includes:
the network port management module is used for starting a second network port in the server if the fact that a physical link between a first network port currently used by the server and a first link interface meets a preset fault condition is determined;
a determining module, configured to determine, according to a correspondence between a stored network port and a media access control MAC address, an MAC address of the second network port;
and the sending module is used for sending a message for broadcasting the MAC address of the second internet access to each client through a physical link between the second internet access and the second link interface, so that each client switches to use the physical link between the second internet access and the second link interface to carry out conversation with the server according to the message.
Optionally, the preset fault condition comprises any one or more of:
currently, no client carries out conversation with the server through the first internet access;
and N clients which are successfully accessed into the server through the first internet access recently can not ping, and no client successfully accesses into the server through the first internet access within a preset time, wherein N is an integer larger than zero.
Optionally, the portal management module is further configured to:
and if the physical link between the first internet access currently used by the server and the first link interface is determined to meet the preset fault condition, closing the first internet access.
Optionally, the method further comprises:
a reading module, configured to read status information of a PHY chip in the server, where the PHY chip is connected to both the first port and the second port, and the status information is used to indicate whether the first port and the second port are closed or not;
the sending module is further configured to determine that the first network port is in a closed state and the second network port is in an open state according to the state information of the PHY chip before sending a packet for broadcasting the MAC address of the second network port to each client through a physical link between the second network port and the second link interface.
Optionally, the server is a central unit CU in a fifth generation 5G mobile communication network, and each client is a distribution unit DU in the 5G mobile communication network;
the server is a time service server, and each client is a base station; alternatively, the first and second electrodes may be,
the server is an extension unit CP and each client is a remote unit DP.
In a third aspect, an embodiment of the present application provides an electronic device, including: at least one processor, and a memory communicatively coupled to the at least one processor, wherein:
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the above-described link switching method.
In a fourth aspect, an embodiment of the present application provides a computer-readable medium, which stores computer-executable instructions for performing the above link switching method.
In addition, for technical effects brought by any one of the design manners in the second aspect to the fourth aspect, reference may be made to technical effects brought by different implementation manners in the first aspect, and details are not described here.
These and other aspects of the present application will be more readily apparent from the following description of the embodiments.
Detailed Description
In order to solve the problem that in the prior art, a physical link between a server and a client is prone to damage, which causes poor stability of the server, embodiments of the present application provide a link switching method and apparatus.
The preferred embodiments of the present application will be described below with reference to the accompanying drawings of the specification, it should be understood that the preferred embodiments described herein are merely for illustrating and explaining the present application, and are not intended to limit the present application, and that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Referring to fig. 1, fig. 1 shows a schematic diagram of a link switching system provided in an embodiment of the present application, including a server, a link system, and a plurality of clients, where the server includes two network ports: a network port 1 and a network port 2; the network port 1 is connected with the interface of the link 1, a plurality of two-layer switches are arranged between the network port 1 and the interface of the link 1, and the two-layer switches form a physical link between the network port 1 and the interface of the link 1; the network port 2 is connected with the link 2 interface, a plurality of two-layer switches are arranged between the network port 2 and the link 2 interface, the two-layer switches form a physical link between the network port 2 and the link 2 interface, and the server can converse with each client through any physical link, wherein, the two-layer switches between the network port 1 and the link 1 interface and the two-layer switches between the network port 2 and the link 2 interface can be completely different or partially same, and the less the two-layer switches are, the better the link backup effect is.
In specific implementation, when the server is a Centralized Unit (CU) in a Fifth Generation (5G) mobile communication network, each client is a Distributed Unit (DU) in the 5G mobile communication network; when the server is a time service server, each client is a base station; when the server is an extended unit (CP) in the pico base station, each client is a remote unit (DP) in the pico base station.
Assuming that the current server uses the physical link between the network port 1 and the link 1 interface to perform a session with each client, in this process, if it is determined that the physical link between the network port 1 and the link 1 interface satisfies a preset fault condition, if no client performs a session with the server through the network port 1, the network port 1 may be closed through Field-Programmable Gate Array (FPGA) programming, the network port 2 may be opened, the MAC address of the network port 2 may be determined according to a stored correspondence between the physical link and the MAC address, and then a message for broadcasting the MAC address of the network port 2 may be sent to each client through the physical link between the network port 2 and the link 2 interface, so that each client may switch to use the physical link between the network port 2 and the link 2 interface to perform a session with the server according to the received message.
Therefore, if the physical link between the first internet access and the first link interface which is currently used by the server fails, the session with each client can be switched to the session with the physical link between the second internet access and the second link interface, so that the influence on the client is small, and the stability of the server is good.
In addition, in the application, each network port corresponds to a dedicated MAC address, and when a physical link is switched, the IP address of the server may be kept unchanged, and only the MAC address is switched, so that the overhead of IP resources is relatively low.
In order to ensure that only the MAC address of the server needs to be changed and the IP address of the server does not need to be changed before and after the physical link is switched, before a packet for broadcasting the MAC address of the network port 2 is sent to each client through the physical link between the network port 2 and the link 2 interface, state information of a PHY chip of a physical interface transceiver connected to both the network port 1 and the network port 2 in the server may also be read, where the state information is used to represent the state of whether the network port 1 and the network port 2 are closed or not, and the network port 1 is determined to be in a closed state and the network port 2 is determined to be in an open state according to the state information of the PHY chip.
In addition, the physical link between the network port 1 and the link 1 interface and the physical link between the network port 2 and the link 2 interface both belong to a service link, and the server may further include a control link, the control link being connected to another network port in the server (not shown in fig. 1), and in particular, the service link and the control link of the server may be separated by using a routing policy, so that service data and control data may be separated, and the security of the service data and the system may be enhanced.
As shown in fig. 2, a flowchart of a link switching method provided in the embodiment of the present application includes the following steps:
s201: and determining that a physical link between a first internet access currently used by the server and a first link interface meets a preset fault condition.
Wherein the preset fault condition comprises any one or more of the following:
currently, no client carries out conversation with the server through the first internet access;
the N clients which successfully access the server through the first internet access recently can not ping and none of the clients successfully access the server through the first internet access within a preset time length, wherein N is an integer larger than zero.
S202: and closing the first network port and opening the second network port.
Here, after the first portal is successfully closed, the physical link between the first portal and the first link interface is unavailable, and after the second portal is successfully opened, the physical link between the second portal and the second link interface is available.
S203: and reading the state information of the PHY chip connected with the first network port and the second network port in the server, wherein the state information is used for representing the state whether the first network port and the second network port are closed or not.
For example, for the first network port, if the state information corresponding to the PHY chip is TRUE, it represents that the first network port is in an open state; if the state information corresponding to the PHY chip is FALSE, the first network port is in a closed state; the second network port is similar and will not be described herein.
S204: judging whether the first internet access is in a closed state and the second internet access is in an open state according to the state information of the PHY chip, if so, entering S205; otherwise, return to S202.
S205: and sending a message for broadcasting the MAC address of the second network port to each client through a physical link between the second network port and the second link interface, so that each client switches to use the physical link between the second network port and the second link interface to carry out conversation with the server according to the message.
For example, a free Address Resolution Protocol (ARP) message may be sent to each client via a physical link between the second network port and the second link interface, so that each client may update the IP Address and the MAC Address of the server stored therein after receiving the ARP message, and subsequently perform a session with the server using the physical link between the second network port and the second link interface according to the updated IP Address and MAC Address of the server.
In the embodiment of the application, if the physical link between the first internet access currently used by the server and the first link interface is determined to meet the preset fault condition, the second internet access in the server is started, determining the MAC address of the second network port according to the stored corresponding relation between the network port and the MAC address, sending a message for broadcasting the MAC address of the second internet access to each client through a physical link between the second internet access and the second link interface, so that each client switches to use the physical link between the second internet access and the second link interface to carry out conversation with the server according to the message, therefore, if the physical link between the first internet access and the first link interface which is currently used by the server fails, the session with each client can be switched to the session with the physical link between the second internet access and the second link interface, so that the influence on the client is small, and the stability of the server is good. In addition, in the application, each network port corresponds to a MAC address dedicated to the network port, when a network port is switched, the IP address of the server remains unchanged, only the MAC address is switched, and the overhead of IP resources is also relatively small.
The above process is described below with reference to specific embodiments.
In specific implementation, after the server is started, the service link and the control link may be separated by using a routing policy, for example, the service gateway and the control gateway are respectively bound to different routing tables by using a routing table, such as the following binding commands:
ip route add 10.10.10.8/24dev eth0table 100;
ip route add default via 10.10.10.254table 100;
ip rule add from 10.10.10.18table 100pref 30000;
therefore, the service data can be separated from the control data, and the safety of the service data and the system is enhanced.
Further, the server may periodically read the value of the bottom PHY chip, if it is determined that the port 1 is in place according to the value of the PHY chip, the port 1 is opened by bottom FPGA programming, and the port 2 is closed, then a free ARP packet is sent to broadcast the IP address of the server and the dedicated MAC address corresponding to the port 1, wait for the connection of the client, if after a set time, such as 2 minutes, no client successfully connects the server through the port 1, close the port 1 by FPGA programming, open the port 2, then send a free ARP packet to broadcast the IP address of the server and the dedicated MAC address corresponding to the port 2, wait for the connection … of the client to sequentially poll the two ports, stop polling until a certain port is detected to have a relevant service data packet, and detect the relevant service data packet.
If it is assumed that the physical link between the network port 1 and the link interface 1 is detected as the network port 1, the server subsequently uses the physical link between the network port 1 and the link interface 1 to perform a session with each client, and in the process of using the physical link between the network port 1 and the link interface 1, if it is detected that no client currently performs a session with the server through the network port 1 and 5 clients which have recently successfully accessed the server through the network port 1 cannot ping and no client has successfully accessed the server through the network port 1 after waiting for 2 minutes, it is determined that the physical link between the network port 1 and the link interface 1 has failed, and at this time, the step of periodically reading the value of the underlying PHY chip can be returned again.
Therefore, the damage problem of the physical link is processed by combining the session condition of the client, the ping mechanism and the waiting time, a complex detection and test mechanism is not needed, and the processing method is simple and efficient.
Referring to fig. 3, a schematic structural diagram of an electronic device provided in this embodiment of the present disclosure includes a transceiver 301 and a processor 302, where the processor 302 may be a Central Processing Unit (CPU), a microprocessor, an application specific integrated circuit, a programmable logic circuit, a large scale integrated circuit, or a digital processing unit. The transceiver 301 is used for data transmission and reception between the electronic device and other devices.
The electronic device may further comprise a memory 303 for storing software instructions executed by the processor 302, but may also store some other data required by the electronic device, such as identification information of the electronic device, encryption information of the electronic device, user data, etc. The memory 303 may be a volatile memory (RAM), such as a random-access memory (RAM); the memory 303 may also be a non-volatile memory (non-volatile memory) such as a read-only memory (ROM), a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD), or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to this. The memory 303 may be a combination of the above memories.
The specific connection medium between the processor 302, the memory 303 and the transceiver 301 is not limited in the embodiment of the present application. In fig. 3, the embodiment of the present application is described by taking only the case where the memory 303, the processor 302, and the transceiver 301 are connected by the bus 304 as an example, the bus is shown by a thick line in fig. 3, and the connection manner between other components is merely illustrative and not limited. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.
The processor 302 may be dedicated hardware or a processor running software, and when the processor 302 can run software, the processor 302 reads software instructions stored in the memory 303 and executes the link switching method involved in the foregoing embodiments under the drive of the software instructions.
When the method provided in the embodiments of the present application is implemented in software or hardware or a combination of software and hardware, a plurality of functional modules may be included in the electronic device, and each functional module may include software, hardware or a combination of software and hardware. Specifically, referring to fig. 4, a schematic structural diagram of a link switching device provided in the embodiment of the present application includes a network port management module 401, a determining module 402, and a sending module 403.
The network port management module 401 is configured to, if it is determined that a physical link between a first network port and a first link interface that are currently used by a server meets a preset fault condition, open a second network port in the server;
a determining module 402, configured to determine, according to a correspondence between a stored network port and a media access control MAC address, an MAC address of the second network port;
a sending module 403, configured to send, to each client, a message for broadcasting the MAC address of the second network port through the physical link between the second network port and the second link interface, so that each client switches to use the physical link between the second network port and the second link interface to perform a session with the server according to the message.
Optionally, the preset fault condition comprises any one or more of:
currently, no client carries out conversation with the server through the first internet access;
and N clients which are successfully accessed into the server through the first internet access recently can not ping, and no client successfully accesses into the server through the first internet access within a preset time, wherein N is an integer larger than zero.
Optionally, the portal management module 401 is further configured to:
and if the physical link between the first internet access currently used by the server and the first link interface is determined to meet the preset fault condition, closing the first internet access.
Optionally, the method further comprises:
a reading module 404, configured to read status information of a PHY chip in the server, where the PHY chip is connected to both the first port and the second port, where the status information is used to represent a status of whether the first port and the second port are closed;
the sending module 403 is further configured to determine that the first network port is in a closed state and the second network port is in an open state according to the state information of the PHY chip before sending, to each client, a packet for broadcasting the MAC address of the second network port through a physical link between the second network port and the second link interface.
Optionally, the server is a central unit CU in a fifth generation 5G mobile communication network, and each client is a distribution unit DU in the 5G mobile communication network;
the server is a time service server, and each client is a base station; alternatively, the first and second electrodes may be,
the server is an extension unit CP and each client is a remote unit DP.
The division of the modules in the embodiments of the present application is schematic, and only one logical function division is provided, and in actual implementation, there may be another division manner, and in addition, each functional module in each embodiment of the present application may be integrated in one processor, may also exist alone physically, or may also be integrated in one module by two or more modules. The coupling of the various modules to each other may be through interfaces that are typically electrical communication interfaces, but mechanical or other forms of interfaces are not excluded. Thus, modules described as separate components may or may not be physically separate, may be located in one place, or may be distributed in different locations on the same or different devices. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions required to be executed by the processor, and includes a program required to be executed by the processor.
In some possible embodiments, the various aspects of the link switching method provided in this application may also be implemented in the form of a program product including program code for causing an electronic device to perform the steps in the link switching method according to various exemplary embodiments of this application described above in this specification when the program product is run on the electronic device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The program product for link switching of embodiments of the present application may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device over any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., over the internet using an internet service provider).
It should be noted that although several units or sub-units of the apparatus are mentioned in the above detailed description, such division is merely exemplary and not mandatory. Indeed, the features and functions of two or more units described above may be embodied in one unit, according to embodiments of the application. Conversely, the features and functions of one unit described above may be further divided into embodiments by a plurality of units.
Further, while the operations of the methods of the present application are depicted in the drawings in a particular order, this does not require or imply that these operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.