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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Thu Jun 10 16:34:11 BST 2010


Author: soohyunc
Date: Thu Jun 10 16:34:11 2010
New Revision: 4859

Modified:
   vic/branches/cc/cc/cc_timer.cpp
   vic/branches/cc/cc/cc_timer.h
   vic/branches/cc/cc/tfrc_rcvr.h
   vic/branches/cc/cc/tfrc_sndr.cpp
   vic/branches/cc/cc/tfrc_sndr.h
   vic/branches/cc/cc/tfwc_rcvr.h
   vic/branches/cc/cc/tfwc_sndr.cpp
   vic/branches/cc/cc/tfwc_sndr.h
   vic/branches/cc/rtp/transmitter.cpp
   vic/branches/cc/rtp/transmitter.h

Log:

*** finished TFRC/TFWC Retransmission Timer Mechanisms ***

min RTO - 200 ms (most Linux TCP implementation)
max RTO = 60 sec (RFC 2988)


Also, TfwcSndr and TfrcSndr can directly call functions defined in Transmitter.
This is specially usefule when TfwcSndr/TfrcSndr want to call
Transmitter::output() method directly.




Modified: vic/branches/cc/cc/cc_timer.cpp
==============================================================================
--- vic/branches/cc/cc/cc_timer.cpp	(original)
+++ vic/branches/cc/cc/cc_timer.cpp	Thu Jun 10 16:34:11 2010
@@ -40,23 +40,22 @@
 		abort();
 
 	msched((int)delay);
-	//status_ = TIMER_HANDLING;
-	set_timer_pending();
+	set_timer_handling();
 }
 
 void CcTimerHandler::resched(double delay) {
 	if (status_ == TIMER_PENDING)
 		return;
 
+	cancel();
 	msched((int)delay);
-	//status_ = TIMER_HANDLING;
-	set_timer_pending();
+	set_timer_handling();
 }
 
