0% found this document useful (0 votes)
16 views29 pages

AWSN

The document provides a comprehensive guide on installing Linux, specifically Ubuntu, using various methods such as USB stick and CD-ROM, as well as setting it up on Windows Subsystem for Linux (WSL2). It also introduces Linux as an open-source operating system, its distributions, commands, advantages, and disadvantages. Additionally, it covers wireless sensor networks (WSN), their applications, simulation types, and installation guidelines for network simulators like NS-2.

Uploaded by

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

AWSN

The document provides a comprehensive guide on installing Linux, specifically Ubuntu, using various methods such as USB stick and CD-ROM, as well as setting it up on Windows Subsystem for Linux (WSL2). It also introduces Linux as an open-source operating system, its distributions, commands, advantages, and disadvantages. Additionally, it covers wireless sensor networks (WSN), their applications, simulation types, and installation guidelines for network simulators like NS-2.

Uploaded by

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

Practical No.

1
Aim: How to install Linux OS on computer and how to setup Ubuntu on WSL2 on Windows
OS.

How to install Linux:

Let’s look the below Linux installation guide which has various methods we can use to
download Linux(Ubuntu) and install it.

Installing Linux using USB stick

This is one of the easiest methods of installing Ubuntu or any distribution on your computer.
Follow the steps to install Ubuntu from USB.

Step 1) Download required files.

 Download the .iso or the OS files on your computer from this link.

Fig 1. Download Ubuntu

Step 2) Download Universal USB Installer.

 Download free software like Universal USB installer to make a bootable USB stick.

Fig 2. Universal-USB-Installer

Step 3) Select Distribution.

 Select an Ubuntu Distribution form the dropdown to put on your USB


 Select your Ubuntu iso file download in step 1.
 Select the drive letter of USB to install Ubuntu and Press create button.

1
Fig 3. Setup

Step 4) Install Ubuntu.

 Click YES to Install Ubuntu in USB.

Step 5) Check your window.

 After everything has been installed and configured, a small window will appear
Congratulations! You now have Ubuntu on a USB stick, bootable and ready to go.

Installing Linux using CD-ROM

Those who like the way a CD runs should try using this method.

(image source)

o Step 1) Download the .iso or the OS files onto your computer from this link
http://www.ubuntu.com/download/desktop.
o Step 2) Burn the files to a CD.
o Step 3) Boot your computer from the optical drive and follow the instructions as they
come.

How to install Ubantu on WLS2 on Windows OS:

Windows Subsystem for Linux (WSL) allows you to install a complete Ubuntu terminal
environment in minutes on your Windows machine, allowing you to develop cross-platform
applications without leaving windows.

1. Open PowerShell as an administrator


2. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-
Subsystem-Linux
3. Restart the computer when prompted.

Install Ubuntu 18.04 (Requires WSL)

1. Open the Microsoft Store (search for "store" from the start menu)

2
Fig 4. Download Ubuntu on Microsoft store

2. Search the store for "Ubuntu 18.04"


3. Install Ubuntu 18.04 LTS (it is not necessary to sign in to the store)
4. Launch Ubuntu 18.04
5. Enter a username. This will create a local user account and you will be automatically
logged in to Ubuntu 18.04 as this user.
6. Enter a password for the user and enter a second time to confirm.
7. Update all Ubuntu 18.04 software packages with sudo apt update && sudo apt upgrade
–y

Fig 5. Package setup

Please refer to https://docs.microsoft.com/en-us/windows/wsl/install-win10 for additional


information. It is strongly recommended that you periodically run sudo apt update && sudo
apt upgrade -y to update all Ubuntu 18.04 software packages.

3
Practical 2
Aim: Familiarization with Linux operating system.

Introduction:

Linux is a community of open-source Unix like operating systems that are based on the Linux
Kernel. It was initially released by Linus Torvalds on September 17, 1991. It is a free and open-
source operating system and the source code can be modified and distributed to anyone
commercially or non-commercially under the GNU General Public License.

Initially, Linux was created for personal computers and gradually it was used in other machines
like servers, mainframe computers, supercomputers, etc. Nowadays, Linux is also used in
embedded systems like routers, automation controls, televisions, digital video recorders, video
game consoles, smartwatches, etc. The biggest success of Linux is Android(operating system)
it is based on the Linux kernel that is running on smartphones and tablets. Due to android Linux
has the largest installed base of all general-purpose operating systems. Linux is generally
packaged in a Linux

