How to Implement Wireless Body Area Network in ns2
To implement a Wireless Body Area Network (WBAN) in ns2 has needs to emulate a network of body-worn sensors that interact wirelessly usually with a central coordinator node such as a personal device or a gateway. These networks are used in health monitoring systems in which the sensors placed on the human body that gathers physiological data and transmit it to a central device for processing. If you face any implementation doubts feel free to contact us we are readily available to guide you.
The given below is the guide on how to implement a basic WBAN in ns2:
Step-by-Step Implementation:
Step 1: Conceptualize the WBAN Simulation
A typical WBAN setup includes:
- Sensor Nodes: It denotes body-worn sensors that track vital signs such as heart rate, temperature, etc.
- Coordinator Node: A central node that gathers the data from the sensors, usually a mobile device or a specialized hub.
- Communication: Wireless communication among the sensors and the coordinator.
Step 2: Create the Tcl Script
The given below is a sample Tcl script that emulates a WBAN with numerous sensor nodes interacting with a central coordinator node.
Example Tcl Script for Simulating a WBAN
# Create a simulator object
set ns [new Simulator]
# Define the topography object
set topo [new Topography]
$topo load_flatgrid 100 100 # Define a small area representing the human body
# Create the General Operations Director (GOD) for wireless simulations
create-god 5 # Number of nodes (4 sensor nodes + 1 coordinator)
# Configure the nodes (sensors and coordinator)
$ns node-config -adhocRouting AODV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channelType Channel/WirelessChannel \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF
# Open trace and NAM files for recording the simulation
set tracefile [open wban_out.tr w]
$ns trace-all $tracefile
set namfile [open wban_out.nam w]
$ns namtrace-all-wireless $namfile 100 100
# Define a finish procedure to close files and end the simulation
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam wban_out.nam &
exit 0
}
# Create sensor nodes
set sensor0 [$ns node]
set sensor1 [$ns node]
set sensor2 [$ns node]
set sensor3 [$ns node]
# Set initial positions for sensor nodes (representing different body parts)
$sensor0 set X_ 30.0
$sensor0 set Y_ 50.0
$sensor0 set Z_ 0.0
$sensor1 set X_ 50.0
$sensor1 set Y_ 70.0
$sensor1 set Z_ 0.0
$sensor2 set X_ 70.0
$sensor2 set Y_ 50.0
$sensor2 set Z_ 0.0
$sensor3 set X_ 50.0
$sensor3 set Y_ 30.0
$sensor3 set Z_ 0.0
# Create the coordinator node (central device)
set coordinator [$ns node]
# Set the position of the coordinator (stationary, near the center of the body)
$coordinator set X_ 50.0
$coordinator set Y_ 50.0
$coordinator set Z_ 0.0
# Define traffic from sensors to the coordinator (data collection)
foreach sensor {sensor0 sensor1 sensor2 sensor3} {
set tcp_[$sensor] [new Agent/TCP]
$ns attach-agent [set $sensor] $tcp_[$sensor]
set sink_[$sensor] [new Agent/TCPSink]
$ns attach-agent $coordinator $sink_[$sensor]
$ns connect $tcp_[$sensor] $sink_[$sensor]
set ftp_[$sensor] [new Application/FTP]
$ftp_[$sensor] attach-agent $tcp_[$sensor]
$ftp_[$sensor] start
}
# Schedule the end of the simulation
$ns at 20.0 “finish”
# Run the simulation
$ns run
Step 3: Run the Tcl Script
Save the script with a .tcl extension, for instance, wban_simulation.tcl. Then, execute the script using the following command in the terminal:
ns wban_simulation.tcl
Step 4: Visualize the WBAN Simulation
To visualize the network topology and traffic, open the created NAM file using:
nam wban_out.nam
Script Explanation
- Sensor Nodes: The nodes sensor0, sensor1, sensor2, and sensor3 denote diverse sensors on the body, each placed at diverse coordinates.
- Coordinator Node: The coordinator node gathers the data from all sensor nodes and is placed centrally on the body.
- Traffic Generation: Each sensor node transfers the data (simulated using FTP over TCP) to the coordinator, simulating the data collection process in a WBAN.
- Static Positions: In this sample, both the sensor nodes and the coordinator are stationary, emulating a scenario in which the sensors are stable on a human body.
Customization
- Mobility Models: Execute the mobility models that need to emulate scenarios in which the body or sensors move like a person walking.
- More Sensors: Add more sensor nodes to mimic a more complex WBAN with additional sensors.
- Different Traffic Patterns: Test with diverse traffic patterns to emulate numerous kinds of data generated by the sensors, like continuous monitoring vs. event-driven data.
- Energy Models: While ns2 is limited in this concern, we need to try to mimic energy consumption by adding latency or packet losses according to the simulated battery life of the sensors.
Limitations
- Simplified Model: This simulation delivers a high-level abstraction of a WBAN and does not contain detailed models of physiological data, energy consumption, or complex body movements.
- No Detailed Physiological Simulation: Mimic doesn’t capture the specific of how physiological data has created and processed.
- Limited Energy Modelling: ns2 does not natively handle the detailed energy consumption models for battery-powered devices such as body-worn sensors.
In the above manual, we demonstrate the comprehensive procedures to implement and execute the wireless body area network that has some limitation, customization and the script explanation that were executed in ns2 tool. Additional specific details regarding the wireless body area network will be provided.