Network traffic generation technology plays a critical role in network testing and security protection. It simulates various network traffic patterns, offering intrusion detection systems with diverse samples. These samples enhance the system’s adaptability to emerging traffic types and improve detection capabilities. Additionally, it provides high-quality data for traffic analysis algorithms. These data help optimize model performance by increasing robustness and applicability. However, traditional generative models, like GAN networks, have limited capacity for capturing temporal flow features. As a result, they produce suboptimal generation outcomes. To address this issue, we propose the diffusion–attention traffic generation (DATG) framework. This framework combines a diffusion model with a self-attention mechanism. This integration ensures more accurate simulation of temporal characteristics. The diffusion model’s progressive denoising process guarantees generation stability. Meanwhile, the self-attention mechanism captures global temporal dependencies in traffic sequences. Experimental results validate the superior performance of our DATG by reducing the JSD to 0.18 through the synergistic optimization of the diffusion model and the self-attention mechanism, which is 41.9% better than that of GAN. Additionally, it establishes cross-step-length dependencies through the time dimension self-attention mechanism, which reduces the CRPS value to 0.13, which is 31.6% lower than that of GAN.