[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] generating MMPP traffic (fwd)





---------- Forwarded message ----------
Date: Tue, 6 Jun 2000 13:25:09 +0530 (IST)
From: Vineet Gupta <[email protected]>
To: [email protected]
Subject: generating MMPP traffic

I have tried to genereate MMPP traffic in NS by adding a class
MMPP_Traffic analgous  to EXPOO_Traffic .only one data member variable
poisson_avg_ has been added to it to get the mean for the poisson process.
I have made additions to the foll. files:

1.~ns/tcl/lib/ns-default.tcl : here i have given default values for all
the parameters (analogous to thos for Traffic/Expoo)

2.~ns/tcl/lib/ns-default.tcl : here i have first declare dmy class as
"Class Application/Traffic/MMPP" and then defined the instprocs for it in
the same way as that for Traffic/Expoo(i.e.
Application/Traffic/Exponential). One more procedure for poisson_avg_ has
been added.

3.~ns/packet.h : here i have made entry for my packet type PT_MMPP in teh
enum defined there . i have also made the entry name_[PT_MMPP]="mmpp"

4. ~ns/trace.h : here in the func. format() i have made entry for my
packet type in the if-condition in line 213.

There is no problem when i compile ns with my file included in the
Makefil. But when i run a tcl script generating MMPP traffic  then it
gives the foll. error 

------------------------------------------------
_o36:unable to dispatch method attach-agent
	while executing 
 "$traffic1 attach-agent $source1"
	(file "vin112.tcl" line40)
-----------------------------------------------

here vin112.tcl is the name of my tcl script
traffic1 is the object Application/Traffic/MMPP
source1 is the object Agent/CBR/UDP

Can Anybody suggest me what to do???
I think i have to make some more additions for my class either in the
application, agent or trace classes or maybe in the above hierarchy.

Plaease help me asap.

Vineet
//* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
/*
 * Copyright (c) Xerox Corporation 1997. All rights reserved.
 *  
 * License is granted to copy, to use, and to make and to use derivative
 * works for research and evaluation purposes, provided that Xerox is
 * acknowledged in all documentation pertaining to any such copy or derivative
 * work. Xerox grants no other licenses expressed or implied. The Xerox trade
 * name should not be used in any advertising without its written permission.
 *  
 * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
 * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
 * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" without
 * express or implied warranty of any kind.
 *  
 * These notices must be retained in any copies of any part of this software.
 */

#ifndef lint
static const char rcsid[] =
    "@(#) $Header: /usr/src/mash/repository/vint/ns-2/expoo.cc,v 1.9 1999/03/04 02:21:37 haoboy Exp $ (Xerox)";
#endif

#include <stdlib.h>
 
#include "random.h"
#include "trafgen.h"
#include "ranvar.h"


/* implement an on/off source with exponentially distributed on and
 * off times.  parameterized by average burst time, average idle time,
 * burst rate and packet size.
 */

class MMPP_Traffic : public TrafficGenerator {
 public:
	MMPP_Traffic();
	virtual double next_interval(int&);
        virtual void timeout();
 protected:
	void init();
	double ontime_;   /* average length of burst (sec) */
	double offtime_;  /* average length of idle time (sec) */
	double rate_;     /* send rate during on time (bps) */
///////	double interval_; /* packet inter-arrival time during burst (sec) */
	unsigned int rem_; /* number of packets left in current burst */
	double poisson_avg; //avg. for the poisson process                 
	int flag12 ;                                                   

	// new stuff using RandomVariable 
	ExponentialRandomVariable burstlen_;
	ExponentialRandomVariable Offtime_;
	ExponentialRandomVariable pkinterval_;
	

};


static class MMPPTrafficClass : public TclClass {
 public:
	MMPPTrafficClass() : TclClass("Application/Traffic/MMPP") {}
	TclObject* create(int, const char*const*) {
		return (new MMPP_Traffic());
	}
} class_mmpp_traffic;

MMPP_Traffic::MMPP_Traffic() : burstlen_(0.0), Offtime_(0.0), pkinterval_(0.0) 
{
	bind_time("burst_time_", &ontime_);
	bind_time("idle_time_", Offtime_.avgp());
	bind_bw("rate_", &rate_);
	bind("packet_size_", &size_);
	bind("poisson_avg",&poisson_avg);  //(vin)
}

void MMPP_Traffic::init()
{
        /* compute inter-packet interval during bursts based on
	 * packet size and burst rate.  then compute average number
	 * of packets in a burst.
	 */
	flag12 = 0;		
	burstlen_.setavg(ontime_);                
	pkinterval_.setavg(poisson_avg);         
	
	rem_ = burstlen_.value() ;             

	if (agent_)
		agent_->set_pkttype(PT_MMPP);
}

double MMPP_Traffic::next_interval(int& size)
{
	double t = pkinterval_.value();        
 
	if (rem_ < t) {                                    	
	/*set the next packet time  after the rem_+one offtime pulse */ //(vin) 
	t = rem_ + Offtime_.value();					//(vin)
	//compute burst length for  next burst   			//(vin)	
	rem_ = burstlen_.value() ;					//(vin)
	flag12 = 1 ;							//(vin)
	}
	rem_ = rem_ - t ;						//(vin)

	size = size_;
	return(t);
}

void MMPP_Traffic::timeout()
{
	if (! running_)
		return;

	/* send a packet */
	// The test tcl/ex/test-rcvr.tcl relies on the "NEW_BURST" flag being 
	// set at the start of any exponential burst ("talkspurt").  
	if ( flag12 == 1 || nextPkttime_ == -1)     			
		{agent_->sendmsg(size_, "NEW_BURST");flag12=0;}
	else 
		agent_->sendmsg(size_);
	/* figure out when to send the next one */
	nextPkttime_ = next_interval(size_);
	/* schedule it */
	if (nextPkttime_ > 0)
		timer_.resched(nextPkttime_);
}