LoRaWAN The LoRa Alliance first defined the LoRaWAN standard with the objective of creating a medium access scheme and a set of network management policies that leverage the properties of […]
Low-power wide-area network (LPWAN). These networks use low-power radio signals, such as those in the sub-1 GHz range, to send small amounts of data over a large area. LPWANs are […]
SUMO has different tools for creating and customizing road networks and traffic flows and traffic signals. In this article, we will use some of those tools available in SUMO to […]
Spring Mobility Spring mobility is nothing but making a node to move in a path similar to that of an expanded circular coil spring. From the top or bottom point […]
Mobility Models of ns-3. The default ns-3 installation will contain the following mobility models. MobilityModel Subclasses ConstantPosition ConstantVelocity ConstantAcceleration GaussMarkov Hierarchical RandomDirection2D RandomWalk2D RandomWaypoint SteadyStateRandomWaypoint Waypoint PositionAllocator Position allocators […]
Aquatic Animal Tracking: Tracking marine animals can be extremely tricky due to GPS signals not functioning well underwater[1]. Underwater acoustic communication is a technique of sending and receiving messages below […]
@CharlesPandian wrote:
You need not do everything in god.cc itself.
You may handle the values inside your new agent code (if any) or pass them to a tcl variable as follows. Here AddNeighborToList will add the neighbors to a tcl list. After that You can use that variable from the simulation script itself.
The c++ part
void MyAgent::FillNeighborList()
{
Tcl& tcl = Tcl::instance();
int TotalNodes=God::instance()->nodes();
for(int i=0;i{
if(God::instance()->IsNeighbor(i , here_.addr_))
{
tcl.evalf("%s AddNeighborToList %d ",name(), i);
}
}
}
the tcl part
Agent/MyAgent instproc AddNeighborToList {nn} {
$self instvar NeighborList_
lappend NeighborList_ $nn
}
I am a novice ns2 user and a dummy in object-oriented programming so I am lost in how to proceed your steps. Do I need to create new files, say myagent.cc and myagent.h to contain this new agent? After that, will I add your Tcl code into the existing file ns-agent.tcl?
If possible please help me once more. At the same time, I will try my best to figure it out.
Ah, and one more thing is, after getting the NeighborList_, I can write its length to a file by this command, is it right?
puts $file [llength NeighborList_]
Thank you very much for your help.
I just want to thank you as soon as possible!!!!! I will try your approach now.