0% found this document useful (0 votes)
120 views

AWSN Practical

The document discusses wireless sensor networks and their simulation. It introduces WSNs and their applications, compares wired and wireless networks, explains why simulation is important for WSNs, describes different types of simulations, and discusses several popular WSN simulators including NS-2, TOSSIM, OMNeT++, and EmStar.

Uploaded by

Hriday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

AWSN Practical

The document discusses wireless sensor networks and their simulation. It introduces WSNs and their applications, compares wired and wireless networks, explains why simulation is important for WSNs, describes different types of simulations, and discusses several popular WSN simulators including NS-2, TOSSIM, OMNeT++, and EmStar.

Uploaded by

Hriday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

INDO GLOBAL GROUP OF COLLEGES

New Chandigarh (Abhipur)


Practical File

Subject: Ad-hoc Wireless Sensor Networks

Submitted To: - Submitted By: -


Er.Puneet (AP CSE) Name: Sourabh Thakur
Roll no: 20346
Sem: 7th
Branch: CSE
Date of Date of Remarks
Allotment Submission
S.
Contents
No.

Introduction of wireless Sensor


1 network application and its
simulation.

Installation of Network Simulator


2 NS2.

To study other wireless sensor


3 network simulators.

Network Simulator installation of


4 wireless sensor network

5
Practical-01
Aim- Introduction of wireless Sensor network application and its simulation.
Theory:-
What is WSN?
With the development of embedded system and network technology, there has been growing
interest in providing fine-grained metering and controlling of living environments using low
power devices. Wireless Sensor Networks (WSNs), which consist of spatially distributed self-
configurable sensors, perfectly meet the requirement. The sensors provide the ability to monitor
physical or environmental conditions, such as temperature, humidity, vibration, pressure, sound,
motion and etc, with very low energy consumption.
The sensors also have the ability to transmit and forward sensing data to the base station. Most
modern WSNs are bi-directional, enabling two-way communication, which could collect sensing
data from sensors to the base station as well as disseminate commands from base station to end
sensors. The development of WSNs was motivated by military applications such as battlefield
surveillance; WSNs are widely used in industrial environments, residential environments and
wildlife environments. Structure health monitoring, healthcare applications, home automation,
and animal tracking become representative WSNs applications.
A typical Wireless Sensor Network (WSN) is built of several hundreds or even thousands of
“sensor nodes”. The topology of WSNs can vary among star network, tree network, and mesh
network. Each node has the ability to communication with every other node wirelessly, thus a
typical sensor node has several components: a radio transceiver with an antenna which has the
ability to send or receive packets, a microcontroller which could process the data and schedule
relative tasks, several kinds of sensors sensing the environment data, and batteries providing
energy supply.
A sensor node might vary in size. The “Smart dust” [SmartDust] sensor node, from Electrical
Engineering and Computer Science department at University of California Berkeley, is smaller
than a coin. The cost of sensor nodes is similarly variable depending on the quality of onboard
chips. One of the main challenges in WSNs is to decrease the cost and size. There are an
increasing number of small companies producing WSN hardwires. The most popular two are
TelosB sensor node, from Crossbow Technology [TelosB] and Tmote Sky sensor node, from
Sentilla [TmoteSky].
Operating systems for WSN nodes are much less complex than general-purpose operating
systems. This is because WSN usually deployed with a particular purpose and low power
microcontrollers cannot afford complicated computing. TinyOS is the most popular operating
system specifically designed for wireless sensor networks. TinyOS is based on an event-driven
architecture using NesC programming language.
Comparison of wired and wireless network
The wired network has been around for decades, as long as the internet itself. Compared with
wireless networks, wired networks are more secure and faster in transfer speeds. However, wired
networks contain one of the biggest growing problems, wires. Complicated wires and power
cords are difficult to manage and hugely degrade the flexibility. Wiring and rewiring are the
bottleneck of development of wired network. With the rapid development of wireless
technology, more and more people prefer to use wireless network as their end-user network.
Compared with the traditional wireless network, WSN has its own features, such as low cost and
low energy consumption. To reduce cost, each sensor board has very limited onboard resource,
such as computing speed, storage and energy source. To achieve long lifetime with limited
power supply usually batteries, onboard components are designed to consume energy as little as
possible. For instance, the transmit power of radio is 1000 times smaller than the one in Wi-Fi
routers. WSN is always deployed in difficult-access areas; the ability of self-configuration is
another design goal.

