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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Thu Aug 14 13:59:36 BST 2008


Author: soohyunc
Date: Thu Aug 14 13:59:35 2008
New Revision: 4270

Modified:
   vic/branches/cc/cc/tfwc_rcvr.cpp
   vic/branches/cc/cc/tfwc_sndr.cpp
   vic/branches/cc/cc/tfwc_sndr.h

Log:
o  added update RTT in TfwcSndr


Modified: vic/branches/cc/cc/tfwc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.cpp	Thu Aug 14 13:59:35 2008
@@ -53,10 +53,9 @@
 void TfwcRcvr::tfwc_rcvr_recv(u_int16_t type, u_int16_t seqno, 
 				u_int16_t ackofack, u_int32_t ts) 
 {
-	debug_msg("received seqno:  %d\n", seqno);
-
 	// parse the received seqno and ackofack
 	if (type == XR_BT_1) {
+		debug_msg("received seqno:  %d\n", seqno);
 		currseq_ = seqno;
 		ackofack_ = ackofack;
 

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Thu Aug 14 13:59:35 2008
@@ -36,6 +36,7 @@
 #include "assert.h"
 #include "config.h"
 #include "timer.h"
+#include "math.h"
 #include "rtp.h"
 #include "inet.h"
 #include "pktbuf-rtp.h"
@@ -57,8 +58,20 @@
 	ntep_(0),
 	epoch_(1)
 {
+	minrto_ = 0.0;
+	maxrto_ = 100000.0;
+	srtt_ = -1.0;
+	rto_ = 3.0;		// RFC 1122
+	rttvar_ = 0.0;
+	df_ = 0.95;
+	sqrtrtt_ = 1.0;
+	alpha_ = 0.125;
+	beta_ = 0.25;
+	g_ = 0.01;
+	k_ = 4;
+
 	// for simulating TCP's 3 dupack rule
-	u_int32_t mvec_ = 0x07;
+	u_int32_t mvec_ = 0x00;
 	UNUSED(mvec_);	// to shut up gcc-4.x
 }
 
@@ -72,7 +85,7 @@
 	now_ = tfwc_sndr_now();
 
 	// timestamp vector for loss history update
-	tsvec_[seqno_%TSZ] = now_;
+	//tsvec_[seqno_%TSZ - 1] = now_;
 
 	// sequence number must be greater than zero
 	assert (seqno_ > 0);
@@ -111,6 +124,33 @@
 		debug_msg(" ts echo:	%d\n", ts_echo_);
 		
 		// update RTT
-		// update_rtt(tao);
+		update_rtt(tao_);
+	}
+}
+
+void TfwcSndr::update_rtt(u_int32_t tao) {
+
+	// double dtao = double(tao); // convert to a real number
+	double dtao;
+	
+	if (srtt_ < 0) {
+		// the first RTT observation
+		srtt_ = dtao;
+		rttvar_ = dtao/2.0;
+		sqrtrtt_ = sqrt(dtao);
+	} else {
+		srtt_ = df_ * srtt_ + (1 - df_) * dtao;
+		rttvar_ = rttvar_ + beta_ * (fabs(srtt_ - dtao) - rttvar_);
+		sqrtrtt_ = df_ * sqrtrtt_ + (1 - df_) * sqrt(dtao);
 	}
+
+	// update the current RTO
+	if (k_ * rttvar_ > g_) 
+		rto_ = srtt_ + k_ * rttvar_;
+	else
+		rto_ = srtt_ + g_;
+
+	// 'rto' could be rounded by 'maxrto'
+	if (rto_ > maxrto_)
+		rto_ = maxrto_;
 }

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Thu Aug 14 13:59:35 2008
@@ -118,11 +118,27 @@
 	u_int32_t *tsvec_;	// timestamp vector
 	u_int32_t tao_;		// sampled RTT
 private:
+	// update RTT
+	void update_rtt(u_int32_t tao);	// update RTT
 	u_int16_t last_ack_;	// last packet seqno from ackvec
 	int ndtp_;		// number of data packet sent
 	int nakp_;		// number of ackvec packet received
 	int ntep_;		// number of ts echo packet received
 	int epoch_;		// communication epoch
+
+	// 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 alpha_;	// smoothing factor for RTT/RTO calculation
+	double beta_;	// smoothing factor for RTT/RTO calculation
+	double g_;	// timer granularity
+	int k_;		// k value
+	double t0_;	// t0 value at TCP throughput equation
+	double df_;	// decay factor
+	double sqrtrtt_;	// the mean of the sqrt of RTT
 };
 
 #endif



More information about the Sumover-dev mailing list