Changeset 4809
 Timestamp:
 05/09/10 15:54:04 (6 years ago)
 Location:
 vic/branches/cc/cc
 Files:

 2 modified
Legend:
 Unmodified
 Added
 Removed

vic/branches/cc/cc/tfrc_sndr.cpp
r4803 r4809 78 78 79 79 // initialize variables 80 minrto_ = 0.0; 81 maxrto_ = 100000.0; 82 srtt_ = 1.0; 83 rto_ = 3.0; // RFC 1122 84 rttvar_ = 0.0; 85 df_ = 0.95; 86 sqrtrtt_ = 1.0; 87 t0_ = 6.0; 88 alpha_ = 0.125; 89 beta_ = 0.25; 90 g_ = 0.01; 91 k_ = 4; 80 92 ts_ = 0.0; 93 81 94 num_missing_ = 0; 95 96 avg_interval_ = 0.0; 97 I_tot0_ = 0.0; 98 I_tot1_ = 0.0; 99 tot_weight_ = 0.0; 100 101 tcp_tick_ = 0.01; 102 srtt_init_ = 12; 103 rttvar_exp_ = 2; 104 t_srtt_ = int(srtt_init_/tcp_tick_) << T_SRTT_BITS; 105 t_rttvar_ = int(rttvar_init_/tcp_tick_) << T_RTTVAR_BITS; 82 106 83 107 // EWMA packet size … … 279 303 * update RTT using sampled RTT value 280 304 */ 281 void TfrcSndr::update_rtt(double tao) { 282 } 305 void TfrcSndr::update_rtt(double rtt_sample) { 306 // calculate t0_ 307 t_rtt_ = int(rtt_sample/tcp_tick_ + .5); 308 if(t_rtt_ == 0) t_rtt_ = 1; 309 310 if(t_srtt_ != 0) { 311 register short rtt_delta; 312 rtt_delta = t_rtt_  (t_srtt_ >> T_SRTT_BITS); 313 314 if ((t_srtt_ += rtt_delta) <= 0) 315 t_srtt_ = 1; 316 317 if (rtt_delta < 0) 318 rtt_delta = rtt_delta; 319 320 rtt_delta = (t_rttvar_ >> T_RTTVAR_BITS); 321 if((t_rttvar_ += rtt_delta) <= 0) 322 t_rttvar_ = 1; 323 } 324 else { 325 t_srtt_ = t_rtt_ << T_SRTT_BITS; 326 t_rttvar_ = t_rtt_ << (T_RTTVAR_BITS1); 327 } 328 329 // finally, t0_ = (smoothed RTT) + 4 * (rtt variance) 330 t0_ = (((t_rttvar_ << (rttvar_exp_ + (T_SRTT_BITS  T_RTTVAR_BITS))) 331 + t_srtt_) >> T_SRTT_BITS ) * tcp_tick_; 332 333 if (t0_ < minrto_) 334 t0_ = minrto_; 335 336 // calculate smoothed RTT 337 if (srtt_ < 0) { 338 // the first RTT observation 339 srtt_ = rtt_sample; 340 rttvar_ = rtt_sample/2.0; 341 sqrtrtt_ = sqrt(rtt_sample); 342 } else { 343 srtt_ = df_ * srtt_ + (1  df_) * rtt_sample; 344 rttvar_ = rttvar_ + beta_ * (fabs(srtt_  rtt_sample)  rttvar_); 345 sqrtrtt_ = df_ * sqrtrtt_ + (1  df_) * sqrt(rtt_sample); 346 } 347 348 // 'rto' could be rounded by 'maxrto' 349 if (rto_ > maxrto_) 350 rto_ = maxrto_; 351 352 print_rtt_info(); 353 } 
vic/branches/cc/cc/tfrc_sndr.h
r4804 r4809 155 155 u_int16_t jacked_; // just acked seqno (head of ackvec) 156 156 int num_missing_; // number of missing seqno 157 double p_; // packet loss probability 158 double avg_interval_; // average loss interval 159 int history_[HSZ+1]; // loss interval history 160 double weight_[HSZ+1]; // weight for calculating avg loss interval 161 double I_tot_; // total sum 162 double I_tot0_; // from 0 to n1 163 double I_tot1_; // from 1 to n 164 double tot_weight_; // total weight 165 int hsz_; // current history size 166 167 // RTT related variables 168 double srtt_; // smoothed RTT 169 double rttvar_; // RTT variation 170 double rto_; // retransmission timeout 171 double minrto_; // min RTO allowed 172 double maxrto_; // max RTO 173 double df_; // decay factor 174 double sqrtrtt_; // the mean of the sqrt of RTT 175 176 // TCP's RTO calculation 177 double alpha_; // smoothing factor for RTT/RTO calculation 178 double beta_; // smoothing factor for RTT/RTO calculation 179 double g_; // timer granularity 180 int k_; // k value 181 int t_rtt_; // RTT 182 int t_rttvar_; // RTT variance 183 int t_srtt_; // smoothed RTT 184 int srtt_init_; // initial val for t_srtt_ 185 int rttvar_init_; // initial val for t_rttvar_ 186 int rttvar_exp_; // exponent of multiple for t0_ 187 double t0_; // t0 value at TCP throughput equation 188 double tcp_tick_; 157 189 158 190 // XR chunk begin/end … … 175 207 fprintf(stderr, " )\n"); 176 208 } 177 209 // print RTT related info for debugging 210 inline void print_rtt_info() { 211 fprintf(stderr, 212 "\t>> now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n", 213 so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_); 214 } 215 inline void print_rtt_info(const char* str) { 216 fprintf(stderr, 217 "\t%s now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n", 218 str, so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_); 219 } 178 220 // print the actual packet size and EWMA estimated one 179 221 inline void print_psize(double now, int size, int len) {