set p_(0) [new Agent/Ping]
$ns_ attach-agent $node_(0) $p_(0)
set p_(1) [new Agent/Ping]
$ns_ attach-agent $node_(1) $p_(1)
$p_(0) set_foo 1
puts “[$p_(0) get_foo]”
$p_(1) set_foo 2
puts “[$p_(1) get_foo]”
Int PingAgent::command(int argc,const char*const* argv){
if (strcomp(argv[1],”set_foo”)==0){
foo = atoi(argv[2]);
return (TCL_OK);
}
if (strcomp(argv[1],”get_foo”)==0){
Tcl::instance().resultf(“%d”,foo);
return (TCL_OK);
}
- return (TCL\_OK),return (TCL\_ERROR)
- Tcl::instance().resultf(“%d”,foo)
- Tcl::instance().evalf("%s",foo)
tclからDSR
int DSRAgent::command(int argc, const char*const* argv) {
if (strcasecmp(argv[1], "route_show") == 0){
Path get_route;
route_cache->findRoute(ID(atoi(argv[2]),::IP), get_route, 1);
for( int i = 0 ; i < get_path.length() ; i++ ){
printf("%s-",get_path[i].dump());
}
return TCL_OK;
}
SRNodeNew instproc dsr_route_show { } {
$self instvar dsr_agent_
$dsr_agent_ route_show 1
}
$ns_ at 3.0 “$node_(0) dsr_route_show”
tclからAODVとかDSDV
Node/MobileNode instproc route_show { } {
set ragent [$self set ragent_]
$ragent route_show
}
$ns_ at 3.0 “$node_(0) route_show”
int DSDV_Agent::command(int argc,const char *const *argv){
if (strcasecmp(argv[1], "route_show") == 0){
return TCL_OK;
}
aodv解説
aodv.h
#define ACTIVE_ROUTE_TIMEOUT 15
(中略)
#define NETWORK_DIAMETER 10