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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Aug 5 19:48:25 BST 2009


Author: soohyunc
Date: Wed Aug  5 19:48:24 2009
New Revision: 4505

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

Log:
(fixed TFWC timer)
TfwcSndr::now() can now represent the current time correctly.


Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Wed Aug  5 19:48:24 2009
@@ -67,6 +67,9 @@
 	// allocate seqvec in memory
 	seqvec_ = (u_int32_t *)malloc(sizeof(u_int32_t) * SSZ);
 
+	// is TFWC running?
+	is_running_ = false;
+
 	// for simulating TCP's 3 dupack rule
 	// (allowing packet re-ordering issue)
 	for (int i = 0; i < DUPACKS; i++)
@@ -106,17 +109,30 @@
 
 	// get seqno and mark timestamp for this data packet
 	seqno_	= ntohs(rh->rh_seqno);
-	now_	= tfwc_sndr_now();		// double type (reference time)
-	t_now_	= tfwc_sndr_t_now();	// u_int32_t type (reference time)
+	now_	= tfwc_sndr_now();		// (double) type 
+	t_now_	= tfwc_sndr_t_now();	// (u_int32_t) type 
+
+	// is TFWC running? (is this the first data packet?)
+	if (!is_running_) {
+		ref_time_ = now_;
+		ref_t_time_ = t_now_;
+		is_running_ = true;
+	}
+
+	// interpret human-readable time format
+	now_	-= ref_time_;	// (double) type
+	//t_now_	-= ref_t_time_;	// (u_int32_t) type
 
 	// timestamp vector for loss history update
 	tsvec_[seqno_%TSZ - 1] = now_;
 
+	printf("\t>> now_:%f, tsvec_[%d]:%f\n", 
+			now(), seqno_%TSZ - 1, tsvec_[seqno_%TSZ-1]);
+
 	// sequence number must be greater than zero
 	assert (seqno_ > 0);
-	//debug_msg("sent seqno:		%d\n", seqno_);
-
-	ndtp_++;	// number of data packet sent
+	// number of total data packet sent
+	ndtp_++;
 }
 
 /*
@@ -179,7 +195,7 @@
 		aoa_ = ackofack(); 
 
 		// update RTT with the sampled RTT
-		tao_ = tfwc_sndr_now() - tsvec_[seqno_%TSZ];
+		tao_ = now() - tsvec_[seqno_%TSZ];
 		update_rtt(tao_);
 
 		// initialize variables for the next pkt reception
@@ -192,7 +208,7 @@
 		ts_echo_ = chunk[num_chunks - 1];
 		printf("    [%s +%d] ts echo:	%f\n", __FILE__,__LINE__, ts_echo_);
 
-		tao_ = 1e-6 * (double)(tfwc_sndr_now() - ts_echo_);
+		tao_ = now() - ts_echo_;
 
 		// update RTT
 		//update_rtt(tao_);

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Wed Aug  5 19:48:24 2009
@@ -86,10 +86,13 @@
 	// set timestamp in double type (TfwcSndr)
 	inline double tfwc_sndr_now() {
 		timeval tv;
-		::gettimeofday(&tv, 0);
+		::gettimeofday(&tv, NULL);
 		return ((double) tv.tv_sec + 1e-6 * (double) tv.tv_usec);
 	}
 
+	// return the current time
+	inline double now() { return now_; }
+
 	// return timestamp in u_int32_t type
 	inline u_int32_t tfwc_sndr_get_ts() { return t_now_; }
 
@@ -192,6 +195,10 @@
 	int nsve_;		// number of seqvec element
 	int epoch_;		// communication epoch
 
+	bool is_running_;	// is TFWC running? 
+	double ref_time_;	// reference time for gettimeofday
+	u_int32_t ref_t_time_;	// reference time (uint32 format)
+
 	u_int32_t *seqvec_;		// generated seqno vec
 	double *tsvec_;			// timestamp vector
 	u_int16_t jacked_;		// just acked seqno (head of ackvec)



More information about the Sumover-dev mailing list