
// TCP-NJ - TCP Newjersey with NewReno Features
//

#ifndef tcp_nj_h
#define tcp_nj_h

#include "tcp.h"

/* used in slowdown(): how to change the cwnd and ssthresh values */
#define CLOSE_TCPNJ	0x00000800


class NJTcpAgent : public virtual NewRenoTcpAgent {
public:
	NJTcpAgent();
	virtual void recv(Packet *pkt, Handler*);
	virtual void dupack_action();
	virtual void timeout (int tno);
	virtual void ecn(int tno);
	
	/* these where originally in class TcpAgent (file: tcp.h) */
	virtual void slowdown(int how);
	virtual void newack(Packet* pkt);
	virtual int  delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer);

protected:
	int loss_diff_;		/* 1: if we do loss differentiation, otherwise treat all loss as cong. */
	int marked_;		/* DUPACK + CW Mark */
	int congested_;		/* used to decide timeout cwnd adjustment */
	TracedInt wloss_cnt_;	/* number of detected wireless loss */
	struct wloss_s_ {	/* trace the wireless loss */
		double	time;
		int	seq;
		int	uid;
	} wloss_;

	TracedDouble current_are_;    	/* Current achievable rate estimation */
	double t_last_;			/* time (or timestampt) of arrival of previous ACK */
        double min_rtt_estimate;	/* smallest recorded RTT estimate */
        
	void reduce_to_est_rate();

        virtual void compute_are(Packet *pkt);

	virtual void traceVar(TracedVar*); 

};

#endif /* tcp_nj_h */

