# Anti-spoofng algorithm design from the block diagram

15 visualizaciones (últimos 30 días)
zihan LI el 10 de Mzo. de 2022
Respondida: Ravi el 25 de En. de 2024
I am currently working on designing an anti-spoofing algorithm, but I don't know how to write the code according to this block diagram from a literature. Would someone help me with it, how to transfer these information into coding or how to draw this block diagram on SIMULINK?
##### 2 comentariosMostrar NingunoOcultar Ninguno
Peter O el 10 de Mzo. de 2022
Can you post the block diagram?
zihan LI el 10 de Mzo. de 2022
Oh I am so sorry i fogot this important part.

Iniciar sesión para comentar.

### Respuestas (1)

Ravi el 25 de En. de 2024
Hi Zihan LI,
We can define a function that takes input the signals data ‘S’, the sampling number ‘N’, and the error threshold, ‘epsilon’. Here, S(i, k) represents the carrier frequency of the ith signal at the kth time slot.
Please note that MATLAB uses one-based indexing.
From the first flow chart, we can observe the following.
1. Relative discrepancies are computed.
2. Difference between relative discrepancies for every two signals ‘i', and ‘j’ at every time slot ‘k’ is calculated.
3. For every pair of signals, the count of the number of time slots for which the relative difference falls with the threshold is maintained.
4. If the count exceeds 2N/3, they are marked as spoofed signals.
The code for the first flow chart looks as follows:
function pair = spoofed(S, N, epsilon)
pair = [];
S_cap = abs(S(:, :) - S(:, 1));
for i = 1:N
for j = 1:N
Nij = 0;
for z = 1:N
diff = abs(S_cap(i, z) - S_cap(j, z));
if diff < epsilon
Nij = Nij + 1;
end
end
if Nij > (2 * N / 3)
disp('signal ' + num2str(i) + ' and signal ' + num2str(j) + ' are spoofed');
pair = [i, j];
end
end
end
end
In the second flow chart, we are computing the sum of squares of relative differences for every pair of signals at each time slot, and checking if the sum falls below the threshold. The code for the second flow chart looks as follows:
function pair = spoofed(S, N, epsilon)
S_cap = abs(S(:, :) - S(:, 1));
for i = 1:N
for j = 1:N
x = S_cap(i, :) - S_cap(j, :);
Eij = sum(x.*x);
if Eij < epsilon
disp('signal ' + num2str(i) + ' and signal ' + num2str(j) + ' are spoofed');
pair = [i, j];
end
end
end
end
I hope this answer helps!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Simulink en Help Center y File Exchange.

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by