12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import numpy as np
- class JammingSignalAlgo:
- @staticmethod
- def generate_noise_jam(bandwidth, duration, sample_rate):
- num_samples = int(duration * sample_rate)
- return np.random.normal(0, 1, num_samples)
- @staticmethod
- def generate_amplitude_noise_jam(bandwidth, duration, sample_rate):
- t = np.arange(0, duration, 1/sample_rate)
- carrier = np.sin(2 * np.pi * bandwidth * t)
- noise = 0.5 * np.random.normal(0, 1, len(t))
- return carrier * noise
- @staticmethod
- def generate_velocity_deceptive_jam(bandwidth, duration, sample_rate):
- t = np.arange(0, duration, 1/sample_rate)
- phase_shift = np.cumsum(np.random.uniform(-0.1, 0.1, len(t)))
- return np.sin(2 * np.pi * bandwidth * t + phase_shift)
- @staticmethod
- def generate_deceptive_jam(bandwidth, duration, sample_rate):
- t = np.arange(0, duration, 1/sample_rate)
- delay = np.random.uniform(0.1, 0.5) # 随机延迟0.1-0.5秒
- amplitude = np.random.uniform(0.5, 2.0) # 随机幅度调制
- return amplitude * np.sin(2 * np.pi * bandwidth * (t - delay))
- @staticmethod
- def frequency_modulation(bandwidth, duration, sample_rate, modulation_index=0.5):
- """噪声调频干扰算法"""
- t = np.arange(0, duration, 1/sample_rate)
- baseband = np.random.normal(0, 1, len(t))
- modulated = np.sin(2 * np.pi * bandwidth * t + modulation_index * np.cumsum(baseband))
- return modulated
- @staticmethod
- def repeater_jamming(bandwidth, duration, sample_rate, delay=0.1, attenuation=0.5):
- """转发式干扰算法"""
- t = np.arange(0, duration, 1/sample_rate)
- original_signal = np.sin(2 * np.pi * bandwidth * t)
- return attenuation * np.roll(original_signal, int(delay * sample_rate))
- @staticmethod
- def velocity_deception(bandwidth, duration, sample_rate, doppler_shift=1000):
- """速度欺骗干扰算法"""
- t = np.arange(0, duration, 1/sample_rate)
- return np.sin(2 * np.pi * (bandwidth + doppler_shift) * t)
- @staticmethod
- def range_deception(bandwidth, duration, sample_rate, fake_range=500):
- """距离欺骗干扰算法"""
- t = np.arange(0, duration, 1/sample_rate)
- fake_delay = 2 * fake_range / 3e8 # 计算双程时延
- return np.sin(2 * np.pi * bandwidth * (t - fake_delay))
|