Anti-spoofng algorithm design from the block diagram
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Ravi
on 25 Jan 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.
- Relative discrepancies are computed.
- Difference between relative discrepancies for every two signals ‘i', and ‘j’ at every time slot ‘k’ is calculated.
- For every pair of signals, the count of the number of time slots for which the relative difference falls with the threshold is maintained.
- 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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!