[Sumover-dev] [svn commit] r4276 - in vic/branches/cc: rtp

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Mon Aug 18 01:30:35 BST 2008


Author: soohyunc
Date: Mon Aug 18 01:30:33 2008
New Revision: 4276

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

Log:
GSoC 2008 wrap-up

o  protytype TFWC implementation done
   (resolved all issues introduced in the previous commit messages)

except...

o  we need to make it Ack driven
   (need to call Transmitter:output() directly at the end of parse_xr() method)



Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Mon Aug 18 01:30:33 2008
@@ -53,12 +53,12 @@
 	ts_(0),
 	ts_echo_(0),
 	now_(0),
-	lastest_ack_(0),
 	ndtp_(0),
 	nakp_(0),
 	ntep_(0),
 	nsve_(0),
-	epoch_(1)
+	epoch_(1),
+	just_acked_(0)
 {
 	// allocate tsvec_ in memory
 	tsvec_ = (double *)malloc(sizeof(double)* TSZ);
@@ -123,17 +123,17 @@
 		nakp_++;		// number of ackvec packet received
 		//ackv_ = ackv;	// store ackvec
 
-		// lastest ack (head of ackvec)
-		lastest_ack_ = get_head_pos(ackv) + aoa_;
+		// just acked seqno (head of ackvec)
+		just_acked_ = get_head_pos(ackv) + aoa_;
 
 		// generate seqno vec
-		gen_seqno_vec(ackv);
+		gen_seqvec(ackv);
 
 		// generate margin vector
 		marginvec(ackv);
 
 		// detect loss
-		is_loss_ = detect_loss(seqvec_, mvec_[DUPACKS-1] - 1, aoa_);
+		is_loss_ = detect_loss(mvec_[DUPACKS-1] - 1, aoa_);
 
 		// TFWC is not turned on (i.e., no packet loss yet)
 		if(!is_tfwc_on_) {
@@ -148,7 +148,7 @@
 		} 
 		// TFWC is turned on, so control that way
 		else {
-			control(seqvec_);
+			control();
 		}
 
 		// set ackofack (real number)
@@ -177,18 +177,28 @@
  * detect packet loss in the received vector
  * @ret: true when there is a loss
  */
-bool TfwcSndr::detect_loss(u_int32_t* vec, u_int16_t end, u_int16_t begin) {
+bool TfwcSndr::detect_loss(u_int16_t end, u_int16_t begin) {
 	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;
-	int tempvec[numvec];
-	bool is_there;
+	u_int32_t tempvec[numvec];
+	bool is_there = false;
 
+	// generate tempvec elements
 	for (int i = 0; i < numvec; i++) {
 		tempvec[i] = (begin + 1) + i;
-		// is there stuff
+	}
+
+	// compare tempvec and seqvec
+	for (int i = 0; i < numvec; i++) {
+		for (int j = 0; j < numvec; j++) {
+			if (tempvec[i] == seqvec_[j]) {
+				is_there = true;
+				break;
+			}
+		}
 
 		if(!is_there) {
 			if(!is_first_loss_seen_) 
@@ -196,6 +206,11 @@
 			lc++;
 		}
 	}
+	
+	// store elements
+	firstvec_ = tempvec[0];
+	lastvec_ = firstvec_ + (numvec - 1);
+
 	return ret = (lc > 0) ? true : false;
 }
 
@@ -230,8 +245,8 @@
 /*
  * core part for congestion window control
  */
-void TfwcSndr::control(u_int32_t* seqvec) {
-	loss_history(seqvec);
+void TfwcSndr::control() {
+	loss_history();
 	avg_loss_interval();
 
 	// loss event rate (p)
@@ -276,7 +291,7 @@
 /*
  * compute packet loss history
  */
-void TfwcSndr::loss_history(u_int32_t* seqvec) {
+void TfwcSndr::pseudo_history() {
 	pseudo_interval_ = 1 / p_;
 
 	/* bzero for all history information */
@@ -340,18 +355,65 @@
 /*
  * compute simulated loss history
  */
-void TfwcSndr::pseudo_history() {
-	pseudo_interval_ = 1 / p_;
+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;
+	u_int32_t tempvec[numvec];
 
-	/* bzero for all history information */
-	for(int i = 0; i <= HSZ+1; i++)
-		history_[i] = 0;
+	for (int i = 0; i < numvec; i++)
+		tempvec[i] = firstvec_ + i;
 
-	/* (let) most recent history information be 0 */
-	history_[0] = 0;
+	// compare tempvec[] with seqvec
+	for (int i = 0; i < numvec; i++) {
+		// is there a loss found?
+		for (int j = 0; j < numvec; j++) {
+			if (tempvec[i] == seqvec_[j]) {
+				is_loss = false;
+				break;
+			} else 
+				is_loss = true;
+		}
 
-	/* (let) the pseudo interval be the first history information */
-	history_[1] = (int) pseudo_interval_;
+		// is this a new loss event?
+		if (tsvec_[tempvec[i]%TSZ] - ts_ > srtt_)
+			is_new_event = true;
+		else
+			is_new_event = false;
+
+		// compute loss history (compare tempvec and seqvec)
+		// o  everytime it sees a loss
+		//    it will compare the timestamp with smoothed RTT
+		//
+		// o  if the time difference is greater than RTT,
+		//    then this loss starts a new loss event
+		// o  if the time difference is less than RTT,
+		//    then we do nothing
+		//
+		// o  if there is no loss, 
+		//    simply increment the loss interval by one
+		if (is_loss && is_new_event) {
+			// this is a new loss event!
+
+			// increase current history size
+			hsz_ = (hsz_ < HSZ) ? ++hsz_ : HSZ;
+
+			// shift history information
+			for (int k = HSZ; k > 0; k--)
+				history_[k] = history_[k-1];
+
+			// record lost packet's timestamp
+			ts_ = tsvec_[tempvec[i]%TSZ];
+
+			// let the most recent history information be one
+			history_[0] = 1;
+		} 
+		else {
+			// this is not a new loss event
+			// increase the current history information
+			history_[0]++;
+		}
+	}
 }
 
 /*

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Mon Aug 18 01:30:33 2008
@@ -42,12 +42,16 @@
 #define TSZ	1000		// tsvec_ size
 #define SSZ 1000		// seqvec_ size
 
+#define SHORT_HISTORY		// history size = 8
 #ifdef  SHORT_HISTORY
 #define HSZ 8   // history size for avg loss history
 #else
 #define HSZ 16  // history size for avg loss history
 #endif
 
+#define T_RTTVAR_BITS	2	// XXX not used
+#define T_SRTT_BITS		3	// XXX not used
+
 // set AckVec bitmap from LSB
 #define SET_BIT_VEC(ackvec_, bit) (ackvec_ = ((ackvec_ << 1) | bit))
 
@@ -103,7 +107,7 @@
 	u_int32_t cwnd_;	// congestion window
 
 protected:
-	// get the first position in ackvec where 1 is marked (mod 32)
+	// get the first position in ackvec where 1 is marked
 	inline u_int32_t get_head_pos(u_int32_t ackvec) {
 		int l;
 		for (l = 0; l < 32; l++) {
@@ -133,12 +137,16 @@
 		}
 	}
 	// generate seqno vector (interpret ackvec to real sequence numbers)
-	inline void gen_seqno_vec(u_int32_t vec) {
+	inline void gen_seqvec(u_int32_t vec) {
 		int hseq = get_head_pos(vec) + aoa_;	// ackvec head seqno
-		int cnt = hseq - aoa_;
+		int cnt = hseq - aoa_;	// number of packets in ackvec
+		int offset = 0;		// if the bit is zero, then increment 
 		
 		for (int i = 0; i < cnt; i++) {
-			seqvec_[i%SSZ]	 = hseq - i;
+			if( CHECK_BIT_AT(vec, (cnt-i)) )
+				seqvec_[(i-offset)%SSZ] = hseq - i;
+			else
+				offset++;
 		}
 	}
 	// ackofack
@@ -160,16 +168,16 @@
 	void update_rtt(double tao);
 
 	// detect packet loss
-	bool detect_loss(u_int32_t*, u_int16_t, u_int16_t);
+	bool detect_loss(u_int16_t, u_int16_t);
 
 	// control congestion window
-	void control(u_int32_t* seqvec);
+	void control();
 
 	// calcuate average loss interval
 	void avg_loss_interval();
 
 	// calculate loss history
-	void loss_history(u_int32_t* seqvec);
+	void loss_history();
 
 	// estimate loss history and loss probability
 	void pseudo_p();
@@ -181,14 +189,15 @@
 	// dupack action
 	void dupack_action();
 
-	u_int16_t lastest_ack_;	// lastest seqno from ackvec
-	u_int32_t *seqvec_;		// generated seqno vec
-	double *tsvec_;	// timestamp vector
 	int ndtp_;		// number of data packet sent
 	int nakp_;		// number of ackvec packet received
 	int ntep_;		// number of ts echo packet received
 	int nsve_;		// number of seqvec element
 	int epoch_;		// communication epoch
+
+	u_int32_t *seqvec_;		// generated seqno vec
+	double *tsvec_;			// timestamp vector
+	u_int16_t just_acked_;	// just acked seqno (head of ackvec)
 	bool is_loss_;
 	bool is_first_loss_seen_;
 	bool is_tfwc_on_;
@@ -206,6 +215,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_;
 
 	// RTT related variables
 	double srtt_;	// smoothed RTT

Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp	(original)
+++ vic/branches/cc/rtp/session.cpp	Mon Aug 18 01:30:33 2008
@@ -1203,6 +1203,9 @@
 			// this XR conveys ts echo, hence parse it
 			tfwc_sndr_recv(flags, 0, ts_echo_);
 		}
+
+		// we need to call Transmitter::output(pb) here
+		//output(pb);
 	}
 }
 



More information about the Sumover-dev mailing list