/*
 * Copyright (c) 1997-98 Stanford University.
 * All rights reserved.
 *
 * TCP-BFA: Buffer Fill Avoidance (http://klamath.stanford.edu/~aaa/tcp-bfa)
 * By: Amr A. Awadallah (aaa@stanford.edu) and Chetan Rai (crai@stanford.edu)
 *
 * You are allowed to do whatever you want with this file as long as copyright
 * above is always reproduced whether in text or binary format. We hereby
 * disclaim any misfortunes that might happen to you due to the use of this
 * code.
 *
 */

#ifndef ns_tcp_bfa_h
#define ns_tcp_bfa_h

#include "tcp.h"

/* IMPORTANT NOTE: We overload the following functions in
   the TcpAgent class in tcp.h:
   
  void traceAll();
  void rtt_init();
  double rtt_timeout();
  void rtt_update(double tao);
  void rtt_backoff();
  void opencwnd();
  void closecwnd(int how);
  void reset();

  Note that these functions might be static in some ns releases, in these
  cases you must edit the TcpAgent class in tcp.h and add the keyword
  "virtual" before all of these functions before you compile.

  */


/* TCP Reno with BFA*/
class BfaRenoTcpAgent : public virtual RenoTcpAgent {
 public:
	BfaRenoTcpAgent();
 protected:

        int bfa_enable_; /* Enables buffer file avoidance */
	TracedInt bfa_flag_;   /* The buffer fill avoidance flag */
	TracedInt bfa_signed_rttvar_; /* signed variance of round-trip time */

        /* bfa signed rttvar thresholds in granuality of 2 bits to
	   right side of binary point. That is in 2.5ms increments.
	   Default value should be -4 and 4 ticks, that is -10 and 10ms. */    
	
	int bfa_on_thresh_;
	int bfa_off_thresh_;

        /* Overloaded functions for controlling cwnd */
  	virtual void reset();
  	virtual void opencwnd();
	virtual void closecwnd(int how);

        /* Overloaded functions for setting bfa_signed_rttvar */
	virtual void rtt_init();
	virtual double rtt_timeout();	/* provide an RTO based on RTT estimates */
	virtual void rtt_update(double tao);	/* update RTT estimate with sample */
	virtual void rtt_backoff();		/* double multiplier */

        /* Overloaded functions for tracing and plotting our variables as well */
        virtual void traceAll();
	virtual void traceVar(TracedVar* v);
        virtual void plot();
};

// Local Variables:
// mode:c++
// End:

#endif





