• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/queue/jobs.h

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.3 2006/12/17 15:22:42 mweigle 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 # ifdef __SUNPRO_CC
00068 #  include <values.h>
00069 #  define       INFINITY        MAXDOUBLE
00070 # else
00071 #  define       INFINITY        +1.0e499
00072 # endif
00073 #endif
00074 #define PRECISION_ERROR +1.0e-10
00075 #define TOL             0.02            // Tolerance in the constraints (2%)
00076 #define MON_WINDOW_SIZE 0.5             // Size of the moving average window
00077 #define RESET_STATS     0
00078 #define UPDATE_STATS    1
00079 
00080 /* Dropping strategy */
00081 #define WITH_UPDATE     3
00082 #define WITHOUT_UPDATE  4
00083 
00084 /* ADC resolution */
00085 #define ORIGINAL_JOBS   0
00086 #define SHARED_PAIN     1
00087 /* FBS resolution */
00088 #define RESOLVE_OVERFLOW        0
00089 #define RESOLVE_ADC             1
00090 
00091 /* Simple macros */
00092 #define min(x, y)   ((x) < (y) ? (x) : (y))
00093 #define max(x, y)   ((x) >= (y) ? (x) : (y))
00094 
00095 /* JoBS class */
00096 class JoBS : public Queue {
00097 
00098 public: 
00099         JoBS();
00100         virtual int command(int argc, const char*const* argv);
00101         void    enque(Packet*);
00102         Packet* deque();
00103         int     link_id_;
00104   
00105 protected:
00106 
00107         long    total_backlog_Pkts_;    // Total backlog in packets
00108         long    total_backlog_Bits_;    // Total backlog in bits
00109         double  mean_pkt_size_;         // in bytes... Needs to be *8
00110         int     drop_front_;            // Drop-from-Front flag
00111         int     trace_hop_;             // Trace Delays and Drops locally?
00112         int     adc_resolution_type_;   // Type of algorithm for meeting ADCs
00113                                         // 0 = ORIGINAL_JOBS (see techrep)
00114                                         // 1 = SHARED_PAIN (drop from all classes)
00115         int     shared_buffer_;         // 0=separate per-class buffers
00116                                         // 1=common buffer
00117         LinkDelay*      link_;          // outgoing link 
00118         char*   file_name_;             // Trace files
00119         int     sampling_period_;
00120         PacketQueue*    cls_[NO_CLASSES+1];     // Class queues: do not use class-0 
00121         int     concerned_RDC_[NO_CLASSES+1];
00122         int     concerned_RLC_[NO_CLASSES+1];
00123         int     concerned_ADC_[NO_CLASSES+1];
00124         int     concerned_ALC_[NO_CLASSES+1];
00125         int     concerned_ARC_[NO_CLASSES+1];
00126         double  RDC_[NO_CLASSES+1];     // RDC parameters
00127         double  RLC_[NO_CLASSES+1];     // RLC parameters
00128         double  ADC_[NO_CLASSES+1];     // ADC parameters
00129         double  ALC_[NO_CLASSES+1];     // ALC parameters
00130         double  ARC_[NO_CLASSES+1];     // ARC parameters
00131 
00132         double  loss_prod_others_[NO_CLASSES+1];
00133         double  prod_others_  [NO_CLASSES+1];   
00134         double  service_rate_[NO_CLASSES+1]; // in bps
00135         double  current_loss_[NO_CLASSES+1]; // in fraction of 1
00136         double  Rin_         [NO_CLASSES+1]; // in bits
00137         double  Rout_        [NO_CLASSES+1]; // in bits
00138         double  Rout_th_     [NO_CLASSES+1]; // in bits
00139         double  Arrival_     [NO_CLASSES+1]; // in bits
00140         double  last_rate_update_[NO_CLASSES+1];
00141         
00142 private:
00143 
00144         // Internal functions
00145         
00146         void    updateError();
00147         double  projDelay(int);
00148         double* assignRateDropsADC();
00149         double* adjustRatesRDC();
00150         int     minRatesNeeded(int);
00151         void    arvAccounting(Packet*);
00152         int     pickDroppedRLC(int);
00153         void    dropTail(int, int);
00154         void    dropFront(int, int);
00155         int     enforceWC();
00156         void    updateStats(Packet*, int);
00157         
00158         // Internal variables
00159         
00160         int     idle_;                          // is the queue idle?
00161         double  idletime_;                      // if so, since when?
00162         int     pkt_count_;
00163         double  min_share_;
00164         double  last_arrival_;
00165         
00166         // Statistics
00167         double  sliding_inter_;
00168         double  sliding_avg_pkt_size_;
00169         double  sliding_arv_pkts_;
00170         double  sliding_arv_pkts_c[NO_CLASSES+1];
00171         double  sliding_serviced_pkts_[NO_CLASSES+1];
00172         double  sliding_serviced_bits_[NO_CLASSES+1];
00173         double  sliding_class_service_rate_[NO_CLASSES+1];
00174         double  sliding_class_delay_[NO_CLASSES+1];
00175         
00176         // Control variables
00177         
00178         double  last_xmit_[NO_CLASSES+1];       // last time a packet was sent
00179         long    backlog_Bits_ [NO_CLASSES+1];
00180         long    backlog_Pkts_ [NO_CLASSES+1];
00181         double  error_        [NO_CLASSES+1];   // in 10e-6*time_unit (us)
00182         double  min_rate_     [NO_CLASSES+1];   // in Mbps
00183         double  min_drop_     [NO_CLASSES+1];   // in fraction of 1
00184         double  max_drop_     [NO_CLASSES+1];   // in fraction of 1
00185         double  Rout_last_up_ [NO_CLASSES+1];   // last update of Rout's value
00186         double  avg_elapsed_  [NO_CLASSES+1];   // average time spent in the queue
00187         double  excess_drops_ [NO_CLASSES+1]; 
00188         
00189         double  util_;                          // Offered load
00190         double  Kp_static_; 
00191         double  Kp_dynamic_;                    // Proportional Controller Parameter
00192         int     ABS_present_; 
00193         double  monitoring_window_;
00194         double  last_monitor_update_;
00195         FILE*   hop_trace_;                     // Trace File
00196 };
00197 
00198 #endif /* JOBS_H */
00199 

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1