Ns2

47
Wireless Sensor Network And Its implementation

description

Wireless Sensor Network And Its implementation using ns2

Transcript of Ns2

Page 1: Ns2

Wireless Sensor Network And

Its implementation

Page 2: Ns2

Overview

• Introduction

• Components of WSN

• Wireless Sensor Network

• Communication in Wireless Sensor Network

• Network Architecture

• WSN Protocol Stack

• WSN Operating Systems

• WSN Simulators

• Operational Challenges of WSN

• Wireless Sensor Networks Features

• Applications of WSN

Page 3: Ns2

Introduction

• A wireless sensor network is a collection of nodes organized into a cooperative network.

• Each node has capability to sense data, process the data. These sensors work with each other to sense some physical phenomenon.

• The nodes in the network are connected via Wireless communication channels.

Page 4: Ns2

Components of WSN

• sensor – A transducer

– converts physical phenomenon e.g. heat, light, motion, vibration, and sound into electrical signals

• sensor node – basic unit in sensor network

– contains on-board sensors, processor, memory, transceiver, and power supply

• sensor network – consists of a large number of sensor nodes

– nodes deployed either inside or very close to the sensed phenomenon

Page 5: Ns2

Wireless Sensor Network

Wireless Sensor Network

Page 6: Ns2

Communication in Wireless Sensor Network

TCP or UDP via Internet

Sensing

UDP type protocol

Communication in Wireless Sensor Network

Page 7: Ns2

Network Architecture

Flat Network Topology Where sensor nodes also act as routers and transfer data to a sink through multi-hop routing

Page 8: Ns2

Network Architecture

Hierarchical Network Topology Higher nodes can be used to process and send the information while low energy nodes can be used to perform the sensing in the proximity of the target.

Page 9: Ns2

Node Architecture

• Hardware components of a sensor node include

– Sensing unit

– Processing unit

– Communication unit

– Power unit.

Page 10: Ns2

Node Architecture (Components of Node)

sensor ADC

Memory

Processor Radio

Battery

Sensing Unit Processing Unit Communication Unit

Power Unit

Figure10:- Architecture of Sensor Node 10

Page 11: Ns2

WSN Protocol Stack

Application Layer

Transport Layer

Network Layer

Data-Link Layer

Physical Layer

Page 12: Ns2

WSN Operating Systems

• TinyOS

• Contiki

• MANTIS

• BTnut

• SOS

• Nano-RK

Page 13: Ns2

TinyOS

• TinyOS system and its programs written in nesC

• Its having a component-based architecture

• TinyOS programs are composed into event handlers and tasks with run-to-completion semantics.

• free and open-source operating system

Page 14: Ns2

WSN Simulators

• NS-2

• GloMoSim

• OPNET

• SensorSim

• J-Sim

• OMNeT++

Page 15: Ns2

Introduction to Network Simulator (NS2)

Page 16: Ns2

overview

• NS2- Network Simulator • Basic Requirements: NS-2 • Download and Installation of NS2 • ''Ns'' Components • Basics of using NS2 • Steps to set up the simulation • Script to start nam • Simple two node wired network • Adding traffic to the link • Record Simulation Trace • Simulate a simple topology

Page 17: Ns2

NS2- Network Simulator

• A package of tools that simulates behavior of networks

• One of the most popular simulator among networking researchers

– Open source, free

• Discrete event simulator targeted at networking research and education

– Protocol design, traffic studies, etc

– Wired and wireless networks

• Back end is in C++ and front end is in oTcl

Page 18: Ns2

Basic Requirements: NS-2

• A computer which is having access to the Internet

• Minimum 512Mb RAM

• Operating system: Linux(Ubuntu 12.04)

• ns-2.34 package(ns-allinone)

• gcc-4.4.3

Page 19: Ns2

Download and Installation of NS2

• http://www.isi.edu/nsnam/ns/

– For easy installation, download ns-allinone

– Includes Tcl, Otcl, TclCL, ns, nam, etc.

• Select the Operating System

– NS2 is available for both Windows and Linux

– Linux is desirable as C++ compiler is free and easy to debug

Page 20: Ns2

''Ns'' Components

• ns, the simulator itself

• nam, the Network AniMator

– visualize ns (or other) output

– GUI input simple ns scenarios

• pre-processing:

– traffic and topology generators

• post-processing:

– simple trace analysis, often in Awk, Perl, or Tcl

Page 21: Ns2

Basics of using NS2

• Define Network topology in .tcl script

• To run ,

$ ns simple.tcl

• Output is in form of trace files

Page 22: Ns2

22

Hello World – Batch mode

#simple.tcl set ns [new Simulator]

$ns at 1 “puts \“Hello World!\””

$ns at 1.5 “exit”

$ns run

linux21% ns simple.tcl

Hello World!

linux21%

Page 23: Ns2

Steps to set up the simulation

• Initialize the simulator

• Define files for output (tracing)

• Set up the topology

• Set up the “agents”

• Set up the traffic between the nodes

• Start the simulation

• Analyze the trace files to compute the parameters of interest

Page 24: Ns2

Script to start nam

#Create a simulator object set ns [new Simulator] #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 } #call 'finish' procedure $ns at 12.0 “finish"

Page 25: Ns2

Simple two node wired network

#Create a simulator object

set ns [new Simulator]

#Open trace files

set f [open out.tr w]

$ns trace-all $f

#Define a 'finish' procedure

proc finish {} {

global ns

$ns flush-trace

close $f

exit 0

}

#Create two nodes

set n0 [$ns node]

set n1 [$ns node]

#Create a duplex link between the nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

#Call the finish procedure after 5 seconds of simulation time

$ns at 5.0 "finish"

