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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Thu Sep 4 16:48:41 BST 2008


Author: soohyunc
Date: Thu Sep  4 16:48:40 2008
New Revision: 4286

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

Log:
(bug fix - related to the issue when an unsigned int gets to be negative value)
o  previosly, "mvec_" is declared in an unsigend int but it could go into a
   negative value, which in turn results in generating some garbage values.


Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Thu Sep  4 16:48:40 2008
@@ -66,8 +66,8 @@
 	seqvec_ = (u_int32_t *)malloc(sizeof(u_int32_t)* SSZ );
 
 	// for simulating TCP's 3 dupack rule
-	u_int32_t mvec_ = 0x00;
-	UNUSED(mvec_);	// to shut up gcc-4.x
+	for (int i = 0; i < DUPACKS; i++)
+		mvec_[i] = 0;
 
 	minrto_ = 0.0;
 	maxrto_ = 100000.0;
@@ -134,7 +134,15 @@
 		marginvec(ackv);
 
 		// detect loss
-		is_loss_ = detect_loss(mvec_[DUPACKS-1] - 1, aoa_);
+		int pt = mvec_[DUPACKS - 1] - 1;
+		u_int16_t end;
+
+		if (pt < 0)
+			end = 0;
+		else
+			end = (u_int16_t) pt;
+
+		is_loss_ = detect_loss(end, aoa_);
 
 		// TFWC is not turned on (i.e., no packet loss yet)
 		if(!is_tfwc_on_) {

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Thu Sep  4 16:48:40 2008
@@ -154,10 +154,15 @@
 	}
 	// ackofack
 	inline u_int16_t ackofack () {
-		return (mvec_[DUPACKS - 1] - 1);
+		int retval = mvec_[DUPACKS - 1] - 1;
+
+		if (retval < 0) 
+			retval = 0;
+
+		return (u_int16_t) retval;
 	}
 
-	u_int32_t mvec_[DUPACKS]; // margin vec (simulatinmg TCP 3 dupacks)
+	int mvec_[DUPACKS]; // margin vec (simulatinmg TCP 3 dupacks)
 	u_int32_t ackv_;	// received AckVec (from TfwcRcvr)
 	u_int32_t pvec_;	// sent packet list
 	u_int16_t aoa_;		// ack of ack



More information about the Sumover-dev mailing list