tcp.h
1 /* 2 * Copyright (c) 1991-1997 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the Computer Systems 16 * Engineering Group at Lawrence Berkeley Laboratory. 17 * 4. Neither the name of the University nor of the Laboratory may be used 18 * to endorse or promote products derived from this software without 19 * specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#) $Header: /cvsroot/nsnam/ns-2/tcp/tcp.h,v 1.132 2011/08/26 19:29:57 tom_henderson Exp $ (LBL) 34 */ 35 #ifndef ns_tcp_h 36 #define ns_tcp_h 37 38 #include "agent.h" 39 #include "packet.h" 40 41 //class EventTrace; 42 43 struct hdr_tcp { 44 #define NSA 3 45 double ts_; /* time packet generated (at source) */ 46 double ts_echo_; /* the echoed timestamp (originally sent by 47 the peer) */ 48 int seqno_; /* sequence number */ 49 int reason_; /* reason for a retransmit */ 50 int sack_area_[NSA+1][2]; /* sack blocks: start, end of block */ 51 int sa_length_; /* Indicate the number of SACKs in this * 52 * packet. Adds 2+sack_length*8 bytes */ 53 int ackno_; /* ACK number for FullTcp */ 54 int hlen_; /* header len (bytes) for FullTcp */ 55 int tcp_flags_; /* TCP flags for FullTcp */ 56 int last_rtt_; /* more recent RTT measurement in ms, */ 57 /* for statistics only */ 58 // Advertised Window, Shigeyuki Osada 2012/01/08 59 double wnd_; 60 61 static int offset_; // offset for this header 62 inline static int& offset() { return offset_; } 63 inline static hdr_tcp* access(Packet* p) { 64 return (hdr_tcp*) p->access(offset_); 65 } 66 67 /* per-field member functions */ 68 double& ts() { return (ts_); } 69 double& ts_echo() { return (ts_echo_); } 70 int& seqno() { return (seqno_); } 71 int& reason() { return (reason_); } 72 int& sa_left(int n) { return (sack_area_[n][0]); } 73 int& sa_right(int n) { return (sack_area_[n][1]); } 74 int& sa_length() { return (sa_length_); } 75 int& hlen() { return (hlen_); } 76 int& ackno() { return (ackno_); } 77 int& flags() { return (tcp_flags_); } 78 int& last_rtt() { return (last_rtt_); } 79 double& wnd() {return (wnd_);} // Shigeyuki Osada 80 }; 81 82 /* these are used to mark packets as to why we xmitted them */ 83 #define TCP_REASON_TIMEOUT 0x01 84 #define TCP_REASON_DUPACK 0x02 85 #define TCP_REASON_RBP 0x03 // used only in tcp-rbp.cc 86 #define TCP_REASON_PARTIALACK 0x04 87 88 /* these are reasons we adjusted our congestion window */ 89 90 #define CWND_ACTION_DUPACK 1 // dup acks/fast retransmit 91 #define CWND_ACTION_TIMEOUT 2 // retransmission timeout 92 #define CWND_ACTION_ECN 3 // ECN bit [src quench if supported] 93 #define CWND_ACTION_EXITED 4 // congestion recovery has ended 94 // (when previously CWND_ACTION_DUPACK) 95 96 /* these are bits for how to change the cwnd and ssthresh values */ 97 98 #define CLOSE_SSTHRESH_HALF 0x00000001 99 #define CLOSE_CWND_HALF 0x00000002 100 #define CLOSE_CWND_RESTART 0x00000004 101 #define CLOSE_CWND_INIT 0x00000008 102 #define CLOSE_CWND_ONE 0x00000010 103 #define CLOSE_SSTHRESH_HALVE 0x00000020 104 #define CLOSE_CWND_HALVE 0x00000040 105 #define THREE_QUARTER_SSTHRESH 0x00000080 106 #define CLOSE_CWND_HALF_WAY 0x00000100 107 #define CWND_HALF_WITH_MIN 0x00000200 108 #define TCP_IDLE 0x00000400 109 #define NO_OUTSTANDING_DATA 0x00000800 110 111 /* 112 * tcp_tick_: 113 * default 0.1, 114 * 0.3 for 4.3 BSD, 115 * 0.01 for new window algorithms, 116 */ 117 118 #define NUMDUPACKS 3 /* This is no longer used. The variable */ 119 /* numdupacks_ is used instead. */ 120 #define TCP_MAXSEQ 1073741824 /* Number that curseq_ is set to for */ 121 /* "infinite send" (2^30) */ 122 123 #define TCP_TIMER_RTX 0 124 #define TCP_TIMER_DELSND 1 125 #define TCP_TIMER_BURSTSND 2 126 #define TCP_TIMER_DELACK 3 127 #define TCP_TIMER_Q 4 128 #define TCP_TIMER_RESET 5 129 130 class TcpAgent; 131 132 class RtxTimer : public TimerHandler { 133 public: 134 RtxTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 135 protected: 136 virtual void expire(Event *e); 137 TcpAgent *a_; 138 }; 139 140 class DelSndTimer : public TimerHandler { 141 public: 142 DelSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 143 protected: 144 virtual void expire(Event *e); 145 TcpAgent *a_; 146 }; 147 148 class BurstSndTimer : public TimerHandler { 149 public: 150 BurstSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 151 protected: 152 virtual void expire(Event *e); 153 TcpAgent *a_; 154 }; 155 156 /* 157 * Variables for HighSpeed TCP. 158 */ 159 //int *hs_win_; // array of cwnd values 160 //int *hs_increase_; // array of increase values 161 //double *hs_decrease_; // array of decrease values 162 struct hstcp { 163 double low_p; // low_p 164 double dec1; // for computing the decrease parameter 165 double dec2; // for computing the decrease parameter 166 double p1; // for computing p 167 double p2; // for computing p 168 /* The next three parameters are for CPU overhead, for computing */ 169 /* the HighSpeed parameters less frequently. A better solution */ 170 /* might be just to have a look-up array. */ 171 double cwnd_last_; /* last cwnd for computed parameters */ 172 double increase_last_; /* increase param for cwnd_last_ */ 173 hstcp() : low_p(0.0), dec1(0.0), dec2(0.0), p1(0.0), p2(0.0), 174 cwnd_last_(0.0), increase_last_(0.0) { } 175 }; 176 177 class TcpAgent : public Agent { 178 friend class XcpEndsys; 179 public: 180 TcpAgent(); 181 virtual ~TcpAgent() {free(tss);} 182 virtual void recv(Packet*, Handler*); 183 virtual void timeout(int tno); 184 virtual void timeout_nonrtx(int tno); 185 int command(int argc, const char*const* argv); 186 virtual void sendmsg(int nbytes, const char *flags = 0); 187 188 void trace(TracedVar* v); 189 virtual void advanceby(int delta); 190 191 virtual void reset(); 192 193 /* These two functions aid Tmix one-way TCP agents */ 194 int is_closed() {return closed_;} 195 void clr_closed() {closed_ = 0;} 196 protected: 197 virtual int window(); 198 virtual double windowd(); 199 void print_if_needed(double memb_time); 200 void traceAll(); 201 virtual void traceVar(TracedVar* v); 202 virtual int headersize(); // a tcp header 203 204 virtual void delay_bind_init_all(); 205 virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer); 206 207 double boot_time_; /* where between 'ticks' this sytem came up */ 208 double overhead_; 209 double wnd_; 210 double wnd_const_; 211 double wnd_th_; /* window "threshold" */ 212 double wnd_init_; 213 double wnd_restart_; 214 double tcp_tick_; /* clock granularity */ 215 int wnd_option_; 216 int wnd_init_option_; /* 1 for using wnd_init_ */ 217 /* 2 for using large initial windows */ 218 double decrease_num_; /* factor for multiplicative decrease */ 219 double increase_num_; /* factor for additive increase */ 220 int tcpip_base_hdr_size_; /* size of base TCP/IP header */ 221 int maxcwnd_; /* max # cwnd can ever be */ 222 int numdupacks_; /* dup ACKs before fast retransmit */ 223 int numdupacksFrac_; /* for a larger numdupacks_ with large */ 224 /* windows */ 225 226 /* connection and packet dynamics */ 227 virtual void output(int seqno, int reason = 0); 228 virtual void send_much(int force, int reason, int maxburst = 0); 229 virtual void newtimer(Packet*); 230 virtual void dupack_action(); /* do this on dupacks */ 231 virtual void send_one(); /* do this on 1-2 dupacks */ 232 virtual void opencwnd(); 233 void update_window(Packet*); // Shigeyuki Osada 2012/01/08 234 235 void slowdown(int how); /* reduce cwnd/ssthresh */ 236 void ecn(int seqno); /* react to quench */ 237 virtual void set_initial_window(); /* set IW */ 238 double initial_window(); /* what is IW? */ 239 void newack(Packet*); 240 void finish(); /* called when the connection is terminated */ 241 int network_limited(); /* Sending limited by network? */ 242 double limited_slow_start(double cwnd, int max_ssthresh, double increment); 243 /* Limited slow-start for high windows */ 244 virtual int numdupacks(double cwnd); /* for getting numdupacks_ */ 245 /* End of section of connection and packet dynamics. */ 246 247 /* General dynamic state. */ 248 TracedInt t_seqno_; /* sequence number */ 249 TracedInt dupacks_; /* number of duplicate acks */ 250 TracedInt curseq_; /* highest seqno "produced by app" */ 251 TracedInt highest_ack_; /* not frozen during Fast Recovery */ 252 TracedDouble cwnd_; /* current window */ 253 TracedInt ssthresh_; /* slow start threshold */ 254 TracedInt maxseq_; /* used for Karn algorithm */ 255 /* highest seqno sent so far */ 256 int last_ack_; /* largest consecutive ACK, frozen during 257 * Fast Recovery */ 258 int recover_; /* highest pkt sent before dup acks, */ 259 /* timeout, or source quench/ecn */ 260 int last_cwnd_action_; /* CWND_ACTION_{TIMEOUT,DUPACK,ECN} */ 261 int count_; /* used in window increment algorithms */ 262 int rtt_active_; /* 1 if a rtt sample is pending */ 263 int rtt_seq_; /* seq # of timed seg if rtt_active_ is 1 */ 264 double rtt_ts_; /* time at which rtt_seq_ was sent */ 265 double firstsent_; /* When first packet was sent --Allman */ 266 double lastreset_; /* W.N. Last time connection was reset - for */ 267 /* detecting pkts from previous incarnations */ 268 int closed_; /* whether this connection has closed */ 269 /* End of general dynamic state. */ 270 271 /* 272 * State encompassing the round-trip-time estimate. 273 * srtt and rttvar are stored as fixed point; 274 * srtt has 3 bits to the right of the binary point, rttvar has 2. 275 */ 276 TracedInt t_rtt_; /* round trip time */ 277 TracedInt t_srtt_; /* smoothed round-trip time */ 278 TracedInt t_rttvar_; /* variance in round-trip time */ 279 TracedInt t_backoff_; /* current multiplier of RTO, */ 280 /* 1 if not backed off */ 281 #define T_RTT_BITS 0 282 int T_SRTT_BITS; /* exponent of weight for updating t_srtt_ */ 283 int srtt_init_; /* initial value for computing t_srtt_ */ 284 int T_RTTVAR_BITS; /* exponent of weight for updating t_rttvar_ */ 285 int rttvar_exp_; /* exponent of multiple for t_rtxcur_ */ 286 int rttvar_init_; /* initial value for computing t_rttvar_ */ 287 double t_rtxcur_; /* current retransmit value */ 288 double rtxcur_init_; /* initial value for t_rtxcur_ */ 289 virtual void rtt_init(); 290 virtual double rtt_timeout(); /* provide RTO based on RTT estimates */ 291 virtual void rtt_update(double tao); /* update RTT estimate */ 292 virtual void rtt_backoff(); /* double multiplier */ 293 /* End of state for the round-trip-time estimate. */ 294 295 /* RTOs: */ 296 double maxrto_; /* max value of an RTO */ 297 double minrto_; /* min value of an RTO */ 298 int ts_resetRTO_; /* Un-backoff RTO after any valid RTT, */ 299 /* including from a retransmitted pkt? */ 300 /* The old version was "false". */ 301 /* But "true" gives better performance, and */ 302 /* seems conformant with RFC 2988. */ 303 /* End of section for RTOs. */ 304 305 /* Timestamps. */ 306 double ts_peer_; /* the most recent timestamp the peer sent */ 307 double ts_echo_; /* the most recent timestamp the peer echoed */ 308 int ts_option_size_; // header bytes in a ts option 309 double *tss; // To store sent timestamps, with bugfix_ts_ 310 int tss_size_; // Current capacity of tss 311 int ts_option_; /* use RFC1323-like timestamps? */ 312 /* End of timestamps. */ 313 314 /* Helper functions. Used by tcp-asym */ 315 virtual void output_helper(Packet*) { return; } 316 virtual void send_helper(int) { return; } 317 virtual void send_idle_helper() { return; } 318 virtual void recv_helper(Packet*); 319 virtual void recv_frto_helper(Packet*); 320 virtual void recv_newack_helper(Packet*); 321 virtual void partialnewack_helper(Packet*) {}; 322 /* End of helper functions. */ 323 324 int force_wnd(int num); 325 void spurious_timeout(); 326 327 /* Timers */ 328 RtxTimer rtx_timer_; 329 DelSndTimer delsnd_timer_; 330 BurstSndTimer burstsnd_timer_; 331 virtual void cancel_timers() { 332 rtx_timer_.force_cancel(); 333 burstsnd_timer_.force_cancel(); 334 delsnd_timer_.force_cancel(); 335 } 336 virtual void cancel_rtx_timer() { 337 rtx_timer_.force_cancel(); 338 } 339 virtual void set_rtx_timer(); 340 void reset_rtx_timer(int mild, int backoff = 1); 341 int timerfix_; /* set to true to update timer *after* */ 342 /* update the RTT, instead of before */ 343 int rfc2988_; /* Use updated RFC 2988 timers */ 344 /* End of timers. */ 345 346 347 /* For modeling SYN and SYN/ACK packets. */ 348 int syn_; /* 1 for modeling SYN/ACK exchange */ 349 int delay_growth_; /* delay opening cwnd until 1st data recv'd */ 350 int max_connects_; /* max number of transmits for syn packet */ 351 /* -1 to allow infinite number of transmits */ 352 /* End of modeling SYN and SYN/ACK packets. */ 353 354 /* Dynamic state for SYN packet retransmissions. */ 355 int syn_connects_; /* number of transmits of syn packet */ 356 /* End of dynamic state for SYN packet retransmissions. */ 357 358 /* F-RTO */ 359 int frto_enabled_; /* != 0 to enable F-RTO */ 360 int sfrto_enabled_; /* != 0 to enabled SACK-based F-RTO */ 361 int spurious_response_; /* Response variant to spurious RTO */ 362 /* End of R-RTO */ 363 364 /* Parameters for backwards compatility with old code. */ 365 int bug_fix_; /* 1 for multiple-fast-retransmit fix */ 366 int less_careful_; /* 1 for Less Careful variant of bug_fix_, */ 367 /* for illustration only */ 368 int exitFastRetrans_; /* True to clean exits of Fast Retransmit */ 369 /* False for buggy old behavior */ 370 int bugfix_ack_; // 1 to enable ACK heuristic, to allow 371 // multiple-fast-retransmits in special cases. 372 // From Andrei Gurtov 373 int bugfix_ts_; // 1 to enable timestamp heuristic, to allow 374 // multiple-fast-retransmits in special cases. 375 // From Andrei Gurtov 376 // Not implemented yet. 377 int old_ecn_; /* For backwards compatibility with the 378 * old ECN implementation, which never 379 * reduced the congestion window below 380 * one packet. */ 381 int bugfix_ss_; // 1 to use window of one when SYN 382 // packet is dropped 383 /* End of parameters for backwards compatility. */ 384 385 /* Parameters for alternate congestion control mechanisms. */ 386 double k_parameter_; /* k parameter in binomial controls */ 387 double l_parameter_; /* l parameter in binomial controls */ 388 int precision_reduce_; /* non-integer reduction of cwnd */ 389 int maxburst_; /* max # packets can send back-2-back */ 390 int aggressive_maxburst_; /* Send on a non-valid ack? */ 391 /* End of parameters for alternate congestion control mechanisms. */ 392 393 FILE *plotfile_; 394 395 /* Dynamic state used for alternate congestion control mechanisms */ 396 double awnd_; /* averaged window */ 397 int first_decrease_; /* First decrease of congestion window. */ 398 /* Used for decrease_num_ != 0.5. */ 399 double fcnt_; /* used in window increment algorithms */ 400 double base_cwnd_; /* base window (for experimental purposes) */ 401 /* End of state for alternate congestion control mechanisms */ 402 403 /* Dynamic state only used for monitoring */ 404 int trace_all_oneline_; /* TCP tracing vars all in one line or not? */ 405 int nam_tracevar_; /* Output nam's variable trace or just plain 406 text variable trace? */ 407 TracedInt ndatapack_; /* number of data packets sent */ 408 TracedInt ndatabytes_; /* number of data bytes sent */ 409 TracedInt nackpack_; /* number of ack packets received */ 410 TracedInt nrexmit_; /* number of retransmit timeouts 411 when there was data outstanding */ 412 TracedInt nrexmitpack_; /* number of retransmited packets */ 413 TracedInt nrexmitbytes_; /* number of retransmited bytes */ 414 TracedInt necnresponses_; /* number of times cwnd was reduced 415 in response to an ecn packet -- sylvia */ 416 TracedInt ncwndcuts_; /* number of times cwnd was reduced 417 for any reason -- sylvia */ 418 TracedInt ncwndcuts1_; /* number of times cwnd was reduced 419 due to congestion (as opposed to idle 420 periods */ 421 /* end of dynamic state for monitoring */ 422 423 /* Specifying variants in TCP algorithms. */ 424 int slow_start_restart_; /* boolean: re-init cwnd after connection 425 goes idle. On by default. */ 426 int restart_bugfix_; /* ssthresh is cut down because of 427 timeouts during a connection's idle period. 428 Setting this boolean fixes this problem. 429 For now, it is off by default. */ 430 TracedInt singledup_; /* Send on a single dup ack. */ 431 int LimTransmitFix_; /* To fix a bug in Limited Transmit. */ 432 int noFastRetrans_; /* No Fast Retransmit option. */ 433 int oldCode_; /* Use old code. */ 434 int useHeaders_; /* boolean: Add TCP/IP header sizes */ 435 /* end of specifying variants */ 436 437 /* Used for ECN */ 438 int ecn_; /* Explicit Congestion Notification */ 439 int cong_action_; /* Congestion Action. True to indicate 440 that the sender responded to congestion. */ 441 int ecn_burst_; /* True when the previous ACK packet 442 * carried ECN-Echo. */ 443 int ecn_backoff_; /* True when retransmit timer should begin 444 to be backed off. */ 445 int ect_; /* turn on ect bit now? */ 446 int SetCWRonRetransmit_; /* True to allow setting CWR on */ 447 /* retransmitted packets. Affects */ 448 /* performance for Reno with ECN. */ 449 int use_rtt_; /* Use RTT for timeout for ECN-marked SYN-ACK */ 450 /* end of ECN */ 451 452 /* used for Explicit Loss Notification */ 453 void tcp_eln(Packet *pkt); /* reaction to ELN (usually wireless) */ 454 int eln_; /* Explicit Loss Notification (wireless) */ 455 int eln_rxmit_thresh_; /* Threshold for ELN-triggered rxmissions */ 456 int eln_last_rxmit_; /* Last packet rxmitted due to ELN info */ 457 /* end of Explicit Loss Notification */ 458 459 /* for High-Speed TCP, RFC 3649 */ 460 double linear(double x, double x_1, double y_1, double x_2, double y_2); 461 /* the "linear" function is for experimental highspeed TCP */ 462 /* These four parameters define the HighSpeed response function. */ 463 int low_window_; /* window for turning on high-speed TCP */ 464 int high_window_; /* target window for new response function */ 465 double high_p_; /* target drop rate for new response function */ 466 double high_decrease_; /* decrease rate at target window */ 467 /* The next parameter is for Limited Slow-Start. */ 468 int max_ssthresh_; /* max value for ssthresh_ */ 469 470 /* These two functions are just an easy structuring of the code. */ 471 double increase_param(); /* get increase parameter for current cwnd */ 472 double decrease_param(); /* get decrease parameter for current cwnd */ 473 int cwnd_range_; /* for determining when to recompute params. */ 474 hstcp hstcp_; /* HighSpeed TCP variables */ 475 /* end of section for experimental high-speed TCP */ 476 477 /* for Quick-Start, RFC 4782 */ 478 virtual void processQuickStart(Packet *pkt); 479 virtual void endQuickStart(); 480 int lossQuickStart(); 481 int rate_request_; /* Rate request in KBps, for QuickStart. */ 482 int qs_enabled_; /* to enable QuickStart. */ 483 int qs_requested_; 484 int qs_approved_; 485 int qs_window_; /* >0: there are outstanding non-acked segments 486 from QS window */ 487 int qs_cwnd_; /* Initial window for Quick-Start */ 488 int tcp_qs_recovery_; /* != 0 if we apply slow start on packet 489 losses during QS window */ 490 int qs_request_mode_; /* 1 = Try to avoid unnecessary QS requests 491 for short flows. Use qs_rtt_ as the RTT 492 used in window calculation. 493 Other: Always request 'rate_request_' bytes, 494 regardless of flow size */ 495 int qs_thresh_; /* Do not use QS if there are less data to send 496 than this. Applies only if 497 qs_request_mode_ == 1 */ 498 int qs_rtt_; /* QS needs some assumption of the RTT in 499 in order to be able to determine how much 500 it needs for rate request with given amount 501 of data to send. milliseconds. */ 502 int print_request_; /* true to print Quick-Start request */ 503 int ttl_diff_; 504 /* end of section for Quick-Start. */ 505 506 /* F-RTO: !=0 when F-RTO recovery is underway, N:th round-trip 507 * since RTO. Can have values between 0-2 */ 508 int frto_; 509 int pipe_prev_; /* window size when timeout last occurred */ 510 511 /* support for event-tracing */ 512 //EventTrace *et_; 513 void trace_event(char *eventtype); 514 515 /* these function are now obsolete, see other above */ 516 void closecwnd(int how); 517 void quench(int how); 518 519 /* TCP quiescence, reducing cwnd after an idle period */ 520 void process_qoption_after_send() ; 521 void process_qoption_after_ack(int seqno) ; 522 void reset_qoption(); /* for QOption with EnblRTTCtr_ */ 523 void rtt_counting(); /* for QOption with EnblRTTCtr_ */ 524 int QOption_ ; /* TCP quiescence option */ 525 int EnblRTTCtr_ ; /* are we using a corase grained timer? */ 526 int T_full ; /* last time the window was full */ 527 int T_last ; 528 int T_prev ; 529 int T_start ; 530 int RTT_count ; 531 int RTT_prev ; 532 int RTT_goodcount ; 533 int F_counting ; 534 int W_used ; 535 int W_timed ; 536 int F_full ; 537 int Backoffs ; 538 int control_increase_ ; /* If true, don't increase cwnd if sender */ 539 /* is not window-limited. */ 540 int prev_highest_ack_ ; /* Used to determine if sender is */ 541 /* window-limited. */ 542 /* end of TCP quiescence */ 543 }; 544 545 /* TCP Reno */ 546 class RenoTcpAgent : public virtual TcpAgent { 547 public: 548 RenoTcpAgent(); 549 virtual int window(); 550 virtual double windowd(); 551 virtual void recv(Packet *pkt, Handler*); 552 virtual void timeout(int tno); 553 virtual void dupack_action(); 554 protected: 555 int allow_fast_retransmit(int last_cwnd_action_); 556 unsigned int dupwnd_; 557 }; 558 559 /* TCP New Reno */ 560 class NewRenoTcpAgent : public virtual RenoTcpAgent { 561 public: 562 NewRenoTcpAgent(); 563 virtual void recv(Packet *pkt, Handler*); 564 virtual void partialnewack_helper(Packet* pkt); 565 virtual void dupack_action(); 566 protected: 567 int newreno_changes_; /* 0 for fixing unnecessary fast retransmits */ 568 /* 1 for additional code from Allman, */ 569 /* to implement other algorithms from */ 570 /* Hoe's paper, including sending a new */ 571 /* packet for every two duplicate ACKs. */ 572 /* The default is set to 0. */ 573 int newreno_changes1_; /* Newreno_changes1_ set to 0 gives the */ 574 /* Slow-but-Steady variant of NewReno from */ 575 /* RFC 2582, with the retransmit timer reset */ 576 /* after each partial new ack. */ 577 /* Newreno_changes1_ set to 1 gives the */ 578 /* Impatient variant of NewReno from */ 579 /* RFC 2582, with the retransmit timer reset */ 580 /* only for the first partial new ack. */ 581 /* The default is set to 0 */ 582 void partialnewack(Packet *pkt); 583 int allow_fast_retransmit(int last_cwnd_action_); 584 int acked_, new_ssthresh_; /* used if newreno_changes_ == 1 */ 585 double ack2_, ack3_, basertt_; /* used if newreno_changes_ == 1 */ 586 int firstpartial_; /* For the first partial ACK. */ 587 int partial_window_deflation_; /* 0 if set cwnd to ssthresh upon */ 588 /* partial new ack (default) */ 589 /* 1 if deflate (cwnd + dupwnd) by */ 590 /* amount of data acked */ 591 /* "Partial window deflation" is */ 592 /* discussed in RFC 2582. */ 593 int exit_recovery_fix_; /* 0 for setting cwnd to ssthresh upon */ 594 /* leaving fast recovery (default) */ 595 /* 1 for setting cwnd to min(ssthresh, */ 596 /* amnt. of data in network) when leaving */ 597 }; 598 599 /* TCP vegas (VegasTcpAgent) */ 600 class VegasTcpAgent : public virtual TcpAgent { 601 public: 602 VegasTcpAgent(); 603 ~VegasTcpAgent(); 604 virtual void recv(Packet *pkt, Handler *); 605 virtual void timeout(int tno); 606 protected: 607 double vegastime() { 608 return(Scheduler::instance().clock() - firstsent_); 609 } 610 virtual void output(int seqno, int reason = 0); 611 virtual void recv_newack_helper(Packet*); 612 int vegas_expire(Packet*); 613 void reset(); 614 void vegas_inflate_cwnd(int win, double current_time); 615 616 virtual void delay_bind_init_all(); 617 virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer); 618 619 double t_cwnd_changed_; // last time cwnd changed 620 double firstrecv_; // time recv the 1st ack 621 622 int v_alpha_; // vegas thruput thresholds in pkts 623 int v_beta_; 624 625 int v_gamma_; // threshold to change from slow-start to 626 // congestion avoidance, in pkts 627 628 int v_slowstart_; // # of pkts to send after slow-start, deflt(2) 629 int v_worried_; // # of pkts to chk after dup ack (1 or 2) 630 631 double v_timeout_; // based on fine-grained timer 632 double v_rtt_; 633 double v_sa_; 634 double v_sd_; 635 636 int v_cntRTT_; // # of rtt measured within one rtt 637 double v_sumRTT_; // sum of rtt measured within one rtt 638 639 double v_begtime_; // tagged pkt sent 640 int v_begseq_; // tagged pkt seqno 641 642 double* v_sendtime_; // each unacked pkt's sendtime is recorded. 643 int* v_transmits_; // # of retx for an unacked pkt 644 645 int v_maxwnd_; // maxwnd size for v_sendtime_[] 646 double v_newcwnd_; // record un-inflated cwnd 647 648 double v_baseRTT_; // min of all rtt 649 650 double v_incr_; // amount cwnd is increased in the next rtt 651 int v_inc_flag_; // if cwnd is allowed to incr for this rtt 652 653 double v_actual_; // actual send rate (pkt/s; needed for tcp-rbp) 654 655 int ns_vegas_fix_level_; // see comment at end of tcp-vegas.cc for details of fixes 656 }; 657 658 // Local Variables: 659 // mode:c++ 660 // c-basic-offset: 8 661 // End: 662 663 #endif