fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
test_tx.cpp File Reference

Transmitter test. More...

#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include <iostream>
#include "transmitter.h"

Go to the source code of this file.

Functions

void test_tx (double freq, double sample_rate, double tx_gain, double amp, Rate phy_rate)
 Function for testing the fun_ofdm transmitter. More...
 
int main (int argc, char *argv[])
 

Variables

double freq = 5.72e9
 
double sample_rate = 5e6
 
double tx_gain = 30
 
double amp = 0.5
 
Rate phy_rate = RATE_1_2_BPSK
 

Detailed Description

Transmitter test.

This file is used to test transmitting OFDM PHY frames over the air.

Definition in file test_tx.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 24 of file test_tx.cpp.

References amp, freq, phy_rate, sample_rate, test_tx(), and tx_gain.

24  {
25 
26  std::cout << "Testing transmit chain..." << std::endl;
28 
29  return 0;
30 }
void test_tx ( double  freq,
double  sample_rate,
double  tx_gain,
double  amp,
Rate  phy_rate 
)

Function for testing the fun_ofdm transmitter.

Parameters
freqCenter Frequency
sample_rateSample Rate
tx_gainTransmitter Gain
ampTransmit Amplitude
phy_rateThe PHY Rate used for all packets in this tx test

This function transmits 1000 packets. The data in the transmitted packets is mostly random except for the first, middle, and last 100 bytes which are a known string. This string is used to verify that the packet was in fact received along with the IEEE CRC-32 check.

Definition at line 45 of file test_tx.cpp.

References fun::RateParams::name, and fun::transmitter::send_packet().

Referenced by main().

46 {
47  srand(time(NULL)); //Initialize random seed
48 
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 }

Variable Documentation

double amp = 0.5

Definition at line 21 of file test_tx.cpp.

double freq = 5.72e9

Definition at line 17 of file test_tx.cpp.

Rate phy_rate = RATE_1_2_BPSK

Definition at line 22 of file test_tx.cpp.

double sample_rate = 5e6

Definition at line 18 of file test_tx.cpp.

double tx_gain = 30

Definition at line 19 of file test_tx.cpp.