Linux Distribution:

Linux distribution is an operating system that is made up of a collection of software based on


Linux kernel or you can say distribution contains the Linux kernel and supporting libraries and
software. And you can get Linux based operating system by downloading one of the Linux
distributions and these distributions are available for different types of devices like embedded
devices, personal computers, etc. Around 600 + Linux Distributions are available and some of
the popular Linux distributions are:

 MX Linux
 Manjaro
 Linux Mint
 elementary
 Ubuntu
 Debian
 Solus
 Fedora
 openSUSE
 Deepindistribution.

Some of the famous linux commands are:

1. ls - The most frequently used command in Linux to list directories


2. pwd - Print working directory command in Linux
3. cd - Linux command to navigate through directories
4. mkdir - Command used to create directories in Linux
5. mv - Move or rename files in Linux

4
6. cp - Similar usage as mv but for copying files in Linux
7. rm - Delete files or directories
8. touch - Create blank/empty files
9. ln - Create symbolic links (shortcuts) to other files
10. cat - Display file contents on the terminal
11. clear - Clear the terminal display
12. echo - Print any text that follows the command

Advantages of Linux

1. The main advantage of Linux, is it is an open-source operating system. This means the
source code is easily available for everyone and you are allowed to contribute, modify
and distribute the code to anyone without any permissions.
2. In terms of security, Linux is more secure than any other operating system. It does not
mean that Linux is 100 percent secure it has some malware for it but is less vulnerable
than any other operating system. So, it does not require any anti-virus software.
3. The software updates in Linux are easy and frequent.
4. Various Linux distributions are available so that you can use them according to your
requirements or according to your taste.
5. Linux is freely available to use on the internet.
6. It has large community support.
7. It provides high stability. It rarely slows down or freezes and there is no need to reboot
it after a short time.
8. It maintains the privacy of the user.
9. The performance of the Linux system is much higher than other operating systems. It
allows a large number of people to work at the same time and it handles them
efficiently.
10. It is network friendly.
11. The flexibility of Linux is high. There is no need to install a complete Linux suit; you
are allowed to install only required components.
12. Linux is compatible with a large number of file formats.
13. It is fast and easy to install from the web. It can also install on any hardware even on
your old computer system.
14. It performs all tasks properly even if it has limited space on the hard disk.

Disadvantages of Linux

1. It is not very user-friendly. So, it may be confusing for beginners.


2. It has small peripheral hardware drivers as compared to windows.

5
Practical 3
Aim: Introduction of Wireless sensor network applications and its simulation.

WIRELESS SENSOR NETWORK (WSN) is an infrastructure-less wireless network that


is deployed in a large number of wireless sensors in an ad-hoc manner that is used to monitor
the system, physical or environmental conditions.

Sensor nodes are used in WSN with the onboard processor that manages and monitors the
environment in a particular area. They are connected to the Base Station which acts as a
processing unit in the WSN system.

Base Station in a WSN System is connected through the Internet to share data.
WSN can be used for processing, analysis, storage, and mining of the data.

Fig.1 Wireless Sensor Network (WSN)

Wireless Sensor Network Applications


Wireless sensor networks may comprise numerous different types of sensors like low
sampling rate, seismic, magnetic, thermal, visual, infrared, radar, and acoustic, which are
clever to monitor a wide range of ambient situations. Sensor nodes are used for constant
sensing, event ID, event detection & local control of actuators. The applications of wireless
sensor networks mainly include health, military, environmental, home, & other commercial
areas.

• Military Applications
• Health Applications
• Environmental Applications
• Home Applications
• Commercial Applications

6
• Area monitoring
• Health care monitoring
• Environmental/Earth sensings
• Air pollution monitoring
• Forest fire detection
• Landslide detection
• Water quality monitoring
• Industrial monitoring

Classification of network simulation:


