This article is about the depiction of simulation and visualization of 3D mobile underwater sensor network based on the Ns3 simulator. Let’s take a look over the overall process of these functions.
Visualizing 3D Mobile UWSN
For an instance, our experts have highlighted some sample ns3 simulation codes for the users to visualize the 3D mobile UWSN and the codes are enlisted below.
- Mobility configuration
mobility.SetPositionAllocator(position);
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(nodesCon);
mobility.Install(sinksCon);
- AquaSim based UWSN node configuration
for (NodeContainer::Iterator i = nodesCon.Begin(); i != nodesCon.End(); i++)
{
Ptr newDevice = CreateObject();
position->Add(boundry);
devices.Add(asHelper.Create(*i, newDevice));
NS_LOG_DEBUG("Node:" << newDevice->GetAddress() << " position(x):"
<< boundry.x);
boundry.x += 100;
//newDevice->GetPhy()->SetTransRange(range);
}
for (NodeContainer::Iterator i = sinksCon.Begin(); i != sinksCon.End(); i++)
{
Ptr newDevice = CreateObject();
position->Add(boundry);
devices.Add(asHelper.Create(*i, newDevice));
NS_LOG_DEBUG("Sink:" << newDevice->GetAddress() << " position(x):" << boundry.x);
boundry.x += 100;
//newDevice->GetPhy()->SetTransRange(range);
}
- AquaSim configuration for UWSN simulation
AquaSimChannelHelper channel = AquaSimChannelHelper::Default();
AquaSimHelper asHelper = AquaSimHelper::Default();
asHelper.SetChannel(channel.Create());
asHelper.SetMac("ns3::AquaSimBroadcastMac");
asHelper.SetRouting("ns3::AquaSimRoutingDummy");
- Include the header files
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/aqua-sim-ng-module.h"
#include "ns3/applications-module.h"
#include "ns3/log.h"
#include "ns3/callback.h"
Configure Ns-3 with 3D Mobile UWSN
Then, we have to configure the ns-3 with 3D Mobile UWSN process through the implementation of the below mentioned commands.
cd /home/research/ns-allinone-3.28/ns-3.28
sudo ./waf configure
Simulate 3D Mobile UWSN File
Following that, the 3D mobile UWSN file is simulate through the execution of the below mentioned commands.
cd /home/research/ns-allinone-3.28/ns-3.28
sudo ./waf --run 3D_Mobile_UWSN --vis
Hopefully, we have come up with the most wanted process based on the simulation and visualization of 3D mobile UWSN in Ns3.