Dynamic Defense Method Against Fake Data Injection Attacks Based on CNN-GAN

By employing a dynamic defense method against spoofing attacks based on CNN-GAN, this method utilizes a dual-path convolutional architecture and a physical constraint module, combined with the dynamic time warp analysis of the discriminator, to solve the problem of spoofing attacks in power distribution network state estimation. This enables fast and accurate attack detection and remediation, improving the robustness and adaptability of the system.

CN123116264APending Publication Date: 2026-11-17NANTONG GOTION NEW ENERGY TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611236358.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-14
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing power distribution network state estimation systems are vulnerable to spoofed data injection attacks, leading to inaccurate state estimation results. Furthermore, traditional defense strategies may violate the physical constraints of the power grid, affecting the reliability of the system's power supply.

Method used

A dynamic defense method against fake data injection attacks based on CNN-GAN is adopted. Temporal dynamic features and spatial topological correlations are extracted by a dual-path convolutional architecture generator. Combined with the dynamic temporal distortion analysis of the physical constraint module and the discriminator, a multi-objective joint optimization loss function is designed to achieve adversarial training and data repair.

Benefits of technology

It significantly improves the real-time performance and accuracy of attack detection and remediation, enhances the robustness and adaptability of the system, ensures the engineering feasibility and security of defense commands, and enables rapid response to the suddenness and stealth of FDIA attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123116264A_ABST
    Figure CN123116264A_ABST
Patent Text Reader

Abstract

This invention discloses a dynamic defense method against spoofed data injection attacks based on CNN-GAN, comprising the following steps: S1, preprocessing multi-dimensional data; S2, using a dual-path convolutional architecture generator to extract the temporal dynamic features and spatial topological correlation of the attacked measurement matrix, and generating preliminary repair data; S3, restricting the preliminary repair data through a physical constraint module to ensure the engineering feasibility of the repair results; S4, using a discriminator for dynamic time warp (DTW) similarity analysis; S5, combining the true / false probability with the attack heatmap, designing a multi-objective joint optimization loss function to achieve consistency between the generated data and the attack-free real data, replacing the attacked data, and achieving FDIA defense. This invention combines the data feature extraction capability of CNN with the data generation capability of GAN, providing an effective countermeasure for the increasing number of network attacks during the operation and control of power distribution networks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of power distribution network state estimation technology, and relates to a dynamic defense method against fake data injection attacks based on convolutional neural network-generative adversarial network. Background Technology

[0002] The operational status of a distribution network directly impacts user experience and power supply reliability. State estimation, a key technology in the theoretical framework of distribution network situational awareness, aims to accurately and quickly grasp the operational status of the distribution network. It is a prerequisite for distribution network operation and maintenance control decisions and a fundamental link in ensuring the safe, reliable, and stable operation of the distribution network. Currently, the construction of projects such as the highly anticipated Energy Internet is accelerating the evolution of distribution networks from simple power systems to integrated cyber-physical systems. Furthermore, the high penetration rate of distributed power sources such as wind and solar power, along with the active promotion and application of advanced measurement systems incorporating advanced data acquisition, communication, and control technologies, is driving the transition of traditional passive distribution networks towards active distribution systems, enabling the distribution network to possess a certain ability to actively regulate and optimize internal resources.

[0003] The high integration of information systems and the extensive deployment of advanced measurement systems, while enabling high-definition, high-density, and controllable distribution networks, also increase the risk of network attacks and other problems in the distribution network status estimation process. This may even affect the accurate perception of the distribution network's operating status, thereby further reducing the reliability of the system's power supply.

[0004] Currently, with the growth of distribution network scale, model complexity, and increased grid connection rate of distributed power sources, the scale of data collection is expanding. However, due to insufficient defense resources, nodes in remote areas have poor defense capabilities and are vulnerable to spoofed data injection attacks, which in turn affect the overall distribution network state estimation results. While current research on FDIA for distribution networks has achieved some results, it is limited by the research mindset of transmission networks, and the established attack models are mostly single-phase or three-phase symmetrical models, which differ from the actual distribution network structure. Furthermore, current defense strategies often involve deleting the attacked vector, leading to low reliability of state estimation. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a dynamic defense method against fake data injection attacks based on CNN-GAN, which aims to improve the ability of power distribution networks to resist network attacks, enhance the robustness of the system itself, and improve the accuracy of state estimation results.

[0006] To address the above technical problems, the technical solution adopted in this invention is: a dynamic defense method against fake data injection attacks based on CNN-GAN, comprising the following steps: S1. Preprocess the multidimensional data; S2. Using a dual-path convolutional architecture generator, extract the temporal dynamic features and spatial topological correlation of the impact measurement matrix, and generate preliminary repair data. S3. Limit the initial repair data through the physical constraint module to ensure the engineering feasibility of the repair results; S4. Shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the true and false probability and the attack heat map. S5. Combining the true / false probability with the attack heatmap, design a multi-objective joint optimization loss function to achieve consistency between the generated data and the real data without attack, replace the attacked data, and achieve FDIA defense.

[0007] Preferably, step 1 specifically includes: Multidimensional data is defined as: various electrical measurement data in the distribution network with different physical units and significantly different numerical magnitudes, specifically including node voltage amplitude, node voltage phase angle, node active power, node reactive power, branch active power, and branch reactive power; historical measurement datasets Data from each node is categorized and statistically analyzed according to measurement type. Each six-column array corresponds to six types of measurements for one node, and each type of measurement is standardized. Taking node m as an example, the six types of measurements are categorized according to node voltage amplitude. Node voltage phase angle Active power at nodes Node reactive power Branch active power Branch reactive power arrangement; Historical measurement dataset Attacked measurement data matrix Generator repairs dataset The j The columns are standardized according to the measurement type: In the formula: T is the time series length, and N is the number of network nodes. express b Set at time t j The input element of the column, , express b Set at time t j The output elements of the column, It is the first j Historical average of column elements It is the first j The historical standard deviation of column elements The processed data are concatenated into the corresponding processed set according to the original node order; by calculating the mean and standard deviation for each type of measurement and standardizing and eliminating dimensional differences, all data are mapped to the same dimensional space.

[0008] Preferably, step 2 specifically includes: The generator is constructed using a dual-path convolutional neural network; The generator includes a temporal convolution module and a spatial convolution module; The temporal convolution module uses a multi-layer one-dimensional convolutional neural network to extract the temporal dynamic features of the impact measurement data, and configures spectral normalization operations between convolutional layers to suppress gradient explosion. The spatial convolution module uses a multi-layer two-dimensional convolutional neural network to fuse the topological adjacency matrix of the distribution network with the impact measurement data to extract the spatial topological correlation between distribution network nodes. The generator also includes a feature fusion module, which concatenates and fuses the temporal dynamic features and the spatial topological correlation in the channel dimension, and upsamples the fused features to the same dimension as the original measurement data through deconvolution decoding to generate preliminary repair data z. raw .

