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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Mar 31 18:23:30 BST 2010


Author: soohyunc
Date: Wed Mar 31 18:23:30 2010
New Revision: 4752

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

Log:
-- trim unnecessary code
-- prepare cwnd computation in bytes



Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Wed Mar 31 18:23:30 2010
@@ -72,7 +72,6 @@
 	nakp_(0),
 	ntep_(0),
 	nsve_(0),
-	epoch_(1),
 	jacked_(0),
 	begins_(0),
 	ends_(0),
@@ -137,6 +136,10 @@
 
 	// packet reordering
 	reorder_ = false;
+
+	// record of packet size in bytes
+	record_ = (u_int16_t *)malloc(sizeof(u_int16_t) * RECORD);
+	clear_record(RECORD);
 }
 
 void TfwcSndr::tfwc_sndr_send(pktbuf* pb, double now) {
@@ -144,6 +147,8 @@
 	if(seqno_ == 0)
 	ts_off_ = tx_ts_offset();
 
+	// number of bytes for this packet
+	record_[seqno_%RECORD] = pb->len;
 	// parse seqno and mark timestamp for this data packet
 	rtphdr* rh = (rtphdr *) pb->data;
 	seqno_	= ntohs(rh->rh_seqno);
@@ -299,9 +304,9 @@
 		else
 		cwnd_++; // TCP-like AIMD
 	} 
-	// TFWC is turned on, so control that way
+	// TFWC is turned on, so compute congestion window
 	else {
-		control();
+		cwnd_in_packets();
 	}
 	print_cwnd();
 
@@ -525,8 +530,9 @@
 
 /*
  * core part for congestion window control
+ * (cwnd is in packets)
  */
