Impl task1 some part of task2
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
addpath("from_matlab_example");
|
||||
|
||||
rxFrame1 = trace1.iq(:);
|
||||
rxFrame2 = trace2.iq(:);
|
||||
rxFrame3 = trace3.iq(:);
|
||||
rxFrame4 = trace4.iq(:);
|
||||
|
||||
beaconFrames1 = extractBeaconFrames(rxFrame1);
|
||||
beaconFrames2 = extractBeaconFrames(rxFrame2);
|
||||
beaconFrames3 = extractBeaconFrames(rxFrame3);
|
||||
beaconFrames4 = extractBeaconFrames(rxFrame4);
|
||||
|
||||
cfgMAC = beaconFrames1(1).MAC_Config;
|
||||
mgmt = cfgMAC.ManagementConfig;
|
||||
|
||||
disp(mgmt)
|
||||
properties(mgmt)
|
||||
|
||||
printBeaconTable(beaconFrames1);
|
||||
printBeaconTable(beaconFrames2);
|
||||
printBeaconTable(beaconFrames3);
|
||||
printBeaconTable(beaconFrames4);
|
||||
|
||||
function beaconFrames = extractBeaconFrames(rxFrame)
|
||||
beaconFrames = struct( ...
|
||||
"SSID", {}, ...
|
||||
"BSSID", {}, ...
|
||||
"Offset", {}, ...
|
||||
"MAC_Config", {}, ...
|
||||
"Bits", {}, ...
|
||||
"SNR_dB", {} ...
|
||||
);
|
||||
|
||||
channel_bandwidth = "CBW20"; % 20MHz
|
||||
|
||||
searchOffset = 0;
|
||||
index = 1;
|
||||
|
||||
while searchOffset < length(rxFrame)
|
||||
oldOffset = searchOffset;
|
||||
[bitsData, decParams, searchOffset, res] = recoverOFDMBits(rxFrame, searchOffset);
|
||||
|
||||
if searchOffset <= oldOffset
|
||||
searchOffset = oldOffset + 1;
|
||||
end
|
||||
|
||||
if isempty(bitsData)
|
||||
continue;
|
||||
end
|
||||
|
||||
[cfgMAC, ~, decodeStatus] = wlanMPDUDecode(bitsData, SuppressWarnings=true);
|
||||
|
||||
if ~decodeStatus && matches(cfgMAC.FrameType, "Beacon")
|
||||
if isempty(cfgMAC.ManagementConfig.SSID)
|
||||
ssid = "Hidden";
|
||||
else
|
||||
ssid = string(cfgMAC.ManagementConfig.SSID);
|
||||
end
|
||||
|
||||
if isfield(res, "PacketOffset")
|
||||
beaconFrames(index).Offset = res.PacketOffset;
|
||||
else
|
||||
beaconFrames(index).Offset = oldOffset;
|
||||
end
|
||||
|
||||
if isfield(res, "LLTFSNR")
|
||||
beaconFrames(index).SNR_dB = res.LLTFSNR;
|
||||
else
|
||||
beaconFrames(index).SNR_dB = NaN;
|
||||
end
|
||||
|
||||
beaconFrames(index).SSID = ssid;
|
||||
beaconFrames(index).BSSID = string(cfgMAC.Address3);
|
||||
beaconFrames(index).MAC_Config = cfgMAC;
|
||||
beaconFrames(index).Bits = bitsData;
|
||||
|
||||
index = index + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function printBeaconTable(beaconFrames)
|
||||
fprintf("\n");
|
||||
fprintf("%-20s %-18s %-10s %-8s %-8s %-8s %-12s %-8s %-20s\n", ...
|
||||
"SSID", "BSSID", "Interval", "B. ch.", "Op. ch.", "SNR", "Vendor", "Std.", "Rates");
|
||||
|
||||
for i = 1:numel(beaconFrames)
|
||||
ssid = string(beaconFrames(i).SSID);
|
||||
bssid = string(beaconFrames(i).BSSID);
|
||||
interval = string(beaconFrames(i).MAC_Config.ManagementConfig.BeaconInterval);
|
||||
snr = sprintf("%.1f", beaconFrames(i).SNR_dB);
|
||||
|
||||
bch = "-";
|
||||
opch = "-";
|
||||
vendor = "-";
|
||||
std = "-";
|
||||
rates = "-";
|
||||
|
||||
fprintf("%-20s %-18s %-10s %-8s %-8s %-8s %-12s %-8s %-20s\n", ...
|
||||
ssid, bssid, interval, bch, opch, snr, vendor, std, rates);
|
||||
end
|
||||
|
||||
fprintf("\n");
|
||||
end
|
||||
Reference in New Issue
Block a user