Why use simulation in WSNs?


Nowadays, the WSN is a hot research topic. Many network details in WSNs are not finalized and
standardized. Building a WSNs testbed is very costly. Running real experiments on a testbed is
costly and difficulty. Besides, repeatability is largely compromised since many factors affect the
experimental results at the same time. It is hard to isolate a single aspect. Moreover, running real
experiments are always time consuming. Therefore, WSNs simulation is important for WSNs
development. Protocols, schemes, even new ideas can be evaluated in a very large scale. WSNs
simulators allow users to isolate different factors by tuning configurable parameters.
Consequently, simulation is essential to study WSNs, being the common way to test new
applications and protocols in the field. This leads to the recent boom of simulator development.
However, obtaining solid conclusions from a simulation study is not a trivial task. There are two
key aspects in WSNs simulators:(1)The correctness of the simulation models and (2) the
suitability of a particular tool to implement the model. A “correct” model based on solid
assumption is mandatory to derive trustful results. The fundamental tradeoff is precision and
necessity of details versus performance and scalability. In the rest of this survey, several main-
stream WSNs simulators are described and compared in more detail.
There are three types of simulation: Monte Carlo Simulation, Trace-Driven Simulation and
Discrete-Event Simulations. The last two simulations are used commonly in WSN. The first
subsection will talk about the concepts of TraceDriven Simulation and Discrete-Event
Simulations. The second subsection will illustrate the concepts of simulator and emulator.

Discrete-Event Simulation
Discrete-event simulation is widely used in WSNs, because it can easily simulate lots of jobs
running on different sensor nodes. Discrete-event simulation includes some of components. This
simulation can list pending events, which can be simulated by routines. The global variables,
which describe the system state, can represent the simulation time, which allow the scheduler to
predict this time in advance. This simulation includes input routines, output routines, initial
routines, and trace routines. In addition, this simulation provides dynamic memory management,
which can add new entities and drop old entities in the model. Debugger breakpoints are
provided in discrete-event simulation, thus users can check the code step by step without
disrupting the program operation.

Trace-Driven Simulation
Trace-Driven Simulation provides different services. This kind of simulation is commonly used
in real system. The simulation results have more credibility. It provides more accurate workload;
these detail information allow users to deeply study the simulation model. Usually, input values
in this simulation constant unchanged. However, this simulation also contains some drawbacks.
For example, the high-level detail information increases the complexity of the simulation;
workloads may change, and thus the representativeness of the simulation needs to be suspicious.

Simulator and Emulator


Simulator is universally used to develop and test protocols of WSNs, especially in the beginning
stage of these designs. The cost of simulating thousands of nodes networks is very low, and the
simulation can be finished within very short execution time. Both general and specialized
simulators are available for uses to simulate WSNs. The tool, which is using firmware as well as
hardware to perform the simulation, is called emulator. Emulation can combine both software
and hardware implementation. Emulator implements in real nodes, thus it may provide more
precision performance. Usually emulator has highly scalability, which can emulate numerous
sensor nodes at the same time.

Simulation Tools
This section illustrates seven main-stream simulation tools used in WSNs: NS-2, TOSSIM,
EmStar, OMNeT++, J-Sim, ATEMU, and Avrora, and analyzes the advantage and disadvantage
of each simulation tool.

1. NS-2
NS-2 is the abbreviation of Network simulator version two, which first been developed by 1989
using as the REAL network simulator. Now, NS-2 is supported by Defense Advanced Research
Projects Agency and National Science Foundation. NS-2 is a discrete event network simulator
built in Object Oriented extension of Tool Command Language and C++ . People can run NS-2
simulator on Linux Operating Systems or on Cygwin, which is a Unix-like environment and
command-line interface running on Windows. NS-2 is a popular non-specific network simulator
can used in both wire and wireless area. This simulator is open source and provides online
document.
Merits:-
 As a non-specific network simulator, NS-2 can support a considerable range of protocols
