您的位置:首页 > 其它

l2dct

2016-04-07 15:23 447 查看
http://paste.ubuntu.com/15664711/

diff -crbB ns-allinone-2.35/ns-2.35/queue/red.cc ns-2.35/queue/red.cc
*** ns-allinone-2.35/ns-2.35/queue/red.cc	2011-10-02 18:32:34.000000000 -0400
--- ns-2.35/queue/red.cc	2014-10-01 14:37:10.684908657 -0400
***************
*** 559,566 ****
edv_.count_bytes = 0;
hdr_flags* hf = hdr_flags::access(pickPacketForECN(pkt));
if (edp_.setbit && hf->ect() &&
!                      (!edp_.use_mark_p || edv_.v_prob1 < edp_.mark_p)) {
hf->ce() = 1; 	// mark Congestion Experienced bit
// Tell the queue monitor here - call emark(pkt)
return (0);	// no drop
} else {
--- 559,567 ----
edv_.count_bytes = 0;
hdr_flags* hf = hdr_flags::access(pickPacketForECN(pkt));
if (edp_.setbit && hf->ect() &&
! 		    (!edp_.use_mark_p || edv_.v_prob1 <= edp_.mark_p)) { // For DCTCP: '<' is changed to '<=' here
hf->ce() = 1; 	// mark Congestion Experienced bit
+ 			//fprintf(stdout,"DCTCP packet marked at time= %f\n", (double)Scheduler::instance().clock());
// Tell the queue monitor here - call emark(pkt)
return (0);	// no drop
} else {
Only in ns-2.35/queue: red.cc~
diff -crbB ns-allinone-2.35/ns-2.35/tcl/lib/ns-default.tcl ns-2.35/tcl/lib/ns-default.tcl
*** ns-allinone-2.35/ns-2.35/tcl/lib/ns-default.tcl	2010-07-03 18:45:45.000000000 -0400
--- ns-2.35/tcl/lib/ns-default.tcl	2012-07-21 21:35:04.000000000 -0400
***************
*** 916,922 ****
Agent/TCP set exitFastRetrans_ true ;	# Added 2003/7/28.
# For clean exits of Fast Retransmit.
# False for old buggy behavior.
! Agent/TCP set window_ 20
Agent/TCP set windowInit_ 2 ;		# default changed on 2001/5/26.
Agent/TCP set windowInitOption_ 1
Agent/TCP set syn_ true ;		# default changed on 2001/5/17.
--- 916,922 ----
Agent/TCP set exitFastRetrans_ true ;	# Added 2003/7/28.
# For clean exits of Fast Retransmit.
# False for old buggy behavior.
! Agent/TCP set window_ 20000000
Agent/TCP set windowInit_ 2 ;		# default changed on 2001/5/26.
Agent/TCP set windowInitOption_ 1
Agent/TCP set syn_ true ;		# default changed on 2001/5/17.
***************
*** 1026,1031 ****
--- 1026,1039 ----

Agent/TCP set SetCWRonRetransmit_ true ; # added on 2005/06/19.
# default changed on 2008/06/05.
+ # DCTCP
+ Agent/TCP set dctcp_ false;
+ Agent/TCP set dctcp_alpha_ 0.0;
+ Agent/TCP set dctcp_g_ 0.0625;
+
+ # D2TCP
+ Agent/TCP set flow_deadline 100000;
+ Agent/TCP set flow_size 10000000000;

# XXX Generate nam trace or plain old text trace for variables.
# When it's true, generate nam trace.
diff -crbB ns-allinone-2.35/ns-2.35/tcp/tcp.cc ns-2.35/tcp/tcp.cc
*** ns-allinone-2.35/ns-2.35/tcp/tcp.cc	2011-06-20 00:51:46.000000000 -0400
--- ns-2.35/tcp/tcp.cc	2014-10-01 14:55:29.020865582 -0400
***************
*** 47,52 ****
--- 47,56 ----
#include "basetrace.h"
#include "hdr_qs.h"

+ #define debug_dctcp 0
+ #define wmax 2.5 	//Max weight a flow can get
+ #define wmin 0.125	//Min weight a flow can get
+
int hdr_tcp::offset_;

static class TCPHeaderClass : public PacketHeaderClass {
***************
*** 76,82 ****
first_decrease_(1), fcnt_(0), nrexmit_(0), restart_bugfix_(1),
cong_action_(0), ecn_burst_(0), ecn_backoff_(0), ect_(0),
use_rtt_(0), qs_requested_(0), qs_approved_(0),
! 	  qs_window_(0), qs_cwnd_(0), frto_(0)
{
#ifdef TCP_DELAY_BIND_ALL
// defined since Dec 1999.
--- 80,86 ----
first_decrease_(1), fcnt_(0), nrexmit_(0), restart_bugfix_(1),
cong_action_(0), ecn_burst_(0), ecn_backoff_(0), ect_(0),
use_rtt_(0), qs_requested_(0), qs_approved_(0),
! 	  qs_window_(0), qs_cwnd_(0), frto_(0), dctcp_maxseq(0)
{
#ifdef TCP_DELAY_BIND_ALL
// defined since Dec 1999.
***************
*** 101,106 ****
--- 105,113 ----
bind("necnresponses_", &necnresponses_);
bind("ncwndcuts_", &ncwndcuts_);
bind("ncwndcuts1_", &ncwndcuts1_);
+ 	bind("dctcp_", &dctcp_);
+ 	bind("dctcp_alpha_", &dctcp_alpha_);
+ 	bind("dctcp_g_", &dctcp_g_);
#endif /* TCP_DELAY_BIND_ALL */

}
***************
*** 123,128 ****
--- 130,140 ----
delay_bind_init_one("overhead_");
delay_bind_init_one("tcpTick_");
delay_bind_init_one("ecn_");
+ 	// DCTCP
+ 	delay_bind_init_one("dctcp_");
+ 	delay_bind_init_one("dctcp_alpha_");
+ 	delay_bind_init_one("dctcp_g_");
+
delay_bind_init_one("SetCWRonRetransmit_");
delay_bind_init_one("old_ecn_");
delay_bind_init_one("bugfix_ss_");
***************
*** 234,239 ****
--- 246,255 ----
if (delay_bind(varName, localName, "overhead_", &overhead_, tracer)) return TCL_OK;
if (delay_bind(varName, localName, "tcpTick_", &tcp_tick_, tracer)) return TCL_OK;
if (delay_bind_bool(varName, localName, "ecn_", &ecn_, tracer)) return TCL_OK;
+ 	// Ali munir
+         if (delay_bind_bool(varName, localName, "dctcp_", &dctcp_, tracer)) return TCL_OK;
+ 	if (delay_bind(varName, localName, "dctcp_alpha_", &dctcp_alpha_ , tracer)) return TCL_OK;
+ 	if (delay_bind(varName, localName, "dctcp_g_", &dctcp_g_ , tracer)) return TCL_OK;
if (delay_bind_bool(varName, localName, "SetCWRonRetransmit_", &SetCWRonRetransmit_, tracer)) return TCL_OK;
if (delay_bind_bool(varName, localName, "old_ecn_", &old_ecn_ , tracer)) return TCL_OK;
if (delay_bind_bool(varName, localName, "bugfix_ss_", &bugfix_ss_ , tracer)) return TCL_OK;
***************
*** 719,724 ****
--- 735,743 ----
hf->ecnecho() = 1;
//			hf->cong_action() = 1;
hf->ect() = 0;
+ 		/* ali munir */
+ 		if (dctcp_)
+ 			hf->ect() = 1;
}
if (qs_enabled_) {
hdr_qs *qsh = hdr_qs::access(p);
***************
*** 775,780 ****
--- 794,807 ----
send(p, 0);
if (seqno == curseq_ && seqno > maxseq_)
idle();  // Tell application I have sent everything so far
+
+ 	/* ali munir: begins*/
+ 	if (dctcp_)
+ 	if (seqno > dctcp_maxseq)
+ 		dctcp_maxseq = seqno;
+
+
+
if (seqno > maxseq_) {
maxseq_ = seqno;
if (!rtt_active_) {
***************
*** 1119,1124 ****
--- 1146,1175 ----
void TcpAgent::opencwnd()
{
double increment;
+ 	double weight_c;	//Ali Munir
+ 	double mywnd_old;	//Ali Munir
+ 	double mywnd_new;	//Ali Munir
+
+ 	/* Ali Munir: Begin */
+ 	mywnd_old = cwnd_;
+
+ 	if (dctcp_) {
+
+ 	if (ndatapack_ <= 200)	weight_c = wmax;
+ 	if (ndatapack_ > 200)	weight_c = wmax - (wmax-wmin) * (ndatapack_ - 200) / 800;
+
+ 	if (weight_c < wmin) weight_c = wmin;
+ 	if (weight_c > wmax) weight_c = wmax;
+
+ 	increase_num_ = weight_c / wmax;
+
+ 	if(debug_dctcp)
+ 	printf("opencwnd: increase=%f\n", increase_num_);
+
+ 	}
+ 	/* Ali Munir: End */
+
+
if (cwnd_ < ssthresh_) {
/* slow-start (exponential) */
cwnd_ += 1;
***************
*** 1127,1136 ****
double f;
switch (wnd_option_) {
case 0:
! 			if (++count_ >= cwnd_) {
! 				count_ = 0;
! 				++cwnd_;
! 			}
break;

case 1:
--- 1178,1188 ----
double f;
switch (wnd_option_) {
case 0:
! 		// Begin
! 			increment = increase_num_ / cwnd_;
! 			cwnd_ += increment;
! 	if(debug_dctcp)
! 		printf("opencwnd: increase=%f, test print # 0\n", increase_num_);
break;

case 1:
***************
*** 1143,1148 ****
--- 1195,1202 ----
max_ssthresh_, increment);
}
cwnd_ += increment;
+ 		if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 1\n", increase_num_);
break;

case 2:
***************
*** 1153,1158 ****
--- 1207,1214 ----
*  with Multiple Congested Gateways".
*  The window is increased by roughly
*  wnd_const_*RTT^2 packets per round-trip time.  */
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 2\n", increase_num_);
f = (t_srtt_ >> T_SRTT_BITS) * tcp_tick_;
f *= f;
f *= wnd_const_;
***************
*** 1178,1183 ****
--- 1234,1241 ----
++cwnd_;
} else
fcnt_ = f;
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 3\n", increase_num_);
break;

case 4:
***************
*** 1192,1197 ****
--- 1250,1257 ----
++cwnd_;
} else
fcnt_ = f;
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 4\n", increase_num_);
break;
case 5:
/* The window is increased by roughly wnd_const_*RTT
***************
*** 1206,1215 ****
--- 1266,1279 ----
++cwnd_;
} else
fcnt_ = f;
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 5\n", increase_num_);
break;
case 6:
/* binomial controls */
cwnd_ += increase_num_ / (cwnd_*pow(cwnd_,k_parameter_));
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 6\n", increase_num_);
break;
case 8:
/* high-speed TCP, RFC 3649 */
***************
*** 1221,1232 ****
--- 1285,1300 ----
max_ssthresh_, increment);
}
cwnd_ += increment;
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # 8\n", increase_num_);
break;
default:
#ifdef notdef
/*XXX*/
error("illegal window option %d", wnd_option_);
#endif
+ 	if(debug_dctcp)
+ 		printf("opencwnd: increase=%f, test print # default\n", increase_num_);
abort();
}
}
***************
*** 1234,1239 ****
--- 1302,1311 ----
if (maxcwnd_ && (int(cwnd_) > maxcwnd_))
cwnd_ = maxcwnd_;

+ 	if(debug_dctcp){
+ 		mywnd_new = cwnd_;
+ 		printf("opencwnd: increase=%f, cwnd: old %f new %f\n", increase_num_, (double)windowd(), mywnd_new);
+ 		}
return;
}

***************
*** 1243,1248 ****
--- 1315,1322 ----
double decrease;  /* added for highspeed - sylvia */
double win, halfwin, decreasewin;
int slowstart = 0;
+ 	double b_;
+ 	double weight_c;
++ncwndcuts_;
if (!(how & TCP_IDLE) && !(how & NO_OUTSTANDING_DATA)){
++ncwndcuts1_;
***************
*** 1297,1302 ****
--- 1371,1381 ----
} else {
ssthresh_ = (int) decreasewin;
}
+ 	else if (how & CLOSE_SSTHRESH_DCTCP) {
+ 		ssthresh_ = (int) ((1 - dctcp_alpha_/2.0) * windowd());
+ 	if(debug_dctcp)
+ 		fprintf(stdout,"DCTCP backoff (ssthresh) applied (alpha=%f) at time= %f\n", (double)dctcp_alpha_, (double)Scheduler::instance().clock());
+ 	}
else if (how & THREE_QUARTER_SSTHRESH)
if (ssthresh_ < 3*cwnd_/4)
ssthresh_  = (int)(3*cwnd_/4);
***************
*** 1306,1311 ****
--- 1385,1407 ----
if (first_decrease_ == 1 || slowstart || decrease_num_ == 0.5) {
cwnd_ = halfwin;
} else cwnd_ = decreasewin;
+ 	else if (how & CLOSE_CWND_DCTCP){
+
+ 		/* Ali Munir: Begin */
+ 		if (ndatapack_ <= 200)	weight_c = wmax;
+ 		if (ndatapack_ > 200)	weight_c = wmax - (wmax-wmin) * (ndatapack_ - 200) / 800;
+
+
+ 		if (weight_c < wmin) weight_c = wmin;
+ 		if (weight_c > wmax) weight_c = wmax;
+
+ 		b_ = pow(dctcp_alpha_,weight_c);
+ 		cwnd_ = (1 - b_/2.0) * windowd();
+
+ 		if(debug_dctcp)
+ 			fprintf(stdout,"DCTCP backoff (cwnd down) applied (alpha=%f) at time= %f, weight=%f b=%f, cwnd %f, fid %d\n", (double)dctcp_alpha_, (double)Scheduler::instance().clock(), weight_c, b_, (double)windowd(), fid_);
+ 		/* Ali Munir: End */
+ 	}
else if (how & CWND_HALF_WITH_MIN) {
// We have not thought about how non-standard TCPs, with
// non-standard values of decrease_num_, should respond
***************
*** 1328,1334 ****
}
if (ssthresh_ < 2)
ssthresh_ = 2;
! 	if (how & (CLOSE_CWND_HALF|CLOSE_CWND_RESTART|CLOSE_CWND_INIT|CLOSE_CWND_ONE))
cong_action_ = TRUE;

fcnt_ = count_ = 0;
--- 1424,1432 ----
}
if (ssthresh_ < 2)
ssthresh_ = 2;
! 	if (cwnd_ < 1)
! 		cwnd_ = 1;
! 	if (how & (CLOSE_CWND_HALF|CLOSE_CWND_RESTART|CLOSE_CWND_INIT|CLOSE_CWND_ONE|CLOSE_CWND_DCTCP))
cong_action_ = TRUE;

