00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* 00002 * Copyright (c) 1991-1997 Regents of the University of California. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. All advertising materials mentioning features or use of this software 00014 * must display the following acknowledgement: 00015 * This product includes software developed by the Computer Systems 00016 * Engineering Group at Lawrence Berkeley Laboratory. 00017 * 4. Neither the name of the University nor of the Laboratory may be used 00018 * to endorse or promote products derived from this software without 00019 * specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00022 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00025 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00026 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00027 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00028 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00029 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00030 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * @(#) $Header: /cvsroot/nsnam/ns-2/tcp/tcp.h,v 1.130 2007/09/29 01:07:22 sallyfloyd Exp $ (LBL) 00034 */ 00035 #ifndef ns_tcp_h 00036 #define ns_tcp_h 00037 00038 #include "agent.h" 00039 #include "packet.h" 00040 00041 //class EventTrace; 00042 00043 struct hdr_tcp { 00044 #define NSA 3 00045 double ts_; /* time packet generated (at source) */ 00046 double ts_echo_; /* the echoed timestamp (originally sent by 00047 the peer) */ 00048 int seqno_; /* sequence number */ 00049 int reason_; /* reason for a retransmit */ 00050 int sack_area_[NSA+1][2]; /* sack blocks: start, end of block */ 00051 int sa_length_; /* Indicate the number of SACKs in this * 00052 * packet. Adds 2+sack_length*8 bytes */ 00053 int ackno_; /* ACK number for FullTcp */ 00054 int hlen_; /* header len (bytes) for FullTcp */ 00055 int tcp_flags_; /* TCP flags for FullTcp */ 00056 int last_rtt_; /* more recent RTT measurement in ms, */ 00057 /* for statistics only */ 00058 00059 static int offset_; // offset for this header 00060 inline static int& offset() { return offset_; } 00061 inline static hdr_tcp* access(Packet* p) { 00062 return (hdr_tcp*) p->access(offset_); 00063 } 00064 00065 /* per-field member functions */ 00066 double& ts() { return (ts_); } 00067 double& ts_echo() { return (ts_echo_); } 00068 int& seqno() { return (seqno_); } 00069 int& reason() { return (reason_); } 00070 int& sa_left(int n) { return (sack_area_[n][0]); } 00071 int& sa_right(int n) { return (sack_area_[n][1]); } 00072 int& sa_length() { return (sa_length_); } 00073 int& hlen() { return (hlen_); } 00074 int& ackno() { return (ackno_); } 00075 int& flags() { return (tcp_flags_); } 00076 int& last_rtt() { return (last_rtt_); } 00077 }; 00078 00079 /* these are used to mark packets as to why we xmitted them */ 00080 #define TCP_REASON_TIMEOUT 0x01 00081 #define TCP_REASON_DUPACK 0x02 00082 #define TCP_REASON_RBP 0x03 // used only in tcp-rbp.cc 00083 #define TCP_REASON_PARTIALACK 0x04 00084 00085 /* these are reasons we adjusted our congestion window */ 00086 00087 #define CWND_ACTION_DUPACK 1 // dup acks/fast retransmit 00088 #define CWND_ACTION_TIMEOUT 2 // retransmission timeout 00089 #define CWND_ACTION_ECN 3 // ECN bit [src quench if supported] 00090 #define CWND_ACTION_EXITED 4 // congestion recovery has ended 00091 // (when previously CWND_ACTION_DUPACK) 00092 00093 /* these are bits for how to change the cwnd and ssthresh values */ 00094 00095 #define CLOSE_SSTHRESH_HALF 0x00000001 00096 #define CLOSE_CWND_HALF 0x00000002 00097 #define CLOSE_CWND_RESTART 0x00000004 00098 #define CLOSE_CWND_INIT 0x00000008 00099 #define CLOSE_CWND_ONE 0x00000010 00100 #define CLOSE_SSTHRESH_HALVE 0x00000020 00101 #define CLOSE_CWND_HALVE 0x00000040 00102 #define THREE_QUARTER_SSTHRESH 0x00000080 00103 #define CLOSE_CWND_HALF_WAY 0x00000100 00104 #define CWND_HALF_WITH_MIN 0x00000200 00105 #define TCP_IDLE 0x00000400 00106 #define NO_OUTSTANDING_DATA 0x00000800 00107 00108 /* 00109 * tcp_tick_: 00110 * default 0.1, 00111 * 0.3 for 4.3 BSD, 00112 * 0.01 for new window algorithms, 00113 */ 00114 00115 #define NUMDUPACKS 3 /* This is no longer used. The variable */ 00116 /* numdupacks_ is used instead. */ 00117 #define TCP_MAXSEQ 1073741824 /* Number that curseq_ is set to for */ 00118 /* "infinite send" (2^30) */ 00119 00120 #define TCP_TIMER_RTX 0 00121 #define TCP_TIMER_DELSND 1 00122 #define TCP_TIMER_BURSTSND 2 00123 #define TCP_TIMER_DELACK 3 00124 #define TCP_TIMER_Q 4 00125 #define TCP_TIMER_RESET 5 00126 00127 class TcpAgent; 00128 00129 class RtxTimer : public TimerHandler { 00130 public: 00131 RtxTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 00132 protected: 00133 virtual void expire(Event *e); 00134 TcpAgent *a_; 00135 }; 00136 00137 class DelSndTimer : public TimerHandler { 00138 public: 00139 DelSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 00140 protected: 00141 virtual void expire(Event *e); 00142 TcpAgent *a_; 00143 }; 00144 00145 class BurstSndTimer : public TimerHandler { 00146 public: 00147 BurstSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; } 00148 protected: 00149 virtual void expire(Event *e); 00150 TcpAgent *a_; 00151 }; 00152 00153 /* 00154 * Variables for HighSpeed TCP. 00155 */ 00156 //int *hs_win_; // array of cwnd values 00157 //int *hs_increase_; // array of increase values 00158 //double *hs_decrease_; // array of decrease values 00159 struct hstcp { 00160 double low_p; // low_p 00161 double dec1; // for computing the decrease parameter 00162 double dec2; // for computing the decrease parameter 00163 double p1; // for computing p 00164 double p2; // for computing p 00165 /* The next three parameters are for CPU overhead, for computing */ 00166 /* the HighSpeed parameters less frequently. A better solution */ 00167 /* might be just to have a look-up array. */ 00168 double cwnd_last_; /* last cwnd for computed parameters */ 00169 double increase_last_; /* increase param for cwnd_last_ */ 00170 hstcp() : low_p(0.0), dec1(0.0), dec2(0.0), p1(0.0), p2(0.0), 00171 cwnd_last_(0.0), increase_last_(0.0) { } 00172 }; 00173 00174 class TcpAgent : public Agent { 00175 friend class XcpEndsys; 00176 public: 00177 TcpAgent(); 00178 virtual ~TcpAgent() {free(tss);} 00179 virtual void recv(Packet*, Handler*); 00180 virtual void timeout(int tno); 00181 virtual void timeout_nonrtx(int tno); 00182 int command(int argc, const char*const* argv); 00183 virtual void sendmsg(int nbytes, const char *flags = 0); 00184 00185 void trace(TracedVar* v); 00186 virtual void advanceby(int delta); 00187 protected: 00188 virtual int window(); 00189 virtual double windowd(); 00190 void print_if_needed(double memb_time); 00191 void traceAll(); 00192 virtual void traceVar(TracedVar* v); 00193 virtual int headersize(); // a tcp header 00194 00195 virtual void delay_bind_init_all(); 00196 virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer); 00197 00198 double boot_time_; /* where between 'ticks' this sytem came up */ 00199 double overhead_; 00200 double wnd_; 00201 double wnd_const_; 00202 double wnd_th_; /* window "threshold" */ 00203 double wnd_init_; 00204 double wnd_restart_; 00205 double tcp_tick_; /* clock granularity */ 00206 int wnd_option_; 00207 int wnd_init_option_; /* 1 for using wnd_init_ */ 00208 /* 2 for using large initial windows */ 00209 double decrease_num_; /* factor for multiplicative decrease */ 00210 double increase_num_; /* factor for additive increase */ 00211 int tcpip_base_hdr_size_; /* size of base TCP/IP header */ 00212 int maxcwnd_; /* max # cwnd can ever be */ 00213 int numdupacks_; /* dup ACKs before fast retransmit */ 00214 int numdupacksFrac_; /* for a larger numdupacks_ with large */ 00215 /* windows */ 00216 00217 /* connection and packet dynamics */ 00218 virtual void output(int seqno, int reason = 0); 00219 virtual void send_much(int force, int reason, int maxburst = 0); 00220 virtual void newtimer(Packet*); 00221 virtual void dupack_action(); /* do this on dupacks */ 00222 virtual void send_one(); /* do this on 1-2 dupacks */ 00223 virtual void opencwnd(); 00224 00225 void slowdown(int how); /* reduce cwnd/ssthresh */ 00226 void ecn(int seqno); /* react to quench */ 00227 virtual void set_initial_window(); /* set IW */ 00228 double initial_window(); /* what is IW? */ 00229 void reset(); 00230 void newack(Packet*); 00231 void finish(); /* called when the connection is terminated */ 00232 int network_limited(); /* Sending limited by network? */ 00233 double limited_slow_start(double cwnd, int max_ssthresh, double increment); 00234 /* Limited slow-start for high windows */ 00235 virtual int numdupacks(double cwnd); /* for getting numdupacks_ */ 00236 /* End of section of connection and packet dynamics. */ 00237 00238 /* General dynamic state. */ 00239 TracedInt t_seqno_; /* sequence number */ 00240 TracedInt dupacks_; /* number of duplicate acks */ 00241 TracedInt curseq_; /* highest seqno "produced by app" */ 00242 TracedInt highest_ack_; /* not frozen during Fast Recovery */ 00243 TracedDouble cwnd_; /* current window */ 00244 TracedInt ssthresh_; /* slow start threshold */ 00245 TracedInt maxseq_; /* used for Karn algorithm */ 00246 /* highest seqno sent so far */ 00247 int last_ack_; /* largest consecutive ACK, frozen during 00248 * Fast Recovery */ 00249 int recover_; /* highest pkt sent before dup acks, */ 00250 /* timeout, or source quench/ecn */ 00251 int last_cwnd_action_; /* CWND_ACTION_{TIMEOUT,DUPACK,ECN} */ 00252 int count_; /* used in window increment algorithms */ 00253 int rtt_active_; /* 1 if a rtt sample is pending */ 00254 int rtt_seq_; /* seq # of timed seg if rtt_active_ is 1 */ 00255 double rtt_ts_; /* time at which rtt_seq_ was sent */ 00256 double firstsent_; /* When first packet was sent --Allman */ 00257 double lastreset_; /* W.N. Last time connection was reset - for */ 00258 /* detecting pkts from previous incarnations */ 00259 int closed_; /* whether this connection has closed */ 00260 /* End of general dynamic state. */ 00261 00262 /* 00263 * State encompassing the round-trip-time estimate. 00264 * srtt and rttvar are stored as fixed point; 00265 * srtt has 3 bits to the right of the binary point, rttvar has 2. 00266 */ 00267 TracedInt t_rtt_; /* round trip time */ 00268 TracedInt t_srtt_; /* smoothed round-trip time */ 00269 TracedInt t_rttvar_; /* variance in round-trip time */ 00270 TracedInt t_backoff_; /* current multiplier of RTO, */ 00271 /* 1 if not backed off */ 00272 #define T_RTT_BITS 0 00273 int T_SRTT_BITS; /* exponent of weight for updating t_srtt_ */ 00274 int srtt_init_; /* initial value for computing t_srtt_ */ 00275 int T_RTTVAR_BITS; /* exponent of weight for updating t_rttvar_ */ 00276 int rttvar_exp_; /* exponent of multiple for t_rtxcur_ */ 00277 int rttvar_init_; /* initial value for computing t_rttvar_ */ 00278 double t_rtxcur_; /* current retransmit value */ 00279 double rtxcur_init_; /* initial value for t_rtxcur_ */ 00280 virtual void rtt_init(); 00281 virtual double rtt_timeout(); /* provide RTO based on RTT estimates */ 00282 virtual void rtt_update(double tao); /* update RTT estimate */ 00283 virtual void rtt_backoff(); /* double multiplier */ 00284 /* End of state for the round-trip-time estimate. */ 00285 00286 /* RTOs: */ 00287 double maxrto_; /* max value of an RTO */ 00288 double minrto_; /* min value of an RTO */ 00289 int ts_resetRTO_; /* Un-backoff RTO after any valid RTT, */ 00290 /* including from a retransmitted pkt? */ 00291 /* The old version was "false". */ 00292 /* But "true" gives better performance, and */ 00293 /* seems conformant with RFC 2988. */ 00294 /* End of section for RTOs. */ 00295 00296 /* Timestamps. */ 00297 double ts_peer_; /* the most recent timestamp the peer sent */ 00298 double ts_echo_; /* the most recent timestamp the peer echoed */ 00299 int ts_option_size_; // header bytes in a ts option 00300 double *tss; // To store sent timestamps, with bugfix_ts_ 00301 int tss_size_; // Current capacity of tss 00302 int ts_option_; /* use RFC1323-like timestamps? */ 00303 /* End of timestamps. */ 00304 00305 /* Helper functions. Used by tcp-asym */ 00306 virtual void output_helper(Packet*) { return; } 00307 virtual void send_helper(int) { return; } 00308 virtual void send_idle_helper() { return; } 00309 virtual void recv_helper(Packet*) { return; } 00310 virtual void recv_frto_helper(Packet*); 00311 virtual void recv_newack_helper(Packet*); 00312 virtual void partialnewack_helper(Packet*) {}; 00313 /* End of helper functions. */ 00314 00315 int force_wnd(int num); 00316 void spurious_timeout(); 00317 00318 /* Timers */ 00319 RtxTimer rtx_timer_; 00320 DelSndTimer delsnd_timer_; 00321 BurstSndTimer burstsnd_timer_; 00322 virtual void cancel_timers() { 00323 rtx_timer_.force_cancel(); 00324 burstsnd_timer_.force_cancel(); 00325 delsnd_timer_.force_cancel(); 00326 } 00327 virtual void cancel_rtx_timer() { 00328 rtx_timer_.force_cancel(); 00329 } 00330 virtual void set_rtx_timer(); 00331 void reset_rtx_timer(int mild, int backoff = 1); 00332 int timerfix_; /* set to true to update timer *after* */ 00333 /* update the RTT, instead of before */ 00334 int rfc2988_; /* Use updated RFC 2988 timers */ 00335 /* End of timers. */ 00336 00337 00338 /* For modeling SYN and SYN/ACK packets. */ 00339 int syn_; /* 1 for modeling SYN/ACK exchange */ 00340 int delay_growth_; /* delay opening cwnd until 1st data recv'd */ 00341 int max_connects_; /* max number of transmits for syn packet */ 00342 /* -1 to allow infinite number of transmits */ 00343 /* End of modeling SYN and SYN/ACK packets. */ 00344 00345 /* Dynamic state for SYN packet retransmissions. */ 00346 int syn_connects_; /* number of transmits of syn packet */ 00347 /* End of dynamic state for SYN packet retransmissions. */ 00348 00349 /* F-RTO */ 00350 int frto_enabled_; /* != 0 to enable F-RTO */ 00351 int sfrto_enabled_; /* != 0 to enabled SACK-based F-RTO */ 00352 int spurious_response_; /* Response variant to spurious RTO */ 00353 /* End of R-RTO */ 00354 00355 /* Parameters for backwards compatility with old code. */ 00356 int bug_fix_; /* 1 for multiple-fast-retransmit fix */ 00357 int less_careful_; /* 1 for Less Careful variant of bug_fix_, */ 00358 /* for illustration only */ 00359 int exitFastRetrans_; /* True to clean exits of Fast Retransmit */ 00360 /* False for buggy old behavior */ 00361 int bugfix_ack_; // 1 to enable ACK heuristic, to allow 00362 // multiple-fast-retransmits in special cases. 00363 // From Andrei Gurtov 00364 int bugfix_ts_; // 1 to enable timestamp heuristic, to allow 00365 // multiple-fast-retransmits in special cases. 00366 // From Andrei Gurtov 00367 // Not implemented yet. 00368 int old_ecn_; /* For backwards compatibility with the 00369 * old ECN implementation, which never 00370 * reduced the congestion window below 00371 * one packet. */ 00372 int bugfix_ss_; // 1 to use window of one when SYN 00373 // packet is dropped 00374 /* End of parameters for backwards compatility. */ 00375 00376 /* Parameters for alternate congestion control mechanisms. */ 00377 double k_parameter_; /* k parameter in binomial controls */ 00378 double l_parameter_; /* l parameter in binomial controls */ 00379 int precision_reduce_; /* non-integer reduction of cwnd */ 00380 int maxburst_; /* max # packets can send back-2-back */ 00381 int aggressive_maxburst_; /* Send on a non-valid ack? */ 00382 /* End of parameters for alternate congestion control mechanisms. */ 00383 00384 FILE *plotfile_; 00385 00386 /* Dynamic state used for alternate congestion control mechanisms */ 00387 double awnd_; /* averaged window */ 00388 int first_decrease_; /* First decrease of congestion window. */ 00389 /* Used for decrease_num_ != 0.5. */ 00390 double fcnt_; /* used in window increment algorithms */ 00391 double base_cwnd_; /* base window (for experimental purposes) */ 00392 /* End of state for alternate congestion control mechanisms */ 00393 00394 /* Dynamic state only used for monitoring */ 00395 int trace_all_oneline_; /* TCP tracing vars all in one line or not? */ 00396 int nam_tracevar_; /* Output nam's variable trace or just plain 00397 text variable trace? */ 00398 TracedInt ndatapack_; /* number of data packets sent */ 00399 TracedInt ndatabytes_; /* number of data bytes sent */ 00400 TracedInt nackpack_; /* number of ack packets received */ 00401 TracedInt nrexmit_; /* number of retransmit timeouts 00402 when there was data outstanding */ 00403 TracedInt nrexmitpack_; /* number of retransmited packets */ 00404 TracedInt nrexmitbytes_; /* number of retransmited bytes */ 00405 TracedInt necnresponses_; /* number of times cwnd was reduced 00406 in response to an ecn packet -- sylvia */ 00407 TracedInt ncwndcuts_; /* number of times cwnd was reduced 00408 for any reason -- sylvia */ 00409 TracedInt ncwndcuts1_; /* number of times cwnd was reduced 00410 due to congestion (as opposed to idle 00411 periods */ 00412 /* end of dynamic state for monitoring */ 00413 00414 /* Specifying variants in TCP algorithms. */ 00415 int slow_start_restart_; /* boolean: re-init cwnd after connection 00416 goes idle. On by default. */ 00417 int restart_bugfix_; /* ssthresh is cut down because of 00418 timeouts during a connection's idle period. 00419 Setting this boolean fixes this problem. 00420 For now, it is off by default. */ 00421 TracedInt singledup_; /* Send on a single dup ack. */ 00422 int LimTransmitFix_; /* To fix a bug in Limited Transmit. */ 00423 int noFastRetrans_; /* No Fast Retransmit option. */ 00424 int oldCode_; /* Use old code. */ 00425 int useHeaders_; /* boolean: Add TCP/IP header sizes */ 00426 /* end of specifying variants */ 00427 00428 /* Used for ECN */ 00429 int ecn_; /* Explicit Congestion Notification */ 00430 int cong_action_; /* Congestion Action. True to indicate 00431 that the sender responded to congestion. */ 00432 int ecn_burst_; /* True when the previous ACK packet 00433 * carried ECN-Echo. */ 00434 int ecn_backoff_; /* True when retransmit timer should begin 00435 to be backed off. */ 00436 int ect_; /* turn on ect bit now? */ 00437 int SetCWRonRetransmit_; /* True to allow setting CWR on */ 00438 /* retransmitted packets. Affects */ 00439 /* performance for Reno with ECN. */ 00440 int use_rtt_; /* Use RTT for timeout for ECN-marked SYN-ACK */ 00441 /* end of ECN */ 00442 00443 /* used for Explicit Loss Notification */ 00444 void tcp_eln(Packet *pkt); /* reaction to ELN (usually wireless) */ 00445 int eln_; /* Explicit Loss Notification (wireless) */ 00446 int eln_rxmit_thresh_; /* Threshold for ELN-triggered rxmissions */ 00447 int eln_last_rxmit_; /* Last packet rxmitted due to ELN info */ 00448 /* end of Explicit Loss Notification */ 00449 00450 /* for High-Speed TCP, RFC 3649 */ 00451 double linear(double x, double x_1, double y_1, double x_2, double y_2); 00452 /* the "linear" function is for experimental highspeed TCP */ 00453 /* These four parameters define the HighSpeed response function. */ 00454 int low_window_; /* window for turning on high-speed TCP */ 00455 int high_window_; /* target window for new response function */ 00456 double high_p_; /* target drop rate for new response function */ 00457 double high_decrease_; /* decrease rate at target window */ 00458 /* The next parameter is for Limited Slow-Start. */ 00459 int max_ssthresh_; /* max value for ssthresh_ */ 00460 00461 /* These two functions are just an easy structuring of the code. */ 00462 double increase_param(); /* get increase parameter for current cwnd */ 00463 double decrease_param(); /* get decrease parameter for current cwnd */ 00464 int cwnd_range_; /* for determining when to recompute params. */ 00465 hstcp hstcp_; /* HighSpeed TCP variables */ 00466 /* end of section for experimental high-speed TCP */ 00467 00468 /* for Quick-Start, RFC 4782 */ 00469 virtual void processQuickStart(Packet *pkt); 00470 virtual void endQuickStart(); 00471 int lossQuickStart(); 00472 int rate_request_; /* Rate request in KBps, for QuickStart. */ 00473 int qs_enabled_; /* to enable QuickStart. */ 00474 int qs_requested_; 00475 int qs_approved_; 00476 int qs_window_; /* >0: there are outstanding non-acked segments 00477 from QS window */ 00478 int qs_cwnd_; /* Initial window for Quick-Start */ 00479 int tcp_qs_recovery_; /* != 0 if we apply slow start on packet 00480 losses during QS window */ 00481 int qs_request_mode_; /* 1 = Try to avoid unnecessary QS requests 00482 for short flows. Use qs_rtt_ as the RTT 00483 used in window calculation. 00484 Other: Always request 'rate_request_' bytes, 00485 regardless of flow size */ 00486 int qs_thresh_; /* Do not use QS if there are less data to send 00487 than this. Applies only if 00488 qs_request_mode_ == 1 */ 00489 int qs_rtt_; /* QS needs some assumption of the RTT in 00490 in order to be able to determine how much 00491 it needs for rate request with given amount 00492 of data to send. milliseconds. */ 00493 int print_request_; /* true to print Quick-Start request */ 00494 int ttl_diff_; 00495 /* end of section for Quick-Start. */ 00496 00497 /* F-RTO: !=0 when F-RTO recovery is underway, N:th round-trip 00498 * since RTO. Can have values between 0-2 */ 00499 int frto_; 00500 int pipe_prev_; /* window size when timeout last occurred */ 00501 00502 /* support for event-tracing */ 00503 //EventTrace *et_; 00504 void trace_event(char *eventtype); 00505 00506 /* these function are now obsolete, see other above */ 00507 void closecwnd(int how); 00508 void quench(int how); 00509 00510 /* TCP quiescence, reducing cwnd after an idle period */ 00511 void process_qoption_after_send() ; 00512 void process_qoption_after_ack(int seqno) ; 00513 void reset_qoption(); /* for QOption with EnblRTTCtr_ */ 00514 void rtt_counting(); /* for QOption with EnblRTTCtr_ */ 00515 int QOption_ ; /* TCP quiescence option */ 00516 int EnblRTTCtr_ ; /* are we using a corase grained timer? */ 00517 int T_full ; /* last time the window was full */ 00518 int T_last ; 00519 int T_prev ; 00520 int T_start ; 00521 int RTT_count ; 00522 int RTT_prev ; 00523 int RTT_goodcount ; 00524 int F_counting ; 00525 int W_used ; 00526 int W_timed ; 00527 int F_full ; 00528 int Backoffs ; 00529 int control_increase_ ; /* If true, don't increase cwnd if sender */ 00530 /* is not window-limited. */ 00531 int prev_highest_ack_ ; /* Used to determine if sender is */ 00532 /* window-limited. */ 00533 /* end of TCP quiescence */ 00534 }; 00535 00536 /* TCP Reno */ 00537 class RenoTcpAgent : public virtual TcpAgent { 00538 public: 00539 RenoTcpAgent(); 00540 virtual int window(); 00541 virtual double windowd(); 00542 virtual void recv(Packet *pkt, Handler*); 00543 virtual void timeout(int tno); 00544 virtual void dupack_action(); 00545 protected: 00546 int allow_fast_retransmit(int last_cwnd_action_); 00547 unsigned int dupwnd_; 00548 }; 00549 00550 /* TCP New Reno */ 00551 class NewRenoTcpAgent : public virtual RenoTcpAgent { 00552 public: 00553 NewRenoTcpAgent(); 00554 virtual void recv(Packet *pkt, Handler*); 00555 virtual void partialnewack_helper(Packet* pkt); 00556 virtual void dupack_action(); 00557 protected: 00558 int newreno_changes_; /* 0 for fixing unnecessary fast retransmits */ 00559 /* 1 for additional code from Allman, */ 00560 /* to implement other algorithms from */ 00561 /* Hoe's paper, including sending a new */ 00562 /* packet for every two duplicate ACKs. */ 00563 /* The default is set to 0. */ 00564 int newreno_changes1_; /* Newreno_changes1_ set to 0 gives the */ 00565 /* Slow-but-Steady variant of NewReno from */ 00566 /* RFC 2582, with the retransmit timer reset */ 00567 /* after each partial new ack. */ 00568 /* Newreno_changes1_ set to 1 gives the */ 00569 /* Impatient variant of NewReno from */ 00570 /* RFC 2582, with the retransmit timer reset */ 00571 /* only for the first partial new ack. */ 00572 /* The default is set to 0 */ 00573 void partialnewack(Packet *pkt); 00574 int allow_fast_retransmit(int last_cwnd_action_); 00575 int acked_, new_ssthresh_; /* used if newreno_changes_ == 1 */ 00576 double ack2_, ack3_, basertt_; /* used if newreno_changes_ == 1 */ 00577 int firstpartial_; /* For the first partial ACK. */ 00578 int partial_window_deflation_; /* 0 if set cwnd to ssthresh upon */ 00579 /* partial new ack (default) */ 00580 /* 1 if deflate (cwnd + dupwnd) by */ 00581 /* amount of data acked */ 00582 /* "Partial window deflation" is */ 00583 /* discussed in RFC 2582. */ 00584 int exit_recovery_fix_; /* 0 for setting cwnd to ssthresh upon */ 00585 /* leaving fast recovery (default) */ 00586 /* 1 for setting cwnd to min(ssthresh, */ 00587 /* amnt. of data in network) when leaving */ 00588 }; 00589 00590 /* TCP vegas (VegasTcpAgent) */ 00591 class VegasTcpAgent : public virtual TcpAgent { 00592 public: 00593 VegasTcpAgent(); 00594 ~VegasTcpAgent(); 00595 virtual void recv(Packet *pkt, Handler *); 00596 virtual void timeout(int tno); 00597 protected: 00598 double vegastime() { 00599 return(Scheduler::instance().clock() - firstsent_); 00600 } 00601 virtual void output(int seqno, int reason = 0); 00602 virtual void recv_newack_helper(Packet*); 00603 int vegas_expire(Packet*); 00604 void reset(); 00605 void vegas_inflate_cwnd(int win, double current_time); 00606 00607 virtual void delay_bind_init_all(); 00608 virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer); 00609 00610 double t_cwnd_changed_; // last time cwnd changed 00611 double firstrecv_; // time recv the 1st ack 00612 00613 int v_alpha_; // vegas thruput thresholds in pkts 00614 int v_beta_; 00615 00616 int v_gamma_; // threshold to change from slow-start to 00617 // congestion avoidance, in pkts 00618 00619 int v_slowstart_; // # of pkts to send after slow-start, deflt(2) 00620 int v_worried_; // # of pkts to chk after dup ack (1 or 2) 00621 00622 double v_timeout_; // based on fine-grained timer 00623 double v_rtt_; 00624 double v_sa_; 00625 double v_sd_; 00626 00627 int v_cntRTT_; // # of rtt measured within one rtt 00628 double v_sumRTT_; // sum of rtt measured within one rtt 00629 00630 double v_begtime_; // tagged pkt sent 00631 int v_begseq_; // tagged pkt seqno 00632 00633 double* v_sendtime_; // each unacked pkt's sendtime is recorded. 00634 int* v_transmits_; // # of retx for an unacked pkt 00635 00636 int v_maxwnd_; // maxwnd size for v_sendtime_[] 00637 double v_newcwnd_; // record un-inflated cwnd 00638 00639 double v_baseRTT_; // min of all rtt 00640 00641 double v_incr_; // amount cwnd is increased in the next rtt 00642 int v_inc_flag_; // if cwnd is allowed to incr for this rtt 00643 00644 double v_actual_; // actual send rate (pkt/s; needed for tcp-rbp) 00645 00646 int ns_vegas_fix_level_; // see comment at end of tcp-vegas.cc for details of fixes 00647 }; 00648 00649 // Local Variables: 00650 // mode:c++ 00651 // c-basic-offset: 8 00652 // End: 00653 00654 #endif