[Sumover-dev] [svn commit] r4659 - vic/branches/cc/cc
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Tue Mar 2 00:52:36 GMT 2010
Author: soohyunc
Date: Tue Mar 2 00:52:36 2010
New Revision: 4659
Modified:
vic/branches/cc/cc/tfwc_sndr.cpp
vic/branches/cc/cc/tfwc_sndr.h
Log:
-- completed TFWC RTO calculation mechanism
-- TFWC will go into timer-out driven mode
when computed cwnd is less than 2
-- during timer-driven mode,
call Transmitter::cc_tfwc_output() directly when timer expires
Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp (original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp Tue Mar 2 00:52:36 2010
@@ -118,7 +118,12 @@
I_tot1_ = 0.0;
tot_weight_ = 0.0;
- timer_driven_ = false;
+ to_driven_ = false;
+ tcp_tick_ = 0.01;
+ srtt_init_ = 12;
+ rttvar_exp_ = 2;
+ t_srtt_ = int(srtt_init_/tcp_tick_) << T_SRTT_BITS;
+ t_rttvar_ = int(rttvar_init_/tcp_tick_) << T_RTTVAR_BITS;
}
void TfwcSndr::tfwc_sndr_send(int seqno, double now, double offset) {
@@ -222,6 +227,10 @@
fprintf(stderr, "\t<< now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
+ // is TFWC being driven by timeout mechanism?
+ if(to_driven_ && is_tfwc_on_)
+ new_rto(tao_);
+
// initialize variables for the next pkt reception
free(ackv_);
init_var();
@@ -334,6 +343,35 @@
* update RTT using the sampled RTT value
*/
void TfwcSndr::update_rtt(double rtt_sample) {
+ // calculate t0_
+ t_rtt_ = int(rtt_sample/tcp_tick_ + .5);
+ if(t_rtt_ == 0) t_rtt_ = 1;
+
+ if(t_srtt_ != 0) {
+ register short rtt_delta;
+ rtt_delta = t_rtt_ - (t_srtt_ >> T_SRTT_BITS);
+
+ if ((t_srtt_ += rtt_delta) <= 0)
+ t_srtt_ = 1;
+
+ if (rtt_delta < 0)
+ rtt_delta = -rtt_delta;
+
+ rtt_delta -= (t_rttvar_ >> T_RTTVAR_BITS);
+ if((t_rttvar_ += rtt_delta) <= 0)
+ t_rttvar_ = 1;
+ }
+ else {
+ t_srtt_ = t_rtt_ << T_SRTT_BITS;
+ t_rttvar_ = t_rtt_ << (T_RTTVAR_BITS-1);
+ }
+
+ // finally, t0_ = (smoothed RTT) + 4 * (rtt variance)
+ t0_ = (((t_rttvar_ << (rttvar_exp_ + (T_SRTT_BITS - T_RTTVAR_BITS)))
+ + t_srtt_) >> T_SRTT_BITS ) * tcp_tick_;
+
+ if (t0_ < minrto_)
+ t0_ = minrto_;
// calculate smoothed RTT
if (srtt_ < 0) {
@@ -348,10 +386,12 @@
}
// update the current RTO
- if (k_ * rttvar_ > g_)
+ if(!to_driven_) {
+ if (k_ * rttvar_ > g_)
rto_ = srtt_ + k_ * rttvar_;
- else
+ else
rto_ = srtt_ + g_;
+ }
// 'rto' could be rounded by 'maxrto'
if (rto_ > maxrto_)
@@ -376,10 +416,15 @@
f_p_ = term1 + term2;
// TFWC congestion window
- t_win_ = 1 / f_p_;
-
+ t_win_ = 1. / f_p_;
cwnd_ = (int) (t_win_ + .5);
+ // timeout driven when cwnd is less than 2
+ if (t_win_ < 2.)
+ to_driven_ = true;
+ else
+ to_driven_ = false;
+
// cwnd should always be greater than 1
if (cwnd_ < 1)
cwnd_ = 1;
@@ -586,12 +631,17 @@
*/
void TfwcSndr::expire(int option) {
if (option == TFWC_TIMER_RTX) {
- if(!timer_driven_)
+ if(!to_driven_)
reset_rtx_timer(1);
else
reset_rtx_timer(0);
- // TBA - need to add send method here
+ // artificially inflate the latest ack
+ if(!to_driven_)
+ jacked_++;
+
+ // trigger packet sending
+ tx_->cc_tfwc_output();
}
}
@@ -623,3 +673,19 @@
// resched() is basically msched(miliseconds)
rtx_timer_ -> resched(rto_ * 1000.);
}
+
+/*
+ * new RTO calculation
+ */
+void TfwcSndr::new_rto(double rtt) {
+ double tmp1 = 3. * sqrt(p_ * 3./8.);
+ double tmp2 = t0_ * p_ * (1. + 32. * pow(p_, 2.));
+
+ if(tmp1 > 1.)
+ tmp1 = 1.;
+
+ double term1 = rtt * sqrt(p_ * 2./3.);
+ double term2 = tmp1 * tmp2;
+
+ rto_ = (term1 + term2) * sqrt(rtt)/sqrtrtt_;
+}
Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h (original)
+++ vic/branches/cc/cc/tfwc_sndr.h Tue Mar 2 00:52:36 2010
@@ -49,8 +49,8 @@
#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
+#define T_RTTVAR_BITS 2
+#define T_SRTT_BITS 3
#define BITLEN 16
@@ -59,6 +59,7 @@
#define TFWC_TIMER_RESET 1
class TfwcSndr;
+class Transmitter;
// re-transmission timer
class TfwcRtxTimer : public CcTimerHandler {
@@ -190,6 +191,8 @@
double so_recv_; // SO_TIMESTAMP (XR packet reception)
double tao_; // sampled RTT
+ Transmitter *tx_;
+
private:
// update RTT
void update_rtt(double tao);
@@ -219,6 +222,9 @@
// dupack action
void dupack_action();
+ // new RTO
+ void new_rto(double rtt);
+
// AckVec clone from Vic
inline void clone_ackv(u_int16_t *c, int n) {
for (int i = 0; i < n; i++)
@@ -282,7 +288,7 @@
double I_tot1_; // form 1 to n
double tot_weight_; // total weight
int hsz_; // current history size
- bool timer_driven_; // is TFWC being driven by timer-out?
+ bool to_driven_; // is TFWC being driven by timer-out?
// RTT related variables
double srtt_; // smoothed RTT
@@ -290,11 +296,6 @@
double rto_; // retransmission timeout
double minrto_; // min RTO allowed
double maxrto_; // max RTO
- double alpha_; // smoothing factor for RTT/RTO calculation
- double beta_; // smoothing factor for RTT/RTO calculation
- double g_; // timer granularity
- int k_; // k value
- double t0_; // t0 value at TCP throughput equation
double df_; // decay factor
double sqrtrtt_; // the mean of the sqrt of RTT
@@ -306,6 +307,20 @@
u_int16_t ends_; // end seqno + 1 that this XR chunk reports
int num_elm_; // number of ackvec elements
int num_vec_; // numver of ackvec chunks
+
+ // TCP's RTO calculation
+ double alpha_; // smoothing factor for RTT/RTO calculation
+ double beta_; // smoothing factor for RTT/RTO calculation
+ double g_; // timer granularity
+ int k_; // k value
+ int t_rtt_; // RTT
+ int t_rttvar_; // RTT variance
+ int t_srtt_; // smoothed RTT
+ int srtt_init_; // initial val for t_srtt_
+ int rttvar_init_; // initial val for t_rttvar_
+ int rttvar_exp_; // exponent of multiple for t0_
+ double t0_; // t0 value at TCP throughput equation
+ double tcp_tick_;
};
#endif
More information about the Sumover-dev
mailing list