RTP Trace System  1.0
bandwidthmanager.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                    Master Thesis Implementation                  ####
00004 // ####  Management of Layered Variable Bitrate Multimedia Streams over  ####
00005 // ####                  DiffServ with A Priori Knowledge                ####
00006 // ####                                                                  ####
00007 // #### ================================================================ ####
00008 // ####                                                                  ####
00009 // ####                                                                  ####
00010 // #### Bandwidth Manager                                                ####
00011 // ####                                                                  ####
00012 // #### Version 1.00  --  February 19, 2001                              ####
00013 // ####                                                                  ####
00014 // #### Copyright (C) 2000/2001 Thomas Dreibholz                         ####
00015 // #### University of Bonn, Department of Computer Science IV            ####
00016 // #### EMail: dreibh@iem.uni-due.de                                     ####
00017 // #### WWW:   https://www.uni-due.de/~be0001/diplom/index.html          ####
00018 // ####                                                                  ####
00019 // ##########################################################################
00020 
00021 
00022 #ifndef BANDWIDTHMANAGER_H
00023 #define BANDWIDTHMANAGER_H
00024 
00025 
00026 #include "system.h"
00027 #include "abstractqosdescription.h"
00028 #include "timedthread.h"
00029 #include "servicelevelagreement.h"
00030 #include "streamdescription.h"
00031 #include "sessiondescription.h"
00032 #include "roundtriptimepinger.h"
00033 #include "rtcppacket.h"
00034 
00035 
00036 #include <multimap.h>
00037 #include <algo.h>
00038 
00039 
00040 namespace Coral {
00041 
00042 
00051 struct ResourceUtilizationSimplePoint
00052 {
00053    // ====== Stream and point identification ================================
00057    StreamDescription* Stream;
00058 
00062    cardinal Point;
00063 
00067    double StreamPriorityFactor;
00068 
00069 
00070    // ====== Point data =====================================================
00074    card64 Bandwidth;
00075 
00079    double BandwidthCost;
00080 
00084    double Utilization;
00085 
00089    double SortingValue;
00090 };
00091 
00095 ostream& operator<<(ostream& os, const ResourceUtilizationSimplePoint& srup);
00096 
00097 
00098 
00107 struct ResourceUtilizationMultiPoint
00108 {
00109    // ====== Comparision operators ==========================================
00113    inline int operator<(const ResourceUtilizationMultiPoint& srup) const;
00114 
00118    inline int operator>(const ResourceUtilizationMultiPoint& srup) const;
00119 
00120 
00121    // ====== Session identification =========================================
00125    SessionDescription* Session;
00126 
00130    double SessionPriorityFactor;
00131 
00132 
00133    // ====== Streams and points identification ==============================
00137    static const cardinal MaxStreamsPerSession = 128;
00138 
00142    cardinal Streams;
00143 
00147    StreamDescription* Stream[MaxStreamsPerSession];
00148 
00152    cardinal Point[MaxStreamsPerSession];
00153 
00154 
00155    // ====== Point data =====================================================
00159    card64 Bandwidth;
00160 
00164    double BandwidthCost;
00165 
00169    double Utilization;
00170 
00174    double SortingValue;
00175 
00176 
00177    // ====== Miscellaneous ==================================================
00182    bool AlreadyAllocated;
00183 };
00184 
00185 
00189 ostream& operator<<(ostream& os, const ResourceUtilizationMultiPoint& srup);
00190 
00191 
00192 
00200 class BandwidthManager : public TimedThread
00201 {
00202    // ====== Constructor/Destructor =========================================
00203    public:
00210    BandwidthManager(ServiceLevelAgreement* sla,
00211                     RoundTripTimePinger*   rttp);
00212 
00216    ~BandwidthManager();
00217 
00218 
00219    // ====== Stream management ==============================================
00227    void addStream(ManagedStreamInterface* stream,
00228                   const cardinal          sessionID = 0,
00229                   const char*             name      = NULL);
00230 
00236    void removeStream(ManagedStreamInterface* stream);
00237 
00243    void updateStream(ManagedStreamInterface* stream);
00244 
00248    inline void forceCompleteRemapping();
00249 
00250    // ====== Events =========================================================
00259    void intervalChangeEvent(ManagedStreamInterface* stream,
00260                             const bool              isNew,
00261                             const card64            when,
00262                             const bool              newRUList);
00263 
00271    void reportEvent(ManagedStreamInterface*         stream,
00272                     const RTCPReceptionReportBlock* report,
00273                     const cardinal                  layer);
00274 
00280    void bufferFlushEvent(ManagedStreamInterface* stream,
00281                          const cardinal          layer);
00282 
00288    void timerEvent();
00289 
00290 
00291    // ====== Settings =======================================================
00297    void setLogStream(ostream* logStream);
00298 
00307    inline void getPartialRemapping(bool&   enabled,
00308                                    double& reservedPortion,
00309                                    double& utilizationTolerance,
00310                                    double& maxRemappingInterval) const;
00311 
00312 
00321    inline void setPartialRemapping(const bool   enabled,
00322                                    const double reservedPortion,
00323                                    const double utilizationTolerance,
00324                                    const double maxRemappingInterval);
00325 
00332    inline void getFairness(double& fairnessSession,
00333                            double& fairnessStream) const;
00334 
00341    inline void setFairness(const double fairnessSession,
00342                            const double fairnessStream);
00343 
00352    inline void getQoSOptimizationParameters(
00353                   cardinal& maxRUPoints,
00354                   double&   utilizationThreshold,
00355                   card64&   bandwidthThreshold,
00356                   double&   systemDelayTolerance,
00357                   bool&     unlayeredAllocation) const;
00358 
00367    inline void setQoSOptimizationParameters(
00368                   const cardinal maxRUPoints,
00369                   const double   utilizationThreshold,
00370                   const card64   bandwidthThreshold,
00371                   const double   systemDelayTolerance,
00372                   const bool     unlayeredAllocation);
00373 
00374 
00375    // ====== Bandwidth variables ============================================
00376    card64 TotalAvailableBandwidth;
00377    card64 ClassAvailableBandwidthArray[TrafficClassValues::MaxValues];
00378    card64 TotalBandwidth;
00379    card64 ClassBandwidthArray[TrafficClassValues::MaxValues];
00380    int64  SLAUpdateRecommendation[TrafficClassValues::MaxValues];
00381 
00382 
00383    // ====== Information about remappings ===================================
00384    card64   StreamIDGenerator;
00385    card64   LastCompleteRemapping;
00386    card64   LastCompleteRemappingDuration;
00387    cardinal CompleteRemappings;
00388    cardinal PartialRemappings;
00389    cardinal TotalBufferFlushes;
00390 
00391 
00392    // ====== Simulator variables ============================================
00393    static card64 SimulatorTime;
00394 
00395 
00396    // ====== Stream and session management ==================================
00397    multimap<ManagedStreamInterface*,StreamDescription*> StreamSet;
00398    multimap<cardinal,SessionDescription*>               SessionSet;
00399    ServiceLevelAgreement*                               SLA;
00400    cardinal                                             Streams;
00401    cardinal                                             Sessions;
00402 
00403 
00404    // ====== Constants ======================================================
00405    cardinal MaxRUPoints;
00406    double   UtilizationThreshold;
00407    card64   BandwidthThreshold;
00408    double   SystemDelayTolerance;
00409    double   FairnessSession;
00410    double   FairnessStream;
00411    double   AlphaLossRate;
00412    double   AlphaJitter;
00413    double   PartialRemappingPortion;
00414    double   PartialRemappingUtilizationTolerance;
00415    card64   MaxRemappingInterval;
00416    bool     EnablePartialRemappings;
00417    bool     UnlayeredAllocation;
00418 
00419 
00420    // ====== Private data ===================================================
00421    private:
00422    cardinal calculateSessionMultiPoints(
00423                SessionDescription*       session,
00424                const cardinal            offset,
00425                const cardinal            lastPoint,
00426                ResourceUtilizationMultiPoint* rumpList);
00427    void getRoundTripTimes(StreamDescription* sd);
00428 
00429    inline double getPriorityFactor(const int8 streamPriority) const;
00430    inline double getResourcePart(const ResourceUtilizationSimplePoint& rup) const;
00431    inline double getResourcePart(const ResourceUtilizationMultiPoint& rump) const;
00432    inline double getStreamSortingValue(const ResourceUtilizationSimplePoint& rup) const;
00433    inline double getSessionSortingValue(const ResourceUtilizationMultiPoint& rump) const;
00434 
00435    static inline void smoothedUpdate(double& value, const double measured, const double alpha);
00436 
00437    public:
00438    void updateReservation(StreamDescription* streamDescription);
00439    private:
00440 
00441    bool tryAllocation(
00442            ResourceUtilizationMultiPoint& rump,
00443            const card64                   bandwidthLimit = (card64)-1);
00444 
00445    void doAllocationTrials(
00446            ResourceUtilizationMultiPoint* rumpList,
00447            const cardinal                 points,
00448            const card64                   bandwidthLimit = (card64)-1);
00449 
00450    bool doPartialRemapping(StreamDescription* streamDescription);
00451    void doCompleteRemapping();
00452 
00453 
00454    RoundTripTimePinger* RTTP;
00455    ostream*             Log;
00456    card64               LogStartupTimeStamp;
00457    bool                 Changed;
00458 };
00459 
00460 
00461 }
00462 
00463 
00464 #include "bandwidthmanager.icc"
00465 
00466 
00467 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines