import numpy as np
import matplotlib.pyplot as plt
# ============================================================
# 1. PARÂMETROS DO LASER
# ============================================================
lambda0 = 1550e-9 # comprimento de onda (m)
freq0 = 3e8 / lambda0 # frequência óptica (Hz)
t = np.linspace(0, 5e-6, 200000) # janela temporal
E0 = 1.0 # amplitude do campo
# ============================================================
# 2. GERADORES DE RUÍDO DE FASE
# ============================================================
def white_phase_noise(t, sigma=0.05):
return np.random.normal(0, sigma, len(t))
def flicker_phase_noise(t, strength=0.02):
f = np.fft.rfftfreq(len(t), t[1]-t[0])
spectrum = strength / np.maximum(f, 1e-3)
phases = np.random.normal(0, 1, len(f)) * spectrum
return np.fft.irfft(phases)
def rf_modulated_noise(t, f_rf=50e3, depth=0.1):
return depth * np.sin(2*np.pi*f_rf*t)
# ============================================================
# 3. INJETOR DE RUÍDO (COMBINADO)
# ============================================================
def phase_noise_injector(t, mode="white"):
if mode == "white":
return white_phase_noise(t)
elif mode == "flicker":
return flicker_phase_noise(t)
elif mode == "rf":
return rf_modulated_noise(t)
elif mode == "hybrid":
return white_phase_noise(t) + flicker_phase_noise(t) + rf_modulated_noise(t)
else:
raise ValueError("Modo inválido.")
# ============================================================
# 4. GERAR CAMPO ÓPTICO COM RUÍDO
# ============================================================
def laser_field(t, mode="white"):
phi_noise = phase_noise_injector(t, mode)
phase = 2*np.pi*freq0*t + phi_noise
return E0 * np.exp(1j * phase)
# ============================================================
# 5. FUNÇÃO DE COERÊNCIA (G1)
# ============================================================
def coherence_function(E):
return np.abs(np.correlate(E, E, mode='full')) / len(E)
# ============================================================
# 6. EXECUÇÃO DO EXPERIMENTO
# ============================================================
mode = "hybrid" # white + flicker + RF
E = laser_field(t, mode)
G1 = coherence_function(E)
# ============================================================
# 7. PLOTS
# ============================================================
plt.figure(figsize=(12,5))
plt.plot(np.real(E[:2000]), label="Real(E)")
plt.plot(np.imag(E[:2000]), label="Imag(E)")
plt.title("Campo óptico com ruído de fase (" + mode + ")")
plt.legend()
plt.grid(True)
plt.figure(figsize=(12,5))
plt.plot(G1[len(G1)//2:], color="green")
plt.title("Função de coerência temporal G1(τ)")
plt.grid(True)
plt.show()
Attack with RF ( Antennas )
import numpy as np
import matplotlib.pyplot as plt
# ============================================================
# 1. PARÂMETROS DO LASER
# ============================================================
lambda0 = 1550e-9
freq0 = 3e8 / lambda0
t = np.linspace(0, 5e-6, 200000)
E0 = 1.0
# ============================================================
# 2. MODELO DA ANTENA COMERCIAL (Laird EXS900)
# ============================================================
f_rf_center = 915e6 # frequência central (Hz)
bw_rf = 26e6 # largura de banda (Hz)
gain_dBi = 2.1 # ganho da antena
gain_lin = 10**(gain_dBi/10)
P_tx = 0.1 # potência transmitida (W)
distance = 0.5 # distância laser-antena (m)
# Campo elétrico irradiado (modelo Friis simplificado)
def rf_field_strength(P_tx, gain, d):
return np.sqrt(30 * P_tx * gain) / d
E_rf = rf_field_strength(P_tx, gain_lin, distance)
# ============================================================
# 3. ESPECTRO RF REALISTA (AM + FM + RUÍDO)
# ============================================================
def realistic_rf_noise(t):
# AM modulation
am = (1 + 0.3*np.sin(2*np.pi*1e3*t))
# FM modulation
fm = np.sin(2*np.pi*f_rf_center*t + 5*np.sin(2*np.pi*2e3*t))
# Thermal noise
thermal = np.random.normal(0, 0.02, len(t))
# Flicker noise (1/f)
f = np.fft.rfftfreq(len(t), t[1]-t[0])
flicker_spectrum = 0.01 / np.maximum(f, 1e-3)
flicker_phase = np.random.normal(0, 1, len(f)) * flicker_spectrum
flicker = np.fft.irfft(flicker_phase)
return E_rf * (am * fm) + thermal + flicker
# ============================================================
# 4. INJEÇÃO DE RUÍDO DE FASE NO LASER
# ============================================================
def laser_field_with_rf(t):
phi_rf = realistic_rf_noise(t)
phase = 2*np.pi*freq0*t + phi_rf
return E0 * np.exp(1j * phase)
# ============================================================
# 5. COERÊNCIA TEMPORAL
# ============================================================
def coherence_function(E):
return np.abs(np.correlate(E, E, mode='full')) / len(E)
# ============================================================
# 6. EXECUTAR SIMULAÇÃO
# ============================================================
E = laser_field_with_rf(t)
G1 = coherence_function(E)
# ============================================================
# 7. PLOTS
# ============================================================
plt.figure(figsize=(12,5))
plt.plot(np.real(E[:2000]), label="Real(E)")
plt.plot(np.imag(E[:2000]), label="Imag(E)")
plt.title("Laser com ruído RF realista (Antena Laird EXS900)")
plt.legend()
plt.grid(True)
plt.figure(figsize=(12,5))
plt.plot(G1[len(G1)//2:], color="green")
plt.title("Função de coerência G1(τ) sob interferência RF")
plt.grid(True)
plt.show()





Antena Wi Fi 2.4 GHz
import numpy as np
import matplotlib.pyplot as plt
# ============================================================
# 1. PARÂMETROS DO LASER
# ============================================================
lambda0 = 1550e-9
freq0 = 3e8 / lambda0
t = np.linspace(0, 5e-6, 200000)
E0 = 1.0
# ============================================================
# 2. ANTENA COMERCIAL (TP-Link TL-ANT2408CL)
# ============================================================
f_rf_center = 2.437e9 # canal 6 Wi-Fi (Hz)
bw_rf = 22e6 # largura de banda OFDM (Hz)
gain_dBi = 8.0
gain_lin = 10**(gain_dBi/10)
P_tx = 0.2 # potência típica (W)
distance = 0.4 # distância laser-antena (m)
# Campo elétrico irradiado (modelo Friis simplificado)
def rf_field_strength(P_tx, gain, d):
return np.sqrt(30 * P_tx * gain) / d
E_rf = rf_field_strength(P_tx, gain_lin, distance)
# ============================================================
# 3. MODELO DE SINAL Wi-Fi REALISTA (OFDM + AM + FM + RUÍDO)
# ============================================================
def wifi_rf_noise(t):
# OFDM subcarriers (simplificado)
subcarriers = [f_rf_center + k*312.5e3 for k in range(-26, 27)]
ofdm = np.zeros_like(t)
for f in subcarriers:
ofdm += np.sin(2*np.pi*f*t + np.random.uniform(0, 2*np.pi))
# AM envelope (variação de potência)
am = 1 + 0.4*np.sin(2*np.pi*1e3*t)
# FM jitter (variação de frequência)
fm = np.sin(2*np.pi*f_rf_center*t + 8*np.sin(2*np.pi*5e3*t))
# Thermal noise
thermal = np.random.normal(0, 0.03, len(t))
# Flicker noise (1/f)
f = np.fft.rfftfreq(len(t), t[1]-t[0])
flicker_spectrum = 0.02 / np.maximum(f, 1e-3)
flicker_phase = np.random.normal(0, 1, len(f)) * flicker_spectrum
flicker = np.fft.irfft(flicker_phase)
return E_rf * (am * fm + 0.2*ofdm) + thermal + flicker
# ============================================================
# 4. INJEÇÃO DE RUÍDO DE FASE NO LASER
# ============================================================
def laser_field_with_wifi(t):
phi_rf = wifi_rf_noise(t)
phase = 2*np.pi*freq0*t + phi_rf
return E0 * np.exp(1j * phase)
# ============================================================
# 5. COERÊNCIA TEMPORAL
# ============================================================
def coherence_function(E):
return np.abs(np.correlate(E, E, mode='full')) / len(E)
# ============================================================
# 6. EXECUTAR SIMULAÇÃO
# ============================================================
E = laser_field_with_wifi(t)
G1 = coherence_function(E)
# ============================================================
# 7. PLOTS
# ============================================================
plt.figure(figsize=(12,5))
plt.plot(np.real(E[:2000]), label="Real(E)")
plt.plot(np.imag(E[:2000]), label="Imag(E)")
plt.title("Laser com ruído RF Wi-Fi (TP-Link TL-ANT2408CL)")
plt.legend()
plt.grid(True)
plt.figure(figsize=(12,5))
plt.plot(G1[len(G1)//2:], color="green")
plt.title("Função de coerência G1(τ) sob interferência Wi-Fi")
plt.grid(True)
plt.show()





Antena Yagi
import numpy as np
import matplotlib.pyplot as plt
# ============================================================
# 1. PARÂMETROS DO LASER
# ============================================================
lambda0 = 1550e-9
freq0 = 3e8 / lambda0
t = np.linspace(0, 5e-6, 200000)
E0 = 1.0
# ============================================================
# 2. ANTENA YAGI 2.4 GHz (14 dBi)
# ============================================================
f_rf_center = 2.437e9 # canal 6 Wi-Fi (Hz)
bw_rf = 22e6 # largura de banda OFDM (Hz)
gain_dBi = 14.0
gain_lin = 10**(gain_dBi/10)
P_tx = 0.3 # potência típica (W)
distance = 0.6 # distância laser-antena (m)
# Campo elétrico irradiado (modelo Friis)
def rf_field_strength(P_tx, gain, d):
return np.sqrt(30 * P_tx * gain) / d
E_rf = rf_field_strength(P_tx, gain_lin, distance)
# ============================================================
# 3. MODELO DE SINAL DIRECIONAL (OFDM + AM + FM + RUÍDO)
# ============================================================
def yagi_rf_noise(t):
# OFDM subcarriers
subcarriers = [f_rf_center + k*312.5e3 for k in range(-26, 27)]
ofdm = np.zeros_like(t)
for f in subcarriers:
ofdm += np.sin(2*np.pi*f*t + np.random.uniform(0, 2*np.pi))
# AM envelope (variação de potência)
am = 1 + 0.5*np.sin(2*np.pi*800*t)
# FM jitter (variação de frequência)
fm = np.sin(2*np.pi*f_rf_center*t + 10*np.sin(2*np.pi*4e3*t))
# Thermal noise
thermal = np.random.normal(0, 0.04, len(t))
# Flicker noise (1/f)
f = np.fft.rfftfreq(len(t), t[1]-t[0])
flicker_spectrum = 0.03 / np.maximum(f, 1e-3)
flicker_phase = np.random.normal(0, 1, len(f)) * flicker_spectrum
flicker = np.fft.irfft(flicker_phase)
# Direcionalidade Yagi → multiplicador forte
directional_gain = 2.5
return directional_gain * E_rf * (am * fm + 0.3*ofdm) + thermal + flicker
# ============================================================
# 4. INJEÇÃO DE RUÍDO DE FASE NO LASER
# ============================================================
def laser_field_with_yagi(t):
phi_rf = yagi_rf_noise(t)
phase = 2*np.pi*freq0*t + phi_rf
return E0 * np.exp(1j * phase)
# ============================================================
# 5. COERÊNCIA TEMPORAL
# ============================================================
def coherence_function(E):
return np.abs(np.correlate(E, E, mode='full')) / len(E)
# ============================================================
# 6. EXECUTAR SIMULAÇÃO
# ============================================================
E = laser_field_with_yagi(t)
G1 = coherence_function(E)
# ============================================================
# 7. PLOTS
# ============================================================
plt.figure(figsize=(12,5))
plt.plot(np.real(E[:2000]), label="Real(E)")
plt.plot(np.imag(E[:2000]), label="Imag(E)")
plt.title("Laser com ruído RF Yagi 2.4 GHz (14 dBi)")
plt.legend()
plt.grid(True)
plt.figure(figsize=(12,5))
plt.plot(G1[len(G1)//2:], color="green")
plt.title("Função de coerência G1(τ) sob interferência Yagi 14 dBi")
plt.grid(True)
plt.show()




Military Antenna attack
import numpy as np
import matplotlib.pyplot as plt
# ============================================================
# 1. PARÂMETROS DO LASER
# ============================================================
lambda0 = 1550e-9
freq0 = 3e8 / lambda0
t = np.linspace(0, 5e-6, 200000)
E0 = 1.0
# ============================================================
# 2. ANTENA MILITAR UHF (400–450 MHz)
# ============================================================
f_rf_center = 425e6 # frequência central militar (Hz)
bw_rf = 20e6 # largura de banda (Hz)
gain_dBi = 10.0
gain_lin = 10**(gain_dBi/10)
P_tx = 15.0 # potência militar (W)
distance = 1.2 # distância laser-antena (m)
# Campo elétrico irradiado (modelo Friis)
def rf_field_strength(P_tx, gain, d):
return np.sqrt(30 * P_tx * gain) / d
E_rf = rf_field_strength(P_tx, gain_lin, distance)
# ============================================================
# 3. MODELO DE SINAL MILITAR (AM + FM + SPREAD-SPECTRUM)
# ============================================================
def military_rf_noise(t):
# Spread-spectrum (salto de frequência)
hop_rates = [f_rf_center + np.random.uniform(-bw_rf/2, bw_rf/2)
for _ in range(50)]
ss = np.zeros_like(t)
for f in hop_rates:
ss += np.sin(2*np.pi*f*t + np.random.uniform(0, 2*np.pi))
# AM envelope (variação lenta)
am = 1 + 0.6*np.sin(2*np.pi*300*t)
# FM jitter (variação de frequência)
fm = np.sin(2*np.pi*f_rf_center*t + 15*np.sin(2*np.pi*1e3*t))
# Thermal noise
thermal = np.random.normal(0, 0.05, len(t))
# Flicker noise (1/f)
f = np.fft.rfftfreq(len(t), t[1]-t[0])
flicker_spectrum = 0.05 / np.maximum(f, 1e-3)
flicker_phase = np.random.normal(0, 1, len(f)) * flicker_spectrum
flicker = np.fft.irfft(flicker_phase)
# Direcionalidade militar → multiplicador forte
directional_gain = 3.0
return directional_gain * E_rf * (am * fm + 0.4*ss) + thermal + flicker
# ============================================================
# 4. INJEÇÃO DE RUÍDO DE FASE NO LASER
# ============================================================
def laser_field_with_military(t):
phi_rf = military_rf_noise(t)
phase = 2*np.pi*freq0*t + phi_rf
return E0 * np.exp(1j * phase)
# ============================================================
# 5. COERÊNCIA TEMPORAL
# ============================================================
def coherence_function(E):
return np.abs(np.correlate(E, E, mode='full')) / len(E)
# ============================================================
# 6. EXECUTAR SIMULAÇÃO
# ============================================================
E = laser_field_with_military(t)
G1 = coherence_function(E)
# ============================================================
# 7. PLOTS
# ============================================================
plt.figure(figsize=(12,5))
plt.plot(np.real(E[:2000]), label="Real(E)")
plt.plot(np.imag(E[:2000]), label="Imag(E)")
plt.title("Laser com ruído RF militar UHF (10 dBi, 15 W)")
plt.legend()
plt.grid(True)
plt.figure(figsize=(12,5))
plt.plot(G1[len(G1)//2:], color="green")
plt.title("Função de coerência G1(τ) sob interferência militar UHF")
plt.grid(True)
plt.show()





No comments:
Post a Comment