Simulation can be classified into the following described classes based on the type of
application area. Among all the different kinds of simulations, DES is preferred by different
network simulators (NetSims) to simulate WSNs. This is because of the fact that this type
of simulation provides ease in simulating multiple jobs or activities occurring at different
nodes at a discrete interval of time.
i. Continuous simulation: Continuous simulation is applied to those models in which
the state variables or parameters varies frequently over time. This kind of simulation
is used in application areas such as WSN deployment in military application to
simulate the missile trajectory, in testing of controller system of underwater vehicles
for underwater deployed sensor networks or to simulate the construction of tunnels
through the use of underground WSNs.
ii. DES: This type of simulation is applied to the systems where the events occur at
discrete intervals of time. Each change noticed in the system is equivalent to the
happening of a particular event. In such a system no change is expected in between
the events.
For example: (i) simulating the communication systems carrying different levels of
traffic to evaluate its performance, (ii) use of DES in military application for training
and war gaming purposes, (iii) use of DES in health care.
iii. Stochastic simulation: This kind of simulation is performed to simulate the systems
in which variables change randomly with change in probabilities . Stochastic
simulation can be applied to the systems that have several possibilities to evolve.
Real-life example of such a system is evaluation of a portfolio to study latency or
delay in telecommunication systems, simulating traffic flow in communication
networks or to study climatic changes. Monte Carlo simulation is a special case of
stochastic simulation.
iv. Deterministic simulation: This kind of simulation is adopted by systems that have
no degree of randomness. Such systems have pre-known inputs and unique set of
outputs.
v. Hybrid simulation: It is a kind of simulation that combines any two of the above
defined simulation types.It is a more efficient approach to test the target system. It

7
makes use of more than one simulation paradigm to evaluate the model. It merges
the merits of two simulation approaches.

VARIOUS SIMULATOR:
NS-2
NS-2 is a discrete event simulator targeted at networking research. NS-2 began as a variant
of the REAL network simulator in 1989 and has evolved substantially over the past few
years. NS-2 has a modular approach and hence is effectively extensible.
Environment: It provides substantial support for simulation of TCP, routing, and multicast
protocols over wired and wireless (local and satellite) networks. Support for wireless
networks was added later to simulate wireless LAN protocols, mobile ad-hoc networks and
wireless sensor networks. The simulator focuses on following the ISO/OSI model.

TOSSIM
TOSSIM is a discrete event simulator for TinyOS wireless sensor networks, which were
developed at UC Berkeley. TOSSIM captures the behavior and interactions of networks not
on the packet level but at network bit granularity. TOSSIM is designed specifically for
TinyOS applications to be run on MICA Motes. TOSSIM simulates entire TinyOS
applications. It works by replacing components with simulation implementations.
TOSSIM can replace a packet-level communication component for packet-level simulation,
or replace a low-level radio chip component for a more precise simulation of the code
execution.

GloMoSim
Global Mobile Information System Simulator (GloMoSim) is a scalable simulation
environment for large wireless and wired communication networks. The node aggregation
technique is introduced into GloMoSim to give significant benefits to the simulation
performance. In GloMoSim, each node represents a geographical area of the simulation.
Hence the network nodes which a particular entity represents are determined by the physical
position of the nodes.

UWSim
UWSim is a simulator used for Underwater Sensor Networks (UWSN). Most of the
currently available simulators focus greatly on ground-based sensor and ad hoc networks
they do not consider the factors that affect the underwater communication [21]. UWSim, on
the other hand, has its focus on handling scenarios specific to UWSN environments, for
example low bandwidth, low frequency, high transmission power, and limited memory. It
is based on a network component-based approach, rather than a layer/protocol-based
approach.

8
Environment: Tailor-designed for simulations of under-water sensor networks.

Avrora
Avrora, a research project of the UCLA Compilers Group, is an open-source cycle- accurate
simulator for embedded sensing programs. Unlike other simulators, that are able to simulate
only specific platforms, Avrora has language and operating system independence. It
provides a framework for program analysis, allowing static checking of embedded software
and an infrastructure for future program analysis research.
Avrora simulates a network of motes, runs the actual microcontroller programs (rather than
models of the software), and runs accurate simulations of the devices and the radio
communication.

9
Practical 4
Aim: Network Simulator installation of wireless sensor network.

