This post is with reference to post title "Creating Broad Cast Agent in NS-2", I am going to present small modification to the existing one. In the previous post all the nodes will broadcast the beacon messages periodically. A modification to this, the problem situation is as follows: There is a base station which transmit a beacon message periodically so that all other client nodes has to receive the beacon message. In this situation we need to make a node as base station and all other nodes as clients.
Here are the modifications to the existing code.
In the SBAgent::command method definition, modify code as
if(argc==2){
if(strcmp(argv[1],"start")==0){
my_addr_ = addr();
return TCL_OK;
}
if(strcmp(argv[1],"base-station")==0){
btimer_.resched((double)0.1);
my_addr_ = addr();
return TCL_OK;
}
}
and Recompile the code.
./configure
make
sudo make install
In the tcl script add the line which indicated in RED under node definition section
#===================================
# Nodes Definition
#===================================
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
}
for {set i 0} {$i < $val(nn)} {incr i} {
set u_($i) [new Agent/SB]
$ns attach-agent $node_($i) $u_($i)
}
$ns at 0.0 "[$node_(0) set ragent_] base-station"
Save and run the file
Here are the modifications to the existing code.
In the SBAgent::command method definition, modify code as
if(argc==2){
if(strcmp(argv[1],"start")==0){
my_addr_ = addr();
return TCL_OK;
}
if(strcmp(argv[1],"base-station")==0){
btimer_.resched((double)0.1);
my_addr_ = addr();
return TCL_OK;
}
}
and Recompile the code.
./configure
make
sudo make install
In the tcl script add the line which indicated in RED under node definition section
#===================================
# Nodes Definition
#===================================
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
}
for {set i 0} {$i < $val(nn)} {incr i} {
set u_($i) [new Agent/SB]
$ns attach-agent $node_($i) $u_($i)
}
$ns at 0.0 "[$node_(0) set ragent_] base-station"
Save and run the file
No comments:
Post a Comment