-void CcTimerHandler::cancel() {
-	if (status_ != TIMER_PENDING)
+void CcTimerHandler::stop() {
+	if (status_ != TIMER_HANDLING)
 		abort();
 
-	//status_ = TIMER_IDLE;
+	cancel();
 	set_timer_idle();
 }

Modified: vic/branches/cc/cc/cc_timer.h
==============================================================================
--- vic/branches/cc/cc/cc_timer.h	(original)
+++ vic/branches/cc/cc/cc_timer.h	Thu Jun 10 16:34:11 2010
@@ -34,8 +34,13 @@
 #ifndef vic_cc_timer_h
 #define vic_cc_timer_h
 
+#include <sys/time.h>
 #include "timer.h"
 
+// timer related
+#define CC_TIMER_RTX    0
+#define CC_TIMER_RESET  1
+
 class CcTimerHandler : public Timer {
 public:
 	CcTimerHandler() : status_(TIMER_IDLE) {}
@@ -43,13 +48,20 @@
 	virtual void timeout() = 0;
 	void sched(double delay);
 	void resched(double delay);
-	void cancel();
+	void stop();
 	enum CcTimerStatus {TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING};
 	inline int status() { return status_; };
 	inline void set_timer_idle() { status_ = TIMER_IDLE; };
 	inline void set_timer_pending() { status_ = TIMER_PENDING; };
 	inline void set_timer_handling() { status_ = TIMER_HANDLING; };
 
+    // gettimeofday
+    inline double cc_now() {
+        timeval tv;
+        ::gettimeofday(&tv, NULL);
+        return ((double) tv.tv_sec + 1e-6 * (double) tv.tv_usec);
+    }
+
 protected:
 	int status_;
 

Modified: vic/branches/cc/cc/tfrc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfrc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfrc_rcvr.h	Thu Jun 10 16:34:11 2010
@@ -57,10 +57,13 @@
 
 	// TfrcRcvr instance
 	static inline TfrcRcvr& instance() { return instance_; }
+	// Transmitter 
+	inline void manager(Transmitter* tm) { tm_ = tm; }
 
 protected:
 
 	static TfrcRcvr instance_;
+	Transmitter *tm_;
 
 	/*
 	 * Variables

Modified: vic/branches/cc/cc/tfrc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfrc_sndr.cpp	Thu Jun 10 16:34:11 2010
@@ -52,6 +52,14 @@
 #define INIT_RATE MAX_RTP
 
 /*
+ * retransmission timer
+ */
+void TfrcSndr::timeout() {
+    if((now() - set_time_) > rto_)
+    expire(CC_TIMER_RTX);
+}
+
+/*
  * TFRC Sender Constructor
  */
 TfrcSndr::TfrcSndr() :
@@ -83,8 +91,8 @@
 	num_refvec_ = 0;
 
 	// initialize variables
-	minrto_ = 0.0;
-	maxrto_ = 100000.0;
+	minrto_ = 0.2;	// Linux TCP implementation
+	maxrto_ = 60.0;	// RFC 2988
 	srtt_ = -1.0;
 	rto_ = 3.0;     // RFC 1122
 	rttvar_ = 0.0;
@@ -96,6 +104,7 @@
 	g_ = 0.01;
 	k_ = 4;
 	ts_ = 0.0;
+	set_time_ = 0.0;
 
 	is_tfrc_on_ = false;
 	is_first_loss_seen_ = false;
@@ -130,7 +139,7 @@
 void TfrcSndr::send(pktbuf* pb, double now) {
 	// the very first data packet
 	if(seqno_ == 0)
-	ts_off_ = tx_ts_offset();
+	ts_off_ = tm_->tx_ts_offset();
 
 	// parse seqno and mark timestamp for this data packet
 	rtphdr* rh = (rtphdr *) pb->data;
@@ -526,9 +535,11 @@
 		sqrtrtt_ = df_ * sqrtrtt_ + (1 - df_) * sqrt(rtt_sample);
 	}
 
-	// 'rto' could be rounded by 'maxrto'
+	// 'rto' could be rounded by "min/maxrto"
 	if (rto_ > maxrto_)
 		rto_ = maxrto_;
+	if (rto_ < minrto_)
+		rto_ = minrto_;
 
 	print_rtt_info();
 }
@@ -656,3 +667,46 @@
 	if (j < hsz_ - 1) fprintf(stderr, ", ");
 }
 
+/*
+ * retransmission timer-out
+ */
+void TfrcSndr::expire(int option) {
+	if (option == CC_TIMER_RTX) {
+		// reset timer
+		reset_rtx_timer(1);
+		// send packets
+		tm_->tfrc_output();
+	}
+}
+
+void TfrcSndr::reset_rtx_timer (int backoff) {
+	if(backoff)
+	backoff_timer();
+
+	set_rtx_timer();
+}
+
+/*
+ * backoff Rtx Timer
+ */
+void TfrcSndr::backoff_timer() {
+	if (srtt_ < 0) srtt_ = 1.0;
+	rto_ = 2.0 * rto_;
+
+	if (rto_ > maxrto_)
+		rto_ = maxrto_;
+	if (rto_ < minrto_)
+		rto_ = minrto_;
+}
+
+/*
+ * set Rtx Timer
+ */
+void TfrcSndr::set_rtx_timer() {
+	//print_rto_info();
+	
+	// mark time when setting timer
+	set_time_ = now_;
+	// resched() is basically msched(miliseconds)
+	resched(rto_ * 1000.);
+}

Modified: vic/branches/cc/cc/tfrc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.h	(original)
+++ vic/branches/cc/cc/tfrc_sndr.h	Thu Jun 10 16:34:11 2010
@@ -42,17 +42,14 @@
 class TfrcSndr;
 
 // TFRC sender class