Network simulation (NS) is one of the types of simulation, which is used to simulate the
networks such as in MANETs, VANETs, etc. It provides simulation for routing and multicast
protocols for both wired and wireless networks. NS is licensed for use under version 2 of the
GNU (General Public License) and is popularly known as NS2. It is an object-oriented, discrete
event-driven simulator written in C++ and Otcl/Tcl.

NS-2 can be used to implement network protocols such as TCP and UDP, traffic source
behavior such as FTP, Telnet, Web, CBR, and VBR, router queues management mechanism
such as Drop Tail, RED, and CBQ, routing algorithms, and many more. In ns2, C++ is used
for detailed protocol implementation and Otcl is used for the setup. The compiled C++ objects
are made available to the Otcl interpreter and in this way, the ready-made C++ objects can be
controlled from the OTcl level.

Installation Guidelines for NS2 on Windows

1. Requirements

a. Free disk space of 5GB required


b. Minimum 256MB RAM suggested

2. Assumptions

Windows installed in Drive partition “C”

3. Installation Instructions for CYGWIN

a. Download CYGWIN using setup.exe from http://www.cygwin.com


b. Run setup.exe

10
c. There are two ways to install after this step:

i. Install from Internet (This option is generally chosen, as everything is done


automatically.)

ii) Download and then Install (This option is desired when needed to install on
large no. of machines.)

d. Selecting Root directory where CYGWIN is installed

Recommended root directory path is “C:\cygwin”.

e. Selecting directory where installation files are stored

11
f. Selecting connection to internet: Direct connection preferred

g. Selecting Mirror site to download cygwin

12
Select one of the mirror site, generally preference is made to site that’s near to download
location.

h. Selection of packages to install

Since CYGWIN has lot of packages , its desirable to install all packages. In order to achieve
this ,Click view button , until it shows “full” .

In order to make all packages installed, click the each of “skip” entry. After this step the
installation window looks like this.

Just click “Next” to make cygwin installed.

4) Installation Instructions for Network Simulator (NS-2)

a. Download NS-2 installation file from: http://www.isi.edu/nsnam/dist/ns-allinone-


2.27.tar.gz

b. Save the above file in: C:\cygwin\

c. Now open the cygwin window by clicking the cygwin shortcut on the desktop.

13
d. In order to extract the NS installation file, go to the location where the installation file is
stored , by following commands:

cd c:
cd cygwin/

e. Extraction of files:

Extract the installation files by the following commands:

gzip –d ns-allinone-2.27.tar.gz
tar –xvf ns-allinone-2.27.tar

by the above commands there will be directory created in the name of ns-allinone-2.27

f. Installing the packages from extracted files:

Commands to be executed:

cd ns-allinone-2.27

after the above step:

./install

This command will initiate the process of installing NS2.

IMP NOTE: if in the process, you get a prompt saying “package diff missing do u want to
proceed, press Y for proceeding or N for exiting.

If all the above steps are followed there should not be any error in installing NS2. if in any
case if u get an error message saying that package missing, it means that those packages are
skipped at the time of installation so u have to install those packages by doing setup again.

g. Validating NS2:

Move to the folder containing NS-2(i.e. ns-2.27) and then type the following command

./validate

This will test the installation of NS2 with the predefined examples.

Standard working principles for NS:

Step 1: Open CYGWIN bash prompt

Step 2: go to location of TCL file

Step 3: type startx

14
Then u will find the following screen shot.

once the above command “startx” is entered. The following window is opened

do all the operations in the above window. Like compiling your tcl scripts etc

15
Installation Guidelines for NS2 on Ubuntu

To view our network simulation traces made using ns-2, we will need Nam: Network
Animator.

Nam is a Tcl/TK based animation tool for viewing network simulation traces and real world
packet traces. It supports topology layout, packet level animation, and various data inspection
tools.

 Install it by running the following command in your terminal:

sudo apt-get install -y nam

 Run the following command in your terminal to install ns-2:

sudo apt-get install -y ns2

16
Practical 5
Aim: Implementation of routing protocol in NS2 for DSR protocol.

