9 #include <boost/date_time/posix_time/posix_time.hpp>
10 #include <boost/date_time/gregorian/gregorian.hpp>
11 #include <boost/program_options.hpp>
30 int main(
int argc,
char * argv[]){
32 std::cout <<
"Running Simulation..." << std::endl;
49 std::string data(
"I'm a little tea pot, short and stout.....here is my handle.....blah blah blah.....this rhyme sucks!");
52 std::vector<unsigned char> payload(data.length()*repeat);
53 for(
int x = 0; x < repeat; x++) memcpy(&payload[x*data.length()], &data[0], data.length());
58 int pad_length = samples.size()*1000;
62 std::cout <<
"Transmitting " << num_frames <<
" frames" << std::endl;
63 std::vector<std::complex<double>> samples_con(samples.size() * num_frames + pad_length);
64 for(
int x = 0; x < num_frames; x++)
66 memcpy(&samples_con[x*samples.size()], &samples[0], samples.size() *
sizeof(std::complex<double>));
70 std::vector<std::complex<double> > zeros(pad_length);
71 memcpy(&samples_con[num_frames*samples.size()], &zeros[0], zeros.size()*
sizeof(std::complex<double>));
73 boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time();
77 int chunk_size = 4096;
80 for(
int x = 0; x < samples_con.size(); x += chunk_size)
83 int end = x + chunk_size;
84 if(end > samples_con.size()) end = samples_con.size();
85 std::vector<std::complex<double> > chunk(&samples_con[start], &samples_con[end]);
87 std::vector<std::vector<unsigned char> > rec_frames = receiver->
process_samples(chunk);
88 count += rec_frames.size();
90 if(rec_frames.size()){
91 for(
int i = 0; i < rec_frames.size(); i++){
92 for(
int j = 0; j < rec_frames[i].size(); j++)
93 std::cout << rec_frames[i][j];
94 std::cout << std::endl << std::endl;
99 boost::posix_time::time_duration elapsed = boost::posix_time::microsec_clock::local_time() - start;
101 printf(
"Received %i packets\n", count);
103 printf(
"Time elapsed: %f\n", elapsed.total_microseconds() / 1000.0);