main content

image transmission and reception using 802.11 waveform and sdr -凯发k8网页登录

this example shows how to encode and pack an image file into wlan packets for transmission and subsequently decode the packets to retrieve the image. the example also shows how to use a software-defined radio (sdr) for over-the-air transmission and reception of the wlan packets.

introduction

this example imports and segments an image file into multiple medium access control (mac) service data units (msdus). it passes each msdu to the function to create a mac protocol data unit (mpdu). this function also utilizes a object as an input, which sequentially numbers the mpdus through the sequencenumber property. the example then passes the mpdus to the physical (phy) layer as phy layer service data units (psdus). each psdu uses a single non-high-throughput (non-ht), 802.11a™ wlan packet for transmission. this example creates a wlan baseband waveform using the function. this function utilizes multiple psdus and processes each to form a series of physical layer convergence procedure (plcp) protocol data units (ppdus) ready for transmission.

the generated waveform then passes through an additive white gaussian noise (awgn) channel to simulate an over-the-air transmission. subsequently, the function takes the noisy waveform and decodes it. then, the sequencenumber property in the recovered mac frame configuration object allows the example to sequentially order the extracted msdus. the information bits in the multiple received msdus combine to recover the transmitted image. this diagram shows the receiver processing.

alternatively, the generated wlan waveform can be transmitted over the air and received using these supported sdrs.

sdrfig.png

communications toolbox support package for analog devices® adalm-pluto radio

  • (communications toolbox support package for analog devices adalm-pluto radio)

  • (communications toolbox support package for analog devices adalm-pluto radio)

communications toolbox support package for usrp® embedded series radio

  • (communications toolbox support package for usrp embedded series radio)

  • (communications toolbox support package for usrp embedded series radio)

communications toolbox support package for xilinx® zynq®-based radio

  • (communications toolbox support package for xilinx zynq-based radio)

  • (communications toolbox support package for xilinx zynq-based radio)

example setup

before running the example, set the channel variable to be one of these options:

  • overtheair: use an sdr to transmit and receive the wlan waveform

  • gaussiannoise: pass the transmission waveform through an awgn channel (default)

  • noimpairments: pass the transmission waveform through with no impairments

if you set channel to overtheair, set frequency band and channel, transmission gain, reception gain, and desired sdr:

  • set to pluto to use the adalm-pluto radio (default)

  • set to e3xx to use the usrp embedded series radio

  • set to ad936x or fmcomms5 to use the xilinx zynq-based radio

channel = "gaussiannoise";
if strcmpi(channel,"overtheair")
    devicename = "pluto";
    channelnumber = 5;
    frequencyband = 2.4;
    txgain = -10;
    rxgain = 10;
elseif strcmpi(channel,"gaussiannoise")
    % specify snr of received signal for a simulated channel 
    snr = 20;
end

configure all the scopes and figures for the example.

% setup handle for image plot
if ~exist('imfig','var') || ~ishandle(imfig) %#ok 
    imfig = figure;
    imfig.numbertitle = 'off';
    imfig.name = 'image plot';
    imfig.visible = 'off';
else
    clf(imfig); % clear figure
    imfig.visible = 'off';
end
% setup spectrum viewer
spectrumscope = spectrumanalyzer( ...
    spectrumtype='power-density', ...
    title='received baseband wlan signal spectrum', ...
    ylabel='power spectral density', ...
    position=[69 376 800 450]);
% setup the constellation diagram viewer for equalized wlan symbols
refqam = wlanreferencesymbols('64qam');
constellation = comm.constellationdiagram(...
    title='equalized wlan symbols',...
    showreferenceconstellation=true,...
    referenceconstellation=refqam,...
    position=[878 376 460 460]);

transmitter design

these steps describe the general procedure of the wlan transmitter.

  1. import an image file and convert it to a stream of decimal bytes

  2. generate a baseband wlan signal using the wlan toolbox

  3. pack the data stream into multiple 802.11a packets

if using an sdr, these steps describe the setup of the sdr transmitter.

  1. prepare the baseband signal for transmission using the sdr hardware

  2. send the baseband data to the sdr hardware for upsampling and continuous transmission at the desired center frequency

prepare image file

read data from the image file, scale it for transmission, and convert it to a stream of decimal bytes. the scaling of the image reduces the quality by decreasing the size of the binary data stream.

