Master device switching processing method, electronic device, and storage medium
By acquiring and fusing multi-layer status information of the master device and utilizing cross-layer feature fusion and dynamic weight allocation, the problem of inaccurate judgment of the master-slave switching system in the existing technology is solved, the accuracy and timeliness of the master device switching are improved, and the system stability and user experience are enhanced.
Patent Information
- Application Number
- CN202510940297.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-07-09
AI Technical Summary
Existing master-slave switching systems often rely on only a single layer of status information when determining whether the master node needs to be switched, resulting in inaccurate and in-time judgments, which affects system stability and user experience.
By obtaining the status information of the network layer, transport layer and application layer of the main device, determining the current feature information of each layer and performing feature fusion processing, using a multi-head attention network for cross-layer information interaction and linear transformation, and dynamically assigning weights based on historical failure probabilities, the health result of the main device is determined, and then deciding whether to switch the main device.
It achieves a comprehensive assessment of the health status of the main device, improves the accuracy and timeliness of the main device switching decision, and enhances the stability of the system and user experience.
Smart Images

Figure CN120434110B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a master device switching processing method, an electronic device, and a storage medium. Background Art
[0002] With the prevalence of computer networks and distributed systems, high availability has become a core requirement for system design. Active-standby architecture is a key means of ensuring continuous system operation. When the primary node fails, the backup node is switched to ensure uninterrupted service.
[0003] Existing active / standby switchover systems often rely on a single layer of status information to determine whether the master node needs to switch, resulting in inaccurate and in-time decisions. For example, if the network layer appears normal but the application layer has a problem, the system may not be able to detect and trigger a switchover, impacting system stability and user experience. Summary of the Invention
[0004] The purpose of this application is to address the deficiencies in the above-mentioned prior art and provide a master device switching processing method, electronic device and storage medium to improve the accuracy of master device switching processing.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present application are as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for processing a master device switching, the method comprising:
[0007] Acquire status information of different layers of the master device at the current moment to obtain multi-layer current status information, wherein the multi-layer current status information includes current status information of the network layer, current status information of the transport layer, and current status information of the application layer;
[0008] Determining current feature information of each layer based on the multiple layers of current state information;
[0009] Perform feature fusion processing according to the current feature information of each layer to obtain a current fusion feature matrix, wherein the current fusion feature matrix includes a current sub-fusion feature matrix of the network layer, a current sub-fusion feature matrix of the transport layer, and a current sub-fusion feature matrix of the application layer;
[0010] Determining the current weight of each layer based on the current feature information of each layer and the historical failure probability of each layer;
[0011] The current health result of the master device is determined according to the current fusion feature matrix and the current weights of the layers, and whether to switch the master device is determined according to the current health result and / or the current feature information of the network layer.
[0012] Optionally, determining the current feature information of each layer according to the multiple layers of current state information includes:
[0013] Determining first initial characteristic information of the network layer based on the link status, number of packet losses, total number of packets, and round-trip time of each packet in the current state information of the network layer, the first initial characteristic information including link connectivity, packet loss rate, and round-trip time;
[0014] Determining second initial characteristic information of the transport layer based on the number of abnormal flag bits, the total number of transmitted packets, the number of active connections, the number of status connections, and the suspected attack traffic rate in the current state information of the transport layer, the second initial characteristic information including a retransmission rate and an attack flag;
[0015] Determining third initial characteristic information of the transport layer based on the total number of transactions, the number of successful transactions, the number of failed transactions, and the average response time in the current state information of the application layer, the third initial characteristic information including a transaction success rate and a transaction response time;
[0016] Normalizing the first initial feature information, the second initial feature information, and the third initial feature information respectively to obtain the current first feature information of the network layer, the current second feature information of the transport layer, and the current third feature information of the application layer.
[0017] Optionally, performing feature fusion processing according to the current feature information of each layer to obtain a current fused feature matrix includes:
[0018] Perform cross-layer information interaction processing based on the current first feature information, the current second feature information, and the current third feature information to obtain a current first feature association matrix, a current second feature association matrix, and a current third feature association matrix, wherein the current first feature association matrix is used to represent the association relationship between the network layer and the transport layer, the current second feature association matrix is used to represent the association relationship between the transport layer and the application layer, and the current third feature association matrix is used to represent the association relationship between the application layer and the network layer;
[0019] The current fused feature matrix is obtained by performing feature fusion processing using linear transformation according to the current first feature association matrix, the current second feature association matrix, and the current third feature association matrix.
[0020] Optionally, performing cross-layer information interaction processing based on the current first feature information, the current second feature information, and the current third feature information in the current feature information of each layer to obtain a current first feature association matrix, a current second feature association matrix, and a current third feature association matrix includes:
[0021] Inputting the current first feature information, the current second feature information, and the current third feature information into a multi-head attention network, the multi-head attention network performing linear transformation on the current first feature information, the current second feature information, and the current third feature information, respectively, to obtain a first feature vector corresponding to the network layer, a second feature vector corresponding to the transport layer, and a third feature vector corresponding to the application layer, wherein the first feature vector, the second feature vector, and the third feature vector respectively include a query vector, a key vector, and a value vector;
[0022] The multi-head attention network calculates the cross-layer attention matrix between the first eigenvector and the second eigenvector to obtain the first feature association matrix, and calculates the cross-layer attention matrix between the second eigenvector and the third eigenvector to obtain the second feature association matrix, and calculates the cross-layer attention matrix between the third eigenvector and the first eigenvector to obtain the third feature association matrix.
[0023] Optionally, performing feature fusion processing by using linear transformation according to the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain the current fused feature matrix includes:
[0024] Concatenate the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain a concatenated matrix;
[0025] Performing a linear transformation on the concatenated matrix to obtain the current fusion feature matrix.
[0026] Optionally, determining the current weight of each layer according to the current feature information of each layer and the historical failure probability of each layer includes:
[0027] Determine a current health status of each layer according to the current feature information of each layer, where the current health status includes healthy or faulty;
[0028] Obtaining a current likelihood probability of each layer according to the current health status of each layer and the total probability of failure of the master device;
[0029] The current weight of each layer is determined according to the current likelihood probability of each layer, the historical failure probability of each layer, and the total failure probability of the master device.
[0030] Optionally, determining the current health result of the master device according to the current fusion feature and the current weight of each layer includes:
[0031] Determining a target state vector of the master device according to a current sub-fusion feature matrix of the network layer, a current sub-fusion feature matrix of the transport layer, a current sub-fusion feature matrix of the application layer, and current weights of the layers in the current fusion feature matrix;
[0032] A current health result of the master device is determined according to the target state vector.
[0033] Optionally, determining the current health result of the master device according to the target state vector includes:
[0034] The target state vector is input into a classifier, and the classifier calculates the current health result of the master device according to the health degree and unhealth degree in the target state vector.
[0035] Optionally, determining whether to switch the master device according to the current health result and / or current characteristic information of the network layer includes:
[0036] If the current health result is less than a preset threshold or the link connectivity in the current characteristic information of the network layer is interrupted, it is determined to switch the master device.
[0037] In the second aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor. When the application is running, the processor communicates with the storage medium through the bus, and the processor executes the program instructions to perform the steps of the master device switching processing method described in the first aspect above.
[0038] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program is read and executes the steps of the master device switching processing method described in the first aspect above.
[0039] The beneficial effects of this application are:
[0040] The present application provides a method for processing switching of a main device, an electronic device, and a storage medium. The method determines the current feature information of each layer based on the current status information of multiple layers; performs feature fusion processing based on the current feature information of each layer to obtain a current fusion feature matrix. According to the current feature information of each layer and the historical failure probability of each layer, the current weight of each layer is determined, and dynamic weight allocation is achieved. According to the current fusion feature matrix and the current weight of each layer, the current health result of the main device is determined, and whether to switch the main device is determined based on the current health result and / or the current feature information of the network layer. By simultaneously collecting the status information of the network layer, the transport layer, and the application layer, multi-layer status information is obtained, and cross-layer feature fusion processing and dynamic weight allocation are performed, a comprehensive assessment of the health status of the main device is achieved, and the switching decision of the main device is determined based on the health probability of the main device obtained by BFD fast detection and / or deep fusion analysis based on the cross-layer fusion model, which can improve the accuracy and timeliness of the main device switching decision. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 A schematic diagram of the architecture of a master device switching processing system provided in an embodiment of the present application;
[0043] Figure 2 A flowchart of a method for processing master device switching provided in an embodiment of the present application;
[0044] Figure 3 A flowchart of a second master device switching processing method provided in an embodiment of the present application;
[0045] Figure 4 A flowchart of a third master device switching processing method provided in an embodiment of the present application;
[0046] Figure 5 A flowchart of a fourth master device switching processing method provided in an embodiment of the present application;
[0047] Figure 6 A flowchart of a fifth master device switching processing method provided in an embodiment of the present application;
[0048] Figure 7 A flowchart of a sixth method for master device switching provided in an embodiment of the present application;
[0049] Figure 8 This is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of illustration and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowcharts can be implemented out of sequence, and steps without logical context can be reversed or implemented simultaneously. In addition, those skilled in the art, under the guidance of the contents of this application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.
[0051] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0052] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0053] Optionally, the master device switching processing method provided in the embodiments of the present application is applied to an electronic device, such as a mobile phone, tablet computer, laptop computer, PDA, desktop computer, or other terminal device with computing and display capabilities, or a server. Specifically, the method can be applied to an application in the terminal device, such as a mobile phone application (APP) or a computer application system.
[0054] Figure 1 This is a schematic diagram of the architecture of a master device switching processing system provided in an embodiment of the present application, such as Figure 1 As shown, the master device switching processing system may include: a data acquisition module, a feature engineering module, a fusion decision module and an execution module.
[0055] The data acquisition module can be used to collect status information of the network layer, the transport layer, and the application layer, and send the collected status information of each layer to the feature engineering module.
[0056] The feature engineering module performs data cleaning, feature extraction, and feature normalization on the received state information of each layer to obtain the feature information of each layer and sends the feature information of each layer to the fusion decision module.
[0057] The fusion decision module uses the Transformer network to process the feature information of each layer, dynamically assign weights, and output the health probability, that is, output the health result of the main device, generate switching instructions based on the health result of the main device, and send the generated switching instructions to the execution module.
[0058] The execution module can execute the operation indicated by the switching instruction.
[0059] The following is a detailed explanation of the specific implementation process of the master device switching process provided in the embodiment of the present application.
[0060] Figure 2 This is a flow chart of a method for processing a master device switch provided by an embodiment of the present application, the execution subject of the method is the aforementioned electronic device. Figure 1 As shown, the method includes:
[0061] S101. Obtain status information of different layers of the master device at the current moment to obtain multiple layers of current status information.
[0062] The multi-layer current status information may include: current status information of the network layer, current status information of the transport layer, and current status information of the application layer. Since there is no redundant detection method for basic connectivity of the network layer, the transport layer is the only layer that can directly reflect the availability of the service port, and the application layer is the final service status that can be perceived by the user. Therefore, in this embodiment, the health result of the main device is determined by collecting the current status information of the network layer, the current status information of the transport layer, and the current status information of the application layer, and based on the status information of these three layers.
[0063] Optionally, the data collection module can simultaneously collect current network, transport, and application layer status information at preset intervals. Specifically, BFD (Bidirectional Forwarding Detection) can be used, with a 200ms heartbeat interval configured for the BFD session, and single-hop mode can be used to collect network layer status information. TCPDump can be used to collect port traffic, and the ss-ant command can be called to obtain the connection status of each request, thereby obtaining current transport layer status information. APM tools, such as the New Relic Java Agent, can be used to obtain application layer status information via the REST API. The collected network, transport, and application layer status information is then sent to the feature engineering module.
[0064] Optionally, the current state information of the network layer may include the link state of the network layer at the current moment, the round-trip time of each heartbeat packet in the network layer, the number of packet losses within a preset time length, and the total number of packets within a preset time length.
[0065] Optionally, the current state information of the transport layer may include the number of abnormal flag bits, the total number of transmitted packets, the number of active state connections, the number of SYN_SENT state connections, the suspected attack traffic rate, etc. at the current moment. A state connection refers to a state connection between the master device and each request, and may include different state connections such as an active state connection and a SYN_SENT state connection. The suspected attack traffic rate may be obtained by comparing the number of SYN_SENT state connections at the current moment with the number of SYN_SENT state connections at the moment before the current moment.
[0066] Optionally, the current state information of the application layer may include the total number of transactions, the number of successful transactions, the number of failed transactions, and the average transaction response time of the network layer at the current moment. Transaction refers to an event in which the application layer returns the requested data based on a request.
[0067] S102: Determine current feature information of each layer based on multiple layers of current state information.
[0068] Specifically, the current characteristic information of the network layer can be determined based on the current state information of the network layer, the current characteristic information of the transport layer can be determined based on the current state information of the transport layer, and the current characteristic information of the application layer can be determined based on the current state information of the application layer.
[0069] Among them, the current characteristic information of the network layer may include the normalized link connectivity, packet loss rate and round-trip time of the network layer at the current moment; the current characteristic information of the transport layer may include the normalized retransmission rate and attack mark of the transport layer at the current moment; the current characteristic information of the application layer may include the normalized transaction success rate and transaction response time of the application layer at the current moment.
[0070] S103: Perform feature fusion processing based on the current feature information of each layer to obtain a current fusion feature matrix.
[0071] The current fusion feature matrix may include the current sub-fusion feature matrix of the network layer, the current sub-fusion feature matrix of the transport layer, and the current sub-fusion feature matrix of the application layer. , where Z is the current fusion feature matrix, is the current sub-fusion feature matrix of the network layer, is the current sub-fusion feature matrix of the transmission layer, is the current sub-fusion feature matrix of the application layer.
[0072] S104: Determine the current weight of each layer based on the current feature information of each layer and the historical failure probability of each layer.
[0073] Specifically, the current weight of the network layer can be obtained using a preset method based on the current characteristic information of the network layer and the historical failure probability of the network layer. For example, the current weight of the network layer is obtained using To express; according to the current characteristic information of the transmission layer and the historical failure probability of the transmission layer, the current weight of the transmission layer can be obtained using a preset method, for example, the current weight of the transmission layer can be expressed using To express; the current weight of the application layer can be obtained using a preset method based on the current feature information of the application layer and the historical failure probability of the application layer, for example, the current weight of the application layer is expressed using To express.
[0074] S105: Determine the current health result of the master device based on the current fusion feature matrix and the current weights of each layer, and determine whether to switch the master device based on the current health result and / or the current feature information of the network layer.
[0075] Specifically, a preset method can be used to determine the current health result of the master device based on the current sub-fusion feature matrix of the network layer, the current sub-fusion feature matrix of the transport layer, and the current sub-fusion feature matrix of the application layer in the current fusion feature matrix, as well as the current weight of the network layer, the current weight of the transport layer, and the current weight of the application layer. The current health result of the master device is a health probability.
[0076] Optionally, whether to switch the master device may be determined based on the current health result of the master device and / or the link connectivity in the current feature information of the network layer.
[0077] In this embodiment, the current feature information of each layer is determined based on the current status information of multiple layers; feature fusion processing is performed based on the current feature information of each layer to obtain a current fused feature matrix. The current weight of each layer is determined based on the current feature information of each layer and the historical failure probability of each layer, thereby realizing dynamic weight allocation. The current health result of the main device is determined based on the current fused feature matrix and the current weight of each layer, and whether to switch the main device is determined based on the current health result and / or the current feature information of the network layer. By simultaneously collecting the status information of the network layer, the transport layer and the application layer, multi-layer status information is obtained, and cross-layer feature fusion processing and dynamic weight allocation are performed, thereby realizing a comprehensive assessment of the health status of the main device, and determining the switching decision of the main device based on the health probability of the main device obtained based on BFD fast detection and / or deep fusion analysis based on the cross-layer fusion model, which can improve the accuracy and timeliness of the main device switching decision.
[0078] Figure 3 A flow chart of a second method for processing master device switching provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the above S102, determining the current feature information of each layer based on the current state information of multiple layers, may include:
[0079] S201. Determine first initial characteristic information of the network layer according to the link status, number of packet losses, total number of packets, and round-trip time of each packet in the current state information of the network layer.
[0080] The first initial characteristic information may include link connectivity, packet loss rate, and round-trip time.
[0081] Specifically, link connectivity can be determined based on the link status. Link connectivity can be 0 or 1, with 0 indicating disconnected and 1 indicating connected. The packet loss rate is calculated by dividing the number of lost packets by the total number of packets. The packet loss rate is expressed as a percentage. The round-trip time of each packet is the round-trip time in the first initial feature information.
[0082] S202. Determine second initial characteristic information of the transport layer based on the number of abnormal flag bits, the total number of transmission packets, the number of active state connections, the number of preset state connections, and the suspected attack traffic rate in the current state information of the transport layer.
[0083] The second initial characteristic information may include a retransmission rate and an attack flag. The preset state connection may be a SYN_SENT state connection.
[0084] Retransmission rate = number of abnormal flag bits / total number of transmitted packets. When an abnormal flag bit is present, a packet needs to be retransmitted. Therefore, the number of abnormal flag bits is the number of retransmitted packets.
[0085] Specifically, if the number of connections in the preset state is greater than the number of connections in the active state * 0.2, and the suspected attack traffic rate is greater than 1000 packets / second, then an attack flag is determined to be present at the transport layer. The attack flag refers to the SYN Flood attack flag. A value of 0 indicates that no attack flag exists, while a value of 1 indicates that an attack flag exists.
[0086] S203: Determine third initial characteristic information of the transport layer according to the total number of transactions, the number of successful transactions, the number of failed transactions, and the average response time in the current state information of the application layer.
[0087] The third initial characteristic information may include transaction success rate and transaction response time.
[0088] Specifically, transaction success rate = number of successful transactions / total number of transactions. Average response time refers to the response time of all transactions divided by the total number of transactions. The average response time is used as the transaction response time in the third initial feature information.
[0089] S204 , normalize the first initial feature information, the second initial feature information, and the third initial feature information respectively to obtain current first feature information of the network layer, current second feature information of the transport layer, and current third feature information of the application layer.
[0090] Among them, the current first feature information , the current second feature information , the current third feature information .
[0091] Specifically, Min-Max can be used to normalize the first initial feature information, the second initial feature information, and the third initial feature information to the interval [0,1] to eliminate the dimension difference. Specifically, the formula Perform normalization processing. is the minimum value, is the maximum value, is the normalized value, is the current value.
[0092] Positive feature processing can be used, that is, the higher the value, the healthier the feature. Specifically, each feature value in the feature information is reversely mapped, and all features are unified into a positive indicator of "the larger the value, the higher the healthiness".
[0093] For example, the range of the round trip time in the network layer status information is set to 10ms-500ms. If the round trip time in the current network layer status information is 100ms, the round trip time in the current network layer status information is normalized to: ; If the round-trip time in the current state information is greater than 500, the round-trip time in the current state information of the network layer is normalized to 1; if the round-trip time in the current state information is less than 10ms, the round-trip time in the current state information of the network layer is normalized to 0.
[0094] For example, the range of the transaction response time of the application layer is set to 20ms-2000ms. If the transaction response time in the current state information of the application layer is 200ms, the transaction response time in the current state information of the application layer is normalized to: If the transaction response time in the current state information of the application layer is greater than 2000ms, the transaction response time in the current state information of the application layer is normalized to 1. If the transaction response time in the current state information of the application layer is less than 20ms, the transaction response time in the current state information of the application layer is normalized to 0.
[0095] The binary features only need to be kept at 0 / 1, that is, the link connectivity of the network layer and the attack mark of the transport layer can be kept.
[0096] Percentile features are normalized to the range of 0-1 by removing the percentage. For example, 4% is normalized to 1-0.04=0.96. Specifically, the packet loss rate in the network layer's current state information, the retransmission rate in the transport layer's current state information, and the transaction success rate in the application layer's current state information are all normalized by removing the percentage. If the application layer's transaction success rate is 99%, it is normalized to 0.99. If the transport layer's attack flag is 0, it is normalized to 1; if it is 1, it is normalized to 0.
[0097] In this embodiment, the initial feature information of each layer is obtained, and each initial feature information is normalized through Min-Max, and the feature data is linearly mapped to the interval [0, 1], so that the feature data of different dimensions and magnitudes are comparable, which facilitates subsequent fusion processing.
[0098] Figure 4 A flow chart of a third master device switching processing method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the above S103, performing feature fusion processing according to the current feature information of each layer to obtain the current fusion feature matrix, may include:
[0099] S301: Perform cross-layer information interaction processing based on the current first feature information, the current second feature information, and the current third feature information to obtain a current first feature association matrix, a current second feature association matrix, and a current third feature association matrix.
[0100] Among them, the current first characteristic correlation matrix represents the correlation relationship between the network layer and the transport layer, the current second characteristic correlation matrix represents the correlation relationship between the transport layer and the application layer, and the current third correlation matrix represents the correlation relationship between the application layer and the network layer.
[0101] S302 , performing feature fusion processing using linear transformation according to the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain a current fused feature matrix.
[0102] Among them, the current first feature correlation matrix can be , the current second feature correlation matrix can be , the current third characteristic correlation matrix can be .
[0103] Figure 5 A flowchart of a fourth master device switching processing method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the above S302, performing feature fusion processing using linear transformation according to the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain the current fused feature matrix, may include:
[0104] S401. Input the current first feature information, the current second feature information, and the current third feature information into the multi-head attention network, and the multi-head attention network performs linear transformation on the current first feature information, the current second feature information, and the current third feature information respectively to obtain the first feature vector corresponding to the network layer, the second feature vector corresponding to the transmission layer, and the third feature vector corresponding to the application layer.
[0105] The first eigenvector, the second eigenvector and the third eigenvector include a query vector Q, a key vector K and a value vector V respectively.
[0106] Specifically, each eigenvector can be obtained by the following formula (1).
[0107] Formula (1)
[0108] Among them, i is the identifier of each layer, , is the current feature information of each layer, such as That is the current first feature information of the network layer, That is the current second characteristic information of the transport layer, This is the current third characteristic information of the application layer. The preset query linear change matrix for each layer, is the preset key linear change matrix of each layer, The preset value linear change matrix of each layer.
[0109] Specifically, the current first characteristic information of the network layer can be , the preset query linear change matrix of the network layer , the preset key linear change matrix of the network layer , the preset value linear change matrix of the network layer Substituting into the above formula (1), we get the first eigenvector corresponding to the network layer 、 、 .
[0110] Specifically, the current first characteristic information of the transport layer can be , the preset query linear change matrix of the transport layer , the preset key linear change matrix of the transmission layer , the preset value linear change matrix of the transmission layer Substituting into the above formula (1), we get the second eigenvector corresponding to the transmission layer 、 、 .
[0111] Specifically, the current first feature information of the application layer can be , the preset query linear change matrix of the application layer , the preset key linear change matrix of the application layer , the preset value linear change matrix of the application layer Substituting into the above formula (1), we get the third eigenvector corresponding to the application layer 、 、 .
[0112] S402. The multi-head attention network calculates the cross-layer attention matrix between the first eigenvector and the second eigenvector to obtain a first feature association matrix, and calculates the cross-layer attention matrix between the second eigenvector and the third eigenvector to obtain a second feature association matrix, and calculates the cross-layer attention matrix between the third eigenvector and the first eigenvector to obtain a third feature association matrix.
[0113] Specifically, the feature correlation matrix can be calculated using the following formula (2).
[0114] Formula (2)
[0115] in, is the feature vector corresponding to a layer, and Each is a feature vector corresponding to another layer.
[0116] Specifically, the first eigenvector corresponding to the network layer can be , the second eigenvector corresponding to the transmission layer 、 Substitute into the above formula (2) to obtain the first characteristic correlation matrix .
[0117] The second eigenvector corresponding to the transmission layer , the third eigenvector corresponding to the application layer 、 Substitute into the above formula (2) to obtain the second characteristic correlation matrix .
[0118] The third eigenvector corresponding to the application layer , the first eigenvector corresponding to the network layer 、 Substituting into the above formula (2), we get the third characteristic correlation matrix .
[0119] Optionally, the above S302, performing feature fusion processing using linear transformation according to the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain the current fused feature matrix, may include:
[0120] The current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix are concatenated to obtain the concatenated matrix, which is the matrix in the following formula (3): Perform linear transformation on the concatenated matrix to obtain the current fusion feature matrix.
[0121] Specifically, the current fusion feature matrix can be obtained by the following formula (3).
[0122] Formula (3)
[0123] in, , , , is the linear transformation matrix after the preset multi-head splicing. The current sub-fusion feature matrix of the network layer, is the current sub-fusion feature matrix of the transmission layer, is the current sub-fusion feature matrix of the application layer, and Z is the current fusion feature matrix.
[0124] In this embodiment, by using multiple different attention heads, the multi-head attention mechanism can learn features from different representation subspaces in parallel. Concatenating the outputs of multiple attention heads can more comprehensively capture data features, enhance the model's ability to model complex relationships, and enable more comprehensive cross-layer state fusion, thereby improving the accuracy of primary device health assessment results.
[0125] Figure 6 A flowchart of a fifth master device switching processing method provided in an embodiment of the present application is shown as follows: Figure 6 As shown, the above S104, determining the current weight of each layer based on the current feature information of each layer and the historical failure probability of each layer, may include:
[0126] S501. Determine the current health status of each layer according to the current characteristic information of each layer.
[0127] The current health status may include healthy or faulty.
[0128] Specifically, for the current first characteristic information of the network layer, if the packet loss rate is greater than the preset packet loss rate threshold or the round-trip time in the current characteristic information of the network layer is greater than the round-trip time threshold, the current health status of the network layer is determined to be faulty; otherwise, it is healthy.
[0129] For the current second characteristic information of the transmission layer, if the retransmission rate is greater than the retransmission rate threshold or the attack flag is 1, the current health state of the transmission layer is determined to be faulty; otherwise, it is healthy.
[0130] For the current third characteristic information of the application layer, if the transaction success rate is lower than the success rate threshold or the transaction response time is greater than the response time threshold, the current health status of the application layer is determined to be faulty; otherwise, it is healthy.
[0131] S502: Obtain the current likelihood probability of each layer according to the current health status of each layer and the total failure probability of the main device.
[0132] Among them, the current likelihood probability refers to the likelihood probability of each layer at the current moment.
[0133] Specifically, the current likelihood probability of each layer is ,in, Refers to the current health status of each layer, H is the main device is faulty, that is It represents the probability that the current status of each layer will affect the main device failure.
[0134] S503 : Determine the current weight of each layer according to the current likelihood probability of each layer, the historical failure probability of each layer, and the total failure probability of the main device.
[0135] Specifically, the current weight of each layer can be obtained by using the following formula (4) through the Bayesian network.
[0136] Formula (4)
[0137] in, is the historical failure probability of layer i, is the current likelihood probability of the i-th layer, is the total failure probability of the main device, The historical failure probability of layer i can be obtained based on the health status of layer i at each historical moment. For example, if the network layer experienced 10 failures and 40 health conditions at 50 historical moments, the historical failure probability of the network layer is 1 / 5. The historical moments refer to moments before the current moment.
[0138] in, , Reflects the total probability of the master device failing in all scenarios, where all scenarios refer to the probability of the master device failing at the historical moment. 、 、 Any combination of scenarios, such as at historical moment 1 =Fault, =Normal, = normal, then =Fault, =Normal, = Normal is a scenario. When the historical moment 2 =Fault, =Fault, = normal, then =Fault, =Fault, =Normal is a scenario. It will be used as a normalization factor to ensure that the current weight calculation result of each layer is between [0,1].
[0139] For example, the current likelihood probability of the network layer can be , the historical failure probability of the network layer , and the total probability of master device failure Substitute into the above formula (4) to get the current weight of the network layer .
[0140] The current likelihood probability of the network layer can be , the historical failure probability of the network layer , and the total probability of master device failure Substitute into the above formula (4) to get the current weight of the network layer .
[0141] For example, the current likelihood probability of the network layer can be , the historical failure probability of the network layer , and the total probability of master device failure Substitute into the above formula (4) to get the current weight of the network layer .
[0142] Optionally, after obtaining the current weights of each layer, the obtained current weights of each layer are subjected to secondary normalization processing to ensure that the sum of the current weights of each layer is 1. For example, , , , after secondary normalization, , , .
[0143] In this embodiment, the essence of the current weight calculated using the Bayesian network is the proportion of the impact of the health status of each layer on the overall health of the main device. Prior knowledge and currently acquired data can be integrated to determine the importance of each layer in assessing the health status of the main device based on the characteristic information of different layers such as the network layer, transport layer, and application layer, and then dynamically adjust the fusion weight. For example, if the network layer fails frequently, the Bayesian network will increase the current weight of the network layer so that the current health results of the main device determined later will be more accurate, making the decision more in line with the actual situation and enhancing the reliability and adaptability of the decision.
[0144] Figure 7 A flow chart of a sixth method for master device switching processing provided in an embodiment of the present application is shown as follows: Figure 7 As shown, the above S105, determining the current health result of the master device according to the current fusion feature matrix and the current weights of each layer, may include:
[0145] S601: Determine a target state vector of the master device according to the current sub-fusion feature matrix of the network layer, the current sub-fusion feature matrix of the transport layer, the current sub-fusion feature matrix of the application layer, and the current weights of each layer in the current fusion feature matrix.
[0146] Specifically, the target state vector can be obtained using the following formula (5).
[0147] Formula (5)
[0148] in, is the target state vector of the master device, is the current weight of the network layer, is the current weight of the transport layer, is the current weight of the application layer, is the current sub-fusion feature matrix of the network layer in the current fusion feature matrix, is the current sub-fusion feature matrix of the transmission layer in the current fusion feature matrix, It is the current sub-fusion feature matrix of the application layer in the current fusion feature matrix.
[0149] S602: Determine the current health result of the master device according to the target state vector.
[0150] The target state vector includes the health and unhealth of the master device.
[0151] Specifically, the target state vector may be input into a classifier, and the classifier calculates the current health result of the master device according to the healthiness and unhealthiness in the target state vector.
[0152] Specifically, the current health result of the master device can be calculated using the following formula (6).
[0153] Formula (6)
[0154] Among them, m is the health degree in the target state vector, n is the unhealth degree in the target state vector, The current health status of the primary device.
[0155] The classifier can be a Softmax classifier, which maps input data to multiple categories and outputs a probability value corresponding to each category, with the sum of these probabilities being 1. In the master-slave decision-making system, the Softmax classifier receives data fused by a Transformer network and weighted by a Bayesian network, and converts the received data into a health probability of the master device. Based on the characteristics of the input data, the Softmax classifier calculates the probability that the master device is healthy. When this probability falls below a preset threshold (such as 0.3), it indicates a possible failure of the master device, triggering subsequent master-slave switchover decisions. This provides the system with an intuitive and quantifiable basis for decision-making.
[0156] Optionally, determining whether to switch the primary device according to the current health result and / or the current characteristic information of the network layer in S105 may include:
[0157] Specifically, if the health probability in the master device's current health result is less than a preset threshold or if the link connectivity in the current network layer feature information is interrupted, the master device is switched. Because the network layer's link connectivity reflects the master device's ability to provide external services, the master device is switched even when the network layer's link connectivity is interrupted, making master device switching more accurate.
[0158] In this embodiment, for link detection at the network layer, in addition to the BFD protocol, other fast detection protocols such as the Hello protocol can also be used to achieve real-time monitoring of link status as a reference for active / standby switching decisions.
[0159] Figure 8 This is a structural block diagram of an electronic device 700 provided in an embodiment of the present application. Figure 8 As shown, the electronic device may include: a processor 701 and a memory 702.
[0160] Optionally, a bus 703 may also be included, wherein the memory 702 is used to store machine-readable instructions executable by the processor 701. When the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703. When the machine-readable instructions are executed by the processor 401, the method steps in the above method embodiment are performed.
[0161] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps in the embodiment of the master device switching processing method are executed.
[0162] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules 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 communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0163] In addition, the functional units in the various embodiments of the present application can be integrated into a single processing unit, each unit can exist physically separately, or two or more units can be integrated into a single unit. If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0164] The above is only a specific implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the protection scope of the present application.
Claims
1. A method for processing master device switching, characterized in that: The method comprises: Acquire status information of different layers of the master device at the current moment to obtain multi-layer current status information, wherein the multi-layer current status information includes current status information of the network layer, current status information of the transport layer, and current status information of the application layer; Determining current feature information of each layer based on the multiple layers of current state information; Perform feature fusion processing according to the current feature information of each layer to obtain a current fusion feature matrix, wherein the current fusion feature matrix includes a current sub-fusion feature matrix of the network layer, a current sub-fusion feature matrix of the transport layer, and a current sub-fusion feature matrix of the application layer; Determining the current weight of each layer based on the current feature information of each layer and the historical failure probability of each layer; Determining a current health result of the master device according to the current fusion feature matrix and the current weights of the layers, and determining whether to switch the master device according to the current health result and / or the current feature information of the network layer; The determining the current feature information of each layer according to the multiple layers of current state information includes: Determining first initial characteristic information of the network layer based on the link status, number of packet losses, total number of packets, and round-trip time of each packet in the current state information of the network layer, the first initial characteristic information including link connectivity, packet loss rate, and round-trip time; Determining second initial characteristic information of the transport layer based on the number of abnormal flag bits, the total number of transmitted packets, the number of active connections, the number of status connections, and the suspected attack traffic rate in the current state information of the transport layer, the second initial characteristic information including a retransmission rate and an attack flag; Determining third initial characteristic information of the transport layer based on the total number of transactions, the number of successful transactions, the number of failed transactions, and the average response time in the current state information of the application layer, the third initial characteristic information including a transaction success rate and a transaction response time; Normalizing the first initial feature information, the second initial feature information, and the third initial feature information respectively to obtain the current first feature information of the network layer, the current second feature information of the transport layer, and the current third feature information of the application layer.
2. The method for master device switching according to claim 1, wherein: The feature fusion processing is performed according to the current feature information of each layer to obtain a current fusion feature matrix, including: Perform cross-layer information interaction processing based on the current first feature information, the current second feature information, and the current third feature information to obtain a current first feature association matrix, a current second feature association matrix, and a current third feature association matrix, wherein the current first feature association matrix is used to represent the association relationship between the network layer and the transport layer, the current second feature association matrix is used to represent the association relationship between the transport layer and the application layer, and the current third feature association matrix is used to represent the association relationship between the application layer and the network layer; The current fused feature matrix is obtained by performing feature fusion processing using linear transformation according to the current first feature association matrix, the current second feature association matrix, and the current third feature association matrix.
3. The method for master device switching according to claim 2, wherein: The performing cross-layer information interaction processing according to the current first feature information, the current second feature information, and the current third feature information in the current feature information of each layer to obtain the current first feature association matrix, the current second feature association matrix, and the current third feature association matrix includes: Inputting the current first feature information, the current second feature information, and the current third feature information into a multi-head attention network, the multi-head attention network performing linear transformation on the current first feature information, the current second feature information, and the current third feature information, respectively, to obtain a first feature vector corresponding to the network layer, a second feature vector corresponding to the transport layer, and a third feature vector corresponding to the application layer, wherein the first feature vector, the second feature vector, and the third feature vector respectively include a query vector, a key vector, and a value vector; The multi-head attention network calculates the cross-layer attention matrix between the first eigenvector and the second eigenvector to obtain the first feature association matrix, and calculates the cross-layer attention matrix between the second eigenvector and the third eigenvector to obtain the second feature association matrix, and calculates the cross-layer attention matrix between the third eigenvector and the first eigenvector to obtain the third feature association matrix.
4. The method for master device switching according to claim 2, wherein: The step of performing feature fusion processing by using linear transformation according to the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain the current fused feature matrix includes: Concatenate the current first feature correlation matrix, the current second feature correlation matrix, and the current third feature correlation matrix to obtain a concatenated matrix; Performing a linear transformation on the concatenated matrix to obtain the current fusion feature matrix.
5. The method for master device switching according to claim 1, wherein: Determining the current weight of each layer according to the current feature information of each layer and the historical failure probability of each layer includes: Determine a current health status of each layer according to the current feature information of each layer, where the current health status includes healthy or faulty; Obtaining a current likelihood probability of each layer according to the current health status of each layer and the total probability of failure of the master device; The current weight of each layer is determined according to the current likelihood probability of each layer, the historical failure probability of each layer, and the total failure probability of the master device.
6. The method for master device switching according to claim 1, wherein: The determining, according to the current fusion feature and the current weights of the layers, a current health result of the master device includes: Determining a target state vector of the master device according to a current sub-fusion feature matrix of the network layer, a current sub-fusion feature matrix of the transport layer, a current sub-fusion feature matrix of the application layer, and current weights of the layers in the current fusion feature matrix; A current health result of the master device is determined according to the target state vector.
7. The method for master device switching according to claim 6, wherein: Determining the current health result of the master device according to the target state vector includes: The target state vector is input into a classifier, and the classifier calculates the current health result of the master device according to the health degree and unhealth degree in the target state vector.
8. The method for master device switching according to claim 1, wherein: The determining whether to switch the master device according to the current health result and / or the current characteristic information of the network layer includes: If the current health result is less than a preset threshold or the link connectivity in the current characteristic information of the network layer is interrupted, it is determined to switch the master device.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the steps of the master device switching processing method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Flow switching method and device, storage medium and network switching equipment
CN118921339A