How to Implement Network In On Off body in NS2
To implement the Network In-body, On-body and Off-body in NS2 encompasses to simulate various communication environments for Wireless Body Area Networks (WBAN). Each kind of communication (In-body, On-body and Off-body) contains various propagation aspects, frequencies and application demands. This simulation can be extended or tailored to replicate the situations by configuring certain parameters and models for each communication type.
In the given below, we are presenting the implementation procedure regarding the types of communication in the network using ns2:
Step-by-Step Implementation:
- Overview of In-body, On-body, and Off-body Communication
- In-body Communication: Refers to communication amongst implantable medical devices into the human body. This variant of communication usually operates at low frequencies (such as Medical Implant Communication Service (MICS) band) and deals with high attenuation because of body tissues.
- On-body Communication: Refers to communication amongst devices placed on the body includes wearable sensors. It is often performs at higher frequencies, and the propagation environment is less modern compared to in-body communication.
- Off-body Communication: Refers to communication amongst body-worn or implanted devices and external devices or networks (for instance: base stations, smartphones). This communication commonly operates in shared wireless bands such as ISM bands (2.4 GHz, 5 GHz).
- Approach to Implementing In-body, On-body, and Off-body Networks in NS2
- In-body Network: Replicate a network of implantable devices with specialized propagation and channel models (like high attenuation and low frequency).
- On-body Network: Mimic wearable devices interacting with one another on the body with particular body-based path loss and frequency models.
- Off-body Network: Imitate communication amidst body devices and external devices, where traditional wireless propagation models may apply (such as free space, two-ray ground).
- Steps to Implement In-body, On-body, and Off-body Networks in NS2
Step 1: Define In-body, On-body, and Off-body Nodes in TCL
We will define three variants of nodes, each belong to In-body, On-body, and Off-body communication devices. These nodes will use various channel and propagation models to replicate the several environments.
# Create a simulator instance
set ns [new Simulator]
# Define trace and nam files for output
set tracefile [open body_network.tr w]
set namfile [open body_network.nam w]
$ns trace-all $tracefile
$ns namtrace-all $namfile
# Define the network topology
set topo [new Topography]
$topo load_flatgrid 1000 1000 ;# 1000×1000 meters simulation area
# Create the General Operations Director (GOD)
set god_ [create-god 10] ;# 10 nodes in the network
# Define the different channels and propagation models for each type of communication
set in_body_channel [new Channel/WirelessChannel]
set on_body_channel [new Channel/WirelessChannel]
set off_body_channel [new Channel/WirelessChannel]
# Define propagation models (e.g., In-body with high attenuation, On-body with medium path loss, Off-body with free-space or two-ray)
Propagation/InBody set pathLossExp_ 3.0 ;# In-body propagation has high path loss
Propagation/OnBody set pathLossExp_ 2.0 ;# On-body propagation with moderate loss
Propagation/FreeSpace set pathLossExp_ 1.0 ;# Off-body communication (free-space)
# Set CSThresh_ (Carrier Sensing Threshold) to simulate different signal strengths
Phy/WirelessPhy set CSThresh_ 1.0e-10 ;# Default carrier sensing threshold
# Create nodes for In-body, On-body, and Off-body communications
set in_body_node [new Node]
set on_body_node [new Node]
set off_body_node [new Node]
# Assign different propagation models to each node
$in_body_node set channel_ $in_body_channel
$on_body_node set channel_ $on_body_channel
$off_body_node set channel_ $off_body_channel
# Set initial positions for the nodes
$in_body_node set X_ 100
$in_body_node set Y_ 100
$on_body_node set X_ 150
$on_body_node set Y_ 150
$off_body_node set X_ 200
$off_body_node set Y_ 200
Step 2: Apply Different Propagation Models and Frequencies
For each type of communication, we need to establish various propagation models and operating frequencies.
- In-body Communication: Uses low-frequency bands (e.g., MICS, around 400 MHz) and high path loss because of body tissues.
- On-body Communication: Operates at higher frequencies (e.g., 2.4 GHz ISM band) with moderate path loss due to proximity and body movement.
- Off-body Communication: Uses standard wireless frequencies like 2.4 GHz or 5 GHz for external communication with access points or base stations.
Example: Setting Frequency and Propagation for Each Type
# Set different frequencies for each type of communication
Phy/WirelessPhy set freq_ 403e6 ;# In-body communication at 403 MHz (MICS band)
Phy/WirelessPhy set freq_ 2.4e9 ;# On-body communication at 2.4 GHz (ISM band)
Phy/WirelessPhy set freq_ 5.8e9 ;# Off-body communication at 5.8 GHz (external)
# Assign appropriate propagation models
$in_body_node set propInstance_ [new Propagation/InBody]
$on_body_node set propInstance_ [new Propagation/OnBody]
$off_body_node set propInstance_ [new Propagation/FreeSpace]
Step 3: Create Traffic Models for In-body, On-body, and Off-body Nodes
Each type of communication will produce various types of traffic. For instance, in-body sensors may set up periodic health observing data, while off-body communication may manage large data transfers to external servers.
# Function to create traffic for in-body sensors
proc start_in_body_traffic {} {
global ns in_body_node
set udp_in [new Agent/UDP]
$ns attach-agent $in_body_node $udp_in
set cbr_in [new Application/Traffic/CBR]
$cbr_in set packetSize_ 512
$cbr_in set interval_ 0.5 ;# Periodic data from in-body sensor
$cbr_in attach-agent $udp_in
# Start traffic at 1 second
$ns at 1.0 “$cbr_in start”
}
# Function to create traffic for on-body sensors
proc start_on_body_traffic {} {
global ns on_body_node
set udp_on [new Agent/UDP]
$ns attach-agent $on_body_node $udp_on
set cbr_on [new Application/Traffic/CBR]
$cbr_on set packetSize_ 1024
$cbr_on set interval_ 0.2 ;# More frequent data from on-body sensor
$cbr_on attach-agent $udp_on
# Start traffic at 2 seconds
$ns at 2.0 “$cbr_on start”
}
# Function to create traffic for off-body communication
proc start_off_body_traffic {} {
global ns off_body_node
set udp_off [new Agent/UDP]
$ns attach-agent $off_body_node $udp_off
set ftp_off [new Application/FTP]
$ftp_off attach-agent $udp_off
# Start FTP transfer at 3 seconds
$ns at 3.0 “$ftp_off start”
}
# Call traffic functions
start_in_body_traffic
start_on_body_traffic
start_off_body_traffic
Step 4: End the Simulation
State the end of the simulation and execute the TCL script.
# End simulation after 100 seconds
$ns at 100.0 “finish”
# End simulation procedure
proc finish {} {
global ns tracefile namfile
close $tracefile
close $namfile
$ns halt
}
# Run the simulation
$ns run
- Explanation of the Script
- Different Propagation Models: The script uses numerous propagation models (Propagation/InBody, Propagation/OnBody, and Propagation/FreeSpace) to replicate different communication environments.
- In-body communication: Uses a high path loss model and a low frequency to indicate communication inside the body.
- On-body communication: Uses a moderate path loss model and operates at higher frequencies typical of wearable sensors.
- Off-body communication: Replicates communication with external devices using the free-space or two-ray ground propagation model.
- Traffic Models: Numerous traffic kinds are generated for each node to reflect the different data transmission demands for in-body, on-body, and off-body communication.
- In-body: Delivers periodic health data with moderate packet size.
- On-body: Sends data more frequently, simulating continuous observing or wearable communication.
- Off-body: Simulates a data transfer like sending data to an external server or base station.
- Running the Simulation
- Log the TCL script as body_network.tcl.
- Execute the simulation using the given command:
ns body_network.tcl
- Analyzing Results
After executing the simulation, assess the trace file (body_network.tr) and the NAM file (body_network.nam) to analyze the activities of the network. Key metrics to see include:
- Packet Delivery Ratio: Check how effectively packets are transmitted amongst nodes in various communication environments.
- Latency: Compute the delay for in-body, on-body, and off-body communications.
- Throughput: Estimate the number of data successfully transmitted for each type of communication.
- Further Enhancements
- Energy Consumption: For in-body and on-body communications, energy utilization is a vital metric. You can extend NS2 to model power utilization of nodes in terms of transmission power and activity.
- Mobility Models: Execute mobility for on-body and off-body nodes to replicate scenarios where devices move like a wearable device on a person walking.
- Interference Modeling: Accomplish interference models to account for intrusion amongst in-body, on-body, and off-body communications, certainly in shared frequency bands.
At the end of this manual, you can get to know about the implementation process in detail regarding how to approach the In-body, On-body and Off-body network communication using ns2 and the establishment of Different Propagation Models and Frequencies and producing traffic models to achieve it. Count on our crew to successfully roll out the implementation of Network In body On body & Off body, customized just for you. Our team will handle the project performance analysis efficiently.