[0009] Preferably, in step S2, after generating preliminary data, the physical constraint module further forces it to meet the power grid operation rules to ensure the engineering feasibility of the repair results. The preliminary repair data zraw ​​is then input into the system. In the formula: z is the system measurement vector, including the three-phase active power, reactive power, and current amplitude of the branch, the three-phase voltage amplitude and phase angle of the node, the real-time measurement data of the three-phase current amplitude and phase angle of the connected branches, and the pseudo-measurement data of conventional load power, photovoltaic power generation system output, and wind power generation system output; x is the system state variable. h (·) is the measurement Jacobian matrix, which is linearized and approximated at the nominal operating point, i.e.: ,in It is a matrix with constant coefficients. Take the rated state (voltage amplitude at each node) Phase angle The rows of the matrix correspond to the measurement types, and the columns correspond to the state variables, including node voltage amplitudes. Phase angle The specific elements are determined by the distribution network topology parameters, i.e., the admittance matrix. G , B Decision, based on nodes i For example, Node voltage amplitude measurement ; ; The subscript 0 indicates the value at the rated operating point. ; The residuals of the feedback power flow equations are: In the formula, z gen It is the generator that repairs the data. z est Based on generated data z gen The measurement estimate obtained through state estimation, with η=0.01 as the residual correction step size; a differentiable voltage limiting function is embedded in the generator's output layer to ensure that the generated data meets operational constraints. First, based on the preliminary repair data from the current generator. z raw Solve for the least squares state estimate using a linearized model: Reconstructed measurement estimates: in, Representation matrix The Moore-Penrose generalized inverse; when the distribution network measurement configuration makes the number of measurements greater than or equal to the number of state variables and When the term of office is completed, When the distribution network is underdetermined (i.e., the number of measurements is less than the number of state variables or the matrix is ​​rank deficient), the generalized inverse is calculated using singular value decomposition (SVD). The generalized inverse ensures that regardless of the Jacobian matrix... Regardless of the dimension and rank of , the projection correction formulas of the above physical constraint modules can be stably calculated and give a unique minimum norm solution. Subsequently, residual calculation and projection correction are performed, and linearized residuals are defined. for: The generator's corrected output is: Substitute Later I learned: After sorting, we get: Subsequently, processing Voltage amplitude components: In the formula, z gen It is the generator that repairs the data. V m gen The node output by the generator m voltage amplitude, k Control the steepness of the clamp. μ The center offset parameter is optimized through backpropagation; SEBlock is the channel attention mechanism module. r The compression ratio is usually set to 16; Clamp is the physical limiting function. The nodes in the initial generated data m voltage amplitude, It is the voltage amplitude after limiting; When the residual current If the voltage exceeds the limit, the generator undergoes iterative optimization, freezing the discriminator parameters, updating the generator parameters, adaptively adjusting the learning rate, and using projective gradient descent. V m gen Mandatory compliance with regulations.

[0010] Preferably, in step S3, constructing and training the discriminator specifically involves: The discriminator adopts a multi-layer shallow two-dimensional convolutional neural network architecture, which expands the receptive field layer by layer to extract local temporal and spatial features of the input data at multiple scales. The discriminator and generator are jointly optimized using an asymmetric alternating adversarial training strategy based on Wasserstein distance; During joint training, when the generator triggers the iterative correction of the physical constraint module, the discriminator parameters are frozen, and the generator parameters are updated only using the projected gradient descent method until the preset iteration termination condition is reached. The iteration termination condition is as follows: on the validation set, the variance fluctuations of the generator and discriminator loss functions converge to a preset stable interval, and the physical constraint satisfaction rate, state estimation accuracy, and attack detection rate simultaneously meet the preset convergence thresholds, thus determining that the model has reached the convergence state.