-void TfwcSndr::control() {
+void TfwcSndr::cwnd_in_packets() {
 	loss_history();
 	avg_loss_interval();
 
@@ -556,6 +562,13 @@
 }
 
 /*
+ * core part for congestion window control
+ * (cwnd is in bytes)
+ */
+void cwnd_in_packets() {
+}
+
+/*
  * generate weighting factors
  */
 void TfwcSndr::gen_weight() {
@@ -581,8 +594,8 @@
 /*
  * compute packet loss history
  */
-void TfwcSndr::pseudo_history() {
-	pseudo_interval_ = 1 / p_;
+void TfwcSndr::pseudo_history(double p) {
+	double pseudo = 1 / p;
 
 	/* bzero for all history information */
 	for(int i = 0; i <= HSZ+1; i++)
@@ -592,7 +605,7 @@
 	history_[0] = 0;
 
 	/* (let) the pseudo interval be the first history information */
-	history_[1] = (int) pseudo_interval_;
+	history_[1] = pseudo;
 }
 
 /*
@@ -614,12 +627,9 @@
 	if (cwnd_ < 1)
 		cwnd_ = 1;
 
-	// temp cwnd to compute the pseudo values
-	tmp_cwnd_ = cwnd_;
-
 	// creating simulated loss history and loss rate
-	pseudo_p();
-	pseudo_history();
+	p_ = pseudo_p(cwnd_);
+	pseudo_history(p_);
 
 	// generate weight factors
 	gen_weight();
@@ -633,17 +643,19 @@
 /*
  * compute simulated loss rate
  */
-void TfwcSndr::pseudo_p() {
-	for (pseudo_p_ = 0.00001; pseudo_p_ < 1.0; pseudo_p_ += 0.00001) {
-		f_p_ = sqrt((2.0/3.0) * pseudo_p_) + 12.0 * pseudo_p_ *
-			(1.0 + 32.0 * pow(pseudo_p_, 2.0)) * sqrt((3.0/8.0) * pseudo_p_);
+double TfwcSndr::pseudo_p(int cwnd) {
+	double pseudo;
+	for (pseudo = 0.00001; pseudo < 1.0; pseudo += 0.00001) {
+	f_p_ = sqrt((2.0/3.0) * pseudo) + 12.0 * pseudo *
+	(1.0 + 32.0 * pow(pseudo, 2.0)) * sqrt((3.0/8.0) * pseudo);
 
-		t_win_ = 1 / f_p_;
+	t_win_ = 1 / f_p_;
 
-		if(t_win_ < tmp_cwnd_)
-			break;
+	if(t_win_ < cwnd)
+		break;
 	}
-	p_ = pseudo_p_;
+
+	return (pseudo);
 }
 
 /*

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Wed Mar 31 18:23:30 2010
@@ -41,6 +41,7 @@
 #define TSZ	1000	// tsvec_ size
 #define SSZ 1000	// seqvec_ size
 #define RSZ 1000	// refvec_ size
+#define RECORD 10000
 
 #define SHORT_HISTORY		// history size = 8
 #ifdef  SHORT_HISTORY
@@ -111,9 +112,6 @@
 	// return the current time
 	inline double now() { return (tfwc_sndr_now()-ts_off_); }
 
-	// return timestamp in u_int32_t type
-	inline u_int32_t tfwc_sndr_get_ts() { return t_now_; }
-
 	// variables
 	u_int16_t seqno_;	// packet sequence number
 	u_int32_t cwnd_;	// congestion window
@@ -121,10 +119,6 @@
 	// Rtx timer
 	void expire(int option);
 
-	// packet reordering
-	bool reorder_;
-	inline bool reordering() { return (reorder_); }
-
 protected:
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
@@ -201,8 +195,6 @@
 	double so_recv_;	// SO_TIMESTAMP (XR packet reception)
 	double tao_;		// sampled RTT
 
-	Transmitter *tx_;
-
 private:
 	// update RTT
 	void update_rtt(double tao);
@@ -211,8 +203,9 @@
 	// (to capture the very first lost packet loss)
 	bool detect_loss();
 
-	// control congestion window
-	void control();
+	// TFWC congestion window
+	void cwnd_in_bytes();
+	void cwnd_in_packets();
 
 	// calcuate average loss interval
 	void avg_loss_interval();
@@ -223,8 +216,8 @@
 	void loss_history();
 
 	// estimate loss history and loss probability
-	void pseudo_p();
-	void pseudo_history();
+	double pseudo_p(int cwnd);
+	void pseudo_history(double p);
 
 	// generate weight factors
 	void gen_weight();
@@ -271,7 +264,7 @@
 		ackv_[i] = 0;
 	}
 
-	// clear ackvec
+	// clear previous ackvec
 	inline void clear_pvec (int n) {
 		for (int i = 0; i < n; i++)
 		pvec_[i] = 0;
@@ -283,6 +276,12 @@
 		refvec_[i] = 0;
 	}
 
+	// clear record for packet size in bytes
+	inline void clear_record (int n) {
+		for (int i = 0; i < n; i++)
+		record_[i] = 0;
+	}
+
 	// number of ackvec chunks
 	inline int get_numvec(int n) {
 	return (n/BITLEN + (n%BITLEN > 0));	
@@ -342,9 +341,7 @@
 	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
 
-	bool is_running_;	// is TFWC running? 
 	double ts_off_;		// timestamp offset for gettimeofday
 	u_int32_t ref_t_time_;	// reference time (uint32 format)
 
@@ -360,9 +357,6 @@
 	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
-	int tmp_cwnd_;      // temporary cwnd value
-	double pseudo_p_;	// faked packet loss probability
-	double pseudo_interval_;// faked loss interval
 	double avg_interval_;	// average loss interval
 	int history_[HSZ+1];	// loss interval history
 	double weight_[HSZ+1];	// weight for calculating avg loss interval
@@ -405,8 +399,13 @@
 	double t0_;		// t0 value at TCP throughput equation
 	double tcp_tick_;
 
+	// packet reordering
+	bool reorder_;
 	// highest/lowest packet sequence numbers (prev ackvec)
 	u_int16_t __jacked_;	// previous highest packet sequence number
+
+	// record of packet size in bytes
+	u_int16_t *record_;
 };
 
 #endif



More information about the Sumover-dev mailing list