Which One Is Most Suitable For WSN Simulation Ns2 Or Matlab

Which One Is Most Suitable For WSN Simulation Ns2 Or Matlab

WSN simulation in NS2

By using the NS2 we can create a simulation network with  multiple sensor nodes and sink or base station nodes. In the simulation , the configuration of the sensor nodes are different based in the specification in the main TCL configuration file. The configurations are based on the different protocols, like 802.11, 802.16, 802.15.4, IR-UWB etc and also different communication and sensing range specifications and also Energy model is different based on the node configuration specification. use the ns2 we can create to send a packet message of network with used defined configurations. During the construction the sensor node location specification is based on either randomly or in a deterministic manner.

The sample NS2 code for Wireless sensor network configuration is,

# Simulator Instance Creation

set ns [new Simulator]

#Fixing the co-ordinate of simulation area

set val(x) 600

set val(y) 600

# Define options

set val(chan) Channel/WirelessChannel ;# channel type

set val(prop) Propagation/TwoRayGround ;# radio-propagation model

set val(netif1) Phy/WirelessPhy ;# network interface type

set val(netif2) Phy/WirelessPhy ;# network interface type

set val(mac) Mac/802_11 ;# MAC type

set val(ifq) Queue/DropTail/PriQueue ;# interface queue type

set val(ll) LL ;# link layer type

set val(ant) Antenna/OmniAntenna ;# antenna model

set val(ifqlen) 50 ;# max packet in ifq

set val(nn) 10 ;# number of mobilenodes

set val(rp) AODV ;# routing protocol

set val(x) 600 ;# X dimension of topography

set val(y) 600 ;# Y dimension of topography

set val(stop) 10.0 ;# time of simulation end

set val(energymodel) EnergyModel ;#Energy set up

# set up topography object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# general operational descriptor- storing the hop details in the network

create-god $val(nn)

WSN simulation in  MATLAB

By using the MATLAB we can create and simulate the Wireless Sensor Network. During the network topology construction/create and simulation process  , we use the communication toolbox set , which is used to build a complete WSN model system in the MATLAB and SIMULINK tool. During the network simulation , we can includes the default the hardware architecture of transmitting nodes, modeling the communication channel and receiving node architecture by using MATLAB. In MATLAB/SIMULINK simulation , we cannot use the dynamic user defined configurations. In  MATLAB and SIMULINK we can use the default build in configuration tools to build the simulation process.

The sample MATLAB source code for the WSN simulation,

clc

clearvars all;

close all;

warning off all;

% x and y maximum (in meters)

x=zeros(100);         

y=zeros(100);         

flag=zeros(100,1);

% Distance between any two nodes

dist=zeros(100,100);    

% Selects the Cluster Head(CH)

ch=zeros(100,1);        

ch1=zeros(200,1);        

dist1=zeros(50,1);      

match=zeros(50,100);    

% Number of neighbouring nodes

neig=zeros(50,1);         

% Energy Model

% calculates the residual energy of each node and Cluster Head

residual=zeros(500);        

energy=zeros(100,1);         

ETX=50*0.000000001;

ERX=50*0.000000001;

% Maximum number of rounds

rmax=300;

n=100;

% The flag of cluster head(CH)—send the information

join=zeros(100,100); 

% Yhe cluster head to join the another cluster head

flag2=zeros(100,100);

join1=zeros(100,1);

distance=zeros(100,100);

% LEACH

figure(1)

for i=1:100

    % x,y position of the sensor node   

    x(i)=rand()*100;

    y(i)=rand()*100;

    residual(i)=2;        

end

for i=1:100

    plot(x(i),y(i),’ko’,’MarkerSize’, 8, ‘MarkerFaceColor’, ‘y’);

    hold on;       

end

% x and y Coordinates of the Sink

x1=randi(100, 1, 1);

y1=randi(100, 1, 1);                  

plot(x1,y1,’r*’,’MarkerSize’, 10);

hold on;

Which one is most suitable for WSN simulation

Compare with MATLAB the ns2 is the suitable simulation tool for perform the wireless sensor network process. because the NS2 is one of the fully network simulation supported tool. By use the NS2 we create the network simulation with dynamic configuration of all sensor nodes. but by use the MATLAB  we cannot use the dynamic user defined configurations. In  MATLAB and SIMULINK we can use the default build in configuration tools to build the simulation process.  So compare with MATLAB , NS2 is the most suitable user friendly simulation tool for the wireless sensor network.

Live Tasks
Technology Ph.D MS M.Tech
NS2 75 117 95
NS3 98 119 206
OMNET++ 103 95 87
OPNET 36 64 89
QULANET 30 76 60
MININET 71 62 74
MATLAB 96 185 180
LTESIM 38 32 16
COOJA SIMULATOR 35 67 28
CONTIKI OS 42 36 29
GNS3 35 89 14
NETSIM 35 11 21
EVE-NG 4 8 9
TRANS 9 5 4
PEERSIM 8 8 12
GLOMOSIM 6 10 6
RTOOL 13 15 8
KATHARA SHADOW 9 8 9
VNX and VNUML 8 7 8
WISTAR 9 9 8
CNET 6 8 4
ESCAPE 8 7 9
NETMIRAGE 7 11 7
BOSON NETSIM 6 8 9
VIRL 9 9 8
CISCO PACKET TRACER 7 7 10
SWAN 9 19 5
JAVASIM 40 68 69
SSFNET 7 9 8
TOSSIM 5 7 4
PSIM 7 8 6
PETRI NET 4 6 4
ONESIM 5 10 5
OPTISYSTEM 32 64 24
DIVERT 4 9 8
TINY OS 19 27 17
TRANS 7 8 6
OPENPANA 8 9 9
SECURE CRT 7 8 7
EXTENDSIM 6 7 5
CONSELF 7 19 6
ARENA 5 12 9
VENSIM 8 10 7
MARIONNET 5 7 9
NETKIT 6 8 7
GEOIP 9 17 8
REAL 7 5 5
NEST 5 10 9
PTOLEMY 7 8 4

Workflow

YouTube Channel

Unlimited Network Simulation Results available here.