![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WiFiMac * 00003 * This file is part of openWNS (open Wireless Network Simulator) 00004 * _____________________________________________________________________________ 00005 * 00006 * Copyright (C) 2004-2007 00007 * Chair of Communication Networks (ComNets) 00008 * Kopernikusstr. 16, D-52074 Aachen, Germany 00009 * phone: ++49-241-80-27910, 00010 * fax: ++49-241-80-22242 00011 * email: info@openwns.org 00012 * www: http://www.openwns.org 00013 * _____________________________________________________________________________ 00014 * 00015 * openWNS is free software; you can redistribute it and/or modify it under the 00016 * terms of the GNU Lesser General Public License version 2 as published by the 00017 * Free Software Foundation; 00018 * 00019 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00021 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00022 * details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ******************************************************************************/ 00028 00029 #include <WIFIMAC/management/protocolCalculatorPlugins/Duration.hpp> 00030 #include <cmath> 00031 00032 using namespace wifimac::management::protocolCalculatorPlugins; 00033 00034 Duration::Duration( FrameLength* fl_, const wns::pyconfig::View& config): 00035 symbolWithoutGI(config.get<wns::simulator::Time>("symbolDurationWithoutGI")), 00036 slot(config.get<wns::simulator::Time>("slot")), 00037 sifs(config.get<wns::simulator::Time>("sifs")), 00038 fl(fl_) 00039 { 00040 00041 } 00042 00043 Duration::Duration( FrameLength* fl_, const ConfigGetter& config ): 00044 symbolWithoutGI(config.get<wns::simulator::Time>("symbolDurationWithoutGI", "d")), 00045 slot(config.get<wns::simulator::Time>("slot", "d")), 00046 sifs(config.get<wns::simulator::Time>("sifs", "d")), 00047 fl(fl_) 00048 { 00049 00050 } 00051 00052 unsigned int 00053 Duration::ofdmSymbols(Bit psduLength, const wifimac::convergence::PhyMode& pm) const 00054 { 00055 unsigned int n_es = 1; 00056 // TODO: correct n_es for higher phy modes 00057 return(static_cast<int>(ceil(static_cast<double>(psduLength + fl->service + fl->tail*n_es) / 00058 static_cast<double>(pm.getDataBitsPerSymbol())))); 00059 } 00060 00061 wns::simulator::Time 00062 Duration::frame(Bit psduLength, const wifimac::convergence::PhyMode& pm) const 00063 { 00064 return(preamble(pm) + ofdmSymbols(psduLength, pm) * symbol(pm)); 00065 } 00066 00067 wns::simulator::Time 00068 Duration::frame(Bit psduLength, const double grossBitRate, const wifimac::convergence::PhyMode& pm) const 00069 { 00070 unsigned int n_es = 1; 00071 // TODO: correct n_es for higher phy modes 00072 double psduFrameSize = fl->service + psduLength + fl->tail*n_es; 00073 double durationPSDU = psduFrameSize / grossBitRate; 00074 return(preamble(pm) + durationPSDU); 00075 } 00076 00077 wns::simulator::Time 00078 Duration::preamble(const wifimac::convergence::PhyMode& pm) const 00079 { 00080 // number of DLFT and ELFT in HT-preamble (D802.11n,D4.00, Table 20-11~13) 00081 // here: N_ss=N_sts=Mt, and N_ess=0 00082 00083 unsigned int dltf = 0; 00084 unsigned int eltf = 0; 00085 wns::simulator::Time s = symbol(pm); 00086 00087 if(pm.getNumberOfSpatialStreams() == 3) 00088 { 00089 dltf = 4; 00090 } 00091 else 00092 { 00093 dltf = pm.getNumberOfSpatialStreams(); 00094 } 00095 00096 if(pm.getPreambleMode() == "Basic") 00097 { 00098 return(16e-6 + s); 00099 } 00100 00101 if(pm.getPreambleMode() == "HT-Mix") 00102 { 00103 // Non-HT short training sequence (D802.11n,D4.00, Table 20-5): 8 us 00104 // Non-HT long training sequence (D802.11n,D4.00, Table 20-5): 8 us 00105 // --> duration of non-HT preamble, (D802.11n,D4.00, 20.4.3): 16 us 00106 // plus signal symbol: 4us 00107 // HT-STF duration: 4 us 00108 // HT first long training field duration for HT-mixed mode: 4 us 00109 // HT second, and subsequent, long training fields duration: 4 us 00110 // --> HT-preamble for mixed mode: 4+4+ (DLTF+ELTF)*4 00111 00112 return(16e-6 + s + (2 + dltf + eltf - 1)*4e-6 + 2*s); 00113 } 00114 00115 if(pm.getPreambleMode() == "HT-GF") 00116 { 00117 // Greenfield mode 00118 // HT-GF short traning field duration 00119 // t_GF_STF = 8 00120 // HT first long traning field duration for HT-GF mode 00121 // t_HT_LTF1_gf = 8 00122 // HT second, and subsequent, long training fields duration 00123 // t_HT_LTFs = 4 00124 // HT preamble for greenfield mode 00125 // t_HT_PRE = t_GF_STF + t_HT_LTF1_gf + (n_DLTF + n_ELTF - 1) * t_HT_LTFs; 00126 // signal symbol for HT mode 00127 // t_HT_SIG = 8 00128 // total duration of HT-GF mode: t_HT_PRE + t_HT_SIG 00129 return(8e-6 + 8e-6 + (dltf + eltf - 1)*4e-6 + 2*s); 00130 } 00131 00132 assure(pm.getPreambleMode() == "Basic" or pm.getPreambleMode() == "HT-Mix" or pm.getPreambleMode() == "HT-GF", "Unknown plcpMode"); 00133 00134 return(1); 00135 } 00136 00137 wns::simulator::Time 00138 Duration::preambleProcessing(const wifimac::convergence::PhyMode& pm) const 00139 { 00140 return(preamble(pm) + 1e-6); 00141 } 00142 00143 wns::simulator::Time 00144 Duration::ack(const wifimac::convergence::PhyMode& pm) const 00145 { 00146 return(this->frame(fl->ack, pm)); 00147 } 00148 00149 wns::simulator::Time 00150 Duration::aifs(unsigned int n) const 00151 { 00152 return(sifs + n * slot); 00153 } 00154 00155 wns::simulator::Time 00156 Duration::eifs(const wifimac::convergence::PhyMode& pm, unsigned int aifsn) const 00157 { 00158 return(sifs + ack(pm) + aifs(aifsn)); 00159 } 00160 00161 wns::simulator::Time 00162 Duration::rts(const wifimac::convergence::PhyMode& pm) const 00163 { 00164 return(this->frame(fl->rts, pm)); 00165 } 00166 00167 wns::simulator::Time 00168 Duration::cts(const wifimac::convergence::PhyMode& pm) const 00169 { 00170 return(frame(fl->cts, pm)); 00171 } 00172 00173 wns::simulator::Time 00174 Duration::blockACK(const wifimac::convergence::PhyMode& pm) const 00175 { 00176 return(frame(fl->blockACK, pm)); 00177 } 00178 00179 wns::simulator::Time 00180 Duration::MSDU_PPDU(Bit msduFrameSize, const wifimac::convergence::PhyMode& pm) const 00181 { 00182 return(frame(fl->getPSDU(msduFrameSize), pm)); 00183 } 00184 00185 wns::simulator::Time 00186 Duration::MSDU_PPDU(Bit msduFrameSize, const double grossBitRate, const wifimac::convergence::PhyMode& pm) const 00187 { 00188 return(frame(fl->getPSDU(msduFrameSize), grossBitRate, pm)); 00189 } 00190 00191 wns::simulator::Time 00192 Duration::MPDU_PPDU(Bit mpduSize, const wifimac::convergence::PhyMode& pm) const 00193 { 00194 return(frame(mpduSize, pm)); 00195 } 00196 00197 wns::simulator::Time 00198 Duration::MPDU_PPDU(Bit mpduSize, const double grossBitRate, const wifimac::convergence::PhyMode& pm) const 00199 { 00200 return(frame(mpduSize, grossBitRate, pm)); 00201 } 00202 00203 wns::simulator::Time 00204 Duration::A_MPDU_PPDU(Bit mpduFrameSize, unsigned int n_aggFrames, const wifimac::convergence::PhyMode& pm) const 00205 { 00206 return(frame(fl->getA_MPDU_PSDU(mpduFrameSize, n_aggFrames), pm)); 00207 } 00208 00209 wns::simulator::Time 00210 Duration::A_MPDU_PPDU(Bit mpduFrameSize, unsigned int n_aggFrames, const double grossBitRate, const wifimac::convergence::PhyMode& pm) const 00211 { 00212 return(frame(fl->getA_MPDU_PSDU(mpduFrameSize, n_aggFrames), grossBitRate, pm)); 00213 } 00214 00215 wns::simulator::Time 00216 Duration::A_MPDU_PPDU(const std::vector<Bit>& mpduFrameSize, const wifimac::convergence::PhyMode& pm) const 00217 { 00218 return(frame(fl->getA_MPDU_PSDU(mpduFrameSize), pm)); 00219 } 00220 00221 wns::simulator::Time 00222 Duration::A_MSDU_PPDU(Bit msduFrameSize, unsigned int n_aggFrames, const wifimac::convergence::PhyMode& pm) const 00223 { 00224 return(frame(fl->getA_MSDU_PSDU(msduFrameSize, n_aggFrames), pm)); 00225 } 00226 00227 wns::simulator::Time 00228 Duration::A_MSDU_PPDU(Bit msduFrameSize, unsigned int n_aggFrames, const double grossBitRate, const wifimac::convergence::PhyMode& pm) const 00229 { 00230 return(frame(fl->getA_MSDU_PSDU(msduFrameSize, n_aggFrames), grossBitRate, pm)); 00231 } 00232 00233 wns::simulator::Time 00234 Duration::A_MSDU_PPDU(const std::vector<Bit>& msduFrameSize, const wifimac::convergence::PhyMode& pm) const 00235 { 00236 return(frame(fl->getA_MSDU_PSDU(msduFrameSize), pm)); 00237 } 00238 00239 wns::simulator::Time 00240 Duration::symbol(const wifimac::convergence::PhyMode &pm) const 00241 { 00242 return(this->symbolWithoutGI + pm.getGuardIntervalDuration()); 00243 }
1.5.5