[Sumover-dev] [svn commit] r4809 - vic/branches/cc/cc

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Sun May 9 15:54:04 BST 2010


Author: soohyunc
Date: Sun May  9 15:54:04 2010
New Revision: 4809

Modified:
   vic/branches/cc/cc/tfrc_sndr.cpp
   vic/branches/cc/cc/tfrc_sndr.h

Log:
added TFRC's RTT update mechanism



Modified: vic/branches/cc/cc/tfrc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfrc_sndr.cpp	Sun May  9 15:54:04 2010
@@ -77,9 +77,33 @@
 	num_refvec_ = 0;
 
 	// initialize variables
+	minrto_ = 0.0;
+	maxrto_ = 100000.0;
+	srtt_ = -1.0;
+	rto_ = 3.0;     // RFC 1122
+	rttvar_ = 0.0;
+	df_ = 0.95;
+	sqrtrtt_ = 1.0;
+	t0_ = 6.0;
+	alpha_ = 0.125;
+	beta_ = 0.25;
+	g_ = 0.01;
+	k_ = 4;
 	ts_ = 0.0;
+
 	num_missing_ = 0;
 
+	avg_interval_ = 0.0;
+	I_tot0_ = 0.0;
+	I_tot1_ = 0.0;
+	tot_weight_ = 0.0;
+
+	tcp_tick_ = 0.01;
+	srtt_init_ = 12;
+	rttvar_exp_ = 2;
+	t_srtt_ = int(srtt_init_/tcp_tick_) << T_SRTT_BITS;
+	t_rttvar_ = int(rttvar_init_/tcp_tick_) << T_RTTVAR_BITS;
+
 	// EWMA packet size
 	asize_ = 0;
 	pcnt_ = 0;
@@ -278,5 +302,52 @@
 /*
  * update RTT using sampled RTT value
  */
-void TfrcSndr::update_rtt(double tao) {
+void TfrcSndr::update_rtt(double rtt_sample) {
+	// calculate t0_ 
+	t_rtt_ = int(rtt_sample/tcp_tick_ + .5);
+	if(t_rtt_ == 0) t_rtt_ = 1;
+
+	if(t_srtt_ != 0) {
+		register short rtt_delta;
+		rtt_delta = t_rtt_ - (t_srtt_ >> T_SRTT_BITS);
+
+		if ((t_srtt_ += rtt_delta) <= 0)
+		t_srtt_ = 1;
+
+		if (rtt_delta < 0)
+		rtt_delta = -rtt_delta;
+
+		rtt_delta -= (t_rttvar_ >> T_RTTVAR_BITS);
+		if((t_rttvar_ += rtt_delta) <= 0)
+		t_rttvar_ = 1;
+	}
+	else {
+		t_srtt_ = t_rtt_ << T_SRTT_BITS;
+		t_rttvar_ = t_rtt_ << (T_RTTVAR_BITS-1);
+	}
+
+	// finally, t0_ = (smoothed RTT) + 4 * (rtt variance)
+	t0_ = (((t_rttvar_ << (rttvar_exp_ + (T_SRTT_BITS - T_RTTVAR_BITS)))
+		+ t_srtt_)  >> T_SRTT_BITS ) * tcp_tick_;
+
+	if (t0_ < minrto_)
+		t0_ = minrto_;
+
+	// calculate smoothed RTT
+	if (srtt_ < 0) {
+		// the first RTT observation
+		srtt_ = rtt_sample;
+		rttvar_ = rtt_sample/2.0;
+		sqrtrtt_ = sqrt(rtt_sample);
+	} else {
+		srtt_ = df_ * srtt_ + (1 - df_) * rtt_sample;
+		rttvar_ = rttvar_ + beta_ * (fabs(srtt_ - rtt_sample) - rttvar_);
+		sqrtrtt_ = df_ * sqrtrtt_ + (1 - df_) * sqrt(rtt_sample);
+	}
+
+	// 'rto' could be rounded by 'maxrto'
+	if (rto_ > maxrto_)
+		rto_ = maxrto_;
+
+	print_rtt_info();
 }

Modified: vic/branches/cc/cc/tfrc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.h	(original)
+++ vic/branches/cc/cc/tfrc_sndr.h	Sun May  9 15:54:04 2010
@@ -154,6 +154,38 @@
 	double *tsvec_;		// timestamp vector
 	u_int16_t jacked_;	// just acked seqno (head of ackvec)
 	int num_missing_;	// number of missing seqno
+	double p_;			// packet loss probability
+	double avg_interval_;	// average loss interval
+	int history_[HSZ+1];	// loss interval history
+	double weight_[HSZ+1];	// weight for calculating avg loss interval
+	double I_tot_;		// total sum
+	double I_tot0_;		// from 0 to n-1
+	double I_tot1_;		// from 1 to n
+	double tot_weight_;	// total weight
+	int hsz_;		// current history size
+
+	// RTT related variables
+	double srtt_;	// smoothed RTT
+	double rttvar_;	// RTT variation
+	double rto_;	// retransmission timeout
+	double minrto_;	// min RTO allowed
+	double maxrto_;	// max RTO
+	double df_;		// decay factor
+	double sqrtrtt_;	// the mean of the sqrt of RTT
+
+	// TCP's RTO calculation
+	double alpha_;  // smoothing factor for RTT/RTO calculation
+	double beta_;   // smoothing factor for RTT/RTO calculation
+	double g_;      // timer granularity
+	int k_;         // k value
+	int t_rtt_;     // RTT
+	int t_rttvar_;  // RTT variance
+	int t_srtt_;    // smoothed RTT
+	int srtt_init_; // initial val for t_srtt_
+	int rttvar_init_;   // initial val for t_rttvar_
+	int rttvar_exp_;    // exponent of multiple for t0_
+	double t0_;     // t0 value at TCP throughput equation
+	double tcp_tick_;
 
 	// XR chunk begin/end
 	u_int16_t begins_;	// start seqno that this XR chunk reports
@@ -174,7 +206,17 @@
 		fprintf(stderr, " %d", vec[i]);
 	fprintf(stderr, " )\n");
 	}
-
+	// print RTT related info for debugging
+	inline void print_rtt_info() {
+	fprintf(stderr,
+	"\t>> now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
+	so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
+	}
+	inline void print_rtt_info(const char* str) {
+	fprintf(stderr,
+	"\t%s now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
+	str, so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
+	}
 	// print the actual packet size and EWMA estimated one
 	inline void print_psize(double now, int size, int len) {
 	fprintf(stderr, "\tnow: %f psize: %d actual: %d\n", now, size, len);



More information about the Sumover-dev mailing list