User Manual, Developers Guide and API Documentation

FrameLength.cpp

Go to the documentation of this file.
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/FrameLength.hpp>
00030 
00031 using namespace wifimac::management::protocolCalculatorPlugins;
00032 
00033 FrameLength::FrameLength(const wns::pyconfig::View& config):
00034     macDataHdr(config.get<Bit>("macDataHdr")),
00035     macDataFCS(config.get<Bit>("macDataFCS")),
00036     amsdu_subhdr(config.get<Bit>("amsdu_subhdr")),
00037     ampdu_delimiter(config.get<Bit>("ampdu_delimiter")),
00038     service(config.get<Bit>("service")),
00039     tail(config.get<Bit>("tail")),
00040     ack(config.get<Bit>("ack")),
00041     rts(config.get<Bit>("rts")),
00042     cts(config.get<Bit>("cts")),
00043     blockACK(config.get<Bit>("blockACK")),
00044     blockACKreq(config.get<Bit>("blockACKreq")),
00045     beacon(config.get<Bit>("beacon"))
00046 {
00047 
00048 }
00049 
00050 FrameLength::FrameLength( const ConfigGetter& config ):
00051     macDataHdr(config.get<Bit>("macDataHdr", "i")),
00052     macDataFCS(config.get<Bit>("macDataFCS", "i")),
00053     amsdu_subhdr(config.get<Bit>("amsdu_subhdr", "i")),
00054     ampdu_delimiter(config.get<Bit>("ampdu_delimiter", "i")),
00055     service(config.get<Bit>("service", "i")),
00056     tail(config.get<Bit>("tail", "i")),
00057     ack(config.get<Bit>("ack", "i")),
00058     rts(config.get<Bit>("rts", "i")),
00059     cts(config.get<Bit>("cts", "i")),
00060     blockACK(config.get<Bit>("blockACK", "i")),
00061     blockACKreq(config.get<Bit>("blockACKreq", "i")),
00062     beacon(config.get<Bit>("beacon", "i"))
00063 {
00064 
00065 }
00066 
00067 Bit
00068 FrameLength::getPSDU(Bit msduFrameSize) const
00069 {
00070     return (msduFrameSize + this->macDataHdr + this->macDataFCS);
00071 }
00072 
00073 Bit
00074 FrameLength::getA_MPDU_PSDU(Bit mpduFrameSize, unsigned int n_aggFrames) const
00075 {
00076     // n frames with padding, blockACKreq without
00077     Bit len = n_aggFrames * pad(this->ampdu_delimiter + mpduFrameSize, 32);
00078     len += (blockACKreq + this->ampdu_delimiter);
00079     return(len);
00080 }
00081 
00082 Bit
00083 FrameLength::getA_MPDU_PSDU(const std::vector<Bit>& mpduFrameSize) const
00084 {
00085     assure(not mpduFrameSize.empty(), "vector must have at least one entry");
00086 
00087     Bit len = 0;
00088     Bit last = 0;
00089 
00090     for(std::vector<Bit>::const_iterator it = mpduFrameSize.begin();
00091         it != mpduFrameSize.end();
00092         ++it)
00093     {
00094         last = pad(this->ampdu_delimiter + (*it), 32);
00095         len += last;
00096     }
00097     len += (blockACKreq + this->ampdu_delimiter);
00098     return(len);
00099 }
00100 
00101 Bit
00102 FrameLength::getA_MSDU_PSDU(Bit msduFrameSize, unsigned int n_aggFrames) const
00103 {
00104     // n-1 frames with padding, last one without
00105     Bit len = (n_aggFrames - 1) * pad(this->amsdu_subhdr + msduFrameSize, 32);
00106     return(len + this->macDataHdr + this->amsdu_subhdr + msduFrameSize + this->macDataFCS);
00107 }
00108 
00109 Bit
00110 FrameLength::getA_MSDU_PSDU(const std::vector<Bit>& msduFrameSize) const
00111 {
00112     assure(not msduFrameSize.empty(), "vector must have at least one entry");
00113 
00114     Bit len = 0;
00115     Bit last = 0;
00116 
00117     for(std::vector<Bit>::const_iterator it = msduFrameSize.begin();
00118         it != msduFrameSize.end();
00119         ++it)
00120     {
00121         last = pad(this->amsdu_subhdr + (*it), 32);
00122         len += last;
00123     }
00124     len += this->macDataHdr + this->amsdu_subhdr + msduFrameSize.back() + this->macDataFCS - last;
00125     return(len);
00126 }
00127 
00128 Bit
00129 FrameLength::pad(Bit frameSize, Bit multiple) const
00130 {
00131     if((frameSize % multiple) == 0)
00132     {
00133         return frameSize;
00134     }
00135     else
00136     {
00137         return (frameSize + (multiple - (frameSize % multiple)));
00138     }
00139 }

Generated on Sun May 27 03:32:12 2012 for openWNS by  doxygen 1.5.5