|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2006 Andras Varga, Levente Meszaros 00003 // Based on the Mobility Framework's SnrEval by Marc Loebbers 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef ABSTRACTRADIO_H 00020 #define ABSTRACTRADIO_H 00021 00022 #include "ChannelAccess.h" 00023 #include "RadioState.h" 00024 #include "AirFrame_m.h" 00025 #include "IRadioModel.h" 00026 #include "IReceptionModel.h" 00027 #include "SnrList.h" 00028 00029 00030 00056 class INET_API AbstractRadio : public ChannelAccess 00057 { 00058 public: 00059 AbstractRadio(); 00060 virtual ~AbstractRadio(); 00061 00062 protected: 00063 virtual void initialize(int stage); 00064 virtual void finish(); 00065 00066 virtual void handleMessage(cMessage *msg); 00067 00068 virtual void handleUpperMsg(AirFrame*); 00069 00070 virtual void handleSelfMsg(cMessage*); 00071 00072 virtual void handleCommand(int msgkind, cPolymorphic *ctrl); 00073 00075 virtual void handleLowerMsgStart(AirFrame *airframe); 00076 00078 virtual void handleLowerMsgEnd(AirFrame *airframe); 00079 00081 virtual void bufferMsg(AirFrame *airframe); 00082 00084 virtual AirFrame *unbufferMsg(cMessage *msg); 00085 00087 virtual void sendUp(AirFrame *airframe); 00088 00090 virtual void sendDown(AirFrame *airframe); 00091 00093 virtual AirFrame *encapsulatePacket(cPacket *msg); 00094 00096 virtual void setRadioState(RadioState::State newState); 00097 00099 virtual int getChannelNumber() const {return rs.getChannelNumber();} 00100 00102 virtual void addNewSnr(); 00103 00105 virtual AirFrame *createAirFrame() {return new AirFrame();} 00106 00114 virtual void changeChannel(int channel); 00115 00120 virtual void setBitrate(double bitrate); 00121 00127 virtual IReceptionModel *createReceptionModel() = 0; 00128 00134 virtual IRadioModel *createRadioModel() = 0; 00135 00136 protected: 00137 IRadioModel *radioModel; 00138 IReceptionModel *receptionModel; 00139 00141 double transmitterPower; 00142 00145 int uppergateOut; 00146 int uppergateIn; 00148 00153 struct SnrStruct 00154 { 00155 AirFrame *ptr; 00156 double rcvdPower; 00157 SnrList sList; 00158 }; 00159 00165 SnrStruct snrInfo; 00166 00171 typedef std::map<AirFrame*,double> RecvBuff; 00172 00177 RecvBuff recvBuff; 00178 00180 RadioState rs; 00181 00183 int newChannel; 00184 00186 double newBitrate; 00187 00189 double noiseLevel; 00190 00194 double carrierFrequency; 00195 00200 double thermalNoise; 00201 00208 double sensitivity; 00209 }; 00210 00211 #endif 00212