umts-phy.h

00001 /* -*-  Mode:C++ -*- */
00002 /*
00003  * Copyright (c) 2007 Regents of the SIGNET lab, University of Padova.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the University of Padova (SIGNET lab) nor the 
00015  *    names of its contributors may be used to endorse or promote products 
00016  *    derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
00020  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00027  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00028  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  */
00030 
00031 #ifndef UMTSPHY_H 
00032 #define UMTSPHY_H
00033 
00034 #include<mphy.h>
00035 
00036 
00037 
00038 #define CODE_UNKNOWN       0
00039 #define CODE_CONVOLUTIONAL 1
00040 #define CODE_TURBO         2
00041 
00042 // Magic number used to scale erfc to get BER
00043 #define ZETA_CONVOLUTIONAL_ONEHALF 2.72
00044 
00045 
00046 #define UMTS_MODNAME "UMTS"
00047 
00048 #define DIRECTION_DOWNLINK 1
00049 #define DIRECTION_UPLINK   2
00050 
00051 
00052 typedef struct pcEntry
00053 {
00054   int id;
00055   bool powerUp_;
00056   double TxPower_;
00057   double Pi;
00058   double sinr;
00059   double SIRtarget;
00060   
00061   struct pcEntry* next_;
00062 } pcEntry;
00063 
00064 
00065 class UmtsPhy : public MPhy 
00066 {
00067 
00068  public:
00069   UmtsPhy();
00070   int command(int argc, const char*const* argv);
00071   int getModulationType(Packet*);
00072   double getTxDuration(Packet* p);
00073   virtual double getDataRate(){assert(0);}
00074 
00075  protected:
00076 
00077   void startTx(Packet* p);
00078   void endTx(Packet* p);
00079   void startRx(Packet* p);
00080   void endRx(Packet* p);
00081 
00082 
00083   /* Power Ctrl methods*/
00084   double getTxPower(Packet* p);
00085   virtual pcEntry* getPcEntry(int id);
00086   virtual void addPcEntry(int id);
00087   virtual void pcUpdateCmd(Packet* p);
00088   virtual void pcUpdatePi(Packet* p);
00089   virtual void pcReadCmd(Packet* p);
00090   
00091   virtual double getPrAfterDeSpreading(Packet* p) {assert(0);}
00092   double sinr2ber(double);
00093 
00094   virtual void calculateErrors(Packet* p);
00095   virtual double getPacketErrorRate(Packet* p, double sinr);
00096   virtual int getNumBits(Packet* p);
00097 
00098   double chip_rate_ ;         
00099   int    spreading_factor_ ;  
00100   int     bits_per_symbol_;    
00101   double coding_rate_;        
00102   int    coding_type_;          
00103   double slot_duration_;      
00104 
00105   int code_id_;     
00111   static int code_id_counter;        
00112 
00113   
00114   static bool mod_initialized; 
00115   static int modid;        
00116 
00117   MSpectralMask* dl_smask_;   
00118   MSpectralMask* ul_smask_;   
00119   
00120   double alpha_;                
00121 
00122   
00123   pcEntry* pcTable_;            
00124 
00125   double maxTxPower_;           
00126 
00127 
00128   double minTxPower_;           
00129   double pcStep_;                       
00130   double SIRtarget_;            
00131   double PERtarget_;            
00132 
00133   int PowerCtrlUpdateCmdAtStartRx_;  
00144   int PowerCtrlReadCmdAtStartRx_; 
00154 
00155 
00156 };
00157 
00158 
00159 
00160 
00161 class UmtsPhyBS : public UmtsPhy 
00162 {
00163 
00164  public:
00165   UmtsPhyBS();
00166   virtual double getDataRate();
00167   double getPrAfterDeSpreading(Packet* p);
00168 
00169  protected:
00170   void startTx(Packet* p);
00171   void endRx(Packet* p);
00172   MSpectralMask* getTxSpectralMask(Packet* p) {return dl_smask_;}
00173   MSpectralMask* getRxSpectralMask(Packet* p) {return ul_smask_;}
00174 
00175   double iuccorr_;     // inter-user spreading code correlation
00176 
00177 };
00178 
00179 
00180 
00181 class UmtsPhyME : public UmtsPhy 
00182 {
00183 
00184  public:
00185   int command(int argc, const char*const* argv);
00186   virtual double getDataRate();
00187   double getPrAfterDeSpreading(Packet* p);
00188 
00189 //   virtual double getSNR();    
00190 //   virtual double getSINR();
00191 
00192  protected:
00193   void startTx(Packet* p);
00194   void endRx(Packet* p);
00195   MSpectralMask* getTxSpectralMask(Packet* p) {return ul_smask_;}
00196   MSpectralMask* getRxSpectralMask(Packet* p) {return dl_smask_;}
00197 
00198 //    double SNR;
00199 //    double SINR;
00200 
00201 
00202   int bs_code_id_;   
00203 
00204 };
00205 
00206 
00207 #endif /* UMTSPHY_H */
00208 
00209 
00210 

Generated on Wed Nov 26 15:47:29 2008 for NS-MIRACLE library by  doxygen 1.5.2