fcnt_ = count_ = 0;
***************
*** 1429,1434 ****
--- 1527,1535 ----
rtt_backoff();
else ecn_backoff_ = 1;
} else ecn_backoff_ = 0;
+ 		if (dctcp_)
+ 			slowdown(CLOSE_CWND_DCTCP|CLOSE_SSTHRESH_DCTCP);
+ 		else
slowdown(CLOSE_CWND_HALF|CLOSE_SSTHRESH_HALF);
++necnresponses_ ;
// added by sylvia to count number of ecn responses
Only in ns-2.35/tcp: tcp.cc~
diff -crbB ns-allinone-2.35/ns-2.35/tcp/tcp.h ns-2.35/tcp/tcp.h
*** ns-allinone-2.35/ns-2.35/tcp/tcp.h	2011-08-26 15:29:57.000000000 -0400
--- ns-2.35/tcp/tcp.h	2012-07-11 06:07:18.000000000 -0400
***************
*** 104,110 ****
#define CWND_HALF_WITH_MIN	0x00000200
#define TCP_IDLE		0x00000400
#define NO_OUTSTANDING_DATA     0x00000800
!
/*
* tcp_tick_:
* default 0.1,
--- 104,111 ----
#define CWND_HALF_WITH_MIN	0x00000200
#define TCP_IDLE		0x00000400
#define NO_OUTSTANDING_DATA     0x00000800
! #define CLOSE_SSTHRESH_DCTCP   0x00001000
! #define CLOSE_CWND_DCTCP       0x00002000
/*
* tcp_tick_:
* default 0.1,
***************
*** 432,437 ****
--- 433,445 ----

/* Used for ECN */
int ecn_;		/* Explicit Congestion Notification */
+
+ 	/* Use for DCTCP */
+ 	int dctcp_;
+ 	double dctcp_alpha_;
+ 	double dctcp_g_;
+ 	int dctcp_maxseq;
+
int cong_action_;	/* Congestion Action.  True to indicate
that the sender responded to congestion. */
int ecn_burst_;		/* True when the previous ACK packet
diff -crbB ns-allinone-2.35/ns-2.35/tcp/tcp-sack1.cc ns-2.35/tcp/tcp-sack1.cc
*** ns-allinone-2.35/ns-2.35/tcp/tcp-sack1.cc	2006-12-24 12:04:44.000000000 -0500
--- ns-2.35/tcp/tcp-sack1.cc	2014-10-01 15:10:19.248830658 -0400
***************
*** 38,43 ****
--- 38,45 ----
#define RECOVER_TIMEOUT 2
#define RECOVER_QUENCH  3

+ #define debug_dctcp 0
+
class Sack1TcpAgent : public TcpAgent {
public:
Sack1TcpAgent();
***************
*** 53,58 ****
--- 55,67 ----
protected:
u_char timeout_;	/* boolean: sent pkt from timeout? */
u_char fastrecov_;	/* boolean: doing fast recovery? */
+ 	/* variables for DCTCP */
+ 	int dctcp_total;
+ 	int dctcp_marked;
+ 	int dctcp_alpha_update_seq;
+ //	int dctcp_maxseq;
+ 	int ce_transition;
+
int pipe_;		/* estimate of pipe size (fast recovery) */
int partial_ack_;	/* Set to "true" to ensure sending */
/*  a packet on a partial ACK.     */
***************
*** 61,66 ****
--- 70,76 ----
int firstpartial_;	/* First of a series of partial acks. */
ScoreBoard* scb_;
static const int SBSIZE=64; /* Initial scoreboard size */
+ 	void update_dctcp_alpha(Packet *); /* DCTCP alpha update */
};