the size of the binary data stream impacts the number of wlan packets required for the transmission of the image data. the number of wlan packets generated for transmission depends on these factors.

  1. the image scaling, set when importing the image file

  2. the length of the data carried in a packet, specified by the msdulength variable

  3. the modulation and coding scheme (mcs) value of the transmitted packet

the combination of the scaling factor and msdu length determines the number of wlan radio packets required for transmission. setting scale to 0.2 and msdulength to 2304 requires the transmission of 11 wlan radio packets. increasing the scaling factor or decreasing the msdu length will result in the transmission of more packets.

% input an image file and convert to binary stream
filetx = 'peppers.png';                   % image file name
fdata = imread(filetx);                          % read image data from file
scale = 0.2;                    % image scaling factor
origsize = size(fdata);                          % original input image size
scaledsize = max(floor(scale.*origsize(1:2)),1); % calculate new image size
heightix = min(round(((1:scaledsize(1))-0.5)./scale 0.5),origsize(1));
widthix = min(round(((1:scaledsize(2))-0.5)./scale 0.5),origsize(2));
fdata = fdata(heightix,widthix,:);               % resize image
imsize = size(fdata);                            % store new image size
tximage = fdata(:);
% plot transmit image
imfig.visible = 'on';
subplot(211);
imshow(fdata);
title('transmitted image');
subplot(212);
title('received image appears here...');
set(gca,'visible','off');

figure image plot contains an axes object. the axes object with title transmitted image contains an object of type image.

set(findall(gca, 'type', 'text'), 'visible', 'on');

fragment transmit data

split the data stream (tximage) into smaller transmit units (msdus) of size msdulength. then, create an mpdu for each transmit unit using the wlanmacframe function. each call to this function creates an mpdu corresponding to the given msdu and the frame configuration object. next, create the frame configuration object using wlanmacframeconfig to configure the sequence number of the mpdu. all the mpdus are then sequentially passed to the physical layer for transmission.

to ensure that the msdu size of the transmission does not exceed the standard-specified maximum, set the msdulength field to 2304 bytes. to make all mpdus the same size, append zeros to the data in the last mpdu.

msdulength = 2304; % msdu length in bytes
nummsdus = ceil(length(tximage)/msdulength);
padzeros = msdulength-mod(length(tximage),msdulength);
txdata = [tximage;zeros(padzeros,1)];
txdatabits = double(int2bit(txdata,8,false));
% divide input data stream into fragments
bitsperoctet = 8;
data = zeros(0,1);
for i=0:nummsdus-1
    % extract image data (in octets) for each mpdu
    framebody = txdata(i*msdulength 1:msdulength*(i 1),:);
    % create mac frame configuration object and configure sequence number
    cfgmac = wlanmacframeconfig(frametype='data',sequencenumber=i);
    % generate mpdu
    [psdu, lengthmpdu]= wlanmacframe(framebody,cfgmac,outputformat='bits');
    % concatenate psdus for waveform generation
    data = [data; psdu]; %#ok
end

generate 802.11a baseband wlan signal

synthesize a non-ht waveform using the wlanwaveformgenerator function with a non-ht format configuration object created by the object. in this example, the configuration object has a 20 mhz bandwidth, one transmit antenna and 64qam rate 2/3 (mcs 6).

nonhtcfg = wlannonhtconfig;       % create packet configuration
nonhtcfg.mcs = 6;                 % modulation: 64qam rate: 2/3
nonhtcfg.numtransmitantennas = 1; % number of transmit antenna
chanbw = nonhtcfg.channelbandwidth;
nonhtcfg.psdulength = lengthmpdu; % set the psdu length

initialize the scrambler with a random integer for each packet.

scramblerinitialization = randi([1 127],nummsdus,1);

set the oversampling factor to 1.5 to generate the waveform at 30 mhz for transmission.

osf = 1.5;
samplerate = wlansamplerate(nonhtcfg); % nominal sample rate in hz
% generate baseband nonht packets separated by idle time
txwaveform = wlanwaveformgenerator(data,nonhtcfg, ...
    numpackets=nummsdus,idletime=20e-6, ...
    scramblerinitialization=scramblerinitialization,...
    oversamplingfactor=osf);

configure sdr for transmission

if using an sdr, set the transmitter gain parameter (txgain) to reduce transmission quality and impair the received waveform.

create an sdrtransmitter object using the sdrtx function. set the center frequency, sample rate, and gain to the corresponding properties of the sdrtransmitter object. for an 802.11a signal on channel 5 in the 2.4 ghz frequency band, the corresponding center frequency is 2.432 ghz as defined in section 16.3.6.3 of the ieee std 802.11-2016.

