ns-allinone-2.35/tcp/tcp-full.cc
int
FullTcpAgent::predict_ok(Packet* pkt)
{
	hdr_tcp *tcph = hdr_tcp::access(pkt);
        hdr_flags *fh = hdr_flags::access(pkt);

	/* not the fastest way to do this, but perhaps clearest */

	int p1 = (state_ == TCPS_ESTABLISHED);		// ready
	int p2 = ((tcph->flags() & (TH_SYN|TH_FIN|TH_ACK)) == TH_ACK); // ACK
	int p3 = ((flags_ & TF_NEEDFIN) == 0);		// don't need fin
	int p4 = (!ts_option_ || fh->no_ts_ || (tcph->ts() >= recent_)); // tsok
	int p5 = (tcph->seqno() == rcv_nxt_);		// in-order data
	int p6 = (t_seqno_ == maxseq_);			// not re-xmit
	int p7 = (!ecn_ || fh->ecnecho() == 0);		// no ECN
	int p8 = (tcph->sa_length() == 0);		// no SACK info

	return (p1 && p2 && p3 && p4 && p5 && p6 && p7 && p8);
}
/*
 * this is the simulated form of the header prediction
 * predicate.  While not really necessary for a simulation, it
 * follows the code base more closely and can sometimes help to reveal
 * odd behavior caused by the implementation structure..
 *
 * Here's the comment from the real TCP:
 *
 * Header prediction: check for the two common cases
 * of a uni-directional data xfer.  If the packet has
 * no control flags, is in-sequence, the window didn't
 * change and we're not retransmitting, it's a
 * candidate.  If the length is zero and the ack moved
 * forward, we're the sender side of the xfer.  Just
 * free the data acked & wake any higher level process
 * that was blocked waiting for space.  If the length
 * is non-zero and the ack didn't move, we're the
 * receiver side.  If we're getting packets in-order
 * (the reassembly queue is empty), add the data to
 * the socket buffer and note that we need a delayed ack.
 * Make sure that the hidden state-flags are also off.
 * Since we check for TCPS_ESTABLISHED above, it can only
 * be TF_NEEDSYN.
 */
this is the simulated form of the header prediction
predicate.  While not really necessary for a simulation, it
follows the code base more closely and can sometimes help to reveal
odd behavior caused by the implementation structure

Here's the comment from the real TCP.

Header prediction: check for the two common cases
of a uni-directional data xfer.  If the packet has
no control flags, is in-sequence, the window didn't
change and we're not retransmitting, it's a
candidate.  If the length is zero and the ack moved
forward, we're the sender side of the xfer.  Just
free the data acked & wake any higher level process
that was blocked waiting for space.  If the length
is non-zero and the ack didn't move, we're the
receiver side.  If we're getting packets in-order
(the reassembly queue is empty), add the data to
the socket buffer and note that we need a delayed ack.
Make sure that the hidden state-flags are also off.
Since we check for TCPS_ESTABLISHED above, it can only
be TF_NEEDSYN.
this is the simulated form of the header prediction predicate . While not really necessary for a simulation it follows the code base more closely and can sometimes help to reveal odd behavior caused by the implementation structure Here ' s the comment from the real TCP . Header prediction : check for the two common cases of a uni - directional data xfer . If the packet has no control flags is in - sequence the window didn ' t change and we ' re not retransmitting it ' s a candidate . If the length is zero and the ack moved forward we ' re the sender side of the xfer . Just free the data acked & wake any higher level process that was blocked waiting for space . If the length is non - zero and the ack didn ' t move we ' re the receiver side . If we ' re getting packets in - order ( the reassembly queue is empty ) add the data to the socket buffer and note that we need a delayed ack . Make sure that the hidden state - flags are also off . Since we check for TCPS_ESTABLISHED above it can only be TF_NEEDSYN .
int
FullTcpAgent::predict_ok(Packet* pkt)
{
	hdr_tcp *tcph = hdr_tcp::access(pkt);
        hdr_flags *fh = hdr_flags::access(pkt);
	int p1 = (state_ == TCPS_ESTABLISHED);		
	int p2 = ((tcph->flags() & (TH_SYN|TH_FIN|TH_ACK)) == TH_ACK); 
	int p3 = ((flags_ & TF_NEEDFIN) == 0);		
	int p4 = (!ts_option_ || fh->no_ts_ || (tcph->ts() >= recent_)); 
	int p5 = (tcph->seqno() == rcv_nxt_);		
	int p6 = (t_seqno_ == maxseq_);			
	int p7 = (!ecn_ || fh->ecnecho() == 0);		
	int p8 = (tcph->sa_length() == 0);		
	return (p1 && p2 && p3 && p4 && p5 && p6 && p7 && p8);
}
int FullTcpAgent :: predict_ok ( Packet * pkt ) { hdr_tcp * tcph = hdr_tcp :: access ( pkt ) ; hdr_flags * fh = hdr_flags :: access ( pkt ) ; int p1 = ( state_ == TCPS_ESTABLISHED ) ; int p2 = ( ( tcph -> flags ( ) & ( TH_SYN | TH_FIN | TH_ACK ) ) == TH_ACK ) ; int p3 = ( ( flags_ & TF_NEEDFIN ) == 0 ) ; int p4 = ( ! ts_option_ || fh -> no_ts_ || ( tcph -> ts ( ) >= recent_ ) ) ; int p5 = ( tcph -> seqno ( ) == rcv_nxt_ ) ; int p6 = ( t_seqno_ == maxseq_ ) ; int p7 = ( ! ecn_ || fh -> ecnecho ( ) == 0 ) ; int p8 = ( tcph -> sa_length ( ) == 0 ) ; return ( p1 && p2 && p3 && p4 && p5 && p6 && p7 && p8 ) ; }
this is the simulated form of the header prediction
 predicate.
this is the simulated form of the header prediction predicate .
/* not the fastest way to do this, but perhaps clearest */ // ready // ACK // don't need fin // tsok // in-order data // not re-xmit // no ECN // no SACK info