in all layers. For example, the ad-hoc and WSN specific protocols are provided by NS-2.
 The open source model saves the cost of simulation, and online documents allow the
users easily to modify and improve the codes.
Limitations:-
 People who want to use this simulator need to familiar with writing scripting language
and modeling technique; the Tool Command Language is somewhat difficulty to
understand and write.
 Sometimes using NS-2 is more complex and time-consuming than other simulators to
model a desired job.
 NS-2 provides a poor graphical support, no Graphical User Interface (GUI) [GUI]; the
users have to directly face to text commands of the electronic devices.
 Due to the continuing changing the code base, the result may not be consistent, or
contains bugs.

2. TOSSIM
TOSSIM is an emulator specifically designed for WSN running on TinyOS, which is an open
source operating system targeting embedded operating system. In 2003, TOSSIM was first
developed by UC Berkeley’s TinyOS project team. TOSSIM is a bit-level discrete event network
emulator built in Python[Python], a high-level programming language emphasizing code
readability, and C++. People can run TOSSIM on Linux Operating Systems or on Cygwin on
Windows. TOSSIM also provides open sources and online documents.
Merits:-
 The open source model free online document save the emulation cost. Also, TOSSIM has
a GUI, TinyViz, which is very convenience for the user to interact with electronic devices
because it provides images instead of text commands.
 TOSSIM is a very simple but powerful emulator for WSN. Each node can be evaluated
under perfect transmission conditions, and using this emulator can capture the hidden
terminal problems.
 TOSSIM can support thousands of nodes simulation. This is a very good feature, because
it can more accurately simulate the real world situation.
 TOSSIM can emulate radio models and code executions. This emulator may be provided
more precise simulation result at component levels because of compiling directly to
native codes.
Limitations:-
 TOSSIM is designed to simulate behaviors and applications of TinyOS, and it is not
designed to simulate the performance metrics of other new protocols. Therefore,
TOSSIM can not correctly simulate issues of the energy consumption in WSN; people
can use Power TOSSIM, another TinyOS simulator extending the power model to
TOSSIM, to estimate the power consumption of each node.
 Every node has to run on NesC code, a programming language that is event-driven,
component-based and implemented on TinyOS, thus TOSSIM can only emulate the type
of homogeneous applications.
 e TOSSIM is specifically designed for WSN simulation, motes-like nodes are the only
thing that TOSSIM can simulate.

3. EmStar
EmStar is an emulator specifically designed for WSN built in C, and it was first developed by
University of California, Los Angeles. EmStar is a trace-driven emulator [Girod04] running in
real-time. People can run this emulator on Linux operating system. This emulator supports to
develop WSN application on better hardware sensors. Besides libraries, tools and services, an
extension of Linux microkernel is included in EmStar emulator.
Merits:-
 The modular programming model in EmStar allows the users to run each module
separately without sacrificing the reusability of the software.
 There is a flexible environment in EmStar that users can freely change between
deployment and simulation among sensors.
 EmStar has a GUI, which is very helpful for users to control electronic devices. When
using EmStar, every execution platform is written by the same codes, which will decrease
bugs when iterate the separate modes.
 EmStar provides many online documents to facilities the widely use of this emulator.
Limitations:-
 It can not support large number of sensors simulation, and the limited scalability will
decrease the reality of simulation.
 EmStar is can only run in real time simulation. Moreover, this emulator can only apply to
iPAQ-class sensor nodes and MICA2 motes.

4. OMNeT++
OMNeT++ is a discrete event network simulator built in C++. OMNeT++ provides both a
noncommercial license, used at academic institutions or non-profit research organizations, and a
commercial license, used at "for-profit" environments. This simulator supports module
programming model. Users can run OMNeT++ simulator on Linux Operating Systems, Unix-
like system and Windows. OMNeT++ is a popular non-specific network simulator, which can be
used in both wire and wireless area. Most of frameworks and simulation models in OMNeT++
are open sources.
Merits:-
 OMNeT++ provides a powerful GUI. This strong GUI makes the tracing and debugging
