802.11 mac frame decoding -凯发k8网页登录
this example shows how to decode ieee® 802.11™ mac frames.
background
the general mac frame format consists of a header, frame-body, and frame check sequence (fcs). the header holds information about the frame. the frame-body carries data that needs to be transmitted. the transmitter calculates the fcs over the header and frame-body. the receiver uses the fcs to confirm that the header and frame-body are properly received. the following diagram shows the structure of a general mac frame.
for more information, see the topic.
introduction
this example shows how wlan mac frames specified in section 9.3 of [ 1 ] or [ 2 ] can be decoded. it also shows how aggregated mac frames specified in section 9.7 of [ 1 ] or [ 2 ] can be deaggregated.
wlan toolbox™ supports mpdu decoding for the following mac frames:
management frames: beacon
data frames: data, null, qos data, qos null
control frames: rts, cts, ack, block ack
in addition to mpdu decoding, wlan toolbox also supports deaggregation of an a-mpdu.
mpdu decoding
an mpdu can be a data, control or management frame type. can be used to decode an mpdu. this function processes the given mpdu and a physical layer configuration object to output the decoded mac parameters.
to illustrate mpdu decoding, a valid mpdu is created using . the created mpdu is passed to the function and the outputs are observed.
create an mpdu
a qos data frame is created for this example using . the following inputs are required to form a non-ht format qos data frame containing a 40-octet payload:
txframecfg
: a mac frame configuration object of type .txmsdu
: a 40-octet payload (msdu) to be included in the qos data frame.
% create a mac frame configuration object txframecfg = wlanmacframeconfig('frametype', 'qos data', ... 'frameformat', 'non-ht'); % 40-octet payload for each 'qos data' frame txmsdu = randi([0, 255], 40, 1); % physical layer configuration phycfg = wlannonhtconfig; % create the mpdu mpdu = wlanmacframe(txmsdu, txframecfg);
decode the mpdu
consumes an mpdu, a phy configuration object of type , , , or and optionally a (name, value) pair for dataformat
specifying the input format of the mpdu. since the mpdu generated using is in terms of octets, dataformat
is set to octets
. decodes the mpdu and outputs the following information:
rxframecfg
: a mac frame configuration object of type , containing the decoded mac parameters.rxmsdu
: a cell array, where each element is an n-by-2 character array representing the decoded msdu. multiple msdus are returned when the mpdu contains an aggregated msdu (a-msdu) as the payload.status
: an enumeration of type , which indicates whether the mpdu decoding was successful.
% decode the mpdu. [rxframecfg, rxmsdu, status] = wlanmpdudecode(mpdu, phycfg, ... 'dataformat', 'octets'); % check if the mpdu is decoded successfully disp(['status of the mpdu decoding: ' char(status)]) % observe the outputs, if the mpdu is decoded successfully if strcmp(status, 'success') disp(['type of the decoded mpdu: ' rxframecfg.frametype]) disp(['number of msdus in the mpdu: ' num2str(numel(rxmsdu))]) for i = 1:numel(rxmsdu) disp(['size of msdu-' num2str(i) ': ' num2str(size(rxmsdu{i}, 1)) ' octets']) end end
status of the mpdu decoding: success type of the decoded mpdu: qos data number of msdus in the mpdu: 1 size of msdu-1: 40 octets
a-mpdu deaggregation
an a-mpdu is an aggregation of multiple mpdus. the type of mpdus in an a-mpdu are restricted as specified in section 9.7.3 of [ 1 ].
can be used to deaggregate an a-mpdu. this function processes the given a-mpdu and the corresponding physical layer configuration object to output the deaggregated list of mpdus. is capable of decoding ht (high throughput), vht (very high throughput), he-su (high efficiency single user) and he-ext-su (high efficiency extended range single user) format a-mpdus as specified in [ 1 ] and [ 2 ].
to illustrate the a-mpdu deaggregation, a valid a-mpdu containing five mpdus is created using . the created a-mpdu is passed to the function and the outputs are observed.
create an a-mpdu
the following inputs are required to form an he-su format a-mpdu containing five mpdus (qos data frames), each mpdu containing a 40-octet payload:
txframecfg
: a mac frame configuration object of type .txmsdulist
: a five element cell array containing payload (msdu) for five mpdus. sincemsduaggregation
is set to false in thetxframecfg
, a separate mpdu is created for each msdu.phycfg
: a physical layer configuration object of type .
% create a mac frame configuration object txframecfg = wlanmacframeconfig('frametype', 'qos data', ... 'frameformat', 'he-su', ... 'mpduaggregation', true, ... 'msduaggregation', false); % 40-octet payload for each 'qos data' frame txmsdulist = repmat({randi([0, 255], 40, 1)}, 1, 5); % physical layer configuration phycfg = wlanhesuconfig('mcs', 3); % create the a-mpdu containing 5 mpdus ampdu = wlanmacframe(txmsdulist, txframecfg, phycfg);
deaggregate the a-mpdu
consumes an a-mpdu, a phy configuration object of type , , or and optionally a (name, value) pair for dataformat
specifying the input format of the a-mpdu. it finds and validates the mpdu delimiters, extracts the mpdus and outputs the following information that can be used for further processing the mpdus:
mpdulist
: a cell array containing the list of mpdus extracted from the a-mpdu.delimcrcfails
: a logical row vector representing delimiter crc validity for the corresponding index inmpdulist
. a value of true represents that the mpdu present inmpdulist
at the corresponding index may not be properly extracted.ampdustatus
: an enumeration of type , which indicates whether the a-mpdu deaggregation was successful.
% deaggregate the a-mpdu [mpdulist, delimcrcfails, ampdustatus] = wlanampdudeaggregate(ampdu, phycfg, ... 'dataformat', 'octets'); % observe the outputs disp(['status of a-mpdu deaggregation: ' char(ampdustatus)]) disp(['number of mpdus extracted from the a-mpdu: ' num2str(numel(mpdulist))]) disp(['number of mpdus with delimiter crc fails: ' num2str(nnz(delimcrcfails))])
status of a-mpdu deaggregation: success number of mpdus extracted from the a-mpdu: 5 number of mpdus with delimiter crc fails: 0
decode the list of mpdus
the mpdulist
contains the list of mpdus extracted from the a-mpdu. each of the mpdus present in the list can be decoded separately. however, if the delimcrcfails
contains any true
values, the mpdu present in mpdulist
at the corresponding index can be considered invalid as it may not be properly extracted because of the delimiter crc failure.
% decode the list of mpdus if strcmp(ampdustatus, 'success') % number of mpdus in the list nummpdus = numel(mpdulist); for i = 1:nummpdus % decode the mpdu only if the corresponding delimiter crc is valid if ~delimcrcfails(i) [rxframecfg, rxmsdu, mpdustatus] = wlanmpdudecode(mpdulist{i}, phycfg, ... 'dataformat', 'octets'); disp(['mpdu-' num2str(i) ' decoding status: ' char(mpdustatus)]) disp(['mpdu-' num2str(i) ' type: ' rxframecfg.frametype]) disp(['mpdu-' num2str(i) ' payload size: ' num2str(size(rxmsdu{1}, 1)) ' octets']) disp(' ') end end end
mpdu-1 decoding status: success mpdu-1 type: qos data mpdu-1 payload size: 40 octets mpdu-2 decoding status: success mpdu-2 type: qos data mpdu-2 payload size: 40 octets mpdu-3 decoding status: success mpdu-3 type: qos data mpdu-3 payload size: 40 octets mpdu-4 decoding status: success mpdu-4 type: qos data mpdu-4 payload size: 40 octets mpdu-5 decoding status: success mpdu-5 type: qos data mpdu-5 payload size: 40 octets
conclusion and further exploration
this example demonstrated how to deaggregate and decode ieee 802.11 mac frames. you can also explore ofdm beacon receiver using software-defined radio and examples for decoding the mac frames retrieved from the captured waveforms.
selected bibliography
ieee std 802.11™-2020. ieee standard for information technology - telecommunications and information exchange between systems - local and metropolitan area networks - specific requirements - part 11: wireless lan medium access control (mac) and physical layer (phy) specifications.
ieee std 802.11ax™-2021. ieee standard for information technology - telecommunications and information exchange between systems - local and metropolitan area networks - specific requirements - part 11: wireless lan medium access control (mac) and physical layer (phy) specifications - amendment 1: enhancements for high-efficiency wlan.