• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/xcp/xcpq.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002  *
00003  * Copyright (C) 2004 by USC/ISI
00004  *               2002 by Dina Katabi
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms are permitted
00009  * provided that the above copyright notice and this paragraph are
00010  * duplicated in all such forms and that any documentation, advertising
00011  * materials, and other materials related to such distribution and use
00012  * acknowledge that the software was developed by the University of
00013  * Southern California, Information Sciences Institute.  The name of the
00014  * University may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020  *
00021  * @(#) $Header: /cvsroot/nsnam/ns-2/xcp/xcpq.h,v 1.12 2006/07/01 19:40:04 tom_henderson Exp $
00022  */
00023 
00024 
00025 #ifndef NS_XCPQ_H
00026 #define NS_XCPQ_H
00027 
00028 #include "drop-tail.h"
00029 #include "packet.h"
00030 #include "xcp-end-sys.h"
00031 
00032 #define  INITIAL_Te_VALUE   0.05       // Was 0.3 Be conservative when 
00033                                        // we don't kow the RTT
00034 
00035 #define TRACE  1                       // when 0, we don't race or write 
00036                                        // var to disk
00037 
00038 class XCPWrapQ;
00039 class XCPQueue;
00040 
00041 class XCPTimer : public TimerHandler { 
00042 public:
00043         XCPTimer(XCPQueue *a, void (XCPQueue::*call_back)() ) 
00044                 : a_(a), call_back_(call_back) {};
00045 protected:
00046         virtual void expire (Event *e);
00047         XCPQueue *a_; 
00048         void (XCPQueue::*call_back_)();
00049 }; 
00050 
00051 
00052 class XCPQueue : public DropTail {
00053         friend class XCPTimer;
00054 public:
00055         XCPQueue();
00056         void Tq_timeout ();  // timeout every propagation delay 
00057         void Te_timeout ();  // timeout every avg. rtt
00058         void everyRTT();     // timeout every highest rtt seen by rtr or some
00059                              // preset rtt value
00060         void setupTimers();  // setup timers for xcp queue only
00061         void setEffectiveRtt(double rtt) ;
00062         void routerId(XCPWrapQ* queue, int i);
00063         int routerId(int id = -1); 
00064   
00065         int limit(int len = 0);
00066         void setBW(double bw);
00067         void setChannel(Tcl_Channel queue_trace_file);
00068         double totalDrops() { return total_drops_; }
00069   
00070         // Overloaded functions
00071         void enque(Packet* pkt);
00072         Packet* deque();
00073         virtual void drop(Packet* p);
00074   
00075         // tracing var
00076         void setNumMice(int mice) {num_mice_ = mice;}
00077 
00078 protected:
00079 
00080         // Utility Functions
00081         double max(double d1, double d2) { return (d1 > d2) ? d1 : d2; }
00082         double min(double d1, double d2) { return (d1 < d2) ? d1 : d2; }
00083         int max(int i1, int i2) { return (i1 > i2) ? i1 : i2; }
00084         int min(int i1, int i2) { return (i1 < i2) ? i1 : i2; }
00085         double abs(double d) { return (d < 0) ? -d : d; }
00086 
00087         virtual void trace_var(char * var_name, double var);
00088   
00089         // Estimation & Control Helpers
00090         void init_vars();
00091         
00092         // called in enque, but packet may be dropped; used for 
00093         // updating the estimation helping vars such as
00094         // counting the offered_load_, sum_rtt_by_cwnd_
00095         virtual void do_on_packet_arrival(Packet* pkt);
00096 
00097         // called in deque, before packet leaves
00098         // used for writing the feedback in the packet
00099         virtual void do_before_packet_departure(Packet* p); 
00100         
00101   
00102         // ---- Variables --------
00103         unsigned int     routerId_;
00104         XCPWrapQ*        myQueue_;   //pointer to wrapper queue lying on top
00105         XCPTimer*        queue_timer_;
00106         XCPTimer*        estimation_control_timer_;
00107         XCPTimer*        rtt_timer_;
00108         double           link_capacity_bps_;
00109 
00110         static const double     ALPHA_;
00111         static const double     BETA_;
00112         static const double     GAMMA_;
00113         static const double     XCP_MAX_INTERVAL;
00114         static const double     XCP_MIN_INTERVAL;
00115 
00116         double          Te_;       // control interval
00117         double          Tq_;    
00118         double          Tr_;
00119         double          avg_rtt_;       // average rtt of flows
00120         double          high_rtt_;      // highest rtt seen in flows
00121         double          effective_rtt_; // pre-set rtt value 
00122         double          Cp_;
00123         double          Cn_;
00124         double          residue_pos_fbk_;
00125         double          residue_neg_fbk_;
00126         double          queue_bytes_;   // our estimate of the fluid model queue
00127         double          input_traffic_bytes_;       // traffic in Te 
00128         double          sum_rtt_by_throughput_;
00129         double          sum_inv_throughput_;
00130         double          running_min_queue_bytes_;
00131         unsigned int    num_cc_packets_in_Te_;
00132   
00133         double          thruput_elep_;
00134         double          thruput_mice_;
00135         double          total_thruput_;
00136         int             num_mice_;
00137         int             min_queue_ci_;
00138         int             max_queue_ci_;
00139         // drops
00140         int             drops_;
00141         double          total_drops_ ;
00142   
00143         // ----- For Tracing Vars --------------//
00144         Tcl_Channel     queue_trace_file_;
00145   
00146 };
00147 
00148 
00149 #endif //NS_XCPQ_H

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