[Click] How to add new information to ns trace files.
Michael Voorhaen
michael.voorhaen at ua.ac.be
Wed Dec 22 08:44:10 EST 2004
Hi,
I am trying to modify nsclick to allow me to add trace information to
the ns trace files from any click element. I have looked through the
interface code between ns and click and added a new function to simclick.h:
int simclick_sim_trace(simclick_sim simins, simclick_click clickinst,
const unsigned char* data, const char* logentry);
This function is then implemented in classifier-click.cc. So right now
I've gotten up to the point where I can send the information that needs
to be traced to ns2. But when I configure my ClickClassifier with a
Trace object and try to add something to the trace, I keep getting
segmentation faults. I suspect this is because the object I am getting
from my ns configuration script is not a Trace object or at least not a
correct one. Since if I create the a trace object in the c++ code I
don't get the segmentation faults.
I've copied the relevant code snippets below. I started from the dsr
code as an example of how to add new trace information to the trace
files. When trying to add something I get the following error:
ClickClassifier: after va_start 85ec488 2
Program received signal SIGSEGV, Segmentation fault.
0x0805c7e2 in BaseTrace::buffer (this=0x2) at basetrace.h:50
50 basetrace.h: No such file or directory.
in basetrace.h
In fact the logtarget_ (see below) points to some object, but
logtarget_->pt_ points to 2. Which is weird since a trace object
creates a basetrace object in it's constructor. Can someone help me with
this problem. I guess that I am doing something wrong in my tcl script,
but the documentation on this is so vague. I've tried a lot of thing but
I don't see any solution.
Best Regards,
Michael
Code snippets below:
In classifier-click.cc
if(strcmp(argv[1], "tracetarget") == 0) {
printf("ClickClassifier: tracetarget called\n");
logtarget_ = (Trace *) argv[2];
return TCL_OK;
}
---------------------
In classifier-click.cc
int
simclick_sim_trace(simclick_sim siminst, simclick_click clickinst, const
unsigned char* data, const char* logentry) {
//printf("classifier-click.cc: need to implement simclick_sim_trace\n");
ClickClassifier* theclassifier = (ClickClassifier*)siminst;
theclassifier->trace("t");
return 1;
}
------------------------------
In classifier-click.cc
void
ClickClassifier::trace(char* fmt, ...)
{
va_list ap;
printf("ClickClassifier: start\n");
if (!logtarget_) {
printf("ClickClassifier: need to configure tracetarget\n");
return;
}
printf("ClickClassifier: after !logtarget_\n");
va_start(ap, fmt);
printf("ClickClassifier: after va_start %x %x \n", logtarget_,
logtarget_->pt_);
vsprintf(logtarget_->pt_->buffer(), fmt, ap);
printf("ClickClassifier: after vs_printf\n");
logtarget_->pt_->dump();
printf("ClickClassifier: after dump\n");
va_end(ap);
printf("ClickClassifier: after va_end\n");
}
----------------------------
in the ns script:
set T [new Trace/Generic]
$T target [$ns_ set nullAgent_]
$T attach $tracefd
$T set src_ [$node_bb_($i) id]
[$node_bb_($i) entry] tracetarget $T
[$node_bb_($i) entry] loadclick "olsr_2int.click"
More information about the click
mailing list