ns-allinone-2.35/tcp/tcp.cc
void TcpAgent::newack(Packet* pkt)
{
	double now = Scheduler::instance().clock();
	hdr_tcp *tcph = hdr_tcp::access(pkt);
	/* 
	 * Wouldn't it be better to set the timer *after*
	 * updating the RTT, instead of *before*? 
	 */
	if (!timerfix_) newtimer(pkt);
	dupacks_ = 0;
	last_ack_ = tcph->seqno();
	prev_highest_ack_ = highest_ack_ ;
	highest_ack_ = last_ack_;

	if (t_seqno_ < last_ack_ + 1)
		t_seqno_ = last_ack_ + 1;
	/* 
	 * Update RTT only if it's OK to do so from info in the flags header.
	 * This is needed for protocols in which intermediate agents
	 * in the network intersperse acks (e.g., ack-reconstructors) for
	 * various reasons (without violating e2e semantics).
	 */	
	hdr_flags *fh = hdr_flags::access(pkt);
	if (!fh->no_ts_) {
		if (ts_option_) {
			ts_echo_=tcph->ts_echo();
			rtt_update(now - tcph->ts_echo());
			if (ts_resetRTO_ && (!ect_ || !ecn_backoff_ ||
			    !hdr_flags::access(pkt)->ecnecho())) { 
				// From Andrei Gurtov
				/* 
				 * Don't end backoff if still in ECN-Echo with
			 	 * a congestion window of 1 packet. 
				 */
				t_backoff_ = 1;
				ecn_backoff_ = 0;
			}
		}
		if (rtt_active_ && tcph->seqno() >= rtt_seq_) {
			if (!ect_ || !ecn_backoff_ || 
				!hdr_flags::access(pkt)->ecnecho()) {
				/* 
				 * Don't end backoff if still in ECN-Echo with
			 	 * a congestion window of 1 packet. 
				 */
				t_backoff_ = 1;
				ecn_backoff_ = 0;
			}
			rtt_active_ = 0;
			if (!ts_option_)
				rtt_update(now - rtt_ts_);
		}
	}
	if (timerfix_) newtimer(pkt);
	/* update average window */
	awnd_ *= 1.0 - wnd_th_;
	awnd_ += wnd_th_ * cwnd_;
}
/*
 * Process a packet that acks previously unacknowleged data.
 */
Process a packet that acks previously unacknowleged data.
Process a packet that acks previously unacknowleged data .
void TcpAgent::newack(Packet* pkt)
{
	double now = Scheduler::instance().clock();
	hdr_tcp *tcph = hdr_tcp::access(pkt);
	if (!timerfix_) newtimer(pkt);
	dupacks_ = 0;
	last_ack_ = tcph->seqno();
	prev_highest_ack_ = highest_ack_ ;
	highest_ack_ = last_ack_;
	if (t_seqno_ < last_ack_ + 1)
		t_seqno_ = last_ack_ + 1;
	hdr_flags *fh = hdr_flags::access(pkt);
	if (!fh->no_ts_) {
		if (ts_option_) {
			ts_echo_=tcph->ts_echo();
			rtt_update(now - tcph->ts_echo());
			if (ts_resetRTO_ && (!ect_ || !ecn_backoff_ ||
			    !hdr_flags::access(pkt)->ecnecho())) { 
				t_backoff_ = 1;
				ecn_backoff_ = 0;
			}
		}
		if (rtt_active_ && tcph->seqno() >= rtt_seq_) {
			if (!ect_ || !ecn_backoff_ || 
				!hdr_flags::access(pkt)->ecnecho()) {
				t_backoff_ = 1;
				ecn_backoff_ = 0;
			}
			rtt_active_ = 0;
			if (!ts_option_)
				rtt_update(now - rtt_ts_);
		}
	}
	if (timerfix_) newtimer(pkt);
	awnd_ *= 1.0 - wnd_th_;
	awnd_ += wnd_th_ * cwnd_;
}
void TcpAgent :: newack ( Packet * pkt ) { double now = Scheduler :: instance ( ) . clock ( ) ; hdr_tcp * tcph = hdr_tcp :: access ( pkt ) ; if ( ! timerfix_ ) newtimer ( pkt ) ; dupacks_ = 0 ; last_ack_ = tcph -> seqno ( ) ; prev_highest_ack_ = highest_ack_ ; highest_ack_ = last_ack_ ; if ( t_seqno_ < last_ack_ + 1 ) t_seqno_ = last_ack_ + 1 ; hdr_flags * fh = hdr_flags :: access ( pkt ) ; if ( ! fh -> no_ts_ ) { if ( ts_option_ ) { ts_echo_ = tcph -> ts_echo ( ) ; rtt_update ( now - tcph -> ts_echo ( ) ) ; if ( ts_resetRTO_ && ( ! ect_ || ! ecn_backoff_ || ! hdr_flags :: access ( pkt ) -> ecnecho ( ) ) ) { t_backoff_ = 1 ; ecn_backoff_ = 0 ; } } if ( rtt_active_ && tcph -> seqno ( ) >= rtt_seq_ ) { if ( ! ect_ || ! ecn_backoff_ || ! hdr_flags :: access ( pkt ) -> ecnecho ( ) ) { t_backoff_ = 1 ; ecn_backoff_ = 0 ; } rtt_active_ = 0 ; if ( ! ts_option_ ) rtt_update ( now - rtt_ts_ ) ; } } if ( timerfix_ ) newtimer ( pkt ) ; awnd_ *= 1.0 - wnd_th_ ; awnd_ += wnd_th_ * cwnd_ ; }
Process a packet that acks previously unacknowleged data.
Process a packet that acks previously unacknowleged data .
/* 
	 * Wouldn't it be better to set the timer *after*
	 * updating the RTT, instead of *before*? 
	 */ /* 
	 * Update RTT only if it's OK to do so from info in the flags header.
	 * This is needed for protocols in which intermediate agents
	 * in the network intersperse acks (e.g., ack-reconstructors) for
	 * various reasons (without violating e2e semantics).
	 */ // From Andrei Gurtov /* 
				 * Don't end backoff if still in ECN-Echo with
			 	 * a congestion window of 1 packet. 
				 */ /* 
				 * Don't end backoff if still in ECN-Echo with
			 	 * a congestion window of 1 packet. 
				 */ /* update average window */