User Manual, Developers Guide and API Documentation

DRPPatternCreator.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiMeMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2011
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 5, 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 #ifndef WIMEMAC_DRP_DRPPATTERNCREATOR_H
00030 #define WIMEMAC_DRP_DRPPATTERNCREATOR_H
00031 
00032 #include <vector>
00033 #include <WNS/service/dll/Address.hpp>
00034 #include <WNS/scheduler/SchedulerTypes.hpp>
00035 #include <WIMEMAC/convergence/PhyMode.hpp>
00036 
00037 
00038 namespace wimemac { namespace lowerMAC {
00039     class Manager;
00040 }}
00041 
00042 namespace wimemac { namespace drp {
00043 typedef std::vector<bool> Vector;
00044   
00045     class DRPPatternCreator
00046     {
00047     public:
00048 
00049             DRPPatternCreator(wns::logger::Logger logger_, double patternPEROffset_, wns::service::dll::UnicastAddress TargetAddress_);
00050 
00051             void SetReservationGap(int SlotAmount);
00052             void SetNIBp6S(int BitAmountMCS);
00053             void SetNumberOfBPSlots(int numberOfBPSlots_);
00054             void SetPhyMode(wimemac::convergence::PhyMode phyMode_);
00055             wimemac::convergence::PhyMode getPhyMode();
00056             void SetTrafficChar(int PacketpFrame, int BitpFrame, int MaxCompoundSize, int reservationBlocks);
00057             void UpdateTrafficChar();
00058             void UpdateTrafficChar(int CompoundspSF, int BitspSF, int MaxCompoundSize);
00059             bool GetPattern(Vector& ProposedPattern, Vector& GlobalDRPMap, bool useInperfectPatterns);
00060             bool AddPattern(Vector& ProposedPattern, Vector& DRPAllocMap, Vector& GlobalDRPMap, bool useInperfectPatterns);
00061             bool CreateRandomPattern(Vector& ProposedPattern, Vector& DRPAllocMap, Vector& ConstraintDRPMap, bool useInperfectPatterns);
00062             void InitVector(Vector& InitMap);
00063 
00064 
00065         protected:
00066 
00067             struct Friends
00068             {
00069                 wimemac::lowerMAC::Manager* manager;
00070             } friends;
00071 
00072             int
00073             CalcMissingPackets(Vector& allocMap_);
00074 
00075             int SlotpSF; //Slot per superframe
00076             int AdjSlot; //direct adjacent slots to transmit generated traffic during area-time
00077             int mAdjSlot; //mandatory adjacent slots to transmit one packet
00078             int ReservationGap; //number of unoccupied slots between reserved slots
00079             int DivideSFintoAreas; // number of areas the SF should be divided into
00080             int PacketpSF; //number of packtes generated during superframe time
00081             int PacketpArea;
00082             int BitpP; //number of bits per packet
00083             int MaxPacketSize; // maximum packet size
00084             int NumberOfBPSlots; // number of slots reserved for BP
00085             wimemac::convergence::PhyMode phyMode;
00086             wns::simulator::Time psduDuration;
00087             wns::simulator::Time FTDuration;
00088             wns::simulator::Time DataDuration;
00089 
00090             double patternPEROffset; // additional percentage added to pattern according to PER
00091             wns::service::dll::UnicastAddress TargetAddress;
00092 
00093             const wns::simulator::Time PreambPlusHeadDuration;
00094             const wns::simulator::Time ACKduration;
00095             const wns::simulator::Time SIFSduration;
00096             const wns::simulator::Time SlotDuration;
00097             const wns::simulator::Time GuardDuration;
00098 
00099 
00100         private:
00101 
00102             //compare proposed reservation pattern with the GlobalDRPMap (already reserved slots)
00103             bool
00104             IsPatternValid(Vector& ProposedMap) const;
00105 
00106             //Calculate the number of areas with reserved slots
00107             int
00108             CalcNumArea(Vector& ProposedMap);
00109 
00110             //search for a possible reservation with the highest number of reserved slots
00111             void
00112             CalcMaxPropMap(Vector& tmpProposedPattern);
00113 
00114             //Remove slots from proposal if there is a conflict with the GlobalDRPMap
00115             bool
00116             ClearConflictArea();
00117 
00118             //If there is a conflict, reserve slots in this area outside desired position
00119             bool
00120             AllocAreaOutside(int first, int last, int CalcAdjSlot);
00121 
00122             //Show areas without a reservation
00123             bool
00124             FindEmptyArea(Vector& tmpProposedPattern, int first, int last);
00125 
00126             //look if there is space left to reserv slots outside the desired position
00127             bool
00128             IsSpaceLeft(int first, int last,int CalcAdjSlot) const;
00129 
00130             //calculate packets which can be transmitted inside this area bounded by [first,last)
00131             int
00132             CalcPacketpArea(int first, int last);
00133 
00134             bool
00135             EvaluateReservation();
00136 
00137             void
00138             BestEfficency(int MissingReservation);
00139 
00140             int
00141             GapFilling(int MissingReservation);
00142 
00143             // Functions for multi stream handling
00144             void
00145             CalcMaxPosMCSPerMAS();
00146 
00147             Vector
00148             GetDRPMapWithPhyModeBetter(Vector& allocMap_, wimemac::convergence::PhyMode lowestAllowedPhy_);
00149 
00150             bool
00151             PatternHasFreeSlots(Vector pattern);
00152 
00153             wns::logger::Logger logger;
00154 
00155             //holds already reserved slots
00156             Vector GlobalDRPMap;
00157 
00158             struct MaxPosPattern
00159             {
00160                 MaxPosPattern():
00161                 conflict(0),
00162                 maxProposedPattern(256,false)
00163                 {}
00164 
00165                 int conflict;
00166                 Vector maxProposedPattern;
00167 
00168                 void SetVector(Vector maxVec)
00169                 {
00170                     for(int i = 0; i < maxVec.size(); i++)
00171                     {
00172                         assure(i < maxProposedPattern.size(), "Vector boundary exeeded; loop error!");
00173                         maxProposedPattern[i] = maxVec[i];
00174                     }
00175                 }
00176             };
00177 
00178 
00179             struct MaxEfficiency
00180             {
00181                 MaxEfficiency():
00182                     AddSlot(0),
00183                     iFragmentDuration(0),
00184                     area(-1),
00185                     AdditionalPackets(0),
00186                     maxProposedPattern(256,false)
00187                 {}
00188 
00189                 Vector maxProposedPattern;
00190 
00191                 void SetVector(Vector maxVec)
00192                 {
00193                     for(int i = 0; i < maxVec.size(); i++)
00194                     {
00195                         assure(i < maxProposedPattern.size(), "Vector boundary exeeded; loop error!");
00196                         maxProposedPattern[i] = maxVec[i];
00197                     }
00198                 }
00199                 void Clear()
00200                 {
00201                     for(int i = 0; i < maxProposedPattern.size(); i++)
00202                         maxProposedPattern[i] = false;
00203                     AddSlot= 0;
00204 
00205                 }
00206 
00207                 int AddSlot;
00208                 int area;
00209                 wns::simulator::Time iFragmentDuration;
00210                 int AdditionalPackets;
00211 
00212             };
00213 
00214             //holds the proposed pattern
00215             MaxPosPattern maxPosPattern;
00216             MaxEfficiency maxEfficiency;
00217 
00218     };
00219 }//drp
00220 }//wimemac
00221 #endif

Generated on Wed May 23 03:32:11 2012 for openWNS by  doxygen 1.5.5