NS2 Simulator
NS-2 is extensively used by the networking research community. It provides substantial support
for simulation of TCP, routing, multicast protocols over wired and wireless (local and satellite)
networks, etc.
DSR Protocol
The Dynamic Source Routing Protocol is a source-routed on-demand routing protocol. A node
maintains route caches containing the source routes that it is aware of. The node updates entries
in the route cache as and when it learns about new routes.DSR does not rely on functions like
periodic routing advertisement, link status sensing or neighbor detection packets and because
of the entirely on demand behavior, the number of overhead packets caused by DSR scales
down to zero.
Implementation of routing protocol in NS2 for DSR protocol:- #Simulation parameters
setup

Phy/WirelessPhy set bandwidth_ 10Mb ;#Data Rate Mac/802_11


set dataRate_ 10Mb ;#Rate for Data Frames set val(chan)
Channel/WirelessChannel ;# channel type set val(prop)
Propagation/TwoRayGround ;# radio-propagation model
set val(netif) 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) 25 ;# number of mobilenodes
set val(rp) DSR ;# routing protocol set val(x) 2146 ;# X
dimension of topography set val(y) 380 ;# Y dimension of
topography set val(stop) 10.0 ;# time of simulation end

# Initialization #Create a ns simulator


set ns [new Simulator] #Setup
topography object set topo [new
Topography] $topo load_flatgrid
$val(x) $val(y) create-god
$val(nn) #Open the NS trace file
set tracefile [open outm.tr w] $ns
trace-all $tracefile #Open the

17
NAM trace file set namfile [open
outm.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y) set
chan [new $val(chan)];#Create wireless channel

# Mobile node parameter setup


$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON

# Nodes Definition
#Create nodes set
n0 [$ns node] $n0
set X_ 573
$n0 set Y_ 357
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node] $n1
set X_ 227
$n1 set Y_ 294
$n1 set Z_ 0.0 $ns
initial_node_pos $n1 20 set
n2 [$ns node] $n2 set X_
103
$n2 set Y_ 109
$n2 set Z_ 0.0 $ns
initial_node_pos $n2 20 set
n3 [$ns node] $n3 set X_
882

18
$n3 set Y_ 112
$n3 set Z_ 0.0 $ns
initial_node_pos $n3 20 set
n4 [$ns node] $n4 set X_
739
$n4 set Y_ 46
$n4 set Z_ 0.0 $ns
initial_node_pos $n4 20 set
n5 [$ns node]
$n5 set X_ 830

$n5 set Y_ -68


$n5 set Z_ 0.0 $ns
initial_node_pos $n5 20 set
n6 [$ns node] $n6 set X_
905
$n6 set Y_ 336
$n6 set Z_ 0.0 $ns
initial_node_pos $n6 20 set
n7 [$ns node] $n7 set X_
161
$n7 set Y_ 20
$n7 set Z_ 0.0 $ns
initial_node_pos $n7 20 set
n8 [$ns node] $n8 set X_
1187
$n8 set Y_ 99
$n8 set Z_ 0.0 $ns
initial_node_pos $n8 20 set
n9 [$ns node] $n9 set X_
934
$n9 set Y_ -79
$n9 set Z_ 0.0 $ns
initial_node_pos $n9 20 set
n10 [$ns node] $n10 set X_
416
$n10 set Y_ 120
$n10 set Z_ 0.0 $ns
initial_node_pos $n10 20 set
n11 [$ns node] $n11 set X_
601
$n11 set Y_ 151

19
$n11 set Z_ 0.0 $ns
initial_node_pos $n11 20 set
n12 [$ns node] $n12 set X_
354
$n12 set Y_ 419
$n12 set Z_ 0.0 $ns
initial_node_pos $n12 20 set
n13 [$ns node] $n13 set X_
1020
$n13 set Y_ 199
$n13 set Z_ 0.0 $ns
initial_node_pos $n13 20 set
n14 [$ns node] $n14 set X_
513
$n14 set Y_ -54

$n14 set Z_ 0.0 $ns


