How to Start 3D Underwater WSN Projects Using NS2
To start 3D Underwater Wireless Sensor Network (WSN) project in NS2 (Network Simulator 2) that requires replicating the interaction between underwater sensor nodes in three dimensions (3D) and representing the underwater communications’ unique challenges like signal attenuation, multi-path fading, and mobility. Here’s a general guide to get started:
Steps to Start 3D Underwater WSN Project in NS2
- Install NS2
Make sure that NS2 is installed on the system before starting the project. We should download and install it to utilise official site or via package managers for Linux.
For Linux:
sudo apt-get install ns2
For macOS/Windows:
- For macOS, we will need to utilise MacPorts or Homebrew for installing NS2.
- For Windows, apply Cygwin or configure a virtual machine running Linux.
When NS2 is installed then we can confirm by executing a sample script to verify if NS2 is properly functioning.
- Understand the Key Challenges in Underwater WSNs
Underwater WSNs are challenging by reason of:
- Signal attenuation: Underwater environments trigger high levels of radio signals attenuation.
- Multi-path fading: Water launches the deliberations and dispersing for complex signal propagation.
- Low data rates: Restricted bandwidth is obtainable for interaction.
- High mobility: Sensors and nodes could contain mobile or dynamic locations by reason of water currents, animals, or vehicles such as underwater robots.
We can design the environment within 3D (X, Y, Z coordinates) and adjust the signal propagation models for 3D simulations.
- Set Up 3D Mobility Models
In a 3D Underwater WSN, we can describe the underwater sensor nodes mobility in all three dimensions which are X, Y, and Z axis. The Z-axis is specifically essential for underwater WSNs as nodes could vertically transfer (depth).
In NS2, mobility is typically having 2D by default; however we will need to prolong it to 3D with the support of custom mobility models.
Define a Simple 3D Mobility Model:
We specify the coordinates (X, Y, Z) for sensor nodes, and make a movement model.
# Create the simulator
set ns [new Simulator]
# Create underwater sensor nodes (e.g., 3 nodes)
set sensor1 [$ns node]
set sensor2 [$ns node]
set sensor3 [$ns node]
# Set positions for each node in 3D (X, Y, Z coordinates)
$sensor1 set X_ 100.0
$sensor1 set Y_ 200.0
$sensor1 set Z_ 50.0 ;# Depth of 50 meters underwater
$sensor2 set X_ 150.0
$sensor2 set Y_ 250.0
$sensor2 set Z_ 60.0 ;# Depth of 60 meters underwater
$sensor3 set X_ 200.0
$sensor3 set Y_ 300.0
$sensor3 set Z_ 70.0 ;# Depth of 70 meters underwater
# Set a simple random movement model (you can expand it to more realistic underwater mobility)
$sensor1 random-motion
$sensor2 random-motion
$sensor3 random-motion
In this case:
- The mobility model is configure to random motion for the underwater nodes, however we may execute the custom mobility models or apply more sophisticated models.
- The Z-axis denotes the depth that is essential for underwater communication.
- Set Up Communication Links
Communication normally occurs through acoustic waves that are depending on crucial attenuation and propagation delay in underwater WSNs. Acoustic Modems are frequently utilised for communication.
We can change the propagation model, allowing for unique characteristics of the medium like signal attenuation, speed of sound in water, and so on. for underwater communication.
Example of Setting Communication Link (Modified for Underwater):
# Set propagation delay for underwater environment (sound speed in water ~1500 m/s)
set sound_speed 1500 ;# meters per second
set distance [expr {sqrt(pow([$sensor1 set X_]-[$sensor2 set X_],2)+pow([$sensor1 set Y_]-[$sensor2 set Y_],2)+pow([$sensor1 set Z_]-[$sensor2 set Z_],2))}]
set propagation_delay [expr {$distance / $sound_speed}]
# Create communication link between sensor1 and sensor2
$ns duplex-link $sensor1 $sensor2 1Mb $propagation_delay DropTail
# Create communication link between sensor2 and sensor3
$ns duplex-link $sensor2 $sensor3 1Mb $propagation_delay DropTail
In this case:
- Propagation delay is computed depends on the distance among two nodes and the speed of sound within water (1500 m/s).
- It determined the distance among two nodes within 3D (X, Y, Z).
- Define Traffic Applications
We will want to utilise CBR (Constant Bit Rate) or FTP (File Transfer Protocol) traffic to make communication among the nodes for a basic simulation.
Example of CBR Traffic Application:
# Create CBR traffic from sensor1 to sensor2
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $sensor1
$ns at 1.0 “$cbr start”
$ns at 5.0 “$cbr stop”
In this instance:
- A CBR traffic generator begins interaction among the sensors like sensor1 and sensor2 at time 1.0 second and ends at 5.0 seconds.
- We need to make traffic for additional nodes and more complex communications among the nodes.
- Modify Propagation and Path Loss Models for Underwater Communication
In NS2, the TwoRayGround model or other default models are normally utilised in terrestrial communication, however we make a custom propagation model to show factors such as attenuation, multi-path fading, and depth effects for underwater communications.
We need to utilise a basic path loss model such as Hata model or Friis transmission equation adjusted for underwater communication.
# Underwater Propagation Model (simplified)
set path_loss [expr {20*log10($distance) + 20*log10(1500) – 147.55}]
This formula should determine the path loss among two nodes within an underwater environment according to its distance and the speed of sound within water.
- Routing Protocols for Underwater Networks
Underwater networks require high mobility and low bandwidth, thus we can select or execute the appropriate routing protocols for this environment. We need to utilise AODV (Ad-hoc On-demand Distance Vector) or DSR (Dynamic Source Routing) for routing, or We can apply underwater-specific protocols like UWSN (Underwater Sensor Network routing protocols).
For instance, using AODV:
# Set routing protocol to AODV
set routing_protocol AODV
$ns rtproto $routing_protocol
- Energy Models (Optional)
In underwater WSNs, nodes are often battery-powered, so simulating energy consumption is important. NS2 provides an EnergyModel that you can attach to your nodes to simulate power consumption for transmission, reception, and idle states.
Example of energy model:
# Create energy model
set energyModel [new EnergyModel]
# Attach energy model to nodes
$ns attach-energy-model $sensor1 $energyModel
$ns attach-energy-model $sensor2 $energyModel
$ns attach-energy-model $sensor3 $energyModel
# Set power consumption for transmission and reception
$energyModel set tx-power_ 0.5 ;# Transmission power in watts
$energyModel set rx-power_ 0.4 ;# Reception power in watts
$energyModel set idle-power_ 0.05 ;# Idle power in watts
- Run the Simulation
When we have configured the mobility, communication links, traffic generation, and routing then we execute the simulation:
ns underwater_wsn.tcl
It will generate trace files including data on metrics such as packet transmissions, node mobility, and energy consumption.
- Analyze the Results
When simulation is executed then we need to examine the outcomes to utilise AWK or XGraph for estimating the performance indicators like:
- Routing performance
- Throughput
- Energy consumption
- Packet loss
- Delay
Example to analyze throughput using AWK:
awk ‘{if ($1 == “r”) print $0}’ underwater_wsn.tr | awk ‘{total+=1} END {print total}’
- Extend the Simulation
When basic simulation executing then we can:
- Execute more complex mobility models, which denote the underwater environments.
- Replicate larger underwater networks including additional nodes and longer durations.
- Test with various routing protocols that are enhanced for underwater WSNs.
- Execute more realistic propagation models with the effect of environmental factors such as salinity, temperature, and water currents.
Conclusion
Starting a 3D Underwater Wireless Sensor Network (WSN) project using NS2:
- Prolong NS2’s mobility model for replicating 3D movement (X, Y, Z).
- Adjust communication links to expose characteristics of underwater propagation.
- Describe the traffic applications such as CBR and FTP for mimicking data transfer.
- Make use of appropriate routing protocols for high mobility and restricted bandwidth.
- Optionally, we have Energy Model for replicating nodes energy utilization.
In this simulation, we had effectively configured and executed the 3d Underwater WSN Projects using above simulation process with custom code within NS2 simulation tool, with more information to be disclosed in the upcoming manual.