four_multi
Multi-Antenna,Multi-Node,Multi-Band,Multi-Cell
examples/SISO_AMC_OFDM_simulator.cpp
00001 //
00002 // Copyright 2011-2013, Per Zetterberg, KTH Royal Institute of Technology
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include "SISO_AMC_OFDM_node.hpp"
00019 namespace po = boost::program_options;
00020 using namespace boost;
00021 
00022 
00023 int UHD_SAFE_MAIN(int argc, char *argv[]){
00024 
00025   uint32_t modulation_order, codec_ix;
00026   bool chase;
00027 
00028     po::options_description desc("Allowed options");
00029     desc.add_options()
00030         ("help", "help message")
00031         ("m",po::value<uint32_t>(&modulation_order)->default_value(16), 
00032           "Modulation 4,16 or 256")
00033         ("codec_ix",po::value<uint32_t>(&codec_ix)->default_value(1), 
00034           "LDPC coder 0,1,2 or 3 means 1/4, 1/2, 5/8 and 3/4 rate")
00035       ("chase",po::value<bool>(&chase)->default_value(false),
00036        "Use chase combining in the receiver");
00037     ;
00038     po::variables_map vm;
00039     po::store(po::parse_command_line(argc, argv, desc), vm);
00040     po::notify(vm);
00041     
00042     if (vm.count("help")){
00043         std::cout << boost::format("SISO_AMC_OFDM_simulator.  %s") % desc << 
00044 std::endl;
00045         return ~0;
00046     }
00047 
00048 
00049     if (!((modulation_order==4) | (modulation_order==16) | 
00050           (modulation_order==256))) {
00051       std::cout << "Sorry, the only modulation orders allowed are 4,16 and 256";
00052     };   
00053 
00054 
00055   std::vector<four_multi_node*> all_my_nodes;
00056   std::vector<std::string> IP_addresses;
00057   block_fading ch_model;
00058   SISO_AMC_OFDM_node *st;
00059 
00060 
00061   /*
00062   if (!(uhd::set_thread_priority_safe(1,true))) {
00063       std::cout << "Problem setting thread priority" << std::endl;
00064       return 1;
00065   };
00066   */
00067 
00068   SISO_AMC_OFDM_node node0(0,0,0, 2490e6,false,
00069                            modulation_order,true,codec_ix,chase,0.1); // RX
00070   SISO_AMC_OFDM_node node1(0,0,1, 2490e6,false,
00071                            modulation_order,true,codec_ix,chase,0.1); // TX
00072 
00073   all_my_nodes.push_back(&node0);
00074   all_my_nodes.push_back(&node1);
00075 
00076   ch_model.scaling_signal=0.01;
00077   ch_model.scaling_noise=20;
00078 
00079   ch_model.is_awgn=true;
00080 
00081 
00082   simulate(&all_my_nodes,&ch_model);
00083   st=&node0;
00084   cout << "BERraw=" << st->BERraw << std::endl;
00085   cout << "BER=" << st->BER << std::endl;
00086 
00087   cout << "/////////////////////////////// \n";
00088  
00089 
00090 
00091     #if 0
00092     it_file d1;
00093     d1.open("d1.it");
00094     d1<< Name("const") << node0.symbols;
00095     d1.close();
00096     #endif
00097 
00098 
00099 
00100   return 0;
00101 
00102 };
 All Classes Functions Variables