[UHD] tx_from_file.cpp (sending a file formed 802.11 packet using UHD)

Hello,
The goal is to send a full 802.11 packet using UHD.

  1. I have created a complex samples of 802.11 packet using MATLAB and
    saved
    it into a file.
  • final: 1440 complex samples

file_name=‘in.dat’;

fid = fopen(file_name,‘w’);

new_save = reshape([real(final);imag(final)],1,2*length(final));

F = fwrite(fid,new_save,‘float’);

fclose all;

  1. current tx_from_file.cpp does not compile, so modified a little bit
  • I think I messed up the data formats.

/-------------------------------------------------------------------------------/

//allocate data to send

std::vector<std::complex<float> > buff;

uhd::tx_metadata_t md;

 std::cout << "Read data to send from file: in.dat" << std::endl;

std::ifstream infile("in.dat", std::ifstream::binary);

while (!infile.eof()) {

    std::complex<float> c;

    infile.read((char *)&c, sizeof(std::complex<float>));

    if (!((c.real() == 0) && (c.imag() == 0))) {

        buff.push_back(c);

//std::cout << "C = " << c << std::endl;

    }

}

samps_per_packet = buff.size();

infile.close();

std::cout << "Number of samples in file: " << samps_per_packet <<

std::endl;

//send the data in multiple packets

size_t num_packets = (total_num_samps+samps_per_packet-1

)/samps_per_packet;

for (size_t i = 0; i < num_packets; i++){

    //setup the metadata flags and time spec

    md.start_of_burst = true;                  //always SOB (good 

for
continuous streaming)

    md.end_of_burst   = (i == num_packets-1);  //only last packet 

has
EOB

    md.has_time_spec  = (i == 0);              //only first packet 

has
time

    md.time_spec = uhd::time_spec_t(seconds_in_future);


    size_t samps_to_send = std::min(total_num_samps -

samps_per_packet*i, samps_per_packet);

    //send the entire packet (driver fragments internally)

    size_t num_tx_samps = dev->send(

        &buff.front(), samps_to_send, md,

        uhd::io_type_t::COMPLEX_FLOAT32,

        uhd::device::SEND_MODE_FULL_BUFF

    );

    if(verbose) std::cout << std::endl << boost::format("Sent %d

samples") % num_tx_samps << std::endl;

}


//finished

std::cout << std::endl << "Done!" << std::endl << std::endl;
  1. I don’t know what the the proper sample rate is for 802.11 6Mbps data
    frame. I set the rate as 6e6 and got following message

Warning:

The hardware does not support the requested TX sample rate:

Target sample rate: 6.000000 MSps

Actual sample rate: 5.882353 MSps

Actual TX Rate: 5.882353 Msps…