# Research on the Simulation Method of HTTP Traffic Based on GAN
## 3 Materials and Methods
### Swin Transformer  
Swin Transformer [30] is a novel architecture based on the transformer framework. Unlike traditional transformers [31], Swin Transformer addresses the issue of processing images with non-standard fixed sizes, reducing computational complexity. By employing a hierarchical architecture similar to CNNs, the model becomes more flexible in handling images of different scales. Additionally, the use of window self-attention helps further reduce computational complexity. To the best of our knowledge, the application of Swin Transformer in generative adversarial networks (GANs) for network traffic synthesis represents a novel approach in the field [32; 33; 34; 35]. While there have been numerous examples of using transformers in both generator and discriminator architectures in the GAN domain, especially in image processing, the utilization of Swin Transformer in network traffic synthesis was unprecedented. In order to reduce the complexity of network data during training and further enhance the quality of generated data, this paper introduced the Swin Transformer structure as the fundamental component of the generator. It replaced the traditional pattern of transposed convolution with batch normalization. Transposed convolution, while emphasizing the rationality of small components, often overlooks the relationship between local and global features. Moreover, using transposed convolution to process network data can lead to the appearance of checkerboard artifacts, posing a challenge to the generation quality of multi-feature network data. In the generation process of network data, any feature that does not meet the requirements can be accurately captured by regulatory authorities. The Swin Transformer architecture employed in this paper utilized both global self-attention mechanisms and local windowed attention mechanisms during training. This enabled the model to capture both global and local features, avoiding situations where local data was irrational. For instance, in a communication process, it is reasonable to have both 5 and 12 packets, as well as accumulated transmission bytes of 1200 and 8300. However, a combination of 5 packets with an accumulated byte count of 8300 is unreasonable because the maximum transmission unit (MTU) is typically 1500 bytes. This highlights the importance of the relationship between global and local features in network data. The overall workflow of the Swin Transformer was as follows. Firstly, the image was partitioned into smaller blocks using the patch partition method. Then, it went through four stages, each consisting of two parts: patch merging and Swin Transformer blocks. The structure of the Swin Transformer block, with a focus on the W-MSA and SW-MSA operations, is illustrated in Figure 3.  
Figure 3 illustrates the architecture of two consecutive blocks. It is important to note that in each stage, the number of blocks was even, as each stage required two different layers: one with window attention (W-MSA) and another with shifted window attention. The reason for choosing W-MSA instead of MSA was due to the task's locality. The transformer can see all elements, but the target to be processed may only be a part of the whole. By using transformer operations within a small window, a significant amount of computational resources was saved. The computational complexity of MSA is shown in Equation (8). \[\Omega(MSA)=4 twC^{2}+2(hw)^{2}C \tag{8}\]  
In the Equation (8), \(h\), \(w\), and \(C\) represent the height, width, and number of channels of the image, respectively. W-MSA is responsible for capturing information within the window, while the information between windows is obtained through SW-MSA. SW-MSA consists of three components: moving window, cyclic shift, and mask. The moving window continuously slides to generate new windows, which may have different sizes. The cyclic shift operation eliminates a portion of the windows. The mask operation is applied to handle the grouping of unrelated parts during the window sliding process, resulting in the final effect.