static class Sack1TcpClass : public TclClass {
***************
*** 71,77 ****
}
} class_sack;

! Sack1TcpAgent::Sack1TcpAgent() : fastrecov_(FALSE), pipe_(-1), next_pkt_(0), firstpartial_(0)
{
bind_bool("partial_ack_", &partial_ack_);
/* Use the Reassembly Queue based scoreboard as
--- 81,88 ----
}
} class_sack;

! Sack1TcpAgent::Sack1TcpAgent() : fastrecov_(FALSE), pipe_(-1), next_pkt_(0), firstpartial_(0),
! 	        dctcp_total(0), dctcp_marked(0), dctcp_alpha_update_seq(0), ce_transition(0)
{
bind_bool("partial_ack_", &partial_ack_);
/* Use the Reassembly Queue based scoreboard as
***************
*** 116,121 ****
--- 127,139 ----
return;
}
++nackpack_;
+
+ 	/* ali munir */
+ 	if (dctcp_)
+ 		update_dctcp_alpha(pkt);
+
+
+
int ecnecho = hdr_flags::access(pkt)->ecnecho();
if (ecnecho && ecn_)
ecn(tcph->seqno());
***************
*** 284,289 ****
--- 304,315 ----

if (ecn_ && last_cwnd_action_ == CWND_ACTION_ECN) {
last_cwnd_action_ = CWND_ACTION_DUPACK;
+
+ 		/* ali  munir: cut window by half when we have 3 dup ack */
+ 		if (dctcp_)
+ 			slowdown(CLOSE_SSTHRESH_HALF|CLOSE_CWND_HALF);
+
+
/*
* What if there is a DUPACK action followed closely by ECN
* followed closely by a DUPACK action?
***************
*** 400,405 ****
--- 426,438 ----
* If DSACK and detection of premature retransmit
*  timeouts, then save some info here.
*/
+ 		/* begin: ali munir */
+ 		//dctcp_alpha_update_seq = tno; /* should be t_seqno_ */
+ 		dctcp_alpha_update_seq = t_seqno_;
+ 		dctcp_maxseq = dctcp_alpha_update_seq;
+
+ 		/* end: ali munir */
+
dupacks_ = 0;
fastrecov_ = FALSE;
timeout_ = TRUE;
***************
*** 419,424 ****
--- 453,507 ----
frto_ = 0;
}

+
+ /*
+  * Update dctcp alpha based on the ecn bit in the received packet.
+  * This procedure is called only when dctcp_ is 1.
+  */
+ void Sack1TcpAgent::update_dctcp_alpha(Packet *pkt)
+ {
+ 	int ecnbit = hdr_flags::access(pkt)->ecnecho();
+ 	int ackno = hdr_tcp::access(pkt)->ackno();
+ 	int seqno = hdr_tcp::access(pkt)->seqno();
+ 	int acked_bytes = seqno - highest_ack_;
+
+ 	if(debug_dctcp)
+ 		printf ("timeout. highest_ack: %i seqno: %i fid: %i seqnum: %i\n",
+ 			(int)highest_ack_, (int)t_seqno_, fid_, seqno);
+
+ 	if (acked_bytes <= 0)
+ //		acked_bytes = size_;	/* it should be one */
+ 		acked_bytes = 1;	/* it should be one */
+ 	dctcp_total += acked_bytes;
+ 	if (ecnbit) {
+ 		dctcp_marked += acked_bytes;
+ 	}
+
+ 	if(debug_dctcp)
+ 		fprintf(stdout,"DCTCP update_alpha 1: (ackno=%i), (dctcp_alpha_update=%f), (dctcp_maxseq=%f), (acked_bytes=%d)\n", (int)ackno, (double)dctcp_alpha_update_seq, (double)dctcp_maxseq, acked_bytes);
+ 	/* Check for barrier indicating its time to recalculate alpha.
+ 	 * This code basically updated alpha roughly once per RTT.
+ 	 */
+ 	if (seqno > dctcp_alpha_update_seq) {
+ 		double temp_alpha;
+ 		dctcp_alpha_update_seq = dctcp_maxseq;
+ 		if (dctcp_total > 0)
+ 			temp_alpha = ((double) dctcp_marked) / dctcp_total;
+ 		else
+ 			temp_alpha = 0.0;
+
+ //		temp_alpha = ((double) dctcp_marked) / 35.0;
+ 		dctcp_alpha_ = (1 - dctcp_g_) * dctcp_alpha_ + dctcp_g_ * temp_alpha;
+ 		dctcp_marked = 0;
+ 		dctcp_total = 0;
+ 	}
+
+ 	if(debug_dctcp)
+ 		fprintf(stdout,"DCTCP update_alpha: (dctcpseq=%d), (marked=%d), (total=%d), (alpha=%f) at time= %f\n", dctcp_maxseq, dctcp_marked, dctcp_total, (double)dctcp_alpha_, (double)Scheduler::instance().clock());
+ }
+
+
+
void Sack1TcpAgent::send_much(int force, int reason, int maxburst)
{
register int found, npacket = 0;
Only in ns-2.35/tcp: tcp-sack1.cc~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: