ns-allinone-2.35/queue/red.cc
void REDQueue::initialize_params()
{
/*
 * If q_weight=0, set it to a reasonable value of 1-exp(-1/C)
 * This corresponds to choosing q_weight to be of that value for
 * which the packet time constant -1/ln(1-q_weight) per default RTT 
 * of 100ms is an order of magnitude more than the link capacity, C.
 *
 * If q_weight=-1, then the queue weight is set to be a function of
 * the bandwidth and the link propagation delay.  In particular, 
 * the default RTT is assumed to be three times the link delay and 
 * transmission delay, if this gives a default RTT greater than 100 ms. 
 *
 * If q_weight=-2, set it to a reasonable value of 1-exp(-10/C).
 */
	if (edp_.q_w == 0.0) {
		edp_.q_w = 1.0 - exp(-1.0/edp_.ptc);
 	} else if (edp_.q_w == -1.0) {
		double rtt = 3.0*(edp_.delay+1.0/edp_.ptc);
		//printf("delay: %5.4f rtt: %5.4f\n", edp_.delay, rtt);
		if (rtt < 0.1) 
			rtt = 0.1;
		edp_.q_w = 1.0 - exp(-1.0/(10*rtt*edp_.ptc));
	} else if (edp_.q_w == -2.0) {
		edp_.q_w = 1.0 - exp(-10.0/edp_.ptc);
	}

	// printf("ptc: %7.5f bandwidth: %5.3f pktsize: %d\n", edp_.ptc, link_->bandwidth(), edp_.mean_pktsize);
        // printf("th_min_pkts: %7.5f th_max_pkts: %7.5f\n", edp_.th_min_pkts, edp_.th_max);
	if (edp_.th_min_pkts == 0) {
		edp_.th_min_pkts = 5.0;
		// set th_min_pkts to half of targetqueue, if this is greater
		//  than 5 packets.
		double targetqueue = edp_.targetdelay * edp_.ptc;
		if (edp_.th_min_pkts < targetqueue / 2.0 )
			edp_.th_min_pkts = targetqueue / 2.0 ;
        }
	if (edp_.th_max_pkts == 0) 
		edp_.th_max_pkts = 3.0 * edp_.th_min_pkts;
        //printf("th_min_pkts: %7.5f th_max_pkts: %7.5f\n", edp_.th_min_pkts, edp_.th_max);
	//printf("q_w: %7.5f\n", edp_.q_w);
	if (edp_.bottom == 0) {
		edp_.bottom = 0.01;
		// Set bottom to at most 1/W, for W the delay-bandwidth 
		//   product in packets for a connection with this bandwidth,
		//   1000-byte packets, and 100 ms RTTs.
		// So W = 0.1 * link_->bandwidth() / 8000 
		double bottom1 = 80000.0/link_->bandwidth();
		if (bottom1 < edp_.bottom) 
			edp_.bottom = bottom1;
		//printf("bottom: %9.7f\n", edp_.bottom);
	}
}
/*
 * Note: if the link bandwidth changes in the course of the
 * simulation, the bandwidth-dependent RED parameters do not change.
 * This should be fixed, but it would require some extra parameters,
 * and didn't seem worth the trouble...
 */
if the link bandwidth changes in the course of the
simulation, the bandwidth-dependent RED parameters do not change.
This should be fixed, but it would require some extra parameters,
and didn't seem worth the trouble
if the link bandwidth changes in the course of the simulation the bandwidth - dependent RED parameters do not change . This should be fixed but it would require some extra parameters and didn ' t seem worth the trouble
void REDQueue::initialize_params()
{
	if (edp_.q_w == 0.0) {
		edp_.q_w = 1.0 - exp(-1.0/edp_.ptc);
 	} else if (edp_.q_w == -1.0) {
		double rtt = 3.0*(edp_.delay+1.0/edp_.ptc);
		if (rtt < 0.1) 
			rtt = 0.1;
		edp_.q_w = 1.0 - exp(-1.0/(10*rtt*edp_.ptc));
	} else if (edp_.q_w == -2.0) {
		edp_.q_w = 1.0 - exp(-10.0/edp_.ptc);
	}
	if (edp_.th_min_pkts == 0) {
		edp_.th_min_pkts = 5.0;
		double targetqueue = edp_.targetdelay * edp_.ptc;
		if (edp_.th_min_pkts < targetqueue / 2.0 )
			edp_.th_min_pkts = targetqueue / 2.0 ;
        }
	if (edp_.th_max_pkts == 0) 
		edp_.th_max_pkts = 3.0 * edp_.th_min_pkts;
	if (edp_.bottom == 0) {
		edp_.bottom = 0.01;
		double bottom1 = 80000.0/link_->bandwidth();
		if (bottom1 < edp_.bottom) 
			edp_.bottom = bottom1;
	}
}
void REDQueue :: initialize_params ( ) { if ( edp_ . q_w == 0.0 ) { edp_ . q_w = 1.0 - exp ( -1.0 / edp_ . ptc ) ; } else if ( edp_ . q_w == -1.0 ) { double rtt = 3.0 * ( edp_ . delay + 1.0 / edp_ . ptc ) ; if ( rtt < 0.1 ) rtt = 0.1 ; edp_ . q_w = 1.0 - exp ( -1.0 / ( 10 * rtt * edp_ . ptc ) ) ; } else if ( edp_ . q_w == -2.0 ) { edp_ . q_w = 1.0 - exp ( -10.0 / edp_ . ptc ) ; } if ( edp_ . th_min_pkts == 0 ) { edp_ . th_min_pkts = 5.0 ; double targetqueue = edp_ . targetdelay * edp_ . ptc ; if ( edp_ . th_min_pkts < targetqueue / 2.0 ) edp_ . th_min_pkts = targetqueue / 2.0 ; } if ( edp_ . th_max_pkts == 0 ) edp_ . th_max_pkts = 3.0 * edp_ . th_min_pkts ; if ( edp_ . bottom == 0 ) { edp_ . bottom = 0.01 ; double bottom1 = 80000.0 / link_ -> bandwidth ( ) ; if ( bottom1 < edp_ . bottom ) edp_ . bottom = bottom1 ; } }
Note: if the link bandwidth changes in the course of the
 simulation, the bandwidth-dependent RED parameters do not change.
Note : if the link bandwidth changes in the course of the simulation the bandwidth - dependent RED parameters do not change .
/*
 * If q_weight=0, set it to a reasonable value of 1-exp(-1/C)
 * This corresponds to choosing q_weight to be of that value for
 * which the packet time constant -1/ln(1-q_weight) per default RTT 
 * of 100ms is an order of magnitude more than the link capacity, C.
 *
 * If q_weight=-1, then the queue weight is set to be a function of
 * the bandwidth and the link propagation delay.  In particular, 
 * the default RTT is assumed to be three times the link delay and 
 * transmission delay, if this gives a default RTT greater than 100 ms. 
 *
 * If q_weight=-2, set it to a reasonable value of 1-exp(-10/C).
 */ //printf("delay: %5.4f rtt: %5.4f\n", edp_.delay, rtt); // printf("ptc: %7.5f bandwidth: %5.3f pktsize: %d\n", edp_.ptc, link_->bandwidth(), edp_.mean_pktsize); // printf("th_min_pkts: %7.5f th_max_pkts: %7.5f\n", edp_.th_min_pkts, edp_.th_max); // set th_min_pkts to half of targetqueue, if this is greater //  than 5 packets. //printf("th_min_pkts: %7.5f th_max_pkts: %7.5f\n", edp_.th_min_pkts, edp_.th_max); //printf("q_w: %7.5f\n", edp_.q_w); // Set bottom to at most 1/W, for W the delay-bandwidth  //   product in packets for a connection with this bandwidth, //   1000-byte packets, and 100 ms RTTs. // So W = 0.1 * link_->bandwidth() / 8000  //printf("bottom: %9.7f\n", edp_.bottom);