ashen-navigator's picture
Add covert-collaboration Eve-detection dataset (data + minimal generator source)
b96185c verified
Raw
History Blame Contribute Delete
2.75 kB
"""OTFS over the same 48x4 time-frequency grid as OFDM.
Delay-Doppler grid: 48 delay bins x 4 Doppler bins per user.
* Embedded pilot: a user-orthogonal code-division sequence spread over the
reserved guard region (delay bins 0..11 x all 4 Doppler bins = 48 REs),
using the same exp(j 2 pi m k / M) sequences as the other formats. Spreading
the pilot over 48 REs (rather than a single delay-Doppler impulse) keeps the
embedded-pilot structure and per-user energy but makes the pilot
SCRAMBLE-ABLE: a common per-RE phase decorrelates the coherent sum, defeating
Eve's pilot-matched detector, while Bob (sharing the PRN) de-scrambles and
estimates by correlating against the known DD sequences.
* Data: delay bins 12..47 x 4 Doppler bins = 144 REs. Mapping order is
delay-major: S[m, 4*i + k] -> (delay 12+i, Doppler k).
ISFFT (unitary): DFT along delay -> subcarrier, IDFT along Doppler -> time,
then the OFDM modulator (48 occupied subcarriers of a 64-FFT, CP 16) per
time symbol. All transforms are unitary, so the loopback inverse is exact.
"""
from __future__ import annotations
import numpy as np
from .ofdm import OFDM
class OTFS(OFDM):
name = "otfs"
n_delay = 48
n_dopp = 4
pilot_guard = 12 # delay bins 0..11 reserved for the spread pilot
def __init__(self, cfg):
assert cfg.n_data == (self.n_delay - self.pilot_guard) * self.n_dopp
super().__init__(cfg) # OFDM base sets self.pilots = pilot_sequences(M, 48)
@property
def n_pilot_re(self) -> int:
return self.pilot_guard * self.n_dopp # 48 guard-region REs
def _fill_grid(self, s):
m = self.cfg.n_tx
dd = np.zeros(s.shape[:-1] + (self.n_delay, self.n_dopp), dtype=np.complex128)
dd[..., self.pilot_guard :, :] = s.reshape(
s.shape[:-1] + (self.n_delay - self.pilot_guard, self.n_dopp)
)
# spread pilot: self.pilots (M, 48) -> guard region (M, 12, 4), broadcast over batch
pil = self.pilots.reshape(m, self.pilot_guard, self.n_dopp)
dd[..., : self.pilot_guard, :] = np.broadcast_to(
pil, s.shape[:-1] + (self.pilot_guard, self.n_dopp)
)
# ISFFT: delay -> subcarrier (DFT, axis -2), Doppler -> time (IDFT, axis -1)
tf = np.fft.fft(np.fft.ifft(dd, axis=-1, norm="ortho"), axis=-2, norm="ortho")
return np.swapaxes(tf, -1, -2) # (..., M, n_sym=4, n_occ=48)
def _extract_data(self, grid):
tf = np.swapaxes(grid, -1, -2) # (..., M, delay-bins-as-subcarriers 48, time 4)
dd = np.fft.fft(np.fft.ifft(tf, axis=-2, norm="ortho"), axis=-1, norm="ortho")
d = dd[..., self.pilot_guard :, :]
return d.reshape(d.shape[:-2] + (self.cfg.n_data,))