initial_node_pos $n14 20 set
n15 [$ns node] $n15 set X_
1019
$n15 set Y_ -17
$n15 set Z_ 0.0
$ns initial_node_pos $n15 20
set n16 [$ns node] $n16 set
X_ 351
$n16 set Y_ -184
$n16 set Z_ 0.0 $ns
initial_node_pos $n16 20 set
n17 [$ns node] $n17 set X_
54
$n17 set Y_ -84
$n17 set Z_ 0.0 $ns
initial_node_pos $n17 20 set
n18 [$ns node] $n18 set X_
278
$n18 set Y_ 267
$n18 set Z_ 0.0 $ns
initial_node_pos $n18 20 set
n19 [$ns node] $n19 set X_
319
$n19 set Y_ -13
$n19 set Z_ 0.0 $ns
initial_node_pos $n19 20 set

20
n20 [$ns node] $n20 set X_
768
$n20 set Y_ -156
$n20 set Z_ 0.0 $ns
initial_node_pos $n20 20 set
n21 [$ns node] $n21 set X_
962
$n21 set Y_ 198
$n21 set Z_ 0.0 $ns
initial_node_pos $n21 20 set
n22 [$ns node] $n22 set X_
747
$n22 set Y_ 293
$n22 set Z_ 0.0 $ns
initial_node_pos $n22 20 set
n23 [$ns node] $n23 set X_
589
$n23 set Y_ -56
$n23 set Z_ 0.0

$ns initial_node_pos $n23 20


set n24 [$ns node] $n24 set
X_ 627
$n24 set Y_ -225
$n24 set Z_ 0.0
$ns initial_node_pos $n24 20

# Generate movement
$ns at 0.3 " $n8 setdest 750 55 50 "
$ns at 0.5 " $n15 setdest 739 46 80 "
$ns at 0.4 " $n16 setdest 742 280 50 "
$ns at 0.2 " $n17 setdest 720 170 80 "
$ns at 0.2 " $n23 setdest 450 144 50 "

# Agents Definition #Setup


a UDP connection set udp0
[new Agent/UDP] $ns
attach-agent $n0 $udp0 set
null1 [new Agent/Null] $ns
attach-agent $n20 $null1
$ns connect $udp0 $null1
$udp0 set packetSize_ 1500
21
# Applications Definition #Setup a CBR Application over UDP connection set cbr0 [new
Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1000
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 5.0 "$cbr0 stop"

# Termination #Define a 'finish' procedure


proc finish {} { global ns
tracefile namfile

$ns flush-trace close


$tracefile close
$namfile exec nam
out.nam &
exit 0 }

