SplitObject error after adding a simple print function

View: New views
2 Messages — Rating Filter:   Alert me  

SplitObject error after adding a simple print function

by Asraf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to print out the route table, and rt_print function in aodv.cc plus this code on in AODV::command:

int
AODV::command(int argc, const char*const* argv) {
...
...
else if (strcasecmp(argv[1], "rt_print") == 0) {// print routing tables to a file
        FILE *fp = fopen("route.txt","a");
        printf("\nRouting table at node %d\n", addr());
        fclose(fp);

        return TCL_OK;
        }
}
 
and call this in my TCL like this:

for {set i 1} {$i < $nodes} {incr i} {
        $ns_ at 10.0 "$node_($i) rt_print"
}

But I get an error:

ns: _o32 rt_print:
    (_o32 cmd line 1)
    invoked from within
"_o32 cmd rt_print"
    invoked from within
"catch "$self cmd $args" ret"
    (procedure "_o32" line 2)
    (SplitObject unknown line 2)
    invoked from within
"_o32 rt_print"


Does anyone know how to solve this SplitObject error. From my understanding, SplitObject error is caused by no having a corresponding C++ object used in TCL. Any pointers??

Or If I want to print out the routing table in AODV, how do I do it?

Many Thanks,
Asraf.

Re: SplitObject error after adding a simple print function

by Mayur-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Asraf wrote:

> I am trying to print out the route table, and rt_print function in aodv.cc
> plus this code on in AODV::command:
>
> int
> AODV::command(int argc, const char*const* argv) {
> ...
> ...
> else if (strcasecmp(argv[1], "rt_print") == 0) {// print routing tables to a
> file
>         FILE *fp = fopen("route.txt","a");
>         printf("\nRouting table at node %d\n", addr());
>         fclose(fp);
>
>         return TCL_OK;
>         }
> }
>  
> and call this in my TCL like this:
>
> for {set i 1} {$i < $nodes} {incr i} {
>         $ns_ at 10.0 "$node_($i) rt_print"
> }
>
> But I get an error:
>
> ns: _o32 rt_print:
>     (_o32 cmd line 1)
>     invoked from within
> "_o32 cmd rt_print"
>     invoked from within
> "catch "$self cmd $args" ret"
>     (procedure "_o32" line 2)
>     (SplitObject unknown line 2)
>     invoked from within
> "_o32 rt_print"
>
>
> Does anyone know how to solve this SplitObject error. From my understanding,
> SplitObject error is caused by no having a corresponding C++ object used in
> TCL. Any pointers??
>
> Or If I want to print out the routing table in AODV, how do I do it?
>
> Many Thanks,
> Asraf.
>
>  
In your TCL script, you have called "rt_print" as :

*$ns_ at 10.0 "$node_($i) rt_print"*

This is as if it is a /procedure of NODE object/, (which is certainly
not true here!). Rather you should call it as
/ ................... "$val(rp) rt_print"/
where, $val(rp) is your AODV, adhocRouting. You can now fine tune
yourself as per your need.

regards,
Mayur