the sdrtransmitter object uses the transmit repeat functionality to transmit the baseband wlan waveform in a loop from the double data rate (ddr) memory on the sdr.

if strcmpi(channel,"overtheair")
    % transmitter properties
    sdrtransmitter = sdrtx(devicename);
    sdrtransmitter.basebandsamplerate = samplerate*osf;
    sdrtransmitter.centerfrequency = wlanchannelfrequency(channelnumber,frequencyband);
    sdrtransmitter.gain = txgain;
    
    % pass the sdr i/o directly to host skipping fpga on zynq radio or usrp
    % embedded series radio
    if ~strcmpi(devicename,"pluto")
        sdrtransmitter.showadvancedproperties = true;
        sdrtransmitter.bypassuserlogic = true;
    end
    fprintf('\ngenerating wlan transmit waveform:\n')
    % scale the normalized signal to avoid saturation of rf stages
    powerscalefactor = 0.8;
    txwaveform = txwaveform.*(1/max(abs(txwaveform))*powerscalefactor);
    % transmit rf waveform
    transmitrepeat(sdrtransmitter,txwaveform);
end

the transmitrepeat function transfers the baseband wlan packets with idle time to the sdr, and stores the signal samples in hardware memory. the example then transmits the waveform continuously over the air until the release of the transmit object.

receiver design

the steps listed below describe the general structure of the wlan receiver.

  1. if using sdr hardware, capture multiple packets of the transmitted wlan signal

  2. detect a packet

  3. coarse carrier frequency offset is estimated and corrected

  4. fine timing synchronization is established. the l-stf, l-ltf and l-sig samples are provided for fine timing to allow to adjust the packet detection at the start or end of the l-stf

  5. fine carrier frequency offset is estimated and corrected

  6. perform a channel estimation for the received signal using the l-ltf

  7. detect the format of the packet

  8. decode the l-sig field to recover the mcs value and the length of the data portion

  9. decode the data field to obtain the transmitted data within each packet

  10. decode the received psdu and check if the frame check sequence (fcs) passed for the psdu

  11. order the decoded msdus based on the sequencenumber property in the recovered mac frame configuration object

  12. combine the decoded msdus from all the transmitted packets to form the received image

this example plots the power spectral density (psd) of the received waveform, and shows visualizations of the equalized data symbols and the received image.

receiver setup

if using an sdr, create an sdrreceiver object using the sdrrx function. set the center frequency, sample rate, and output data type to the corresponding properties of the sdrreceiver object.

otherwise, apply gaussian noise to the txwaveform using the function or pass the txwaveform straight through to receiver processing.

if strcmpi(channel,"overtheair")
    sdrreceiver = sdrrx(devicename);
    sdrreceiver.basebandsamplerate = sdrtransmitter.basebandsamplerate;
    sdrreceiver.centerfrequency = sdrtransmitter.centerfrequency;
    sdrreceiver.outputdatatype = 'double';
    sdrreceiver.gainsource = 'manual';
    sdrreceiver.gain = rxgain;
    if ~strcmpi(devicename,"pluto")
        sdrreceiver.showadvancedproperties = true;
        sdrreceiver.bypassuserlogic = true;
    end
    % configure the capture length equivalent to twice the length of the
    % transmitted signal, this is to ensure that psdus are received in order.
    % on reception the duplicate mac fragments are removed.
    sdrreceiver.samplesperframe = 2*length(txwaveform);
    fprintf('\nstarting a new rf capture.\n')
    rxwaveform = capture(sdrreceiver,sdrreceiver.samplesperframe,'samples');
elseif strcmpi(channel,"gaussiannoise")
    rxwaveform = awgn(txwaveform,snr,'measured');
else % no impairments
    rxwaveform = txwaveform;
end

show the power spectral density of the received waveform.

spectrumscope.samplerate = samplerate*osf;
spectrumscope(rxwaveform);
release(spectrumscope);

receiver processing

design a rate conversion filter for resampling the waveform to the nominal baseband rate for receiver processing using the function.

astop = 40; % stopband attenuation
ofdminfo = wlannonhtofdminfo('nonht-data',nonhtcfg); % ofdm parameters
scs = samplerate/ofdminfo.fftlength; % subcarrier spacing
txbw = max(abs(ofdminfo.activefrequencyindices))*2*scs; % occupied bandwidth
[l,m] = rat(1/osf);
maxlm = max([l m]);
r = (samplerate-txbw)/samplerate;
tw = 2*r/maxlm; % transition width
b = designmultiratefir(l,m,tw,astop);

