ns-allinone-2.35/tcp/tcp.cc
void TcpAgent::recv(Packet *pkt, Handler*)
{
	hdr_tcp *tcph = hdr_tcp::access(pkt);
	int valid_ack = 0;
	if (qs_approved_ == 1 && tcph->seqno() > last_ack_) 
		endQuickStart();
	if (qs_requested_ == 1)
		processQuickStart(pkt);
#ifdef notdef
	if (pkt->type_ != PT_ACK) {
		Tcl::instance().evalf("%s error \"received non-ack\"",
				      name());
		Packet::free(pkt);
		return;
	}
#endif
	/* W.N.: check if this is from a previous incarnation */
	if (tcph->ts() < lastreset_) {
		// Remove packet and do nothing
		Packet::free(pkt);
		return;
	}
	++nackpack_;
	ts_peer_ = tcph->ts();
	int ecnecho = hdr_flags::access(pkt)->ecnecho();
	if (ecnecho && ecn_)
		ecn(tcph->seqno());
	recv_helper(pkt);
	recv_frto_helper(pkt);
	/* grow cwnd and check if the connection is done */ 
	if (tcph->seqno() > last_ack_) {
		recv_newack_helper(pkt);
		if (last_ack_ == 0 && delay_growth_) { 
			cwnd_ = initial_window();
		}
	} else if (tcph->seqno() == last_ack_) {
                if (hdr_flags::access(pkt)->eln_ && eln_) {
                        tcp_eln(pkt);
                        return;
                }
		if (++dupacks_ == numdupacks_ && !noFastRetrans_) {
			dupack_action();
		} else if (dupacks_ < numdupacks_ && singledup_ ) {
			send_one();
		}
	}

	if (QOption_ && EnblRTTCtr_)
		process_qoption_after_ack (tcph->seqno());

	if (tcph->seqno() >= last_ack_)  
		// Check if ACK is valid.  Suggestion by Mark Allman. 
		valid_ack = 1;
	Packet::free(pkt);
	/*
	 * Try to send more data.
	 */
	if (valid_ack || aggressive_maxburst_)
		send_much(0, 0, maxburst_);
}
/*
 * main reception path - should only see acks, otherwise the
 * network connections are misconfigured
 */
main reception path - should only see acks, otherwise the
network connections are misconfigured
main reception path - should only see acks otherwise the network connections are misconfigured
void TcpAgent::recv(Packet *pkt, Handler*)
{
	hdr_tcp *tcph = hdr_tcp::access(pkt);
	int valid_ack = 0;
	if (qs_approved_ == 1 && tcph->seqno() > last_ack_) 
		endQuickStart();
	if (qs_requested_ == 1)
		processQuickStart(pkt);
#ifdef notdef
	if (pkt->type_ != PT_ACK) {
		Tcl::instance().evalf("%s error \"received non-ack\"",
				      name());
		Packet::free(pkt);
		return;
	}
#endif
	if (tcph->ts() < lastreset_) {
		Packet::free(pkt);
		return;
	}
	++nackpack_;
	ts_peer_ = tcph->ts();
	int ecnecho = hdr_flags::access(pkt)->ecnecho();
	if (ecnecho && ecn_)
		ecn(tcph->seqno());
	recv_helper(pkt);
	recv_frto_helper(pkt);
	if (tcph->seqno() > last_ack_) {
		recv_newack_helper(pkt);
		if (last_ack_ == 0 && delay_growth_) { 
			cwnd_ = initial_window();
		}
	} else if (tcph->seqno() == last_ack_) {
                if (hdr_flags::access(pkt)->eln_ && eln_) {
                        tcp_eln(pkt);
                        return;
                }
		if (++dupacks_ == numdupacks_ && !noFastRetrans_) {
			dupack_action();
		} else if (dupacks_ < numdupacks_ && singledup_ ) {
			send_one();
		}
	}
	if (QOption_ && EnblRTTCtr_)
		process_qoption_after_ack (tcph->seqno());
	if (tcph->seqno() >= last_ack_)  
		valid_ack = 1;
	Packet::free(pkt);
	if (valid_ack || aggressive_maxburst_)
		send_much(0, 0, maxburst_);
}
void TcpAgent :: recv ( Packet * pkt , Handler * ) { hdr_tcp * tcph = hdr_tcp :: access ( pkt ) ; int valid_ack = 0 ; if ( qs_approved_ == 1 && tcph -> seqno ( ) > last_ack_ ) endQuickStart ( ) ; if ( qs_requested_ == 1 ) processQuickStart ( pkt ) ; #ifdef notdef if ( pkt -> type_ != PT_ACK ) { Tcl :: instance ( ) . evalf ( " \" \" " , name ( ) ) ; Packet :: free ( pkt ) ; return ; } #endif if ( tcph -> ts ( ) < lastreset_ ) { Packet :: free ( pkt ) ; return ; } ++ nackpack_ ; ts_peer_ = tcph -> ts ( ) ; int ecnecho = hdr_flags :: access ( pkt ) -> ecnecho ( ) ; if ( ecnecho && ecn_ ) ecn ( tcph -> seqno ( ) ) ; recv_helper ( pkt ) ; recv_frto_helper ( pkt ) ; if ( tcph -> seqno ( ) > last_ack_ ) { recv_newack_helper ( pkt ) ; if ( last_ack_ == 0 && delay_growth_ ) { cwnd_ = initial_window ( ) ; } } else if ( tcph -> seqno ( ) == last_ack_ ) { if ( hdr_flags :: access ( pkt ) -> eln_ && eln_ ) { tcp_eln ( pkt ) ; return ; } if ( ++ dupacks_ == numdupacks_ && ! noFastRetrans_ ) { dupack_action ( ) ; } else if ( dupacks_ < numdupacks_ && singledup_ ) { send_one ( ) ; } } if ( QOption_ && EnblRTTCtr_ ) process_qoption_after_ack ( tcph -> seqno ( ) ) ; if ( tcph -> seqno ( ) >= last_ack_ ) valid_ack = 1 ; Packet :: free ( pkt ) ; if ( valid_ack || aggressive_maxburst_ ) send_much ( 0 , 0 , maxburst_ ) ; }
main reception path - should only see acks, otherwise the
 network connections are misconfigured
main reception path - should only see acks otherwise the network connections are misconfigured
/* W.N.: check if this is from a previous incarnation */ // Remove packet and do nothing /* grow cwnd and check if the connection is done */ // Check if ACK is valid.  Suggestion by Mark Allman.  /*
	 * Try to send more data.
	 */