for {set i 0} {$i < $val(nn)} { incr i } {


$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

22
Practical 6
Aim: Study other wireless sensor network simulators (Mannasim. Contiki).

Configuring Access Points(Mannasim):-To create an access point (AP) the first thing it to
set node-config structure. This is a ns-2 structure used to define a bunch of mobile node
parameters. In Mannasim context the only difference from the tradicional settings is the
inclusion of -sensorNode ON command. With this command whenever an instance of a mobile
node is instantiated a wireless sensor node is automatically created. The box bellow shows a
sample configuration (note the use of val() vector).

$ns_ node-config -sensorNode ON


-adhocRouting $val(rp)
-adhocRouting $val(rp)
-llType $val(ll)
-macType $val(mac)
-ifqType $val(ifq)
-ifqLen $val(ifqlen)
-antType $val(ant)
-propType $val(prop)
-energyModel $val(en)

Next thing to be done is to set sensor node functionalitys like for example, a transporte protocol,
a data generator, a processing module and an application running within the sensor node. All
these functionalities have have configuration parameteres of there own that will be explained
shortly.

set node_($counter) [$ns_ node] set udp_($counter) [new Agent/UDP]


set app_($counter) [new Application/SensorBaseApp/AccessPointApp]

Configuring teh sensor node requires the adjustment of nodes position, motion characteristics
(in the box example, 0 means that the sensor node is static) and the transport protocol.
IMPORTANT: when attaching the transport protocol to an AP node the port value used must
be the same of all network elements (common nodes, cluster heads, etc).

$node_($counter) random-motion 0
$node_($counter) set X_ 5.0
$node_($counter) set Y_ 5.0
$node_($counter) set Z_ 0.0
$node_($counter) attach $udp_($counter) $val(port)

To finish the AP stop time should be sheduled in the simulation object.

$ns_ at 1200.0 "$app_($counter) stop"

On demand Networks

23
On demand networks require that the AP or other outsider send requests messages to the WSN.
These messages specifies the situation when the network should provide data to the requester.

To create a request message to be send by the AP the following parameters should be set:

 when requested data should be sent back to AP (for example, send data when
temperature exceeds 25 celcius degrees).

 request type - two values are possible: REAL (0) when sensor node drops all data all
data from its buffer, gather new one, process and deliver it to the disseminating module.
BUFFER (1) when sensor node process data from its buffer and give the results to the
disseminating module.

The sample code provided bellow defines the request time, schedules when data structure that
encapulates request data is created and when request message will be sent.

$app_($counter) set request_type_ 25 0


$ns_ at 120.0 "$app_($counter) add_temp_data_param 25 0"
$ns_ at 120.5 "$app_ send_request"

Configuring Common Node

The Common Node (CN) configuration presents the greater number of parameter to be set.
Since a CN has an application, a processing module and a data generation module used to
simulate sensing tasks.

Sensor node creation is equal to Access Point node creation. Just put in the tradicional
nodeconfig structure the -sensorNode ON command.

Next step is to create common node functionality modules including a transport protocol, an
sensor application, a processing and a data generator. The data generator module is the
difference between a Cluster Head and a Common Node configuration. In the example box
presented bellow an UDP transport protocol, an AggregateProcessing processing module, a
TemperatureDataGenerator data generator module and a
CommonNodeApplication application module were used.

set node_($counter) [$ns_ node] set udp_($counter) [new Agent/UDP]


set processing_($counter) [new Processing/AggregateProcessing]
set gen_($counter) [new DataGenerator/TemperatureDataGenerator]
set app_($counter) [new Application/SensorBaseApp/CommonNodeApp]

Common node application parameters include dissemination interval and type (PERIODIC -
0, CONTINUOUS - 1, ON_DEMAND - 2 and EVENT_DRIVEN - 3), sent messages

destination address. The attachements list is bigger including sensor node, transport protocol,
processing and data generator module (see example box following).

$app_($counter) set destination_id_ 0;

24
$app_($counter) set dissemination_type 0;
$app_($counter) set dissemination_interval 30.0;
$app_($counter) node $node_($counter);
$app_($counter) attach-agent $udp_($counter)
$app_($counter) attach_data_generator $gen_($counter)
$app_($counter) attach-processing $processing_($counter)

CONTIKI COOJA SIMULATOR

Overview of Contiki Cooja Simulator: Cooja is one of the sensor network simulators and it
is the short form of Contiki OS Java simulator. The Contiki OS is a convenient OS used for
the limited source of devices such as the sensor nodes and it is created in the event-driven
kernel.

Significant Uses of Contiki Cooja Simulator

The following is about the most important compensations in the Contiki Cooja.The Contiki
provides assistance for the pre-emptive and pre-process multi-threading and for interaction
process by message transmission over the optimal GUI subsystem

Notable Modules in Cooja Simulator

Let us discuss significant modules and the functions of that module based on the Cooja
simulator

Modules and their Functions

Arm

 It is used for the execution of atomic functions by the instructions of DMB, STREX,
and LDREX.

 Arm-gcc in Contiki and arm related Contiki ports are created by the toolchain Major
Classes in Contiki Cooja Simulator

Hereby, we have listed down the notable classes which are useful for the development of the
research project. There are many significant classes based on the Contiki Cooja simulator but
we have listed down a class with their uses for your reference

Classes and its Purposes

 File Target

 It is utilized for the process of hash table which related to file writing

System Specifications in Contiki Cooja Simulator

Hereby, we have highlighted some programming language for the implementation process in
the research based on the Contiki Cooja r and we support your ideas with our guidance

25
Programming Languages in Contiki Cooja

 Java
 C
The essential and supportive operating systems for the Contiki Cooja simulator are listed down.
If research scholars need some more requirements you can contact us for your research support
and our research experts will provide the complete guidance

OS Support in Cooja Simulator

 Contiki-2.7

 Ubuntu-14.04

Hereby, we have enlisted the version details for Cooja simulator. Similarly, research scholars
may select different versions for their research implementation process with our research expert
guidance

Cross level Sensor Network

 It is a new method of wireless sensor network simulation which permits the holistic
simulation in several levels

 For instance, we are executing the simulator such as Cooja and Contiki sensor node.
Here Cooja permits the operating system level, machine code instruction level, and
network-level

Topmost Subjects in Contiki Cooja Simulator:

The subject modules used in the Contiki Cooja are highlighted below. The research scholars
may use the module which suits their research projects with our support

 Wireless Sensor Network

 Internet of Things

26
Practical 7
Aim: Implementation of routing protocol in NS2 for AODV protocol for TORA protocol.

#Define options
setval(chanl) Channel/WirelessChannel ; #channel type

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


model

set val(netif) 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) 25 ; #number of mobilnodes set
val(rp) AODV ;#routing protocol set val(x)
500 ; #X dimensions of topography set val(y)
400 ; #Y dimensions of topography set
val(stop) 150 ; #time of simulation endc

