generate and parse wlan mac frames -凯发k8网页登录
this example shows how to configure and generate wlan mac frames, then recover the payload of msdus by parsing the mac frame.
introduction
the ieee® 802.11™ family of standards supports four types of mac frame: control, data, management, and extension. within each of these types, the standard defines a range of subtypes, each of which serves a specific purpose in an 802.11™ network.
this example demonstrates how to configure, generate, and parse mpdus and a-mpdus by using wlan toolbox™ configuration objects and functions.
generate and decode mpdu
create a mac frame configuration object for a data frame, specifying a high-efficiency single-user (he su) physical layer (phy) configuration.
cfgmpdu = wlanmacframeconfig('frametype','data','frameformat','he-su');
specify an msdu as a numeric vector of octets in bit format. you can also specify msdus as a character vector or string of octets in hexadecimal format.
msdu = randi([0 255],32,1);
generate the mpdu by calling the function, specifying bits as the output format.
[mpdu,mpdulength] = wlanmacframe(msdu,cfgmpdu,'outputformat','bits');
recover the msdu by calling the function. the function also returns the mac frame configuration object and the status of the decoding. check that the decoding operation returns the correct frame format and display the status.
[rxcfgmpdu,payload,status] = wlanmpdudecode(mpdu,wlanhesuconfig); disp(isequal(cfgmpdu.frameformat,rxcfgmpdu.frameformat))
1
disp(status)
success
generate and parse a-mpdu
create a configuration object for a qos data mac frame, specifying an he su phy configuration. enable mpdu aggregation and disable msdu aggregation.
cfgampdu = wlanmacframeconfig('frametype','qos data','frameformat','he-su',... 'mpduaggregation',true,'msduaggregation',false);
specify a cell array of msdus, specifying each msdu as a numeric vector of octets in bit format. you can also specify msdus as a character vector or string of octets in hexadecimal format.
msdulist = repmat({randi([0 255],32,1)},1,4);
generate the mpdu for a he su phy configuration by calling the function.
cfgphy = wlanhesuconfig('mcs',5); [ampdu,ampdulength] = wlanmacframe(msdulist,cfgampdu,cfgphy,'outputformat','bits');
deaggregate the a-mpdu to return the mpdu list by calling the function. the function also returns the result of the delimiter cyclic redundancy check (crc) and the status of a-mpdu deaggregation.
[mpdulist,delimitercrcfailure,status] = wlanampdudeaggregate(ampdu,cfgphy);
display the number of delimiter crc failures and the status of deaggregation.
disp(nnz(delimitercrcfailure))
0
disp(status)
success
obtain the msdus by decoding the deaggregated mpdus with the function and display the status of the decoding process.
if strcmp(status,'success') for i = 1:numel(mpdulist) if ~delimitercrcfailure(i) [cfg,msdu,decodestatus] = wlanmpdudecode(mpdulist{i},cfgphy,'dataformat','octets'); disp(['mpdu ' num2str(i) ' decoding status: ' char(decodestatus)]) end end end
mpdu 1 decoding status: success mpdu 2 decoding status: success mpdu 3 decoding status: success mpdu 4 decoding status: success