resample the oversampled waveform back to 20 mhz for processing using the system object and the filter designed above.

firrc = dsp.firrateconverter(l,m,b);
rxwaveform = firrc(rxwaveform);

if using an sdr, the sdr continuously transmits the 802.11 waveform over-the-air in a loop. the first packet received by the sdrreceiver may not be the first transmitted packet. this means that the packets may be decoded out of sequence. to enable the received packets to be recombined in the correct order, their sequence number must be determined. the wlanmpdudecode function decodes the mpdu from the decoded psdu bits of each packet and outputs the msdu as well as the recovered mac frame configuration object wlanmacframeconfig. the sequencenumber property in the recovered mac frame configuration object can be used for ordering the msdus in the transmitted sequence.

to display each packet's decoded l-sig contents, the evm measurements, and sequence number, check the displayflag box.

displayflag = false; 

set up required variables for receiver processing.

rxwaveformlen = size(rxwaveform,1);
searchoffset = 0; % offset from start of the waveform in samples

get the required field indices within a psdu.

ind = wlanfieldindices(nonhtcfg);
ns = ind.lsig(2)-ind.lsig(1) 1; % number of samples in an ofdm symbol
% minimum packet length is 10 ofdm symbols
lstflen = double(ind.lstf(2)); % number of samples in l-stf
minpktlen = lstflen*5;
pktind = 1;
finetimingoffset = [];
packetseq = [];
rxbit = [];
% perform evm calculation
evmcalculator = comm.evm(averagingdimensions=[1 2 3]);
evmcalculator.maximumevmoutputport = true;

use a while loop to process the received out-of-order packets.

