Changeset 4753
- Timestamp:
- 03/31/10 20:40:15 (3 years ago)
- Location:
- vic/branches/cc/cc
- Files:
-
- 2 modified
-
tfwc_sndr.cpp (modified) (12 diffs)
-
tfwc_sndr.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vic/branches/cc/cc/tfwc_sndr.cpp
r4752 r4753 64 64 rtx_timer_(this), 65 65 aoa_(0), 66 t_now_(0),67 t_ts_(0),68 t_ts_echo_(0),69 66 now_(0), 70 67 so_recv_(0), … … 134 131 clear_pvec(num_vec_); 135 132 __jacked_ = 0; 133 // previous average loss intervals 134 prev_interval_ = (double *)malloc(sizeof(double) * RSZ); 135 clear_prev_interval(RSZ); 136 new_hist_seqno_ = (u_int16_t *)malloc(sizeof(u_int16_t) * RSZ); 137 clear_new_hist_seqno(RSZ); 138 new_hist_seqno_size_ = 0; 136 139 137 140 // packet reordering … … 187 190 bool outofack = false; 188 191 UNUSED(outofack); 192 // revert to the previous history? 193 bool revert = false; 189 194 190 195 // get start/end seqno that this XR chunk reports … … 234 239 // trigger packets out to keep Jacob's packet conservation rule 235 240 if(shift >= DUPACKS) 236 packet_clocking(pb, recv_by_ch); 241 revert = revert_interval(jacked_); 242 cwnd_in_packets(revert); 243 print_cwnd(); 237 244 return; 238 245 } … … 293 300 // triggering only if the disorder is beyond 3 dupack rule, 294 301 if (shift >= DUPACKS) 295 packet_clocking(pb, recv_by_ch); 302 revert = revert_interval(jacked_); 303 cwnd_in_packets(revert); 304 print_cwnd(); 296 305 reset_var(); 297 306 return; … … 301 310 if(!is_tfwc_on_) { 302 311 if(detect_loss()) 303 dupack_action( );312 dupack_action(first_lost_pkt_); 304 313 else 305 314 cwnd_++; // TCP-like AIMD … … 307 316 // TFWC is turned on, so compute congestion window 308 317 else { 309 cwnd_in_packets( );318 cwnd_in_packets(revert); 310 319 } 311 320 print_cwnd(); … … 533 542 * (cwnd is in packets) 534 543 */ 535 void TfwcSndr::cwnd_in_packets() { 544 void TfwcSndr::cwnd_in_packets(bool revert) { 545 if(!revert) { 536 546 loss_history(); 537 547 avg_loss_interval(); 548 } 538 549 539 550 // loss event rate (p) … … 614 625 * o marking pseudo loss history and loss rate 615 626 */ 616 void TfwcSndr::dupack_action( ) {627 void TfwcSndr::dupack_action(int seqno) { 617 628 // this is the very first packet loss 618 629 is_first_loss_seen_ = true; … … 636 647 637 648 // finally, record the very first lost packet's timestamp 638 ts_ = tsvec_[ first_lost_pkt_%TSZ];649 ts_ = tsvec_[seqno%TSZ]; 639 650 // then, turn on TFWC algo 640 651 is_tfwc_on_ = true; … … 699 710 // this is a new loss event! 700 711 712 // store previous ALI before changing history 713 record_history(refvec_[i], avg_interval_, ts_); 714 701 715 // increase current history size 702 716 hsz_ = (hsz_ < HSZ) ? ++hsz_ : HSZ; … … 757 771 758 772 /* 773 * store loss interval and timestamp 774 */ 775 void TfwcSndr::record_history(int seqno, double interval, double ts) { 776 // store seqno 777 new_hist_seqno_[new_hist_seqno_size_++] = seqno; 778 // store average loss interval 779 prev_interval_[seqno%RSZ] = interval; 780 // store timestamp 781 prev_ts_ = ts; 782 // copy history 783 for(int i = 0; i < hsz_; i++) 784 prev_history_[i] = history_[i]; 785 } 786 787 /* 788 * revert average loss interval on packet re-ordering 789 */ 790 bool TfwcSndr::revert_interval(int reseq) { 791 // we didn't see the first lost packet yet. 792 if(!is_first_loss_seen_) { 793 dupack_action(reseq); 794 return (false); 795 } 796 797 // check if this re-ordered seqno actually triggered a new loss event 798 // if yes, revert to the previous state 799 if(find_seqno(new_hist_seqno_, new_hist_seqno_size_, reseq)) { 800 // reverting to the previous ALI 801 avg_interval_ = prev_interval_[reseq%RSZ]; 802 // reverting to the previous timestamp 803 ts_ = prev_ts_; 804 // reverting to the previous history 805 for (int i = 0; i < hsz_; i++) 806 history_[i] = prev_history_[i]; 807 808 print_ALI(); 809 810 // finally, clear up the state variables 811 clear_prev_interval(RSZ); 812 clear_new_hist_seqno(new_hist_seqno_size_); 813 return (true); 814 } 815 return (false); 816 } 817 818 /* 819 * find seqno in the array 820 */ 821 bool TfwcSndr::find_seqno (u_int16_t *v, int n, int target) { 822 for (int i = 0; i < n; i++) { 823 if (v[i] == target) 824 return true; 825 } 826 return false; 827 } 828 829 /* 759 830 * print history item 760 831 */ -
vic/branches/cc/cc/tfwc_sndr.h
r4752 r4753 187 187 u_int16_t *pvec_; // previous (stored) AckVec 188 188 u_int16_t aoa_; // ack of ack 189 u_int32_t t_now_; // the time when the data packet sent190 u_int32_t t_ts_; // time stamp (u_int32_t type)191 u_int32_t t_ts_echo_; // echo time stamp from the receiver192 189 double ts_; // time stamp (double type) 193 190 double ts_echo_; // time stamp echo (double type) … … 195 192 double so_recv_; // SO_TIMESTAMP (XR packet reception) 196 193 double tao_; // sampled RTT 194 double prev_ts_; 197 195 198 196 private: … … 206 204 // TFWC congestion window 207 205 void cwnd_in_bytes(); 208 void cwnd_in_packets( );206 void cwnd_in_packets(bool revert); 209 207 210 208 // calcuate average loss interval … … 212 210 void print_history_item (int); 213 211 void print_history_item (int, int); 212 bool revert_interval(int reseq); 213 void record_history(int seqno, double interval, double ts); 214 214 215 215 // calculate loss history … … 224 224 225 225 // dupack action 226 void dupack_action( );226 void dupack_action(int seqno); 227 227 228 228 // new RTO … … 283 283 } 284 284 285 // clear seqno that triggered a new loss event 286 inline void clear_prev_interval (int n) { 287 for (int i = 0; i < n; i++) 288 prev_interval_[i] = 0; 289 } 290 291 // clear seqno that triggered a new loss event 292 inline void clear_new_hist_seqno (int n) { 293 for (int i = 0; i < n; i++) 294 new_hist_seqno_[i] = 0; 295 new_hist_seqno_size_ = 0; 296 } 297 285 298 // number of ackvec chunks 286 299 inline int get_numvec(int n) { … … 302 315 __jacked_ = highest; 303 316 } 317 318 // find seqno 319 bool find_seqno(u_int16_t *v, int n, int target); 304 320 305 321 // print cwnd for debugging … … 344 360 345 361 double ts_off_; // timestamp offset for gettimeofday 346 u_int32_t ref_t_time_; // reference time (uint32 format)347 362 348 363 u_int32_t *seqvec_; // generated seqno vec … … 360 375 double avg_interval_; // average loss interval 361 376 int history_[HSZ+1]; // loss interval history 377 int prev_history_[HSZ];// previous loss interval history 362 378 double weight_[HSZ+1]; // weight for calculating avg loss interval 363 379 double I_tot_; // total sum … … 404 420 // highest/lowest packet sequence numbers (prev ackvec) 405 421 u_int16_t __jacked_; // previous highest packet sequence number 422 double *prev_interval_; // previous avgerage intervals 423 u_int16_t *new_hist_seqno_; // seqno that introduced a new loss event 424 int new_hist_seqno_size_; 406 425 407 426 // record of packet size in bytes
