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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Tue Aug 4 18:46:20 BST 2009


Author: soohyunc
Date: Tue Aug  4 18:46:19 2009
New Revision: 4500

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

Log:
(bug fixed)
Previously, AckVec wasn't really doing correctly when there are packets losses.

    Now, AckVec is able to represents those losses correctly both the sender and 
    receiver side.


Modified: vic/branches/cc/cc/tfwc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.cpp	Tue Aug  4 18:46:19 2009
@@ -95,22 +95,37 @@
 		// there is no packet loss (or reordering)
 		if (currseq_ == prevseq_ + 1) {
 			// set next bit to 1
-			if (diffNumElm > 0 || currseq_ == 1)
+			if (diffNumElm > 0 || currseq_ == 1) {
 				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+			}
 			// free unnecessary bits
 			else if (diffNumElm < 0) {
-				// freeing whole AcvVec chunks that is not necessary
+				// freeing unnecessary AcvVec chunk(s) 
 				if (currNumVec_ != prevNumVec_) {
 					for (int i = prevNumVec_; i > currNumVec_; i--) {
 						for (int j = 1; j <= 16; j++)
 							SET_BIT_VEC(tfwcAV[i-1], 0);
 					}
 				}
+
+				// set next bit to 1
+				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+
+				// and clear the bit(s) that we don't need it anymore
 				int k = (currNumElm_%16 == 0) ? 16: (currNumElm_%16);
-				// freeing the rest of bits
 				for (int i = 16; i > k; i--)
 					CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
 			}
+			// we just need the same number of AckVec element
+			// (i.e., diffNumElm==0), 
+			// hence just left shift by one and clear the top bit
+			else {
+				// set next bit to 1
+				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+
+				// and clear the bit which we don't need it anymore
+				CLR_BIT_AT(tfwcAV[currNumVec_-1], currNumElm_+1);
+			}
 		} 
 		// we have one or more packet losses (or reordering)
 		else {
@@ -153,6 +168,15 @@
 
 			// then, set this packet as received (this is important)
 			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+
+			// and clear the top two bits which we don't need
+			// (because we have pushed '0' and '1' at the end of this AckVec)
+			// it doesn't really matter if diffNumElm is greater than 0.
+			if (diffNumElm <= 0) {
+				int b = abs(diffNumElm) + currNumElm_ + numLoss;
+				for (int i = currNumElm_+1; i <= b; i++)
+					CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
+			}
 		}
 
 		// print ackvec

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Tue Aug  4 18:46:19 2009
@@ -90,6 +90,8 @@
 	is_tfwc_on_ = false;
 	is_first_loss_seen_ = false;
 	first_lost_pkt_ = -1;
+	is_loss_ = false;
+	num_loss_ = 0;
 
 	avg_interval_ = 0.0;
 	I_tot0_ = 0.0;
@@ -147,7 +149,6 @@
 				__FILE__, __LINE__, begins_, ends_, jacked_);
 		gen_seqvec(num_chunks, ackv_);
 		free(ackv_);
-		print_seqvec(begins_, ends_);
 
 		// generate margin vector
 		marginvec(jacked_);
@@ -180,6 +181,9 @@
 		// update RTT with the sampled RTT
 		tao_ = tfwc_sndr_now() - tsvec_[seqno_%TSZ];
 		update_rtt(tao_);