[0011] Preferably, in step S4, shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the authenticity probability and the attack heatmap. Historical measurement dataset { z(k) real} K ( k =1), K =10 4 Input discriminator level 2 to obtain feature maps Then for each F ( k ) real By spatial location ( m , n Slicing to obtain temporal feature vectors To ensure data accuracy, newly collected non-attack data is incrementally added to the baseline database every 24 hours after feature extraction at level 2, with a maximum capacity of [missing information]. K max =10 4 ; The detection data is input into discriminator level 2 to obtain a feature map. Temporal features are extracted by slicing the map at each location. Then, the M candidate patterns with the smallest DTW distance are retrieved from the benchmark database: In the formula, M is set to 5 to retain the top five similar candidates; the candidate patterns are weighted and averaged to generate the final baseline pattern: In the formula, η =0.1 is the temperature coefficient, which controls the steepness of the weight distribution; time t The derived measurement innovation vector is: When not subjected to FDIA, the sequence follows a zero-mean normal distribution; at this time, the first and second halves of the benchmark and test sequences... i The innovative elements of each element are: In the formula: ν u,i,a It is the benchmark sequence number i The element of the first a A measurement innovation vector, ν o,i,b It is the test sequence number i The element of the first b A measurement innovation vector, P u It is the number of benchmark sequence entries. P o It tests the number of innovative sequence entries. P u = P o =T, f= N is the total number of measurement innovation vectors; To derive the DTW distance, a pair of nodes is constructed ( q , s Cost matrix C q,s : Based on the principles of dynamic programming, the paired nodes are calculated along the positive direction. q ,s Minimum cumulative cost matrix D q,s : In the formula: D 0,0 Initialize to 0, D q,0 = D 0,s =∞, At this time, the first i The DTW distance of each innovative element is the distance between paired nodes ( P u , P o Total cumulative cost: D ( m , n ) dtw The DTW distance between two points; using an attention mechanism to improve operational efficiency: In the formula, a ( m , n ) dtw It is spatial location ( m , n The importance weight of time-series features, β It is the temperature coefficient; when D ( m , n ) dtw When smaller, a ( m , n ) dtw High, retaining characteristics of normal regions; when D ( m , n ) dtw When it is large, reduce a ( m , n ) dtw Suppress attacks and interference; Level 3 further compresses the temporal and spatial dimensions using a step size of 2. and After two rounds of downsampling, the receptive field of this layer expands to the corresponding four time step spans to detect temporal distribution shifts and regional power imbalances caused by attacks over long time spans. The number of channels is increased to 256, complex distribution patterns are modeled, and 3×3 convolutional kernels slide in the spatial dimension, covering a 3×3 node group. Changes, identifying regional power imbalances: When an attack occurs The system exhibits regional power imbalance. After capturing the temporal distribution shift caused by the attack at level 3, the discriminator further enhances its sensitivity to null space perturbations through a channel attention mechanism. Null space perturbations refer to spurious injection components where the attack vector falls within the column space of the measurement Jacobian matrix, making the state estimation residual test undetectable. Channel attention adaptively weights the 512-dimensional channel response at level 4, amplifying the slight deviations of the attack sample on specific topologically sensitive channels, thereby achieving covert attack identification under the premise of undetectable residuals. Level 4 is a channel attention-enhanced null space perturbation detection system. In the formula, the fourth layer also adopts... With a convolution kernel and a stride of 2, the temporal and spatial dimensions are further compressed to... and At this point, the network's total receptive field reaches the corresponding set span of 8 time steps, used to capture concealed and sparse zero-space perturbation attack signals, and in conjunction with the channel attention mechanism to enhance the characteristic response of sensitive channels. r It is the compression ratio of the channel attention function CAttn; In the formula, It is global information. s It is an adaptive weight. Fattn 4 is feature recalibration. δ It is the ReLU activation function. σ It is the Sigmoid function; F up This is the upsampled feature map; null space perturbations are difficult to detect in traditional detection methods, but channel attention amplifies the signal strength of relevant channels by increasing their weights. Furthermore, it uses adaptive weights... sSuppressing noise channels and focusing on attack-sensitive channels; the high-dimensional spatiotemporal features of the output of level 4 need to be further aggregated into global discrimination signals. To this end, the discriminator introduces global average pooling and heatmap generation modules to achieve seamless connection from fine-grained features to decision output. In the formula, f gap It is the feature vector after global average pooling. D ( z The value ∈ [0,1] is the final output of the discriminator; the larger the value, the more realistic it is. It is a location ( t , n The original score of ) H (t,n) It is an attack heatmap that accurately marks attacked nodes and time intervals.

[0012] Preferably, in step S5, a multi-objective joint optimization loss function is designed by combining the true and false probabilities with the attack heatmap to achieve consistency between the generated data and the real data without attack, and to replace the attacked data to achieve FDIA defense. Regarding the feedback of the discrimination signal, the probability of true or false signals. D ( z Directly involved in the discriminator loss L D The calculation measures the difference in distribution between generated data and real data, and attacks the heatmap. H (t,n) Provides space-time dimension repair guidance for the generator, implicitly including physical consistency loss. In the middle, then there is the adversarial dynamic equilibrium, where the discriminator maximizes... D ( z real ) and minimization D ( z To improve attack detection sensitivity, the generator minimizes log(1- D ( G ( z This deceives the discriminator while ensuring the satisfaction of physical constraints, forming a closed loop of "attack generation - detection and countermeasure - repair and iteration". Based on the above feature outputs, the discriminator and generator are jointly optimized using the following multi-objective loss function: In the formula, D ,G It consists of a generator and a discriminator. It measures the distribution of generated data Compared with the actual data distribution distance, It's a gradient penalty that forces the discriminator to satisfy the Lipschitz continuity constraint, preventing training instability. It is based on the temporal alignment difference between data generated by dynamic time warp quantization and the real mode. , The weighting coefficients are determined through cross-validation. It is to combat losses. It is a physical residual. These are weighting coefficients. It is a reconstruction error that ensures the generation of data. Compared to real data without attacks Pixel-level consistency These are gradient penalty weight parameters. These are the weight parameters of the DTW loss term. These are the weighting parameters for the physical residual terms. It is a reconstruction of the error term weight parameters, and each weight parameter is subjected to rolling cross-validation based on the time series.

[0013] Historical no-attack measurement dataset k=10 4 Each sample is a complete measurement matrix of T*N, serving as the data source for time-series rolling cross-validation. The dataset is arranged in chronological order and divided into three parts: training set (70%), validation set (15%), and test set (15%). To prevent data leakage, both the validation and test sets are taken from time periods following the training set, and overlap between adjacent samples is allowed (sliding window step size is 1). To further improve stability, a 5-fold rolling validation is used: the training set + validation set is divided into 5 equal parts in chronological order, and 4 parts are used for training and 1 part for validation, repeated 5 times. The average performance index is used as the basis for weight selection. On the validation set, for each candidate weight combination Accuracy of state estimation Attack detection rate Physical feasibility Training stability Four indicators, plus a weighted overall score: In the formula, N It is the total number of network nodes. Repairing nodes after generator m voltage amplitude, For nodes in real measurements without attacks at the same time m The voltage amplitude; In the formula, TP To determine the number of attack samples that were correctly detected, FN This represents the number of attack samples that were missed. In the formula, M The total number of samples in the validation set. m For sample index ( ), For the first m The power flow residual vector of each sample; In the formula, The variance of the generator loss value; The weighted scoring formula is: According to the overall score S Bayesian optimization is used for the search; the search range for each parameter is... Step size 0.1 Step size 2, Step size 0.2 The step size is logarithmic; 20 random samples are initialized, and then the Gaussian process surrogate model is iterated 50 times. Each time, the candidate point with the largest expected improvement is selected for evaluation; when the comprehensive score improvement of 10 consecutive iterations is less than 0.5%, the process stops, the historical best weight combination is taken as the final result, and the generalization performance of the selected weights is verified on the test set. If the test set score is not lower than 90% of the validation set score, the weights are considered reasonable; otherwise, the process regresses to the suboptimal combination.

[0014] Compared with existing technologies, the dynamic defense method against spoofing attacks based on CNN-GAN provided by this invention achieves at least the following beneficial effects: 1. This invention achieves a deep integration of data-driven approaches and physical laws, ensuring the safety and feasibility of defensive actions. Traditional data-driven defense models often suffer from "repair illusions" due to neglecting power grid physical constraints, rendering repair solutions infeasible. This invention embeds a differentiable voltage limiting function into the generator, integrating physical rules such as power flow equations into the training process in a differentiable form, forcing repair results to strictly conform to the electrical limits and topological constraints of the power grid. This fundamentally solves the problem of traditional methods potentially violating Kirchhoff's laws in repair data, making the generated defense commands physically real and safe, directly usable for subsequent control, and greatly improving engineering practicality.

[0015] 2. Significantly improves the real-time performance and accuracy of attack detection, localization, and remediation, achieving dynamic proactive defense. This invention constructs a dual-path spatiotemporal feature extractor by extracting spatial features using multi-scale CNNs and capturing temporal dynamics through adversarial training of GANs. Combined with the attention mechanism of the discriminator, it can accurately generate attack heatmaps, enabling rapid attack localization. Tests show that this architecture reduces attack remediation time by 60% and achieves a 75% remediation rate within 30 seconds after an attack. This signifies a shift in defense mode from post-attack analysis to real-time, dynamic proactive interception and rapid self-healing, effectively addressing the suddenness and stealth of FDIAs.

[0016] 3. Demonstrates strong robustness and environmental adaptability to high-penetration renewable energy access and extreme operating conditions. Traditional centralized defense models suffer severe performance degradation in scenarios with highly random and volatile renewable energy output. The distributed GAN architecture and data-driven training mode employed in this invention enable it to better learn and adapt to complex and changing operating states. In extreme test scenarios with high renewable energy penetration, the degradation rate of key performance indicators of this method is only 10% of that of traditional centralized methods, demonstrating its stronger reliability and broader adaptability in future new power distribution systems. This provides an effective solution to address the security defense challenges in highly uncertain "source-load" environments. Attached Figure Description

[0017] Figure 1 This is a diagram of the IEEE 123 node distribution network test system containing PMU and FTU measurement devices; Figure 2 This is a comparison chart of the system's ability to maintain security thresholds; Figure 3 (a) is a comparison chart of repair times under the first attack scenario; Figure 3 (b) is a comparison chart of repair times under the second attack scenario; Figure 4 (a) is a comparison of the repair effects under the first attack scenario; Figure 4 (b) is a comparison of the repair effect under the second attack scenario. Detailed Implementation

[0018] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0019] like Figure 1-4 As shown, the dynamic defense method against spoofing attacks based on CNN-GAN includes the following steps: S1. Preprocess the multidimensional data; S2. Using a dual-path convolutional architecture generator, extract the temporal dynamic features and spatial topological correlation of the impact measurement matrix, and generate preliminary repair data. S3. Limit the initial repair data through the physical constraint module to ensure the engineering feasibility of the repair results; S4. Shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the true and false probability and the attack heat map. S5. Combining the true / false probability with the attack heatmap, design a multi-objective joint optimization loss function to achieve consistency between the generated data and the real data without attack, replace the attacked data, and achieve FDIA defense.

[0020] Step 1 is as follows: Multidimensional data is defined as: various electrical measurement data in the distribution network with different physical units and significantly different numerical magnitudes, specifically including node voltage amplitude, node voltage phase angle, node active power, node reactive power, branch active power, and branch reactive power; historical measurement datasets Data from each node is categorized and statistically analyzed according to measurement type. Each six-column array corresponds to six types of measurements for one node, and each type of measurement is standardized. Taking node m as an example, the six types of measurements are categorized according to node voltage amplitude. Node voltage phase angle Active power at nodes Node reactive power Branch active power Branch reactive power arrangement; Historical measurement dataset Attacked measurement data matrix Generator repairs dataset The j The columns are standardized according to the measurement type: In the formula: T is the time series length, and N is the number of network nodes. express b Set at time t j The input element of the column, , express b Set at time t j The output elements of the column, It is the first j Historical average of column elements It is the first j The historical standard deviation of column elements The processed data are concatenated into the corresponding processed set according to the original node order; by calculating the mean and standard deviation for each type of measurement and standardizing and eliminating dimensional differences, all data are mapped to the same dimensional space.

[0021] Step 2 is as follows: The generator is constructed using a dual-path convolutional neural network; The generator includes a temporal convolution module and a spatial convolution module; The temporal convolution module uses a multi-layer one-dimensional convolutional neural network to extract the temporal dynamic features of the impact measurement data, and configures spectral normalization operations between convolutional layers to suppress gradient explosion. The spatial convolution module uses a multi-layer two-dimensional convolutional neural network to fuse the topological adjacency matrix of the distribution network with the impact measurement data to extract the spatial topological correlation between distribution network nodes. The generator also includes a feature fusion module, which concatenates and fuses the temporal dynamic features and the spatial topological correlation in the channel dimension, and upsamples the fused features to the same dimension as the original measurement data through deconvolution decoding to generate preliminary repair data z. raw .

[0022] In step S2, after generating preliminary data, the physical constraint module further forces it to meet the power grid operation rules to ensure the engineering feasibility of the repair results. The preliminary repair data zraw ​​is then input into the system. In the formula: z is the system measurement vector, including the three-phase active power, reactive power, and current amplitude of the branch, the three-phase voltage amplitude and phase angle of the node, the real-time measurement data of the three-phase current amplitude and phase angle of the connected branches, and the pseudo-measurement data of conventional load power, photovoltaic power generation system output, and wind power generation system output; x is the system state variable. h (·) is the measurement Jacobian matrix, which is linearized and approximated at the nominal operating point, i.e.: ,in It is a matrix with constant coefficients. Take the rated state (voltage amplitude at each node) Phase angle The rows of the matrix correspond to the measurement types, and the columns correspond to the state variables, including node voltage amplitudes. Phase angle The specific elements are determined by the distribution network topology parameters, i.e., the admittance matrix. G , B Decision, based on nodes i For example, Node voltage amplitude measurement ; ; The subscript 0 indicates the value at the rated operating point. ; The residuals of the feedback power flow equations are: In the formula,z gen It is the generator that repairs the data. z est Based on generated data z gen The measurement estimate obtained through state estimation, with η=0.01 as the residual correction step size; a differentiable voltage limiting function is embedded in the generator's output layer to ensure that the generated data meets operational constraints. First, based on the preliminary repair data from the current generator. z raw Solve for the least squares state estimate using a linearized model: Reconstructed measurement estimates: in, Representation matrix The Moore-Penrose generalized inverse; when the distribution network measurement configuration makes the number of measurements greater than or equal to the number of state variables and When the term of office is completed, When the distribution network is underdetermined (i.e., the number of measurements is less than the number of state variables or the matrix is ​​rank deficient), the generalized inverse is calculated using singular value decomposition (SVD). The generalized inverse ensures that regardless of the Jacobian matrix... Regardless of the dimension and rank of , the projection correction formulas of the above physical constraint modules can be stably calculated and give a unique minimum norm solution. Subsequently, residual calculation and projection correction are performed, and linearized residuals are defined. for: The generator's corrected output is: Substitute Later I learned: After sorting, we get: Subsequently, processing Voltage amplitude components: In the formula, z gen It is the generator that repairs the data. V m gen The node output by the generator m voltage amplitude,k Control the steepness of the clamp. μ The center offset parameter is optimized through backpropagation; SEBlock is the channel attention mechanism module. r The compression ratio is usually set to 16; Clamp is the physical limiting function. The nodes in the initial generated data m voltage amplitude, It is the voltage amplitude after limiting; When the residual current If the voltage exceeds the limit, the generator undergoes iterative optimization, freezing the discriminator parameters, updating the generator parameters, adaptively adjusting the learning rate, and using projective gradient descent. V m gen Mandatory compliance with regulations.

[0023] In step S3, the discriminator is constructed and trained, specifically as follows: The discriminator adopts a multi-layer shallow two-dimensional convolutional neural network architecture, which expands the receptive field layer by layer to extract local temporal and spatial features of the input data at multiple scales. The discriminator and generator are jointly optimized using an asymmetric alternating adversarial training strategy based on Wasserstein distance; During joint training, when the generator triggers the iterative correction of the physical constraint module, the discriminator parameters are frozen, and the generator parameters are updated only using the projected gradient descent method until the preset iteration termination condition is reached. The iteration termination condition is as follows: on the validation set, the variance fluctuations of the generator and discriminator loss functions converge to a preset stable interval, and the physical constraint satisfaction rate, state estimation accuracy, and attack detection rate simultaneously meet the preset convergence thresholds, thus determining that the model has reached the convergence state.

[0024] In step S4, shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the authenticity probability and the attack heatmap. Historical measurement dataset { z(k) real} K ( k =1), K =10 4 Input discriminator level 2 to obtain feature maps Then for each F ( k ) real By spatial location ( m , n Slicing to obtain temporal feature vectors To ensure data accuracy, newly collected non-attack data is incrementally added to the baseline database every 24 hours after feature extraction at level 2, with a maximum capacity of [missing information]. K max =10 4 ; The detection data is input into discriminator level 2 to obtain a feature map. Temporal features are extracted by slicing the map at each location. Then, the M candidate patterns with the smallest DTW distance are retrieved from the benchmark database: In the formula, M is set to 5 to retain the top five similar candidates; the candidate patterns are weighted and averaged to generate the final baseline pattern: In the formula, η =0.1 is the temperature coefficient, which controls the steepness of the weight distribution; time t The derived measurement innovation vector is: When not subjected to FDIA, the sequence follows a zero-mean normal distribution; at this time, the first and second halves of the benchmark and test sequences... i The innovative elements of each element are: In the formula: ν u,i,a It is the benchmark sequence number i The element of the first a A measurement innovation vector, ν o,i,b It is the test sequence number i The element of the first b A measurement innovation vector, P u It is the number of benchmark sequence entries. P o It tests the number of innovative sequence entries. P u = P o =T, f= N is the total number of measurement innovation vectors; To derive the DTW distance, a pair of nodes is constructed ( q , s Cost matrix C q,s : Based on the principles of dynamic programming, the paired nodes are calculated along the positive direction. q , s Minimum cumulative cost matrix D q,s : In the formula: D 0,0 Initialize to 0, D q,0 = D 0,s =∞, At this time, the first i The DTW distance of each innovative element is the distance between paired nodes ( P u , P o Total cumulative cost: D ( m , n ) dtw The DTW distance between two points; using an attention mechanism to improve operational efficiency: In the formula, a ( m , n ) dtw It is spatial location ( m , n The importance weight of time-series features, β It is the temperature coefficient; when D ( m , n ) dtw When smaller, a ( m , n ) dtw High, retaining characteristics of normal regions; when D ( m , n ) dtw When it is large, reduce a ( m , n ) dtw Suppress attacks and interference; Level 3 further compresses the temporal and spatial dimensions using a step size of 2. and After two rounds of downsampling, the receptive field of this layer expands to the corresponding four time step spans to detect temporal distribution shifts and regional power imbalances caused by attacks over long time spans. The number of channels is increased to 256, complex distribution patterns are modeled, and 3×3 convolutional kernels slide in the spatial dimension, covering a 3×3 node group. Changes, identifying regional power imbalances: When an attack occurs The system exhibits regional power imbalance. After capturing the temporal distribution shift caused by the attack at level 3, the discriminator further enhances its sensitivity to null space perturbations through a channel attention mechanism. Null space perturbations refer to spurious injection components where the attack vector falls within the column space of the measurement Jacobian matrix, making the state estimation residual test undetectable. Channel attention adaptively weights the 512-dimensional channel response at level 4, amplifying the slight deviations of the attack sample on specific topologically sensitive channels, thereby achieving covert attack identification under the premise of undetectable residuals. Level 4 is a channel attention-enhanced null space perturbation detection system. In the formula, the fourth layer also adopts... With a convolution kernel and a stride of 2, the temporal and spatial dimensions are further compressed to... and At this point, the network's total receptive field reaches the corresponding set span of 8 time steps, used to capture concealed and sparse zero-space perturbation attack signals, and in conjunction with the channel attention mechanism to enhance the characteristic response of sensitive channels. r It is the compression ratio of the channel attention function CAttn; In the formula, It is global information. s It is an adaptive weight. Fattn 4 is feature recalibration. δ It is the ReLU activation function. σ It is the Sigmoid function; F up This is the upsampled feature map; null space perturbations are difficult to detect in traditional detection methods, but channel attention amplifies the signal strength of relevant channels by increasing their weights. Furthermore, it uses adaptive weights... s Suppressing noise channels and focusing on attack-sensitive channels; the high-dimensional spatiotemporal features of the output of level 4 need to be further aggregated into global discrimination signals. To this end, the discriminator introduces global average pooling and heatmap generation modules to achieve seamless connection from fine-grained features to decision output. In the formula, f gap It is the feature vector after global average pooling. D ( z The value ∈ [0,1] is the final output of the discriminator; the larger the value, the more realistic it is. It is a location ( t , n The original score of ) H (t,n) It is an attack heatmap that accurately marks attacked nodes and time intervals.

[0025] In step S5, a multi-objective joint optimization loss function is designed by combining the true and false probabilities with the attack heatmap to achieve consistency between the generated data and the real data without attack, and to replace the attacked data to achieve FDIA defense. Regarding the feedback of the discrimination signal, the probability of true or false signals. D ( z Directly involved in the discriminator loss L D The calculation measures the difference in distribution between generated data and real data, and attacks the heatmap. H (t,n) Provides space-time dimension repair guidance for the generator, implicitly including physical consistency loss. In the middle, then there is the adversarial dynamic equilibrium, where the discriminator maximizes... D ( z real ) and minimization D ( z To improve attack detection sensitivity, the generator minimizes log(1- D ( G ( z This deceives the discriminator while ensuring the satisfaction of physical constraints, forming a closed loop of "attack generation - detection and countermeasure - repair and iteration". Based on the above feature outputs, the discriminator and generator are jointly optimized using the following multi-objective loss function: In the formula, D , G It consists of a generator and a discriminator. It measures the distribution of generated data Compared with the actual data distribution distance, It's a gradient penalty that forces the discriminator to satisfy the Lipschitz continuity constraint, preventing training instability. It is based on the temporal alignment difference between data generated by dynamic time warp quantization and the real mode. , The weighting coefficients are determined through cross-validation. It is to combat losses. It is a physical residual. These are weighting coefficients. It is a reconstruction error that ensures the generation of data. Compared to real data without attacks Pixel-level consistency These are gradient penalty weight parameters. These are the weight parameters of the DTW loss term. These are the weighting parameters for the physical residual terms. These are the weight parameters for reconstructing the error term, and each weight parameter is subjected to rolling cross-validation based on the time series. Historical no-attack measurement dataset k=10 4 Each sample is a complete measurement matrix of T*N, serving as the data source for time-series rolling cross-validation. The dataset is arranged in chronological order and divided into three parts: training set (70%), validation set (15%), and test set (15%). To prevent data leakage, both the validation and test sets are taken from time periods following the training set, and overlap between adjacent samples is allowed (sliding window step size is 1). To further improve stability, a 5-fold rolling validation is used: the training set + validation set is divided into 5 equal parts in chronological order, and 4 parts are used for training and 1 part for validation, repeated 5 times. The average performance index is used as the basis for weight selection. On the validation set, for each candidate weight combination Accuracy of state estimation Attack detection rate Physical feasibility Training stability Four indicators, plus a weighted overall score: In the formula, N It is the total number of network nodes. Repairing nodes after generator m voltage amplitude, For nodes in real measurements without attacks at the same time m The voltage amplitude; In the formula, TP To determine the number of attack samples that were correctly detected, FN This represents the number of attack samples that were missed. In the formula, M The total number of samples in the validation set. m For sample index ( ), For the first m The power flow residual vector of each sample; In the formula, The variance of the generator loss value; The weighted scoring formula is: According to the overall score S Bayesian optimization is used for the search; the search range for each parameter is... Step size 0.1 Step size 2, Step size 0.2 The step size is logarithmic; 20 random samples are initialized, and then the Gaussian process surrogate model is iterated 50 times. Each time, the candidate point with the largest expected improvement is selected for evaluation; when the comprehensive score improvement of 10 consecutive iterations is less than 0.5%, the process stops, the historical best weight combination is taken as the final result, and the generalization performance of the selected weights is verified on the test set. If the test set score is not lower than 90% of the validation set score, the weights are considered reasonable; otherwise, the process regresses to the suboptimal combination.

[0026] The feasibility and effectiveness of the proposed dynamic defense strategy against spoofing attacks based on convolutional neural networks and generative adversarial networks are tested and verified using an improved IEEE 123-node test system. The test system has a rated voltage of 4.16 kV, and the total three-phase load capacities are 1420+j775 kVA (phase a), 915+j515 kVA (phase b), and 1155+j635 kVA (phase c). The rated power and network parameters for each phase of each load are shown in the reference (Cheng Yanzhe. State estimation of three-phase unbalanced distribution networks considering spoofing attacks [D]. Southeast University, Nanjing, 2021). The system consists of 123 load node buses and 122 lines (excluding tie lines). The test system is divided into four overlapping sub-regions using a partitioning method, as follows: Figure 1As shown, node 152 is the boundary node between sub-regions I and II, node 135 is the boundary node between sub-regions I and III, and node 160 is the boundary node between sub-regions II and IV. High-precision phasor measurement units (PMUs) are installed at these boundary nodes and the relaxed bus nodes, and multiple feeder terminal units (FTUs) are installed on other lines. These devices provide measurement data for the distribution network state estimation process. Furthermore, to provide a more intuitive analysis of the distributed dynamic state estimation results of the distribution network under network attacks, the nodes in the four sub-regions of the IEEE 123-node test network are renumbered in ascending order: sub-region I contains 39 nodes, sub-region II contains 32 nodes, sub-region III contains 23 nodes, and sub-region IV contains 29 nodes.

[0027] (1) Comparison of the robustness of adversarial correction strategies To verify the dynamic adaptability of different defense mechanisms under complex perturbation scenarios, extreme conditions were constructed, including detection of false negatives (10% of attack samples masked), gradient spoofing attacks (Δ=0.003 pu / s), and coupling of source-load random fluctuations. This was used to compare the robustness differences between traditional residual compensation correction (RCC), LSTM prediction correction (LSTM-SPC), and the proposed CNGN-GAN dynamic defense strategy. In the experiment, the attack window covered the load abrupt change phase (t=100s±25% step change), and was superimposed with photovoltaic power Beta distribution fluctuations conforming to IEC61850 (α=2, β=5, amplitude ±15%).

[0028] Depend on Figure 2 It is evident that under extreme conditions of detection failure, the CNN-GAN defense mechanism exhibits superior safety threshold maintenance capabilities, controlling the maximum voltage deviation below 0.041 pu, representing an improvement of over 54% compared to traditional methods. This eliminates the risk of overload on critical lines and compresses the node frequency offset rate to 2.1%, a 78% reduction compared to the optimal control group. This advantage stems from a dual mechanism of spatial feature decoupling and dynamic adversarial compensation. Specifically, the CNN precisely isolates contaminated measurement nodes, while the GAN generator reconstructs safe measurements under gradient attacks in real time. This constructs a robust underlying defense for system resilience in scenarios with multiple perturbations, providing core protection for high-reliability distribution networks.

[0029] (2) Comparison of repair time To verify the advantages of the proposed method in terms of repair time, different types of detection methods were selected for simulation comparison under different attack scenarios, including: traditional generalized likelihood ratio test (GLRT), support vector machine (SVM), and long short-term memory network (LSTM). Attack scenario a involves disrupting the measurement state variables related to the 152 nodes at 30s, amplifying the active and reactive power of the 152 nodes by a factor of 1.25; attack scenario b involves disrupting the predicted state variables of the 152 nodes at 30s, amplifying the predicted state variables of the 152 nodes by 1.25 pu. Simulation results are as follows. Figure 3 As shown.

[0030] Depend on Figure 3 As can be seen, the repair time of the method of this invention shows a significant advantage in both attack scenarios. In scenario a, after the attack occurs, the repair time of the method of this invention is 8 seconds, which is reduced by 33.3%, 46.7%, and 60% compared with the repair times of LSTM, SNM, and GLRT, respectively. As the attack continues, relying on the three core mechanisms of spatiotemporal data fusion, dynamic threshold optimization, and sub-region collaboration, the attack feature extraction efficiency of the method of this invention is improved, and the repair time is significantly reduced. In scenario b, where the attack situation is more complex, the method of this invention has better adaptability. After the attack occurs, the repair time is only 40% of that of the traditional GLRT method, and the slope of the repair efficiency curve is also significantly better than that of LSTM and SVM.

[0031] (3) Comparison of repair effects By comparing with LSTM, SNM, and GLRT methods, the superior repair performance of the method of this invention is demonstrated. Figure 4 As can be seen, in attack scenario a, the method of this invention achieves an initial repair rate of 75% 30 seconds after the attack, which is 114% and 66.7% higher than the 35% of the traditional GLRT method and the 45% of the SVM method, respectively. Furthermore, as time progresses, the method of this invention achieves complete repair 60 seconds after the attack, demonstrating the continuous optimization capability of the spatiotemporal feature fusion mechanism of this invention. Facing the more complex attack scenario b, the method of this invention still maintains an initial repair rate of 65%, far exceeding the 35% of the SVM method and the 25% of the GLRT method. The method of this invention demonstrates good performance in repair speed, error suppression, and convergence stability, which is attributed to the use of three-phase coupled feature analysis, dynamic adversarial training mechanism, and partitioned collaborative verification.

[0032] The above embodiments are not intended to limit the present invention, and the present invention is not limited to the examples given above. Any changes, modifications, additions or substitutions made by those skilled in the art within the scope of the technical solution of the present invention are also within the protection scope of the present invention.

Claims

1. A dynamic defense method against spoofing attacks based on CNN-GAN, characterized by: Includes the following steps: S1. Preprocess the multidimensional data; S2. Using a dual-path convolutional architecture generator, extract the temporal dynamic features and spatial topological correlation of the impact measurement matrix, and generate preliminary repair data. S3. Limit the initial repair data through the physical constraint module to ensure the engineering feasibility of the repair results; S4. Shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the true and false probability and the attack heat map. S5. Combining the true / false probability with the attack heatmap, design a multi-objective joint optimization loss function to achieve consistency between the generated data and the real data without attack, replace the attacked data, and achieve FDIA defense.

2. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: Step 1 is as follows: Multidimensional data is defined as: various electrical measurement data in the distribution network with different physical units and significantly different numerical magnitudes, specifically including node voltage amplitude, node voltage phase angle, node active power, node reactive power, branch active power, and branch reactive power; historical measurement datasets The data of each node are classified and statistically analyzed according to the measurement type. Each of the six columns corresponds to the six types of measurements of a node, and each type of measurement is standardized. Taking node m as an example, the six types of measurements are based on the node voltage amplitude. Node voltage phase angle Active power at nodes Node reactive power Branch active power Branch reactive power arrangement; Historical measurement dataset Attacked measurement data matrix Generator repairs dataset The j The columns are standardized according to the measurement type: ; In the formula: T is the time series length, and N is the number of network nodes. express b Set at time t j The input element of the column, , express b Set at time t j The output elements of the column, It is the first j Historical average of column elements It is the first j The historical standard deviation of column elements The processed data are concatenated into the corresponding processed set according to the original node order; by calculating the mean and standard deviation for each type of measurement and standardizing and eliminating dimensional differences, all data are mapped to the same dimensional space.

3. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: Step 2 is as follows: The generator is constructed using a dual-path convolutional neural network; The generator includes a temporal convolution module and a spatial convolution module; The temporal convolution module uses a multi-layer one-dimensional convolutional neural network to extract the temporal dynamic features of the impact measurement data, and configures spectral normalization operations between convolutional layers to suppress gradient explosion. The spatial convolution module uses a multi-layer two-dimensional convolutional neural network to fuse the topological adjacency matrix of the distribution network with the impact measurement data to extract the spatial topological correlation between distribution network nodes. The generator also includes a feature fusion module, which concatenates and fuses the temporal dynamic features and the spatial topological correlation in the channel dimension, and upsamples the fused features to the same dimension as the original measurement data through deconvolution decoding to generate preliminary repair data z. raw .

4. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: In step S2, after generating preliminary data, the physical constraint module further forces it to meet the power grid operation rules to ensure the engineering feasibility of the repair results. The preliminary repair data zraw ​​is then input into the system. In the formula: z is the system measurement vector, including the three-phase active power, reactive power, and current amplitude of the branch, the three-phase voltage amplitude and phase angle of the node, the real-time measurement data of the three-phase current amplitude and phase angle of the connected branches, and the pseudo-measurement data of conventional load power, photovoltaic power generation system output, and wind power generation system output; x is the system state variable. h (·) is the measurement Jacobian matrix, which is linearized and approximated at the nominal operating point, i.e.: ,in It is a matrix with constant coefficients. Take the rated state (voltage amplitude at each node) Phase angle The rows of the matrix correspond to the measurement types, and the columns correspond to the state variables, including node voltage amplitudes. Phase angle ; The specific elements are determined by the distribution network topology parameters, i.e., the admittance matrix. G , B Decision, based on nodes i For example, Node voltage amplitude measurement ; ; The subscript 0 indicates the value at the rated operating point. ; The residuals of the feedback power flow equations are: In the formula, z gen It is the generator that repairs the data. z est Based on generated data z gen The measurement estimate obtained through state estimation, with η=0.01 as the residual correction step size; a differentiable voltage limiting function is embedded in the generator's output layer to ensure that the generated data meets operational constraints. First, based on the preliminary repair data from the current generator. z raw Solve for the least squares state estimate using a linearized model: Reconstructed measurement estimates: in, Representation matrix The Moore-Penrose generalized inverse; when the distribution network measurement configuration makes the number of measurements greater than or equal to the number of state variables and When the term of office is completed, When the distribution network is underdetermined, i.e., the number of measurements is less than the number of state variables or the matrix is ​​rank deficient, the generalized inverse is calculated through singular value decomposition (SVD); the generalized inverse is used to guarantee that regardless of the Jacobian matrix... Regardless of the dimension and rank of , the projection correction formulas of the above physical constraint modules can be stably calculated and give a unique minimum norm solution. Subsequently, residual calculation and projection correction are performed, and linearized residuals are defined. for: The generator's corrected output is: Substitute Later it was found that: After sorting, we get: Subsequently, processing Voltage amplitude components: In the formula, z gen It is the generator that repairs the data. V m gen The node output by the generator m voltage amplitude, k Control the steepness of the clamp. μ The center offset parameter is optimized through backpropagation; SEBlock is the channel attention mechanism module. r The compression ratio is usually set to 16; Clamp is the physical limiting function. The nodes in the initial generated data m voltage amplitude, It is the voltage amplitude after limiting; When the residual current If the voltage exceeds the limit, the generator undergoes iterative optimization, freezing the discriminator parameters, updating the generator parameters, adaptively adjusting the learning rate, and using projective gradient descent. V m gen Mandatory compliance with regulations.

5. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: In step S3, the discriminator is constructed and trained, specifically as follows: The discriminator adopts a multi-layer shallow two-dimensional convolutional neural network architecture, which expands the receptive field layer by layer to extract local temporal and spatial features of the input data at multiple scales. The discriminator and generator are jointly optimized using an asymmetric alternating adversarial training strategy based on Wasserstein distance; During joint training, when the generator triggers the iterative correction of the physical constraint module, the discriminator parameters are frozen, and the generator parameters are updated only using the projected gradient descent method until the preset iteration termination condition is reached. The iteration termination condition is as follows: on the validation set, the variance fluctuations of the generator and discriminator loss functions converge to a preset stable interval, and the physical constraint satisfaction rate, state estimation accuracy, and attack detection rate simultaneously meet the preset convergence thresholds, thus determining that the model has reached the convergence state.

6. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: In step S4, shallow convolution is used to initially capture the abnormal traces of the attack in local time and space. The discriminator uses dynamic time warp (DTW) similarity analysis to quantify the degree of temporal deviation between the generated data and the real pattern, and obtain the authenticity probability and the attack heatmap. Historical measurement dataset { z(k) real } K ( k =1), K =10 4 Input discriminator level 2 to obtain feature maps Then for each F ( k ) real By spatial location ( m , n Slicing to obtain temporal feature vectors To ensure data accuracy, newly collected non-attack data is incrementally added to the baseline database every 24 hours after feature extraction at level 2, with a maximum capacity of [missing information]. K max =10 4 ; The detection data is input into discriminator level 2 to obtain a feature map. Temporal features are extracted by slicing the map at each location. Then, the M candidate patterns with the smallest DTW distance are retrieved from the benchmark database: In the formula, M is set to 5 to retain the top five similar candidates; the candidate patterns are weighted and averaged to generate the final baseline pattern: In the formula, η =0.1 is the temperature coefficient, which controls the steepness of the weight distribution; time t The derived measurement innovation vector is: When not subjected to FDIA, the sequence follows a zero-mean normal distribution; at this time, the first and second halves of the benchmark and test sequences... i The innovative elements of each element are: In the formula: ν u,i,a It is the benchmark sequence number i The element of the first a A measurement innovation vector, ν o,i,b It is the test sequence number i The element of the first b A measurement innovation vector, P u It is the number of benchmark sequence entries. P o It tests the number of innovative sequence entries. P u = P o =T, f= N is the total number of measurement innovation vectors; To derive the DTW distance, a pair of nodes is constructed ( q , s Cost matrix C q,s : Based on the principles of dynamic programming, the paired nodes are calculated along the positive direction. q , s Minimum cumulative cost matrix D q,s : In the formula: D 0,0 Initialize to 0, D q,0 = D 0,s =∞, At this time, the first i The DTW distance of each innovative element is the distance between paired nodes ( P u , P o Total cumulative cost: D ( m , n ) dtw The DTW distance between two points; using an attention mechanism to improve operational efficiency: In the formula, a ( m , n ) dtw It is spatial location ( m , n The importance weight of time-series features, β It is the temperature coefficient; when D ( m , n ) dtw When smaller, a ( m , n ) dtw High, retaining characteristics of normal regions; when D ( m , n ) dtw When it is large, reduce a ( m , n ) dtw Suppress attacks and interference; Level 3 further compresses the temporal and spatial dimensions using a step size of 2. and After two rounds of downsampling, the receptive field of this layer expands to the corresponding four time step spans to detect temporal distribution shifts and regional power imbalances caused by attacks over long time spans. The number of channels is increased to 256, complex distribution patterns are modeled, and 3×3 convolutional kernels slide in the spatial dimension, covering a 3×3 node group. Changes, identifying regional power imbalances: When an attack occurs Regional power imbalance; After capturing the temporal distribution shift caused by the attack at level 3, the discriminator further enhances its sensitivity to null space perturbations through a channel attention mechanism. Null space perturbations refer to spurious injection components where the attack vector falls within the column space of the measurement Jacobian matrix, making the state estimation residual test undetectable. Channel attention adaptively weights the 512-dimensional channel response at level 4, amplifying the slight deviations of the attack sample on specific topologically sensitive channels, thereby achieving covert attack identification even when the residual is undetectable. Level 4 is a channel attention-enhanced null space perturbation detection mechanism. In the formula, the fourth layer also adopts... With a convolution kernel and a stride of 2, the temporal and spatial dimensions are further compressed to... and At this point, the network's total receptive field reaches the corresponding set span of 8 time steps, used to capture concealed and sparse zero-space perturbation attack signals, and in conjunction with the channel attention mechanism to enhance the characteristic response of sensitive channels. r It is the compression ratio of the channel attention function CAttn; In the formula, It is global information. s It is an adaptive weight. Fattn 4 is feature recalibration. δ It is the ReLU activation function. σ It is the Sigmoid function; F up This is the upsampled feature map; null space perturbations are difficult to detect in traditional detection methods, but channel attention amplifies the signal strength of relevant channels by increasing their weights. Furthermore, it uses adaptive weights... s Suppressing noise channels and focusing on attack-sensitive channels; the high-dimensional spatiotemporal features of the output of level 4 need to be further aggregated into global discrimination signals. To this end, the discriminator introduces global average pooling and heatmap generation modules to achieve seamless connection from fine-grained features to decision output. In the formula, f gap It is the feature vector after global average pooling. D ( z The value ∈ [0,1] is the final output of the discriminator; the larger the value, the more realistic it is. It is a location ( t , n The original score of ) H (t,n) It is an attack heatmap that accurately marks attacked nodes and time intervals.

7. The dynamic defense method against spoofing attacks based on CNN-GAN according to claim 1, characterized in that: In step S5, a multi-objective joint optimization loss function is designed by combining the true and false probabilities with the attack heatmap to achieve consistency between the generated data and the real data without attack, and to replace the attacked data to achieve FDIA defense. Regarding the feedback of the discrimination signal, the probability of true or false signals. D ( z Directly involved in the discriminator loss L D The calculation measures the difference in distribution between generated data and real data, and attacks the heatmap. H (t,n) Provides space-time dimension repair guidance for the generator, implicitly including physical consistency loss. In the middle, then there is the adversarial dynamic equilibrium, where the discriminator maximizes... D ( z real ) and minimization D ( z To improve attack detection sensitivity, the generator minimizes log(1- D ( G ( z This deceives the discriminator while ensuring the satisfaction of physical constraints, forming a closed loop of "attack generation - detection and countermeasure - repair and iteration". Based on the above feature outputs, the discriminator and generator are jointly optimized using the following multi-objective loss function: In the formula, D , G It consists of a generator and a discriminator. It measures the distribution of generated data Compared with the actual data distribution distance, It's a gradient penalty that forces the discriminator to satisfy the Lipschitz continuity constraint, preventing training instability. It is based on the temporal alignment difference between data generated by dynamic time warp quantization and the real mode. , The weighting coefficients are determined through cross-validation. It is to combat losses. It is a physical residual. These are weighting coefficients. It is a reconstruction error that ensures the generation of data. Compared to real data without attacks Pixel-level consistency These are gradient penalty weight parameters. These are the weight parameters of the DTW loss term. These are the weighting parameters for the physical residual terms. These are the weight parameters for reconstructing the error term, and each weight parameter is subjected to rolling cross-validation based on the time series. Historical no-attack measurement dataset k=10 4 Each sample is a complete measurement matrix of T*N, serving as the data source for time-series rolling cross-validation. The dataset is arranged in chronological order and divided into three parts: training set (70%), validation set (15%), and test set (15%). To prevent data leakage, both the validation and test sets are taken from time periods following the training set, and overlap between adjacent samples is allowed (sliding window step size is 1). To further improve stability, a 5-fold rolling validation is used: the training set + validation set is divided into 5 equal parts in chronological order, and 4 parts are used for training and 1 part for validation, repeated 5 times. The average performance index is used as the basis for weight selection. On the validation set, for each candidate weight combination Accuracy of state estimation Attack detection rate Physical feasibility Training stability Four indicators, plus a weighted overall score: In the formula, N It is the total number of network nodes. Repairing nodes after generator m voltage amplitude, For nodes in real measurements without attacks at the same time m The voltage amplitude; In the formula, TP To determine the number of attack samples that were correctly detected, FN This represents the number of attack samples that were missed. In the formula, M The total number of samples in the validation set. m For sample index ( ), For the first m The power flow residual vector of each sample; In the formula, The variance of the generator loss value; The weighted scoring formula is: Based on the overall score S Bayesian optimization is used for the search; the search range for each parameter is... Step size 0.1 Step size 2, Step size 0.2 The step size is logarithmic; 20 random samples are initialized, and then the Gaussian process surrogate model is iterated 50 times. Each time, the candidate point with the largest expected improvement is selected for evaluation; when the comprehensive score improvement of 10 consecutive iterations is less than 0.5%, the process stops, the historical best weight combination is taken as the final result, and the generalization performance of the selected weights is verified on the test set. If the test set score is not lower than 90% of the validation set score, the weights are considered reasonable; otherwise, the process regresses to the suboptimal combination.