while (searchoffset minpktlen)<=rxwaveformlen
    % packet detect
    pktoffset = wlanpacketdetect(rxwaveform,chanbw,searchoffset,0.5);
    % adjust packet offset
    pktoffset = searchoffset pktoffset;
    if isempty(pktoffset) || (pktoffset double(ind.lsig(2))>rxwaveformlen)
        if pktind==1
            disp('** no packet detected **');
        end
        break;
    end
    % extract non-ht fields and perform coarse frequency offset correction
    % to allow for reliable symbol timing
    nonht = rxwaveform(pktoffset (ind.lstf(1):ind.lsig(2)),:);
    coarsefreqoffset = wlancoarsecfoestimate(nonht,chanbw);
    nonht = frequencyoffset(nonht,samplerate,-coarsefreqoffset);
    % symbol timing synchronization
    finetimingoffset = wlansymboltimingestimate(nonht,chanbw);
    % adjust packet offset
    pktoffset = pktoffset finetimingoffset;
    % timing synchronization complete: packet detected and synchronized
    % extract the non-ht preamble field after synchronization and
    % perform frequency correction
    if (pktoffset<0) || ((pktoffset minpktlen)>rxwaveformlen)
        searchoffset = pktoffset 1.5*lstflen;
        continue;
    end
    fprintf('\npacket-%d detected at index %d\n',pktind,pktoffset 1);
    % extract first 7 ofdm symbols worth of data for format detection and
    % l-sig decoding
    nonht = rxwaveform(pktoffset (1:7*ns),:);
    nonht = frequencyoffset(nonht,samplerate,-coarsefreqoffset);
    % perform fine frequency offset correction on the synchronized and
    % coarse corrected preamble fields
    lltf = nonht(ind.lltf(1):ind.lltf(2),:);           % extract l-ltf
    finefreqoffset = wlanfinecfoestimate(lltf,chanbw);
    nonht = frequencyoffset(nonht,samplerate,-finefreqoffset);
    cfocorrection = coarsefreqoffset finefreqoffset; % total cfo
    % channel estimation using l-ltf
    lltf = nonht(ind.lltf(1):ind.lltf(2),:);
    demodlltf = wlanlltfdemodulate(lltf,chanbw);
    chanestlltf = wlanlltfchannelestimate(demodlltf,chanbw);
    % noise estimation
    noisevarnonht = wlanlltfnoiseestimate(demodlltf);
    % packet format detection using the 3 ofdm symbols immediately
    % following the l-ltf
    format = wlanformatdetect(nonht(ind.lltf(2) (1:3*ns),:), ...
        chanestlltf,noisevarnonht,chanbw);
    disp(['  ' format ' format detected']);
    if ~strcmp(format,'non-ht')
        fprintf('  a format other than non-ht has been detected\n');
        searchoffset = pktoffset 1.5*lstflen;
        continue;
    end
    % recover l-sig field bits
    [reclsigbits,failcheck] = wlanlsigrecover( ...
        nonht(ind.lsig(1):ind.lsig(2),:), ...
        chanestlltf,noisevarnonht,chanbw);
    if failcheck
        fprintf('  l-sig check fail \n');
        searchoffset = pktoffset 1.5*lstflen;
        continue;
    else
        fprintf('  l-sig check pass \n');
    end
    % retrieve packet parameters based on decoded l-sig
    [lsigmcs,lsiglen,rxsamples] = helperinterpretlsig(reclsigbits,samplerate);
    if (rxsamples pktoffset)>length(rxwaveform)
        disp('** not enough samples to decode packet **');
        break;
    end
    % apply cfo correction to the entire packet
    rxwaveform(pktoffset (1:rxsamples),:) = frequencyoffset(...
        rxwaveform(pktoffset (1:rxsamples),:),samplerate,-cfocorrection);
    % create a receive non-ht config object
    rxnonhtcfg = wlannonhtconfig;
    rxnonhtcfg.mcs = lsigmcs;
    rxnonhtcfg.psdulength = lsiglen;
    % get the data field indices within a ppdu
    indnonhtdata = wlanfieldindices(rxnonhtcfg,'nonht-data');
    % recover psdu bits using transmitted packet parameters and channel
    % estimates from l-ltf
    [rxpsdu,eqsym] = wlannonhtdatarecover(rxwaveform(pktoffset ...
        (indnonhtdata(1):indnonhtdata(2)),:), ...
        chanestlltf,noisevarnonht,rxnonhtcfg);
    constellation(reshape(eqsym,[],1)); % current constellation
    release(constellation);
    refsym = wlanclosestreferencesymbol(eqsym,rxnonhtcfg);
    [evm.rms,evm.peak] = evmcalculator(refsym,eqsym);
    % decode the mpdu and extract msdu
    [cfgmacrx,msdulist{pktind},status] = wlanmpdudecode(rxpsdu,rxnonhtcfg); %#ok<*sagrow>
    if strcmp(status,'success')
        disp('  mac fcs check pass');
        % store sequencing information
        packetseq(pktind) = cfgmacrx.sequencenumber;
        % convert msdu to a binary data stream
        rxbit{pktind} = int2bit(hex2dec(cell2mat(msdulist{pktind})),8,false);
    else % decoding failed
        if strcmp(status,'fcsfailed')
            % fcs failed
            disp('  mac fcs check fail');
        else
            % fcs passed but encountered other decoding failures
            disp('  mac fcs check pass');
        end
        % since there are no retransmissions modeled in this example, we
        % extract the image data (msdu) and sequence number from the mpdu,
        % even though fcs check fails.
        % remove header and fcs. extract the msdu.
        macheaderbitslength = 24*bitsperoctet;
        fcsbitslength = 4*bitsperoctet;
        msdulist{pktind} = rxpsdu(macheaderbitslength 1:end-fcsbitslength);
        % extract and store sequence number
        sequencenumstartindex = 23*bitsperoctet 1;
        sequencenumendindex = 25*bitsperoctet-4;
        conversionlength = sequencenumendindex-sequencenumstartindex 1;
        packetseq(pktind) = bit2int(rxpsdu(sequencenumstartindex:sequencenumendindex),conversionlength,false);
        % msdu binary data stream
        rxbit{pktind} = double(msdulist{pktind});
    end
    % display decoded information
    if displayflag
        fprintf('  estimated cfo: %5.1f hz\n\n',cfocorrection); %#ok<*unrch> 
        disp('  decoded l-sig contents: ');
        fprintf('                            mcs: %d\n',lsigmcs);
        fprintf('                         length: %d\n',lsiglen);
        fprintf('    number of samples in packet: %d\n\n',rxsamples);
        fprintf('  evm:\n');
        fprintf('    evm peak: %0.3f%%  evm rms: %0.3f%%\n\n', ...
            evm.peak,evm.rms);
        fprintf('  decoded mac sequence control field contents:\n');
        fprintf('    sequence number: %d\n\n',packetseq(pktind));
    end
    % update search index
    searchoffset = pktoffset double(indnonhtdata(2));
    
    % finish processing when a duplicate packet is detected. the
    % recovered data includes bits from duplicate frame
    % remove the data bits from the duplicate frame
    if length(unique(packetseq)) < length(packetseq)
        rxbit = rxbit(1:length(unique(packetseq)));
        packetseq = packetseq(1:length(unique(packetseq)));
        break
    end
    pktind = pktind 1;