#Run the simulation

$ns run But we have no traffic !

Page 26: Ns2

Simple two node wired network

# Create two nodes

set n0 [$ns node]

set n1 [$ns node]

# Create a duplex link between the nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

n0 n1

Page 27: Ns2

Adding traffic to the link

# Create a UDP agent and attach it to node n0

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

udp

n0 n1

null

cbr

Page 28: Ns2

Adding traffic to the link

# Create a CBR traffic source and attach it to udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0

udp

n0 n1

null

cbr

Page 29: Ns2

Adding traffic to the link

# Create a Null agent (a traffic sink) and attach it to node n1

set null0 [new Agent/Null]

$ns attach-agent $n1 $null0

udp

n0 n1

null

cbr

Page 30: Ns2

Adding traffic to the link

#Connect the traffic source with the traffic sink

$ns connect $udp0 $null0

#Schedule events for the CBR agent

$ns at 0.5 "$cbr0 start"

$ns at 4.5 "$cbr0 stop”

$ns at 5.0 "finish“

$ns run

udp

n0 n1

null

cbr

Page 31: Ns2

Record Simulation Trace

+ enqueue - dequeue r receive d drop

time

Nodes involved in this event

Packet type

packet length

packet flags

flow ID

source/dest addresses

seq number

packet ID

Page 32: Ns2

32

Simulate a simple topology

Page 33: Ns2

33

Simulate a simple topology – (Contd.)

#Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10

Page 34: Ns2

34

Simulate a simple topology – (Contd.)

#Give node position (for NAM) $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5 #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1

Page 35: Ns2

35

Simulate a simple topology – (Contd.)

#Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2

Page 36: Ns2

36

Simulate a simple topology – (Contd.)

#Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop"

Page 37: Ns2

37

Simulate a simple topology – (Contd.)

#Detach tcp and sink agents (not really necessary) $ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" #Run the simulation $ns run

Page 38: Ns2

Operational Challenges of WSN

• Heterogeneity

• Distributed Processing

• Low Bandwidth Communication

• Large Scale Coordination

• Utilization of Sensors

• Real Time Computation

Page 39: Ns2

Wireless Sensor Networks Features

• Much cheaper to deploy than wired sensors

• Sensor nodes can be added or removed easily

• Node location can be changed without rewiring

• Can be configured into different network topologies

• Large Network size

• Self-organized

• All nodes acts as routers

• Potential multihop routes

Page 40: Ns2

Applications of WSNs

• Intelligent (smart) buildings • Monitoring of structures • Monitoring of water quality • Health care • Disaster detection • Environmental monitoring • Social studiesPrecision agriculture • Habitat monitoring • Facility management • Logistics • Tracking of containers and boxes • Military applications

Page 41: Ns2

Applications of WSN

Military Applications • Monitoring friendly forces, equipment, and

ammunition

• Battlefield surveillance

• Reconnaissance of opposing forces and terrain

• Targeting

• Battle damage assessment

• Nuclear, biological, and chemical attack detection

Page 42: Ns2

Applications of WSNs

Industrial Sensing

• To monitor the “health” of machines

• To ensure safe operation.

• Monitoring corrosion

• prevent the incidents of contaminating the food supply chain

• Eg.Rohrback Cosasco Systems (RCS) (Rohrback Cosasco Systems, n.d.) is the world leader in corrosion monitoring technology

Page 43: Ns2

Applications of WSNs

Health Applications

• Tracking and monitoring doctors and patients inside a hospital

• Special kinds of sensors which can measure blood pressure, body temperature and electrocardiograph (ECG) can even be knitted into clothes to provide remote nursing for the elderly.

• Drug administration in hospitals

Page 44: Ns2

Applications of WSNs

Environmental Applications

• Animal tracking

• Weather forecasting.

• Forest fire detection

• Bio-complexity mapping of environment

• Flood detection

• Air and water pollution

• Eg.University of Southampton have built a glacial environment monitoring system using WSNs in Norway

Page 45: Ns2

Many WSN Applications

Page 46: Ns2

Conclusion

• WSNs possible today due to technological advancement in various domains

• Envisioned to become an essential part of our lives

• Design Constraints need to be satisfied for realization of sensor networks

• Tremendous research efforts being made in different layers of WSNs protocol stack

46

WSNs possible today due to technological advancement in various domains Envisioned to become an essential part of our lives Design Constraints need to be satisfied for realization of sensor networks .ns2 can be use as one the simulation tool to analyze network behavior. Tremendous research efforts being made in different layers of WSNs protocol stack

Conclusion

Page 47: Ns2

Conclusion

• WSNs possible today due to technological advancement in various domains

• Envisioned to become an essential part of our lives

• Design Constraints need to be satisfied for realization of sensor networks

• Tremendous research efforts being made in different layers of WSNs protocol stack

47

• Wireless Sensor Networks - An Introduction by QinghuaWang and Ilangko Balasingham.

• System Architecture for Wireless Sensor Networks by Jason Lester Hill, University of California, Berkeley, 2003.

• Networking Wireless Sensors by Bhaskar Krishnamachari, 2005. • A Survey of Wireless Sensor Networks Technology by I. Khemapech, I. Duncan and A. • Fundamentals of Wireless Sensor Networks: Theory and Practice, Waltenegus Dargie • Wireless Sensor Networks by F. L. LEWIS ,2004 • Wikipedia • The VINT project, The ns manual • The network simulator - ns-2,( http://www.isi.edu/nsnam/ns/ ) • ns-2 Tutorial:( http://www.isi.edu/nsnam/ns/tutorial/nsindex.html ) • Marc Greis’s Tutorial (http://www.isi.edu/nsnam/ns/tutorial/index.html )

References