-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
905 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
if [ $1 == 1]; then | ||
|
||
# wget -O /boot/raspi-expand-rootfs.sh https://raw.githubusercontent.com/lgierth/pimesh/master/files/raspi-expand-rootfs.sh | ||
# chmod +x /boot/raspi-expand-rootfs.sh | ||
# sh /boot/raspi-expand-rootfs.sh | ||
|
||
resize2fs /dev/mmcblk0p2 | ||
apt-get update -y | ||
apt-get upgrade -y | ||
apt-get update -y | ||
apt-get dist-upgrade -y | ||
|
||
# passwd root | ||
|
||
apt-get install -y openssh-server | ||
update-rc.d -f ssh remove | ||
update-rc.d -f ssh defaults | ||
|
||
|
||
|
||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
if [ $1 == 1]; then | ||
wget -O /boot/raspi-expand-rootfs.sh https://raw.githubusercontent.com/lgierth/pimesh/master/files/raspi-expand-rootfs.sh | ||
chmod +x /boot/raspi-expand-rootfs.sh | ||
sh /boot/raspi-expand-rootfs.sh | ||
fi | ||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
clc; clear; close all; | ||
|
||
[filename,pathname] = uigetfile('*.dat'); | ||
csi_trace = read_bf_file(fullfile(pathname,filename)); | ||
|
||
T0 = csi_trace{1}.timestamp_low; | ||
|
||
CarrierIndex = 5; | ||
|
||
for i = 1:size(csi_trace,1) | ||
if(~isempty(csi_trace{i})) | ||
csi = get_scaled_csi(csi_trace{i}); | ||
csi_db = db(abs(squeeze(csi).')); | ||
csi_single_carrier(i) = csi_db(CarrierIndex); | ||
end | ||
end | ||
|
||
figure;plot(csi_single_carrier,'linewidth',2);grid on; | ||
title(['CSI for carrier ',num2str(CarrierIndex)]); | ||
xlabel('Packet index'); | ||
ylabel('SNR [dB]'); | ||
set(gca,'fontsize',14); | ||
|
||
|
||
figure; | ||
for i = 1:1:12 | ||
csi = get_scaled_csi(csi_trace{i}); | ||
subplot(3,4,i); plot(db(abs(squeeze(csi).')));grid on; | ||
title(['Time ',num2str(csi_trace{i}.timestamp_low-T0),' sec']); | ||
xlabel('Subcarrier index'); | ||
ylabel('SNR [dB]'); | ||
%set(gca,'fontsize',14); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function ret = apply_sm(csi, sm) | ||
|
||
error(nargchk(2,2,nargin)); | ||
|
||
%% Shortcut for 1 TX antenna | ||
[M, ~, S] = size(csi); | ||
if M == 1 | ||
ret = csi; | ||
return; | ||
end | ||
|
||
%% Allocate return array | ||
ret = zeros(size(csi)); | ||
|
||
%% Actually undo the input spatial mapping | ||
for i=1:S | ||
t = squeeze(csi(:,:,i)); | ||
H = t.' * sm; | ||
ret(:,:,i) = H.'; | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]> | ||
% | ||
function ret = bpsk_ber(snr) | ||
ret = qfunc(sqrt(2*snr)); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]> | ||
% | ||
function ret = bpsk_berinv(ber) | ||
ret = qfuncinv(ber).^2 / 2; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%DBINV Convert from decibels. | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]> | ||
% | ||
function ret = dbinv(x) | ||
ret = 10.^(x/10); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
%GET_EFF_SNRS Compute the effective SNR values from a CSI matrix | ||
% Note that the matrix is expected to have dimensions M x N x S, where | ||
% M = # TX antennas | ||
% N = # RX antennas | ||
% S = # subcarriers | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]>, | ||
% Wenjun Hu | ||
% | ||
function ret=get_eff_SNRs(csi) | ||
ret = zeros(7,4) + eps; % machine epsilon is smallest possible SNR | ||
|
||
% [M N S] = size(csi); % If next line doesn't compile | ||
[M N ~] = size(csi); | ||
k = min(M,N); | ||
|
||
% Do the various SIMO configurations (i.e., TX antenna selection) | ||
if k >= 1 | ||
snrs = get_simo_SNRs(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Do the various MIMO2 configurations (i.e., TX antenna selection) | ||
if k >= 2 | ||
snrs = get_mimo2_SNRs(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Do the MIMO3 configuration | ||
if k >= 3 | ||
snrs = get_mimo3_SNRs(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Apparently, sometimes it can be infinite so cap it at 40 dB | ||
%ret(ret==Inf) = dbinv(40); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
%GET_EFF_SNRS_SM Compute the effective SNR values from a CSI matrix | ||
% Note that the matrix is expected to have dimensions M x N x S, where | ||
% M = # TX antennas | ||
% N = # RX antennas | ||
% S = # subcarriers | ||
% This version takes into account the spatial mapping performed by Intel NICs. | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]>, | ||
% Wenjun Hu | ||
% | ||
function ret=get_eff_SNRs_sm(csi) | ||
ret = zeros(7,4) + eps; % machine epsilon is smallest possible SNR | ||
|
||
% [M N S] = size(csi); % If next line doesn't compile | ||
[M N ~] = size(csi); | ||
k = min(M,N); | ||
|
||
% Do the various SIMO configurations (i.e., TX antenna selection) | ||
if k >= 1 | ||
snrs = get_simo_SNRs(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret((1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Do the various MIMO2 configurations (i.e., TX antenna selection) | ||
if k >= 2 | ||
snrs = get_mimo2_SNRs_sm(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(3+(1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Do the MIMO3 configuration | ||
if k >= 3 | ||
snrs = get_mimo3_SNRs_sm(csi); | ||
|
||
bers = bpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),1) = bpsk_berinv(mean_ber); | ||
|
||
bers = qpsk_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),2) = qpsk_berinv(mean_ber); | ||
|
||
bers = qam16_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),3) = qam16_berinv(mean_ber); | ||
|
||
bers = qam64_ber(snrs); | ||
mean_ber = mean(mean(bers, 3), 2); | ||
ret(6+(1:length(mean_ber)),4) = qam64_berinv(mean_ber); | ||
end | ||
|
||
% Apparently, sometimes it can be infinite so cap it at 40 dB | ||
%ret(ret==Inf) = dbinv(40); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
%GET_MIMO2_SNRS Calculates the MIMO2 SNRs for a scaled CSI matrix. | ||
% Note that the matrix is expected to have dimensions M x N x S, where | ||
% M = # TX antennas | ||
% N = # RX antennas | ||
% S = # subcarriers | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]>, | ||
% Wenjun Hu | ||
% | ||
function ret = get_mimo2_SNRs(csi) | ||
% Make sure at least 2 TX and RX antennas | ||
[M N S] = size(csi); | ||
if (M < 2) | ||
error('CSI matrix must have at least 2 TX antennas'); | ||
end | ||
if (N < 2) | ||
error('CSI matrix must have at least 2 RX antennas'); | ||
end | ||
|
||
% Since the incoming CSI is scaled to single-TX reduce by 2 for 2 streams | ||
csi = csi / sqrt(2); | ||
|
||
% Separate out 3 and 2 antenna cases | ||
if M == 2 | ||
ret = zeros(1,2,S); | ||
for i = 1:S | ||
ret(1,:,i) = mimo2_mmse(squeeze(csi(:,:,i))); | ||
end | ||
return; | ||
end | ||
% else M == 3 | ||
|
||
% There are 3 TX configs: TX AB, AC, BC | ||
ret = zeros(3,2,S); | ||
for i = 1:S | ||
ret(1,:,i) = mimo2_mmse(squeeze(csi([1 2],:,i))); | ||
ret(2,:,i) = mimo2_mmse(squeeze(csi([1 3],:,i))); | ||
ret(3,:,i) = mimo2_mmse(squeeze(csi([2 3],:,i))); | ||
end | ||
return; | ||
end | ||
|
||
% Compute the MMSE stream SNRs of a single channel matrix | ||
function ret = mimo2_mmse(csi) | ||
% We want | ||
% H' * H + I | ||
% but, since csi = H transposed, we instead use | ||
% conj(csi) * csi.' | ||
M = inv(conj(csi) * csi.' + eye(2)); | ||
ret = 1 ./ diag(M) - 1; | ||
|
||
% ret is real. Really. | ||
ret = real(ret); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
%GET_MIMO2_SNRS_SM Calculates the MIMO2 SNRs for a scaled CSI matrix. | ||
% Note that the matrix is expected to have dimensions M x N x S, where | ||
% M = # TX antennas | ||
% N = # RX antennas | ||
% S = # subcarriers | ||
% This version takes into account the spatial mapping performed by Intel NICs. | ||
% | ||
% (c) 2008-2011 Daniel Halperin <[email protected]>, | ||
% Wenjun Hu | ||
% | ||
function ret = get_mimo2_SNRs_sm(csi) | ||
error(nargchk(1,1,nargin)); | ||
|
||
% Make sure at least 2 TX and RX antennas | ||
[M, N, S] = size(csi); | ||
if (M < 2) | ||
error('CSI matrix must have at least 2 TX antennas'); | ||
end | ||
if (N < 2) | ||
error('CSI matrix must have at least 2 RX antennas'); | ||
end | ||
|
||
% Since the incoming CSI is scaled to single-TX reduce by 2 for 2 streams | ||
csi = csi / sqrt(2); | ||
|
||
% Separate out 3 and 2 antenna cases | ||
if M == 2 | ||
ret = zeros(1,2,S); | ||
for i = 1:S | ||
ret(1,:,i) = mimo2_mmse_sm(squeeze(csi(:,:,i))); | ||
end | ||
return; | ||
end | ||
% else M == 3 | ||
|
||
% There are 3 TX configs: TX AB, AC, BC | ||
ret = zeros(3,2,S); | ||
for i = 1:S | ||
ret(1,:,i) = mimo2_mmse_sm(squeeze(csi([1 2],:,i))); | ||
ret(2,:,i) = mimo2_mmse_sm(squeeze(csi([1 3],:,i))); | ||
ret(3,:,i) = mimo2_mmse_sm(squeeze(csi([2 3],:,i))); | ||
end | ||
return; | ||
end | ||
|
||
% Compute the MMSE stream SNRs of a single channel matrix | ||
function ret = mimo2_mmse_sm(csi_i) | ||
% Load and apply SM matrices | ||
sm_matrices; | ||
csi = apply_sm(csi_i, sm_2_20); | ||
|
||
% We want | ||
% H' * H + I | ||
% but, since csi = H transposed, we instead use | ||
% conj(csi) * csi.' | ||
M = inv(conj(csi) * csi.' + eye(2)); | ||
ret = 1 ./ diag(M) - 1; | ||
|
||
% ret is real. Really. | ||
ret = real(ret); | ||
end |
Oops, something went wrong.