much easier than using other simulators.
 OMNeT++ has a mobility framework. This simulator can support MAC protocols as well
as some localized protocols in WSN.
 People can use OMNeT++ to simulate channel controls in WSNs. In addition, OMNeT++
can simulate power consumption problems in WSNs.
Limitations:-
 The number of available protocols is not larger enough.
 The compatible problem will rise since individual researching groups developed the
models separately, this makes the combination of models difficult and programs may
have high probability report bugs.

5. J-Sim
J-Sim is a discrete event network simulator built in Java. This simulator provides GUI library,
which facilities users to model or compile the Mathematical Modeling Language, a “text-based
language” written to J-Sim models. J-Sim provides open source models and online documents.
This simulator is commonly used in physiology and biomedicine areas, but it also can be used in
WSN simulation. In addition, J-Sim can simulate real-time processes.
Merits:-
 Models in J-Sim have good reusability and interchangeability, which facilities easily
simulation.
 J-Sim contains large number of protocols; this simulator can also support data diffusions,
routings and localization simulations in WSNs by detail models in the protocols of J-Sim.
J-Sim can simulate radio channels and power consumptions in WSNs.
 J-Sim provides a GUI library, which can help users to trace and debug programs. The
independent platform is easy for users to choose specific components to solve the
individual problem.
 Comparing with NS-2, J-Sim can simulate larger number of sensor nodes, around 500,
and J-Sim can save lots of memory sizes.
Limitations:-
 The execution time is much longer than that of NS-2. Because J-Sim was not originally
designed to simulate WSNs, the inherently design of J-Sim makes users hardly add new
protocols or node components.

6. ATEMU
ATEMU is an emulator of an AVR processor for WSN built in C; AVR is a single chip
microcontroller commonly used in the MICA platform. ATEMU provides GUI, Xatdb; people
can use this GUI to run codes on sensor nodes, debug codes and monitor program executions.
People can run ATEMU on Solaris and Linux operating system. ATEMU is a specific emulator
for WSNs; it can support users to run TinyOS on MICA2 hardware. ATEMU can emulate not
only the communication among the sensors, but also every instruction implemented in each
sensor. This emulator provides open sources and online documents.
Merits:-
 ATEMU can simulate multiple sensor nodes at the same time, and each sensor node can
run different programs.
 ATEMU has a large library of a wide rage of hard devices.
 ATEMU can provide a very high level of detail emulation in WSNs. For example, it can
emulate different sensor nodes in homogeneous networks or heterogeneous networks.
 The GUI can help users debug programs, and monitor program executions. The open
source saves the cost of simulation.
 ATEMU can provide an accurate model, which helps users to give unbiased comparisons
and get more realistic results.
Limitations:-
 For instance, although ATEMU can give a highly accuracy results, the simulation time is
much longer than other simulation tools.
 ATEMU has fewer functions to simulate routing and clustering problems.

7. Avrora
Avrora [Avrora,Shu08,Yi08] is a simulator specifically designed for WSNs built in Java. Similar
to ATEMU, Avrora can also simulate AVR-based microcontroller MICA2 sensor nodes. This
simulator was developed by University of California, Los Angeles Compilers Group. Avrora
provides a wide range of tools that can be used in simulating WSNs. This simulator combines the
merits of TOSSIM and ATEMU, and limits their drawbacks. Avrora does not provide GUI.
Avrora also supports energy consumption simulation. This simulator provides open sources and
online documents. However, this simulator has some drawbacks. It does not have GUI. In
addition, Avrora can not simulate network management algorithms because it does not provide
network communication tools.
Merits:-
 Avrora is an instruction-level simulator, which removes the gap between TOSSIM and
ATEMU. The codes in Avrora run instruction by instruction, which provides faster speed
and better scalability.
 Avrora can support thousands of nodes simulation, and can save much more execution
time with similar accuracy.
 Avrora provides larger scalability than ATEMU does with equivalent accuracy; Avrora
provides more accuracy than TOSSIM does with equivalent scales of sensor nodes.
 Unlike TOSSIM and ATEMU, Avrora is built in Java language, which provides much