end
packet-1 detected at index 7
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-2 detected at index 8647
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-3 detected at index 17287
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-4 detected at index 25927
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-5 detected at index 34567
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-6 detected at index 43207
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-7 detected at index 51847
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-8 detected at index 60487
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-9 detected at index 69127
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-10 detected at index 77767
  non-ht format detected
  l-sig check pass 
  mac fcs check pass
packet-11 detected at index 86407
  non-ht format detected
  l-sig check pass 

  mac fcs check pass

if using an sdr, release the sdrtransmitter and sdrreceiver objects to stop the continuous transmission of the 802.11 waveform and to allow for any modification of the sdr object properties.

if strcmpi(channel,"overtheair")
    release(sdrtransmitter);
    release(sdrreceiver);
end

reconstruct image

reconstruct the image using the received mac frames.

if ~(isempty(finetimingoffset) || isempty(pktoffset))
    % convert decoded bits from cell array to column vector
    rxdata = cat(1,rxbit{:});
    % remove any extra bits
    rxdata = rxdata(1:end-(mod(length(rxdata),msdulength*8)));
    % reshape such that each column length has bits equal to msdulength*8
    rxdata = reshape(rxdata,msdulength*8,[]);
    % remove duplicate packets if any. duplicate packets are located at the
    % end of rxdata
    if length(packetseq)>nummsdus
        numduppackets = size(rxdata,2)-nummsdus;
        rxdata = rxdata(:,1:end-numduppackets);
    end
    % initialize variables for while loop
    startseq = [];
    i=-1;
    % only execute this if one of the packet sequence values have been decoded
    % accurately
    if any(packetseqwhile isempty(startseq)
            % this searches for a known packetseq value
            i = i   1;
            startseq = find(packetseq==i);
        end
        % circularly shift data so that received packets are in order for image reconstruction. it
        % is assumed that all packets following the starting packet are received in
        % order as this is how the image is transmitted.
        rxdata = circshift(rxdata,[0 -(startseq(1)-i-1)]); % order mac fragments
        % perform bit error rate (ber) calculation on reordered data
        biterrorrate = comm.errorrate;
        err = biterrorrate(double(rxdata(:)), ...
            txdatabits(1:length(reshape(rxdata,[],1))));
        fprintf('  \nbit error rate (ber):\n');
        fprintf('          bit error rate (ber) = %0.5f\n',err(1));
        fprintf('          number of bit errors = %d\n',err(2));
        fprintf('    number of transmitted bits = %d\n\n',length(txdatabits));
    end
    decdata = bit2int(reshape(rxdata(:),8,[]),8,false)';
    % append nans to fill any missing image data
    if length(decdata)else
        decdata = decdata(1:length(tximage));
    end
    % recreate image from received data
    fprintf('\nconstructing image from received data.\n');
    receivedimage = uint8(reshape(decdata,imsize));
    % plot received image
    if exist('imfig','var') && ishandle(imfig) % if tx figure is open
        figure(imfig); subplot(212);
    else
        figure; subplot(212);
    end
    imshow(receivedimage);
    title(sprintf('received image'));
end
  
bit error rate (ber):
          bit error rate (ber) = 0.00000
          number of bit errors = 0
    number of transmitted bits = 202752
constructing image from received data.

figure image plot contains 2 axes objects. axes object 1 with title transmitted image contains an object of type image. axes object 2 with title received image contains an object of type image.

further exploration

  • if using an sdr, modify or to observe the difference in the evm and ber after signal reception and processing. you may see errors in the displayed, received image.

  • if running the example without an sdr, modify to observe the difference in the evm and ber after signal reception and processing.

  • increase the scaling factor () to improve the quality of the received image by generating more transmit bits. this also increases the number of transmitted ppdus.

  • decrease msdu size () to decrease the number of bits transmitted per packet and observe the differences in evm and ber when a signal is received with a lower snr.

sdr troubleshooting

  • adalm-pluto radio (communications toolbox support package for analog devices adalm-pluto radio)

  • usrp embedded series radio (communications toolbox support package for usrp embedded series radio)

  • xilinx zynq-based radio (communications toolbox support package for xilinx zynq-based radio)

网站地图