IA_CoMP
Interference Alignment and Coordinated Multipoint
IA2/IA2_node.hpp
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 #ifndef IA2_NODE_EXAMPLE_HPP
00019 #define IA2_NODE_EXAMPLE_HPP
00020 
00021 #include <uhd/device.hpp>
00022 #include <uhd/utils/thread_priority.hpp>
00023 #include <uhd/utils/safe_main.hpp>
00024 #include <uhd/usrp/multi_usrp.hpp>
00025 #include <iostream>
00026 #include <complex>
00027 #include <uhd/types/clock_config.hpp>
00028 #include <four_multi/gps.hpp>
00029 #include <four_multi/four_multi.hpp>
00030 #include <four_multi/modem_OFDM2.hpp>
00031 #include <four_multi/AMC.hpp>
00032 #include <itpp/itbase.h>
00033 #include <itpp/itcomm.h>
00034 #include <itpp/stat/misc_stat.h>
00035 
00036 
00037 using namespace itpp;
00038 
00050 class IA2_node : public four_multi_node {
00051 
00052    public:
00053    
00054 
00091    IA2_node(uint32_t no_ant1, uint32_t no_ant2 , uint32_t skip_ant, 
00092            float start_gain,  uint32_t node_ix , double frequency,
00093             bool use_same_antenna,std::vector<std::string> IP_addresses,
00094             bool simulate, int receiver_delay_samples,int seed, 
00095             bool run_decoder, int scenario);
00096 
00097    uint32_t frame_ix(void ){ return d_frame_ix;};
00098    int codec_ix, modulation_order; // Codec index, and modulation order used with LDPC code.
00099 
00100    double offset_time;
00101   
00102    ~IA2_node();
00103   
00104    double get_gain(void) {return d_gain_rx;};
00105    std::vector<OFDM2> ai;
00106    uint32_t num_streams_per_bs; 
00107    uint32_t num_streams_per_ms; 
00108    uint32_t num_antennas_in_system; 
00109   
00110    cmat waveform_rx;
00111    cvec waveform_tx, waveform_tx_temp; 
00112 
00114    vec BERraw;
00116    vec BER;
00117 
00118    vec EVM;
00119    vec SINR;
00120    double SINR_temp;
00121    int ber_i;
00122    bvec input, transmitted;
00123    bvec message_hat, decoded_bits, transmitted_hat;
00124    vec soft_bit;
00125 
00126    cmat H[8][20]; //Channel matrices for beamforming design at the node_ix=0.
00127                  // Max 20 transmitter antennas in system
00128                  // max 8 mobile-station.
00129   
00130    double time_between_frames;
00131 
00135    uint32_t MIMO_active_tx_node_tx;
00137    bool MIMO_closed_loop;
00139    bool MIMO_all_active;
00140 
00141    protected: 
00142 
00143 
00144    virtual frame_settings node_init(void) ;
00145    virtual frame_settings node_process(void) ;
00146    virtual void end_of_run(void) ;
00147 
00148    void calculate_beamformers(void);
00149    void iteration(const cmat v_old,int subcarrier_ix_start,
00150  int subcarrier_ix_stop,
00151                   int increment);
00152 
00153 
00154    static const int iterations = 5;
00155    static const uint32_t block_length=400;
00156    static const uint32_t noise_estimation_start=1000;
00157    static const uint32_t noise_estimation_length=800;
00158    static const uint32_t constraint_length = 3;
00159 
00160    double scaling_tx_signal;
00161    ivec demodulation_position;
00162 
00163    uint32_t d_frame_ix, d_no_frames, scenario;
00164    bool do_calculate_beamformers;
00165    double d_gain_rx, d_gain_tx, d_frequency;
00166   //cmat waveform_rx;
00167   // cvec waveform_tx, waveform_tx_temp; 
00168   //bvec input, transmitted;
00169   //vec soft_bit;
00170    ivec interleaver_sequence;
00171    std::string metric;
00172    double logmax_scale_factor;
00173    bool adaptive_stop;
00174    ivec gen;
00175    BERC berc;
00176    ivec nrof_used_iterations;
00177    double target_rx_base_band_rms_ampl;
00178    ivec reorder_all[10]; // Max 10 streams in the system.
00179    uint32_t num_links, num_bs, num_ms;
00180    uint32_t num_ant_ms, num_ant_bs;
00181    cmat v[10]; // Precoding matrices for the user in question. Max 10 streams.
00182   //cmat u[10]; // Receiver matrices for the user in question. Max 10 streams.
00183    cmat Vbig[10]; // Precoding matrices matrices for all streams
00184                    // Used by node_ix=0.. Max 10 streams.
00185   //cmat Ubig[10]; // Receiver matrices for all streams. Max 10 streams.
00186                      // Used by node_ix=0.
00187 
00188    cvec symbols; // Transmit signal of a stream.
00189   
00190   
00191 
00192    std::complex<int16_t> *feedback_buffer; // Place to store samples used for 
00193                                            // RX to TX feedback
00194 
00195    std::complex<int16_t> *feedback_buffer0; // Place to store samples used for 
00196                                            // RX to TX feedback
00197 
00198    std::complex<int16_t> *feedback_buffer1; // Place to store samples used for 
00199                                            // RX to TX feedback
00200 
00201    std::complex<int16_t> *feedback_buffer2; // Place to store samples used for 
00202                                            // RX to TX feedback
00203 
00204    std::vector<uint32_t> other_node_ixs;
00205    std::vector<void  *> pointers_to_data;
00206    std::vector<uint32_t> num_bytess;
00207    
00208 
00209    int feedback_buffer_size; // RX->TX
00210    int feedback_buffer_size_tx; // TX->TX
00211 
00212    ivec antenna_pilot_position;
00213    ivec antenna_pilot_position_this_bs;
00214    ivec known_pos_all;
00215    bool is_bs;
00216 
00217    uint32_t shift_transmit_signal_samples;
00218    uint32_t replicas_start;
00219    uint32_t replicas_spacing;
00220    ivec replica_positions_this_bs;
00221    ivec replica_positions;
00222 
00223    ivec stream_ix_this_node;
00224    imat bs_to_stream_ix;
00225    ivec stream_ix_to_ms_ix;
00226    int d_seed;
00227    uint32_t num_streams; // Total number of streams in the system.
00228 
00229    void normalize_columns(cmat &M);
00230    void calculate_v(void);
00231 
00232    void format_tx_symbols(uint32_t codec_ix, uint32_t modulation_order, int stream_ix);
00233    void decode_rx_symbols(uint32_t codec_ix, uint32_t modulation_order, int stream_ix);
00234    AMC amc; // Adaptive coding and modulation object
00235    int word_length; // Code-word length
00236    double noise_variance_norm;
00237    double noise_variance;
00238    bool d_run_decoder;
00239    uint64_t temp_seed;
00240    bool use_old_rand;
00241 
00242    Real_Timer timer;
00243 };
00244 
00245 
00246 
00247 #endif
 All Classes Functions Variables