flexibility. Avrora can simulate different programming code projects, but TOSSIM can
only support TinyOS simulation.
Practical-02
Aim- Installation of Network Simulator NS2.
Theory: -
What is NS2
NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulator
designed specifically for research in computer communication networks.

Features of NS2
1. It is a discrete event simulator for networking research.

2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https and
DSR.
3. It simulates wired and wireless network.

4. It is primarily Unix based.

5. Uses TCL as its scripting language.

6. Otcl: Object oriented support

7. Tclcl: C++ and otcl linkage

8. Discrete event scheduler

Steps to install NS2 simulator:-


STEP 1

Turn on Developer Mode

Open search (Windows + S) and type “developer settings” and click on Open as shown below:
Turn on the option “Install apps from any source…” as shown below, click YES and close the
window.

STEP 2

Turn on WSL (Windows Subsystem for Linux)

Open search and type “turn windows features on or off” and click on Open as shown below:

Scroll down the options and check the item named “Windows Subsystem for Linux” and click on
OK as shown below:
STEP 3

Install Ubuntu from Microsoft Store.

Click on search and type “Microsoft Store” and click on Open.

In the search bar at the top, type “Ubuntu” and click on “Install” button.

It will take some time to download and install the Ubuntu app as it is nearly 700 MB.

STEP 4

Install Xming.

Open Google in a browser and type “Xming Download” or go to this URL


https://sourceforge.net/projects/xming/ and click on the “Download” button.

After downloading Xming, install it.

STEP 5

Open search and type “Ubuntu” and click on Open.

As it is the first time you are opening Ubuntu, it will ask for Username and Password. Give a
username and password and hit enter key. Now you should see a prompt as shown below:

Type the following commands one by one and hit enter after each command:

1. sudo apt update


2. sudo apt-get install ns2
3. sudo apt-get install nam
4. sudo apt-get install gedit
5. sudo apt install tcl
If your Internet connection is slow, this step will take some time to complete. When asked for
username and password provide them as given before.

STEP 6

Changing the location to working directory.

For this example, for working directory name is “ns2” and it is located on my “Desktop”. The
complete path to “ns2” directory on my PC is “C:\Users\Admin\Desktop\ns2”.

To change the location to the above directory, type the following command and hit Enter key.

cd /mnt/c/Users/Admin/Desktop/ns2

You can see the above command in action in the below figure:

Note the path may vary from system to system. My ns2 programs are going to be saved in the
“ns2” folder as shown above.

STEP 7

Opening gedit and typing the program.

Type the following command in the terminal (black window) and hit Enter key.

gedit ex1.tcl

You might get a warning message as shown in below figure:


For opening the “gedit” application we have to start the “Xming” application.

Open search and type “Xming” and click on “Open”.

The “Xming” server will be started and it will available in the system tray on the taskbar.
Sometimes it might get hidden in the system tray and is not always visible.

Now, in the terminal type the following command as shown in the figure below and hit enter
key.

Now, type the following command in the terminal (black window) and hit Enter key.

gedit ex1.tcl

You should be able to see a blank gedit window as shown in the image below.

Type the following sample program and save (CTRL + s) the file. Now close gedit window.

#Create global variables

set ns [new Simulator]


#setting nam trace

set namf [open wired1.nam w]

$ns namtrace-all $namf

#open the trace file

set tracef [open wired1.tr w]

$ns trace-all $tracef

set proto rlm

#setting the color values

$ns color 1 blue

$ns color 2 yellow

$ns color 3 red

#———- creating client- router- end server node—————-#

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

#establish the link between the nodes

$ns duplex-link $n0 $n1 2Mb 100ms DropTail

$ns duplex-link $n1 $n2 200Kb 100ms DropTail

#Label the nodes

$ns at 0.0 “$n0 label Client1”

$ns at 0.0 “$n1 label Server”

$ns at 0.0 “$n2 label Client2”


#setting the color for nodes

$n0 color blue

$n1 color red

$n2 add-mark pradeep green square

#Shaping the nodes for differentiation

$n1 shape hexagon

$n2 shape square

#finish procedure

