mphy.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 MPHY_H 
00032 #define MPHY_H
00033 
00034 #include<module.h>
00035 
00036 
00037 #include <minterference.h>
00038 #include <mpropagation.h>
00039 #include <mcorrelation.h>
00040 #include <mantenna.h>
00041 #include <mspectralmask.h>
00042 #include <mphy_pktheader.h>
00043 #include <mphy_timers.h>
00044 
00045 
00046 
00047 #define MPHY_DROP_ERROR_INTERFERENCE "EINTRF" 
00048 #define MPHY_DROP_ERROR_NOISE        "ENOISE"
00049 
00050 
00051 class MPhy : public Module
00052 {
00053   friend class MPhyRxTimer;
00054   friend class MPhyTxTimer;
00055 
00056 public:
00057 
00058   MPhy();
00059   virtual ~MPhy();
00060   virtual void recv(Packet* p);
00061 
00062   virtual int recvSyncClMsg(ClMessage* m);
00063 
00077   virtual double getTxDuration(Packet* p) = 0;
00078 
00089   virtual double getTxPower(Packet* p) {return TxPower_;}
00090 
00103   virtual double getRxPower(Packet* p);
00104 
00121   virtual double getNoisePower(Packet* p);
00122 
00134   virtual MAntenna* getTxAntenna(Packet* p) {return antenna_;}
00135 
00147   virtual MAntenna* getRxAntenna(Packet* p) {return antenna_;}
00148 
00157   virtual MSpectralMask* getTxSpectralMask(Packet* p) {return spectralmask_;}
00158 
00159 
00167   virtual MSpectralMask* getRxSpectralMask(Packet* p) {return spectralmask_;} 
00168 
00169 
00170 
00181   static int registerModulationType(const char* name);
00182 
00183 
00192   static const char* getModulationName(int modtype);
00193 
00194 
00204   virtual int getModulationType(Packet* p) = 0;
00205 
00206 
00207 
00216   virtual int command(int argc, const char* const* argv);
00217 
00218 protected:
00219 
00232   virtual void startTx(Packet* p) = 0;
00233 
00244   virtual void endTx(Packet* p)   = 0;
00245 
00257   virtual void startRx(Packet* p) = 0;
00258 
00259 
00286   virtual void endRx(Packet* p)   = 0;
00287 
00291   void turnOn() {isOn = true; }
00292 
00293 
00297   void turnOff() {isOn = false; }
00298 
00299 
00309   void Phy2MacEndTx(const Packet* p);
00310 
00321   void Phy2MacStartRx(const Packet* p);
00322 
00323 
00335   void Phy2MacCCA(bool cca); 
00336 
00337 
00338 
00339   MPhyTxTimer txtimer; 
00340   MPhyRxTimer rxtimer; 
00341 
00342   MInterference* interference_;  
00343 
00344 
00345   MPropagation*  propagation_;   
00346 
00347 
00348   MAntenna*      antenna_;       
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357   MSpectralMask* spectralmask_;  
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370   MCorrelation* correlation_;    
00378   double TxPower_;    
00379 
00380 
00381 
00382 
00383 
00384 
00385   double NoiseSPD_;   
00386 
00387 
00388 
00389 
00390 
00391 
00392   bool isOn; 
00393 
00394 };
00395 
00396 
00397 
00398 
00399 
00400 
00401 #endif /* MPHY_H */

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