jobs.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000-2002, by the Rector and Board of Visitors of the 
00003  * University of Virginia.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, 
00007  * with or without modification, are permitted provided 
00008  * that the following conditions are met:
00009  *
00010  * Redistributions of source code must retain the above 
00011  * copyright notice, this list of conditions and the following 
00012  * disclaimer. 
00013  *
00014  * Redistributions in binary form must reproduce the above 
00015  * copyright notice, this list of conditions and the following 
00016  * disclaimer in the documentation and/or other materials provided 
00017  * with the distribution. 
00018  *
00019  * Neither the name of the University of Virginia nor the names 
00020  * of its contributors may be used to endorse or promote products 
00021  * derived from this software without specific prior written 
00022  * permission. 
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00025  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00026  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00027  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00028  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 
00029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
00030  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00031  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00032  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
00033  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00034  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00035  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
00036  * THE POSSIBILITY OF SUCH DAMAGE.
00037  */
00038 /*
00039  *                                                                     
00040  * JoBS - ns-2 prototype implementation                                
00041  *                                                                     
00042  * Author: Nicolas Christin <nicolas@cs.virginia.edu>, 2000-2002       
00043  *                                    
00044  * JoBS algorithms originally devised and proposed by             
00045  * Nicolas Christin and Jorg Liebeherr                                 
00046  * Grateful acknowledgments to Tarek Abdelzaher for his help and       
00047  * comments.                                                           
00048  *                                                                     
00049  * $Id: jobs.h,v 1.2 2003/07/11 00:10:10 johnh Exp $
00050  */
00051 
00052 #ifndef JOBS_H
00053 #define JOBS_H
00054 
00055 #include <stdlib.h>
00056 #include <string.h>
00057 #include <math.h>
00058 #include "queue.h"
00059 #include "template.h"
00060 #include "random.h"
00061 #include "flags.h"
00062 #include "delay.h"
00063 #include "marker.h"
00064 
00065 /* JoBS Queuing */
00066 #ifndef INFINITY
00067 #define INFINITY    +1.0e499
00068 #endif
00069 #define PRECISION_ERROR +1.0e-10
00070 #define TOL     0.02        // Tolerance in the constraints (2%)
00071 #define MON_WINDOW_SIZE 0.5     // Size of the moving average window
00072 #define RESET_STATS 0
00073 #define UPDATE_STATS    1
00074 
00075 /* Dropping strategy */
00076 #define WITH_UPDATE 3
00077 #define WITHOUT_UPDATE  4
00078 
00079 /* ADC resolution */
00080 #define ORIGINAL_JOBS   0
00081 #define SHARED_PAIN 1
00082 /* FBS resolution */
00083 #define RESOLVE_OVERFLOW    0
00084 #define RESOLVE_ADC     1
00085 
00086 /* Simple macros */
00087 #define min(x, y)   ((x) < (y) ? (x) : (y))
00088 #define max(x, y)   ((x) >= (y) ? (x) : (y))
00089 
00090 /* JoBS class */
00091 class JoBS : public Queue {
00092 
00093 public: 
00094     JoBS();
00095     virtual int command(int argc, const char*const* argv);
00096     void    enque(Packet*);
00097     Packet* deque();
00098     int link_id_;
00099   
00100 protected:
00101 
00102     long    total_backlog_Pkts_;    // Total backlog in packets
00103     long    total_backlog_Bits_;    // Total backlog in bits
00104     double  mean_pkt_size_;         // in bytes... Needs to be *8
00105     int drop_front_;        // Drop-from-Front flag
00106     int trace_hop_;     // Trace Delays and Drops locally?
00107     int adc_resolution_type_;   // Type of algorithm for meeting ADCs
00108                     // 0 = ORIGINAL_JOBS (see techrep)
00109                     // 1 = SHARED_PAIN (drop from all classes)
00110     int shared_buffer_;     // 0=separate per-class buffers
00111                     // 1=common buffer
00112     LinkDelay*  link_;      // outgoing link 
00113     char*   file_name_;     // Trace files
00114     int sampling_period_;
00115     PacketQueue*    cls_[NO_CLASSES+1]; // Class queues: do not use class-0 
00116     int concerned_RDC_[NO_CLASSES+1];
00117     int concerned_RLC_[NO_CLASSES+1];
00118     int concerned_ADC_[NO_CLASSES+1];
00119     int concerned_ALC_[NO_CLASSES+1];
00120     int concerned_ARC_[NO_CLASSES+1];
00121     double  RDC_[NO_CLASSES+1]; // RDC parameters
00122     double  RLC_[NO_CLASSES+1]; // RLC parameters
00123     double  ADC_[NO_CLASSES+1]; // ADC parameters
00124     double  ALC_[NO_CLASSES+1]; // ALC parameters
00125     double  ARC_[NO_CLASSES+1]; // ARC parameters
00126 
00127     double  loss_prod_others_[NO_CLASSES+1];
00128     double  prod_others_  [NO_CLASSES+1];   
00129     double  service_rate_[NO_CLASSES+1]; // in bps
00130     double  current_loss_[NO_CLASSES+1]; // in fraction of 1
00131     double  Rin_         [NO_CLASSES+1]; // in bits
00132     double  Rout_        [NO_CLASSES+1]; // in bits
00133     double  Rout_th_     [NO_CLASSES+1]; // in bits
00134     double  Arrival_     [NO_CLASSES+1]; // in bits
00135     double  last_rate_update_[NO_CLASSES+1];
00136     
00137 private:
00138 
00139     // Internal functions
00140     
00141     void    updateError();
00142     double  projDelay(int);
00143     double* assignRateDropsADC();
00144     double* adjustRatesRDC();
00145     int minRatesNeeded(int);
00146     void    arvAccounting(Packet*);
00147     int pickDroppedRLC(int);
00148     void    dropTail(int, int);
00149     void    dropFront(int, int);
00150     int enforceWC();
00151     void    updateStats(Packet*, int);
00152     
00153     // Internal variables
00154     
00155     int idle_;              // is the queue idle?
00156     double  idletime_;          // if so, since when?
00157     int pkt_count_;
00158     double  min_share_;
00159     double  last_arrival_;
00160     
00161     // Statistics
00162     double  sliding_inter_;
00163     double  sliding_avg_pkt_size_;
00164     double  sliding_arv_pkts_;
00165     double  sliding_arv_pkts_c[NO_CLASSES+1];
00166     double  sliding_serviced_pkts_[NO_CLASSES+1];
00167     double  sliding_serviced_bits_[NO_CLASSES+1];
00168     double  sliding_class_service_rate_[NO_CLASSES+1];
00169     double  sliding_class_delay_[NO_CLASSES+1];
00170     
00171     // Control variables
00172     
00173     double  last_xmit_[NO_CLASSES+1];   // last time a packet was sent
00174     long    backlog_Bits_ [NO_CLASSES+1];
00175     long    backlog_Pkts_ [NO_CLASSES+1];
00176     double  error_        [NO_CLASSES+1];   // in 10e-6*time_unit (us)
00177     double  min_rate_     [NO_CLASSES+1];   // in Mbps
00178     double  min_drop_     [NO_CLASSES+1];   // in fraction of 1
00179     double  max_drop_     [NO_CLASSES+1];   // in fraction of 1
00180     double  Rout_last_up_ [NO_CLASSES+1];   // last update of Rout's value
00181     double  avg_elapsed_  [NO_CLASSES+1];   // average time spent in the queue
00182     double  excess_drops_ [NO_CLASSES+1]; 
00183     
00184     double  util_;              // Offered load
00185     double  Kp_static_; 
00186     double  Kp_dynamic_;            // Proportional Controller Parameter
00187     int ABS_present_; 
00188     double  monitoring_window_;
00189     double  last_monitor_update_;
00190     FILE*   hop_trace_;         // Trace File
00191 };
00192 
00193 #endif /* JOBS_H */
00194 

Generated on Tue Mar 6 16:47:46 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6