jamming_signal_algo_20250421173814.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import numpy as np
  2. class JammingSignalAlgo:
  3. @staticmethod
  4. def generate_noise_jam(bandwidth, duration, sample_rate):
  5. num_samples = int(duration * sample_rate)
  6. return np.random.normal(0, 1, num_samples)
  7. @staticmethod
  8. def generate_amplitude_noise_jam(bandwidth, duration, sample_rate):
  9. t = np.arange(0, duration, 1/sample_rate)
  10. carrier = np.sin(2 * np.pi * bandwidth * t)
  11. noise = 0.5 * np.random.normal(0, 1, len(t))
  12. return carrier * noise
  13. @staticmethod
  14. def generate_velocity_deceptive_jam(bandwidth, duration, sample_rate):
  15. t = np.arange(0, duration, 1/sample_rate)
  16. phase_shift = np.cumsum(np.random.uniform(-0.1, 0.1, len(t)))
  17. return np.sin(2 * np.pi * bandwidth * t + phase_shift)
  18. @staticmethod
  19. def generate_deceptive_jam(bandwidth, duration, sample_rate):
  20. t = np.arange(0, duration, 1/sample_rate)
  21. delay = np.random.uniform(0.1, 0.5) # 随机延迟0.1-0.5秒
  22. amplitude = np.random.uniform(0.5, 2.0) # 随机幅度调制
  23. return amplitude * np.sin(2 * np.pi * bandwidth * (t - delay))
  24. @staticmethod
  25. def frequency_modulation(bandwidth, duration, sample_rate, modulation_index=0.5):
  26. """噪声调频干扰算法"""
  27. t = np.arange(0, duration, 1/sample_rate)
  28. baseband = np.random.normal(0, 1, len(t))
  29. modulated = np.sin(2 * np.pi * bandwidth * t + modulation_index * np.cumsum(baseband))
  30. return modulated
  31. @staticmethod
  32. def repeater_jamming(bandwidth, duration, sample_rate, delay=0.1, attenuation=0.5):
  33. """转发式干扰算法"""
  34. t = np.arange(0, duration, 1/sample_rate)
  35. original_signal = np.sin(2 * np.pi * bandwidth * t)
  36. return attenuation * np.roll(original_signal, int(delay * sample_rate))
  37. @staticmethod
  38. def velocity_deception(bandwidth, duration, sample_rate, doppler_shift=1000):
  39. """速度欺骗干扰算法"""
  40. t = np.arange(0, duration, 1/sample_rate)
  41. return np.sin(2 * np.pi * (bandwidth + doppler_shift) * t)
  42. @staticmethod
  43. def range_deception(bandwidth, duration, sample_rate, fake_range=500):
  44. """距离欺骗干扰算法"""
  45. t = np.arange(0, duration, 1/sample_rate)
  46. fake_delay = 2 * fake_range / 3e8 # 计算双程时延
  47. return np.sin(2 * np.pi * bandwidth * (t - fake_delay))