proc finish {} {

global ns tracefnamf

$ns flush-trace

close $tracef

close $namf

puts “Opening nam…”

exec nam wired1.nam &

exit 0

#Calling finish procedure

$ns at 2.0 “finish”

$ns run

STEP 8

Running the program using “ns” command.

Type the following command in the terminal to run the program and see the output.

ns ex1.tcl
Now, you should be able to see the network animator (nam) window with the topology as shown
in the below figure.

If you can see the above output, it means that you have installed ns2 successfully on your
system.
Practical-03
Aim- To study other wireless sensor network simulators.
Theory: -

ATEMU
ATEMU is an emulator of an AVR processor for WSN built in C; AVR is a single chip
microcontroller commonly used in the MICA platform. ATEMU provides GUI, Xatdb; people
can use this GUI to run codes on sensor nodes, debug codes and monitor program executions.
People can run ATEMU on Solaris and Linux operating system. ATEMU is a specific emulator
for WSNs; it can support users to run TinyOS on MICA2 hardware. ATEMU can emulate not
only the communication among the sensors, but also every instruction implemented in each
sensor. This emulator provides open sources and online documents.
Advantage
 Multiple nodes at the same time and each node can run different programs.
 Large library with hard devices.
Disadvantage
 Simulation time is much longer than other simulation tools
 Only few functions are used to simulate routing and clustering problems
Avrora
Avrora is a simulator specifically designed for WSNs built in Java. Similar to ATEMU, Avrora
can also simulate AVR-based microcontroller MICA2 sensor nodes. This simulator was
developed by University of California, Los Angeles Compilers Group. Avrora provides a wide
range of tools that can be used in simulating WSNs.
Advantage
 It is a combination of TOSSIM and ATEMU simulators
 It supports for energy consumption
 It provides open source and online documents
 Supports faster speed and better scalability
 More accuracy than Tossim Disadvantage
 Not have GUI
 It doesn’t support network communication tools
SENS
A Sensor Environment and Network Simulator. SENS is a wireless sensor network simulator
with modular, layered architecture with customizable components which model an application,
network communication, and the physical environment. It enables realistic simulations, by using
values from real sensors to represent the behavior of component implementations. Such behavior
includes sound and radio signal strength characteristics and power usage.
Advantage
 It is writtern in C++
 Platform independent
 WSN applications feature tight integration of computation, communication
 Interaction with the physical environment
Disadvantage
 Less customizable

COOJA (COntiki Os JAva)


COOJA is a simulator for the Contiki sensor node operating system. MSP Sim can be integrated
into COOJA, forming COOJA/MSP Sim. It allows simultaneous cross-level simulation at
application, operating system and machine code instruction set level. COOJA combines low
level simulation of sensor node hardware and simulation of high-level behavior in a single
simulation.
Advantage
 COOJA is flexible and extensible in that all levels of the system can be changed.
 Sensor node platforms, operating system software, radio transceivers, and radio
propagation models.
 COOJA is a Java application, all interaction with compiled Contiki code is done through
Java Native Interface (JNI).
Disadvantage
 It is extensible and it is low efficiency
 GUI is absent and making extensible and time dependent difficult.

Castalia
Castalia is an application-level simulator for Wireless Sensor Network based on OMNeT++. It
can be used to evaluate different platform characteristics for specific applications, since it is
highly parametric, and can simulate a wide range of platforms. In Castalia, sensor nodes are
implemented as compound modules, consisting of sub-modules that represent, for instance,
network stack layers, application, and sensor.
Advantage
 Sensing device noise, bias and node clock drift
Disadvantage
 Reliable and realistic framework for the first order validation of an algorithm before
moving to implementation on a specific sensor platform.

Mannasim
Mannasim simulation environment for WSN is actually a framework based on foregoing ns2..
This section describes how can Mannasim be utilized with ns-2. It consists of two following
parts:
• Mannasim Framework – The Mannasim Framework is a module for WSN simulation which
extends ns-2 introducing new modules for design, development and analysis of different WSN
applications.
• Script Generator Tool – The Script Generator Tool (SGT) is a front-end for Tcl simulation
scripts easy creation. It is written in Java.

You might also like