[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to add own agents..??
>
> hi,
>
> i am a new ns user....i hv my own source code for traffic generator(in
> C++)..i want the traffic generated by this source to be used by TCP New
> Reno of ns ...i am wondering how i can add my own traffic source or any
> agent in the hirarchie....i hv gone through section 8.6 of ns
> documentation but still, i am not clear about creating own agents..
>
> i will appreciate if anyone of ns users can guide me..
>
> regards..
>
> Hamid
>
>
Hamid
I have had the same problem. I made a template to an agent that is very useful. Just insert your stuff into the template, update the Makefile and recompile ns(ok, you need some Otcl stuff too...:). The template cannot do anything useful by itself, but adding stuff into it results in magic... hehehe... cheers!
skelAgent.h:
######################
#ifndef skelAgent_h
#define skelAgent_h
#include "connector.h"
#include "packet.h" // not really needed
#include "tcp.h" // same here..
#include "classifier.h"
class SkelAgent : public Connector {
public:
SkelAgent();
void recv(Packet*, Handler*);
protected:
int command(int argc, const char*const* argv);
};
#endif
##########
skelAgent.cc:
################
#include "skelAgent.h"
#include "packet.h"
#include "tcp.h"
#include "connector.h"
#include "classifier.h"
static class AgentSkelClass : public TclClass {
public:
AgentSkelClass() : TclClass("SkelAgent") {}
TclObject* create(int, const char*const*) {
return (new SkelAgent());
}
} class_skelAgent;
SkelAgent::SkelAgent() : Connector()
{
}
int SkelAgent::command(int argc, const char*const* argv)
{
return Connector::command(argc, argv);
}
void SkelAgent::recv(Packet* p, Handler* h)
{
Tcl& tcl = Tcl::instance();
if (target_)
target_->recv(p, h);
}
###########