set ns [new Simulator] set tracefd


[open testAODV.tr w] set
windowVsTime2 [open win.tr w] set
namtrace [open testAODV.nam w]

$ns trace-all $tracefd


$ns namtrace-all-wireless $namtrace $val(x) $val(y)

#set up topography object set


topo [new Topography]

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


create-god $val(nn)

#Create nn mobilenodes [$val(nn)] and attach them to the


channel.
#configure the nodes
$ns node-config -adhocRouting$val(rp)\
-llType $val(ll)\
-macType $val(mac)\
-ifqType $val(ifq) \

27
-ifqLen $val(ifqlen)\
-antType $val(ant)\
-propType $val(prop)\
-phyType $val(netif) \
-channelType $val(chanl)\
-topo Instance$topo \
-agentTrace ON\
-routerTrace ON\
-macTrace OFF \
-movementTrace ON

for{seti 0} {$i<$val(nn)} {incr i } { set


node_($i) [$ns node]
$node_($i) set X_ [ expr 10+round(rand()*480) ]

$node_($i) set Y_ [ expr 10+round(rand()*380) ]


$node_($i) set Z_ 0.0
}

for {set i 0} {$i < $val(nn) } {incr i } { $ns at [


expr 15+round(rand()*60) ] "$node_($i) setdest
[expr 10+round(rand()*480)]
[expr10+round(rand()*380) ] [ expr 2+round(rand()*15)
]"
}
#Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 70.0 "$node_(2) setdest 480.0 300.0 5.0"
$ns at 20.0 "$node_(3) setdest 200.0 200.0 5.0"
$ns at 25.0 "$node_(4) setdest 50.0 50.0 10.0"
$ns at 60.0 "$node_(5) setdest 150.0 70.0 2.0"
$ns at 90.0 "$node_(6) setdest 380.0 150.0 8.0"
$ns at 42.0 "$node_(7) setdest 200.0 100.0 15.0"
$ns at 55.0 "$node_(8) setdest 50.0 275.0 5.0"
$ns at 19.0 "$node_(9) setdest 250.0 250.0 7.0"
$ns at 90.0 "$node_(10) setdest 150.0 150.0 20.0"

#Set a TCP connection between node_(2) and node_(11)


set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2 set sink [new
Agent/TCPSink] $ns attach-
agent $node_(2) $tcp

28
$ns attach-agent $node_(11) $sink
$ns connect $tcp $sink set ftp [new
Application/FTP] $ftp attach-
agent $tcp
$ns at 10.0 "$ftp start"

#Printing the window size proc


plotWindow {tcpSource file} {
global ns set time 0.01 set now
[$ns now] set cwnd [$tcpSource
set cwnd_] puts $file "$now
$cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource
$file"}
$ns at 10.1 "plotWindow $tcp $windowVsTime2"

#Define node initial position in nam


for {set i 0} {$i < $val(nn)} {incr i } {
#30 defines the node size for nam
$ns initial_node_pos $node_($i)30
}

#Telling nodes when the simulation ends


for{set i 0} {$i<$val(nn)} {incr i } {
$ns at $val(stop) "$node_($i) reset";
}

#ending nam and the simulation


$ns at $val(stop)"$ns nam-end-wireless $val(stop)"
$ns at $val(stop)"stop"
$ns at 150 "puts\"end simulation\" ;$ns halt"

proc stop {} { global ns


tracefd namtrace $ns
flush-trace close $tracefd
close $namtrace
}

$ns run

29

You might also like