Physical Layer: Frequency Hopping Spread Spectrum (FHSS) Simulation
Introduction to Frequency Hopping Spread Spectrum
Frequency Hopping Spread Spectrum (FHSS) is a wireless communication technique where the transmitter and receiver synchronously switch (or "hop") between multiple frequency channels according to a predetermined pattern. This method provides three key advantages:
- Anti-jamming protection: By rapidly changing frequencies, only a portion of the transmission is affected by narrowband jamming.
- Security: The hopping pattern acts as an additional layer of encryption
- Coexistence: Multiple networks can operate in the same band with minimal interference
This tutorial explores a Python simulation that demonstrates FHSS with encryption and error correction, providing insights into the mathematical foundations of secure wireless communication.
1. Frequency Hopping Model
The core FHSS transmission can be modeled as:
s(t) = A·cos(2πfₙt + ϕ)·d(t)
Where:
fₙ ∈ {f₁,f₂,...f_N}
is the hopping frequency at time td(t) ∈ {0,1}
is the digital dataA
is amplitude, ϕ
is phaseThe hopping pattern is typically pseudorandom but known to both transmitter and receiver. In our simulation:
hopping_pattern = np.random.choice(frequencies, size=num_bits)
frequencies = np.linspace(2.4, 2.6, 10) # 10 channels from 2.4-2.6 GHz
This creates a uniform distribution across the frequency band, with each bit transmitted on a randomly selected channel.
2. XOR Encryption
I implement a symmetric key cipher using bitwise XOR:
ciphertext = plaintext ⊕ key
Properties:
Reversible:
plaintext = ciphertext ⊕ key
Perfect secrecy: When key
is truly random, used once, and same length as plaintext (Shannon 1949)key = np.random.randint(0, 2, num_bits) # Random key
encrypted = np.bitwise_xor(plaintext, key)
3. Channel Effects Model
I simulate three channel impairments:
-> Jamming (Barrage model):
Jams all frequencies within ±B_j/2
of f_j
with probability P_jam
Modeled as complete signal erasure: r(t) = 0
when jammed
-> Attenuation:
Path loss:
Implemented as random scaling factor
Path loss:
P_r = P_t·L·|h|²
where h ~ CN(0,1)
(Rayleigh fading)Implemented as random scaling factor
-> AWGN Noise:
Additive White Gaussian Noise:
Additive White Gaussian Noise:
n(t) ~ N(0,σ²)
Causes detection errors at threshold boundaries4. Error Correction (Parity Check Code)
I implement a simple (n+1,n) single parity check code:
-> Encoding: For n-bit block
b₀b₁...bₙ₋₁
, add parity bit p = ⊕bᵢ
-> Decoding: Check if
⊕bᵢ = p
for received block-> Capabilities:
Detects all odd-numbered bit errors
Cannot correct errors (only detect)
Code rate:
Detects all odd-numbered bit errors
Cannot correct errors (only detect)
Code rate:
R = n/(n+1)
Visualization and Analysis
The simulation generates four key plots:
-> Frequency Hopping Pattern:
Shows time-frequency allocation
Highlights jammed intervals in red
Shows time-frequency allocation
Highlights jammed intervals in red
-> Transmission States:
Color-coded bits (green=good, orange=error, red=jammed)
Color-coded bits (green=good, orange=error, red=jammed)
-> Bit Sequence Comparison:
Original vs received bits
Shows effectiveness of error correction
Original vs received bits
Shows effectiveness of error correction
-> Performance Statistics:
Calculates Bit Error Rate (BER)
Shows effectiveness against jamming
Quantifies error correction benefits
Calculates Bit Error Rate (BER)
Shows effectiveness against jamming
Quantifies error correction benefits
Key Results and Interpretation
-> Jamming Resistance:
Only bits transmitted at/near
Error correction helps recover non-jammed bits
Only bits transmitted at/near
f_j
are affectedError correction helps recover non-jammed bits
-> Error Correction Tradeoffs:
Parity check detects errors but cannot correct them
More advanced codes (Hamming, Reed-Solomon) would perform better
Parity check detects errors but cannot correct them
More advanced codes (Hamming, Reed-Solomon) would perform better
-> Security Analysis:
Random key provides good security
Repeating key vulnerable to frequency analysis
Random key provides good security
Repeating key vulnerable to frequency analysis
The underlying code is implemented in Rahul-Github FHSS.ipynb code.
Comments
Post a Comment