-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetPktDropRates.m
31 lines (24 loc) · 901 Bytes
/
getPktDropRates.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function pktDropRates = getPktDropRates(SNR_list)
if iscell(SNR_list)
SNR_list = cell2mat(SNR_list);
disp(SNR_list)
end
numOctetsPerPkt = 7;
numPkt = 10^2;
pktDropRates = zeros(size(SNR_list));
dataConfig = lrwpan.MACFrameConfig('FrameType','Data');
for snr_ith = 1:1:length(SNR_list)
numSuccPkt = 0;
for pkt_ith = 1:1:numPkt
payload = dec2hex(randi([0 2^8-1], numOctetsPerPkt, 1), 2);
txBits = lrwpan.MACFrameGenerator(dataConfig, payload);
rxBits = w2z_link(txBits', SNR_list(1, snr_ith), false);
[~, netFrame] = lrwpan.MACFrameDecoder(rxBits');
if ~isempty(netFrame)
numSuccPkt = numSuccPkt + 1;
end
end
pktDropRates(1, snr_ith) = 1 - numSuccPkt ./ numPkt;
end
save ../pktDropRates.mat pktDropRates
end