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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Fri Feb 26 16:16:26 GMT 2010


Author: soohyunc
Date: Fri Feb 26 16:16:26 2010
New Revision: 4652

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

Log:
-- changed loss detection mechanism in a simpler way
   (previously, we had to created a sort of temporary seqno array to capture the
    packet loss(es) in a number of different places in TfwcSndr)
   we have created the "reference vector" in the XR reception path in the
   sender, and use "refvec" for the various calculations.

Upon XR(ackvec) reception:
    -> parse ackvec 
    -> gen 3 dupacks 
    -> gen refvec 
    -> loss history 
    -> ALI
    -> cwnd computation 
    -> update RTT 



Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Fri Feb 26 16:16:26 2010
@@ -71,6 +71,11 @@
 	clear_sqv(SSZ);
 	num_seqvec_ = 0;
 
+	// allocate refvec in memory
+	refvec_ = (u_int32_t *)malloc(sizeof(u_int32_t) * RSZ);
+	clear_refv(RSZ);
+	num_refvec_ = 0;
+
 	// for simulating TCP's 3 dupack rule
 	// (allowing packet re-ordering issue)
 	for (int i = 0; i < DUPACKS; i++)
@@ -94,8 +99,7 @@
 	is_tfwc_on_ = false;
 	is_first_loss_seen_ = false;
 	first_lost_pkt_ = -1;
-	is_loss_ = false;
-	num_loss_ = 0;
+	num_missing_ = 0;
 
 	avg_interval_ = 0.0;
 	I_tot0_ = 0.0;
@@ -166,14 +170,15 @@
 		marginvec(jacked_);
 		print_mvec();
 
-		// detect loss
+		// generate reference vector
+		// (it represents seqvec when there are no losses)
 		// 	@begin: aoa_+1 (lowest seqno)
 		// 	@end: mvec_[DUPACKS-1] - 1
-		is_loss_ = detect_loss(mvec_[DUPACKS-1]-1, aoa_+1);
+		gen_refvec(mvec_[DUPACKS-1]-1, aoa_+1);
 
 		// TFWC is not turned on (i.e., no packet loss yet)
 		if(!is_tfwc_on_) {
-			if(is_loss_) {
+			if(detect_loss()) {
 				is_tfwc_on_ = true;
 				dupack_action();
 				ts_ = tsvec_[first_lost_pkt_%TSZ];
@@ -199,7 +204,7 @@
 
 		// initialize variables for the next pkt reception
 		free(ackv_);
-		init_loss_var();
+		init_var();
 	}
 	// retrieve ts echo
 	else if (type == XR_BT_3) {
@@ -235,7 +240,7 @@
 		for (j = BITLEN; j > 0; j--) {
 			if( CHECK_BIT_AT(v[i], j) )
 				seqvec_[k++%SSZ] = start;
-			else num_loss_++;
+			else num_missing_++;
 			start++;
 		}
 	}
@@ -244,40 +249,49 @@
 	for (i = a; i > 0; i--) {
 		if( CHECK_BIT_AT(v[n-1], i) )
 			seqvec_[k++%SSZ] = start;
-		else num_loss_++;
+		else num_missing_++;
 		start++;
 	}
 
 	// therefore, the number of seqvec elements is:
-	num_seqvec_ = num_elm_ - num_loss_;
+	num_seqvec_ = num_elm_ - num_missing_;
 	// printing retrieved sequence numbers from received AckVec
 	print_seqvec(num_seqvec_);
 }
 
 /*
+ * generate reference vector
+ * (it represents the seqno vector when no losses)
+ * @end:    end seqno	(highest)
+ * @begin:  begin seqno (lowest)
+ */
+void TfwcSndr::gen_refvec(int end, int begin) {
+	// clear previous reference vector
+	clear_refv(num_refvec_);
+	// number of reference element - when no loss
+	num_refvec_ = end - begin + 1;
+
+	// generate refvec elements
+	fprintf(stderr, "\tcomparing numbers: (");
+	for (int i = 0; i < num_refvec_; i++) {
+		refvec_[i] = begin + i;
+		fprintf(stderr, " %d", refvec_[i]);
+	} fprintf(stderr, " )\n");
+}
+
+/*
  * detect packet loss in the received vector
  * @ret: true when there is a loss
  */
-bool TfwcSndr::detect_loss(int end, int begin) {
+bool TfwcSndr::detect_loss() {
 	bool ret;	// 'true' when there is a loss
 	bool is_there = false;
 	int count = 0; // packet loss counter
 
-	// number of tempvec element when no loss
-	int num = end - begin + 1;
-	u_int32_t tempvec[num];
-
-	// generate tempvec elements
-	fprintf(stderr, "\tcomparing numbers: (");
-	for (int i = 0; i < num; i++) {
-		tempvec[i] = begin + i;
-		fprintf(stderr, " %d", tempvec[i]);
-	} fprintf(stderr, " )\n");
-
-	// compare tempvec and seqvec
-	for (int i = 0; i < num; i++) {
+	// compare refvec and seqvec
+	for (int i = 0; i < num_refvec_; i++) {
 		for (int j = num_seqvec_-1; j >= 0; j--) {
-			if (tempvec[i] == seqvec_[j]) {
+			if (refvec_[i] == seqvec_[j]) {
 				is_there = true;
 				// we found it, so reset count
 				count = 0; break;
@@ -290,14 +304,9 @@
 		// record the very first lost packet seqno
 		if(!is_there) {
 			if(!is_first_loss_seen_) 
-				first_lost_pkt_ = tempvec[i];
+				first_lost_pkt_ = refvec_[i];
 		}
 	}
-	
-	// store tempvec elements for updating loss history
-	first_elm_ = tempvec[0];
-	last_elm_ = first_elm_ + (num - 1);
-
 	return ret = (count > 0) ? true : false;
 }
 
@@ -448,17 +457,12 @@
 void TfwcSndr::loss_history() {
 	bool is_loss = false;		// is there a loss found in seqvec?
 	bool is_new_event = false;	// is this a new loss event?
-	int numvec = last_elm_ - first_elm_ + 1;
-	u_int32_t tempvec[numvec];
-
-	for (int i = 0; i < numvec; i++)
-		tempvec[i] = first_elm_ + i;
 
-	// compare tempvec[] with seqvec
-	for (int i = 0; i < numvec; i++) {
+	// compare reference with seqvec
+	for (int i = 0; i < num_refvec_; i++) {
 		// is there a loss found?
 		for (int j = 0; j < num_seqvec_; j++) {
-			if (tempvec[i] == seqvec_[j]) {
+			if (refvec_[i] == seqvec_[j]) {
 				is_loss = false;
 				break;
 			} else 
@@ -467,13 +471,13 @@
 
 		// is this a new loss event?
 		if (is_loss) {
-			if (tsvec_[tempvec[i]%TSZ] - ts_ > srtt_)
+			if (tsvec_[refvec_[i]%TSZ] - ts_ > srtt_)
 			is_new_event = true;
 			else
 			is_new_event = false;
 		}
 
-		// compute loss history (compare tempvec and seqvec)
+		// compute loss history (compare refvec and seqvec)
 		// o  everytime it sees a loss
 		//    it will compare the timestamp with smoothed RTT
 		//
@@ -495,7 +499,7 @@
 				history_[k] = history_[k-1];
 
 			// record lost packet's timestamp
-			ts_ = tsvec_[tempvec[i]%TSZ];
+			ts_ = tsvec_[refvec_[i]%TSZ];
 
 			// let the most recent history information be one
 			history_[0] = 1;

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Fri Feb 26 16:16:26 2010
@@ -39,6 +39,7 @@
 #define DUPACKS 3   // simulating TCP's 3 dupacks
 #define TSZ	1000	// tsvec_ size
 #define SSZ 1000	// seqvec_ size
+#define RSZ 1000	// refvec_ size
 
 #define SHORT_HISTORY		// history size = 8
 #ifdef  SHORT_HISTORY
@@ -99,10 +100,12 @@
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
 
-	// init loss related variables
-	inline void init_loss_var() {
-		is_loss_ = false;
-		num_loss_ = 0;
+	// generate reference seqno
+	void gen_refvec(int end, int begin);
+
+	// init variables
+	inline void init_var() {
+		num_missing_ = 0;
 	}
 
 	// get the first position in ackvec where 1 is marked
@@ -163,7 +166,8 @@
 	void update_rtt(double tao);
 
 	// detect packet loss
-	bool detect_loss(int, int);
+	// (to capture the very first lost packet loss)
+	bool detect_loss();
 
 	// control congestion window
 	void control();
@@ -210,6 +214,12 @@
 			ackv_[i] = 0;
 	}
 
+	// clear refvec
+	inline void clear_refv (int n) {
+		for (int i = 0; i < n; i++)
+			refvec_[i] = 0;
+	}
+
 	int ndtp_;		// number of data packet sent
 	int nakp_;		// number of ackvec packet received
 	int ntep_;		// number of ts echo packet received
@@ -222,12 +232,13 @@
 
 	u_int32_t *seqvec_;		// generated seqno vec
 	int	num_seqvec_;		// number of seqvec elements
+	u_int32_t *refvec_;		// reference seqno vec
+	int num_refvec_;		// number of refvec elements
 	double *tsvec_;			// timestamp vector
 	u_int16_t jacked_;		// just acked seqno (head of ackvec)
-	bool is_loss_;
 	bool is_first_loss_seen_;
 	bool is_tfwc_on_;
-	int num_loss_;	// number of detected packet loss
+	int num_missing_;	// number of missing seqno
 	double f_p_;	// f(p) = sqrt(2/3)*p + 12*p*(1+32*p^2)*sqrt(3/8)*p
 	double p_;		// packet loss probability
 	double t_win_;      // temporal cwin size to get p_ value
@@ -242,8 +253,6 @@
 	double I_tot1_;		// form 1 to n
 	double tot_weight_;	// total weight
 	int hsz_;		// current history size
-	u_int32_t first_elm_;
-	u_int32_t last_elm_;
 
 	// RTT related variables
 	double srtt_;	// smoothed RTT



More information about the Sumover-dev mailing list