-class TfrcSndr {
+class TfrcSndr : public CcTimerHandler {
 public:
 	// constructor
 	TfrcSndr();
 	virtual ~TfrcSndr() {};
 
 	// virtual functions
-	virtual void tfrc_output(bool ack_clock=0) {UNUSED(ack_clock);};
-	virtual void tfrc_output(pktbuf*) {};
-	virtual double tx_ts_offset() {};
-	virtual int tx_buf_size() {};
+	virtual void timeout();
 
 	// parse seqno and timestamp
 	void send(pktbuf*, double);
@@ -71,12 +68,19 @@
 	u_int16_t seqno_;	// packet sequence number
 	double x_rate_;		// send rate (bytes/sec)
 
+	// Rtx timer
+	void expire(int option);
+
 	// TfrcSndr instance
 	static inline TfrcSndr& instance() { return instance_; }
 
+    // Transmitter 
+	inline void manager(Transmitter* tm) { tm_ = tm; }
+
 protected:
 
 	static TfrcSndr instance_;
+	Transmitter *tm_;
 
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
@@ -85,12 +89,20 @@
 	// reset variables
 	void reset_var(bool reverted);
 
+    // return the current time
+	inline double now() { return (cc_now()-ts_off_); }
+
+	void set_rtx_timer();
+	void reset_rtx_timer(int backoff);
+	void backoff_timer();
+
 	u_int16_t *ackv_;	// received AckVec
 	u_int16_t aoa_;	// ack of ack
 	double ts_;			// timestamp
 	double now_;		// real-time now
 	double so_recv_;	// SO_TIMESTAMP
 	double tao_;		// sampled RTT
+	double set_time_;	// set time for rtx_timer
 
 	// packet size
 	int asize_;		// average packet size per frame

Modified: vic/branches/cc/cc/tfwc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.h	Thu Jun 10 16:34:11 2010
@@ -61,9 +61,13 @@
 	// TfwcRcvr instance
 	static inline TfwcRcvr& instance() { return instance_; }
 
+    // Transmitter 
+	inline void manager(Transmitter* tm) { tm_ = tm; }
+
 protected:
 
 	static TfwcRcvr instance_;
+	Transmitter *tm_;
 
 	/*
 	 * Variables

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Thu Jun 10 16:34:11 2010
@@ -43,17 +43,17 @@
 #include "transmitter.h"
 #include "tfwc_sndr.h"
 
+// TfwcSndr instance
+TfwcSndr TfwcSndr::instance_;
+
 /*
  * retransmission timer
  */
-void TfwcRtxTimer::timeout() {
-	debug_msg("\t*------ TIMEOUT! ------*\n");
-	s_ -> expire(TFWC_TIMER_RTX);
+void TfwcSndr::timeout() {
+	if((now() - set_time_) > rto_)
+	expire(CC_TIMER_RTX);
 }
 
-// TfwcSndr instance
-TfwcSndr TfwcSndr::instance_;
-
 /* 
  * TFWC sender definition
  */
@@ -61,7 +61,6 @@
 	seqno_(0),
 	cwnd_(1),		// initial cwnd in packet
 	bcwnd_(MAX_RTP),// initial cwnd in byte
-	rtx_timer_(this),
 	aoa_(0),
 	now_(0),
 	so_recv_(0),
@@ -94,8 +93,8 @@
 	for (int i = 0; i < DUPACKS; i++)
 		mvec_[i] = 0;
 
-	minrto_ = 0.0;
-	maxrto_ = 100000.0;
+	minrto_ = 0.2;	// Linux TCP implementation
+	maxrto_ = 60.0;	// RFC 2988
 	srtt_ = -1.0;
 	rto_ = 3.0;		// RFC 1122
 	rttvar_ = 0.0;
@@ -108,6 +107,7 @@
 	k_ = 4;
 	ts_ = 0.0;
 	ts_echo_ = 0.0;
+	set_time_ = 0.0;
 
 	is_tfwc_on_ = false;
 	is_first_loss_seen_ = false;
@@ -153,8 +153,8 @@
 
 void TfwcSndr::send(pktbuf* pb, double now) {
 	// the very first data packet
-	if(seqno_ == 0)
-	ts_off_ = tx_ts_offset();
+	if(seqno_ < 1)
+	ts_off_ = tm_->tx_ts_offset();
 
 	// parse seqno and mark timestamp for this data packet
 	rtphdr* rh = (rtphdr *) pb->data;
@@ -580,9 +580,11 @@
 		rto_ = srtt_ + g_;
 	}
 
-	// 'rto' could be rounded by 'maxrto'
+	// 'rto' could be rounded by "min/maxrto"
 	if (rto_ > maxrto_)
 		rto_ = maxrto_;
+	if (rto_ < minrto_)
+		rto_ = minrto_;
 
 	print_rtt_info();
 }
@@ -897,7 +899,7 @@
  * retransmission timer-out
  */
 void TfwcSndr::expire(int option) {
-	if (option == TFWC_TIMER_RTX) {
+	if (option == CC_TIMER_RTX) {
 		if(!to_driven_)
 		reset_rtx_timer(1);
 		else
@@ -908,7 +910,7 @@
 			jacked_++;
 
 		// trigger packet sending
-		tfwc_output();
+		tm_->tfwc_output();
 	}
 }
 
@@ -917,7 +919,7 @@
  */
 void TfwcSndr::reset_rtx_timer (int backoff) {
 	if(backoff)
-		backoff_timer();
+	backoff_timer();
 
 	set_rtx_timer();
 }
@@ -927,18 +929,24 @@
  */
 void TfwcSndr::backoff_timer() {
 	if (srtt_ < 0) srtt_ = 1.0;
-	rto_ = 2.0 * srtt_;
-
+	rto_ = 2.0 * rto_;
+	
 	if (rto_ > maxrto_)
 		rto_ = maxrto_;
+	if (rto_ < minrto_)
+		rto_ = minrto_;
 }
 
 /*
  * set Rtx Timer
  */
 void TfwcSndr::set_rtx_timer() {
+	//print_rto_info();
+
+	// mark time when setting timer
+	set_time_ = now_;
 	// resched() is basically msched(miliseconds)
-	rtx_timer_.resched(rto_ * 1000.);
+	resched(rto_ * 1000.);
 }
 
 /*
@@ -962,7 +970,7 @@
  */
 void TfwcSndr::packet_clocking (pktbuf* pb, bool flag) {
 	if (flag)
-		tfwc_trigger();
+		tm_->tfwc_trigger();
 	else
-		tfwc_trigger(pb);
+		tm_->tfwc_trigger(pb);
 }

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Thu Jun 10 16:34:11 2010
@@ -38,36 +38,20 @@
 #include "bitmap.h"	// bitmap operations
 #include "cc_common.h"
 #include "cc_timer.h"
-
-// timer related
-#define TFWC_TIMER_RTX		0
-#define TFWC_TIMER_RESET	1
+#include "transmitter.h"
 
 class TfwcSndr;
-
-// re-transmission timer
-class TfwcRtxTimer : public CcTimerHandler {
-public:
-	TfwcRtxTimer(TfwcSndr *s) : CcTimerHandler() { s_ = s;}
-	virtual void timeout();
-
-protected:
-	TfwcSndr *s_;
-};
+class Transmitter;
 
 // TFWC sender class
-class TfwcSndr {
+class TfwcSndr : public CcTimerHandler {
 public:
 	// constructor
 	TfwcSndr();
 	virtual ~TfwcSndr() {};
 
 	// virtual functions
-	virtual void tfwc_output(bool ack_clock=0) {UNUSED(ack_clock);};
-	virtual void tfwc_output(pktbuf*, bool) {};
-	virtual void tfwc_trigger(pktbuf* pb=0) {UNUSED(pb);};
-	virtual double tx_ts_offset() {};
-	virtual int tx_buf_size() {};
+	virtual void timeout();
 
 	// parse seqno and timestamp
 	void send(pktbuf*, double);
@@ -87,15 +71,8 @@
 	inline u_int32_t magic() { return cwnd_; }
 	inline int b_magic() { return bcwnd_; }
 
-	// set timestamp in double type (TfwcSndr)
-	inline double tfwc_sndr_now() {
-		timeval tv;
-		::gettimeofday(&tv, NULL);
-		return ((double) tv.tv_sec + 1e-6 * (double) tv.tv_usec);
-	}
-
 	// return the current time
-	inline double now() { return (tfwc_sndr_now()-ts_off_); }
+	inline double now() { return (cc_now()-ts_off_); }
 
 	// variables
 	u_int16_t seqno_;	// packet sequence number
@@ -109,9 +86,13 @@
 	// TfwcSndr instance
 	static inline TfwcSndr& instance() { return instance_; }
 
+	// Transmitter 
+	inline void manager(Transmitter* tm) { tm_ = tm; }
+
 protected:
 
 	static TfwcSndr instance_;
+	Transmitter *tm_;
 
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
@@ -150,9 +131,6 @@
 		0 : (u_int16_t) (mvec_[DUPACKS - 1] - 1);
 	}
 
-	// retransmission timer
-	TfwcRtxTimer rtx_timer_;
-
 	void set_rtx_timer();
 	void reset_rtx_timer(int backoff);
 	void backoff_timer();
@@ -167,6 +145,7 @@
 	double so_recv_;	// SO_TIMESTAMP (XR packet reception)
 	double tao_;		// sampled RTT
 	double prev_ts_;
+	double set_time_;	// set time for rtx_timer
 
 	// packet size
 	int asize_;		// average packet size per frame
@@ -337,6 +316,11 @@
 	"\t%s now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
 	str, so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
 	}
+	// print RTO info
+	inline void print_rto_info() {
+	fprintf(stderr,
+	"\t>> now_: %f rto: %f\n", now(), rto_);
+	}
 
 	// print ALI for debugging
 	inline void print_ALI() {

Modified: vic/branches/cc/rtp/transmitter.cpp
==============================================================================
--- vic/branches/cc/rtp/transmitter.cpp	(original)
+++ vic/branches/cc/rtp/transmitter.cpp	Thu Jun 10 16:34:11 2010
@@ -107,10 +107,18 @@
 	  case WBCC:
 		tfwc_sndr_ = TfwcSndr::instance();
 		tfwc_rcvr_ = TfwcRcvr::instance();
+
+		tfwc_sndr_.manager(this);
+		tfwc_rcvr_.manager(this);
+
 	  break;
 	  case RBCC:
 		tfrc_sndr_ = TfrcSndr::instance();
 		tfrc_rcvr_ = TfrcRcvr::instance();
+
+		tfrc_sndr_.manager(this);
+		tfrc_rcvr_.manager(this);
+
 	  break;
 	}
 	

Modified: vic/branches/cc/rtp/transmitter.h
==============================================================================
--- vic/branches/cc/rtp/transmitter.h	(original)
+++ vic/branches/cc/rtp/transmitter.h	Thu Jun 10 16:34:11 2010
@@ -101,12 +101,12 @@
 	void send(pktbuf*);
 	inline bool is_cc_on() { return is_cc_active_; }
 	// TFWC output
-	virtual void tfwc_output(bool ack_clock=0);
-	virtual void tfwc_output(pktbuf*, bool ack_clock);
-	virtual void tfwc_trigger(pktbuf*);
+	void tfwc_output(bool ack_clock=0);
+	void tfwc_output(pktbuf*, bool ack_clock);
+	void tfwc_trigger(pktbuf* pb=0);
 	// TFRC output
-	virtual void tfrc_output(bool ack_clock=0);
-	virtual void tfrc_output(pktbuf*);
+	void tfrc_output(bool ack_clock=0);
+	void tfrc_output(pktbuf*);
 
 	/*
 	 * Buffer allocation hooks.



More information about the Sumover-dev mailing list