+
+		// initialize variables for the next pkt reception
+		init_loss_var();
 	}
 	// retrieve ts echo
 	else if (type == XR_BT_3) {
@@ -213,8 +217,9 @@
 	for (i = 0; i < num_chunks-1; i++) {
 		for (j = 0; j < 16; j++) {
 			if ( CHECK_BIT_AT(ackvec[i], (j+1)) )
-				seqvec_[k++%SSZ] = start;
-			start--;
+				seqvec_[k%SSZ] = start;
+		else num_loss_++;
+			k++; start--;
 		}
 	}
 
@@ -222,8 +227,12 @@
 	for (i = 0; i < a; i++) {
 		if ( CHECK_BIT_AT(ackvec[num_chunks-1], i+1 ))
 			seqvec_[k++%SSZ] = start;
+		else num_loss_++;
 		start--;
 	}
+
+	// printing retrieved sequence numbers from received AckVec
+	print_seqvec(numElm - num_loss_);
 }
 
 /*
@@ -234,14 +243,14 @@
 	bool ret;	// 'true' when there is a loss
 	int lc = 0;	// loss counter
 
-	// number of tempvec element
-	int numvec = (end - begin < 0) ? 0 : end - begin;
-	u_int32_t tempvec[numvec];
+	// number of tempvec element when no loss
+	int numelm = (end - begin < 0) ? 0 : end - begin;
+	u_int32_t tempvec[numelm];
 	bool is_there = false;
 
 	// generate tempvec elements
 	printf("\tcomparing numbers: (");
-	for (int i = 0; i < numvec; i++) {
+	for (int i = 0; i < numelm; i++) {
 		tempvec[i] = (begin + 1) + i;
 		printf(" %d", tempvec[i]);
 	} printf(" )\n");
@@ -250,14 +259,16 @@
 	int numseq = ends_ - begins_;
 
 	// compare tempvec and seqvec
-	for (int i = 0; i < numvec; i++) {
+	for (int i = 0; i < numelm; i++) {
 		for (int j = 0; j < numseq; j++) {
 			if (tempvec[i] == seqvec_[j]) {
+				printf("\t\tyes! -- s:[%d] t:[%d]\n", seqvec_[j], tempvec[i]);
 				is_there = true;
 				break;
 			}
 		}
 
+		// packet loss should be captured by now
 		if(!is_there) {
 			if(!is_first_loss_seen_) 
 				first_lost_pkt_ = tempvec[i];
@@ -266,8 +277,8 @@
 	}
 	
 	// store elements
-	firstvec_ = tempvec[0];
-	lastvec_ = firstvec_ + (numvec - 1);
+	first_elm_ = tempvec[0];
+	last_elm_ = first_elm_ + (numelm - 1);
 
 	return ret = (lc > 0) ? true : false;
 }
@@ -373,7 +384,6 @@
  *   o  marking pseudo loss history and loss rate
  */
 void TfwcSndr::dupack_action() {
-
 	// this is the very first packet loss
 	is_first_loss_seen_ = true;
 
@@ -420,11 +430,11 @@
 void TfwcSndr::loss_history() {
 	bool is_loss;		// is there a loss found in seqvec?
 	bool is_new_event;	// is this a new loss event?
-	int numvec = lastvec_ - firstvec_ + 1;
+	int numvec = last_elm_ - first_elm_ + 1;
 	u_int32_t tempvec[numvec];
 
 	for (int i = 0; i < numvec; i++)
-		tempvec[i] = firstvec_ + i;
+		tempvec[i] = first_elm_ + i;
 
 	// compare tempvec[] with seqvec
 	for (int i = 0; i < numvec; i++) {

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Tue Aug  4 18:46:19 2009
@@ -101,6 +101,12 @@
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t num_chunks, u_int16_t *ackvec);
 
+	// init loss related variables
+	inline void init_loss_var() {
+		is_loss_ = false;
+		num_loss_ = 0;
+	}
+
 	// get the first position in ackvec where 1 is marked
 	inline u_int16_t get_head_pos(u_int16_t ackvec) {
 		int l;
@@ -136,11 +142,9 @@
 				mvec_[0], mvec_[1], mvec_[2]);
 	}
 	// printf seqvec
-	inline void print_seqvec(u_int16_t begins, u_int16_t ends) {
-        int cnt = ends - begins;  // number of packets in ackvec
-
+	inline void print_seqvec(int numelm) {
 		printf("\tsequence numbers: (");
-		for (int i = 0; i < cnt; i++)
+		for (int i = 0; i < numelm; i++)
 			printf(" %d", seqvec_[i]);
 		printf(" )\n");
 	}
@@ -194,6 +198,7 @@
 	bool is_loss_;
 	bool is_first_loss_seen_;
 	bool is_tfwc_on_;
+	int num_loss_;	// number of detected packet loss
 	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
@@ -208,8 +213,8 @@
 	double I_tot1_;		// form 1 to n
 	double tot_weight_;	// total weight
 	int hsz_;		// current history size
-	u_int32_t firstvec_;
-	u_int32_t lastvec_;
+	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