symbol_num = 128; oversample = 16; % samples in one symbol amplitude = 127;
waveform = int8([]); complex_waveform = []; for ii = 1:symbol_num data = 2*randint-1; % BPSK symbol symbol = kron(data,ones(1,oversample))*amplitude*(1+j); % rotate 45 degrees to make it complex type complex_waveform = [complex_waveform,symbol]; symbol_re = int8(real(symbol)); % 8-bit width waveform data symbol_im = int8(imag(symbol)); symbol_iq = reshape([symbol_re;symbol_im],1,[]); waveform = [waveform, symbol_iq]; end
% save waveform file filename = sprintf('waveform_randombpsk_width%d_amp%d_totallen%d.sig',oversample,amplitude,symbol_num*oversample); fid = fopen(filename,'wb'); fwrite(fid, waveform); fclose(fid); % save .mat file for the receiver side filename = sprintf('waveform_randombpsk_width%d_amp%d_totallen%d.mat',oversample,amplitude,symbol_num*oversample); save(filename,'complex_waveform');
下面这个函数是读dump文件的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
function data = read_dump_file(filename) fid = fopen(filename, 'r'); sample = fread(fid, inf, 'int16'); total_len = length(sample); fclose(fid); if rem(total_len,64)~=0 error('Error: The length of file is wrong!'); end num_rx_desc = total_len/64; % discard the rx_desc header reshape_sample = reshape(sample,64,num_rx_desc); reshape_sample = reshape_sample(9:end,:); sample = reshape(reshape_sample,2,[]);
Dut tool or dot11config can capture a snapshot of the wireless channel and store the raw I/Q samples into a file located at c:\. The post explains the format of the dump file.
The dump file is basically a binary file that contains an array of RX descriptors. A RX descriptor (RX_DESC) is defined as follows: