fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
test_tx.cpp
Go to the documentation of this file.
1 
7 #include "stdio.h"
8 #include "stdlib.h"
9 #include "time.h"
10 #include <iostream>
11 #include "transmitter.h"
12 
13 using namespace fun;
14 
15 void test_tx(double freq, double sample_rate, double tx_gain, double amp, Rate phy_rate);
16 
17 double freq = 5.72e9;
18 double sample_rate = 5e6;
19 double tx_gain = 30;
20 //double rx_gain = 30;
21 double amp = 0.5;
23 
24 int main(int argc, char * argv[]){
25 
26  std::cout << "Testing transmit chain..." << std::endl;
28 
29  return 0;
30 }
31 
45 void test_tx(double freq, double sample_rate, double tx_gain, double amp, Rate phy_rate)
46 {
47  srand(time(NULL)); //Initialize random seed
48 
49  transmitter tx = transmitter(freq, sample_rate, tx_gain, amp);
50  std::string known_string("This known string is used to verify the correctness of the received data along with the IEEE CRC-32!");
51 
52  int num_packets = 1000;
53  int packet_length = 1500;
54  std::vector<std::vector<unsigned char> > packets(num_packets, std::vector<unsigned char>(packet_length));
55 
56  // Build all the packets
57  for(int i = 0; i < num_packets; i++)
58  {
59  //Insert the known string in the beginning, middle, and end with random data inbetween
60  memcpy(&packets[i][0], &known_string[0], known_string.length());
61  for(int j = 100; j < 1000; j++) packets[i][j] = (unsigned char) rand() % 256;
62  memcpy(&packets[i][1000], &known_string[0], known_string.length());
63  for(int j = 1100; j < 1400; j++) packets[i][j] = (unsigned char) rand() % 256;
64  memcpy(&packets[i][1400], &known_string[0], known_string.length());
65  }
66 
67  //Transmit all the packets
68  std::string tx_phy_rate = RateParams(phy_rate).name;
69  for(int i = 0; i < num_packets; i++)
70  {
71  std::cout << "Sending packet " << i + 1 << " of " << num_packets << " at " << tx_phy_rate << std::endl;
72  tx.send_packet(packets[i], phy_rate);
73  }
74 
75 }
76 
77 
78 
79