Professional Documents
Culture Documents
Step-by-Step
Milan Simek, Patrik Moravek and Jorge sa Silva
AbstractWe present an extensive guide for the researchers
that aim to validate proposed algorithms for wireless sensor
networks in Matlab environment. In this paper, we describe step
by step all necessary tasks that must be accomplished for the
full operation of the Matlab WSN simulation model. The goal of
this paper is to describe processes how to simulate the lifetime
of the WSN network during a data gathering. We describe tasks
such as topology generation and visualization, data routing and
communication cost calculation. To estimate lifetime of network,
we have proposed the Matlab energy model that goes from the
analysis of the real Zigbe network.
Index Termswireless sensor networks, Matlab, implementa-
tion, simulation, guide, matrix.
I. INTRODUCTION
T
HIS paper introduces step-by-step implementation of
the wireless sensor networking in Matlab environ-
ment(particularly Matlab 2007b). It aims to bring detailed
directions for under/postgraduate students and researches deal-
ing with the wireless sensor simulation under the Matlab
environment. Hence a longterm data gathering is the funda-
mental task of the wireless sensor networks, we show how to
implement all necessary tasks related with the data gathering
processes. In the considered simulation, each battery equipped
node unicasts in the regular intervals (refferred to as rounds of
data gathering) a one packet with the dened size. The packets
are multihoped through the network to the base station that
is power supplied. Simulation ends when there is no path to
the base station, meaning that all neighbors of base station
are out of energy. The results of the simulation are presented
by the colored topology showing the residual energy on each
node and a plot of number of alive nodes in the network
during increasing number of gathering rounds. The rest of
paper is structured as follows: Section I brings the steps of
network topology denition. In Section II, we show how to
nd the shortest path between two nodes in ad-hoc network.
An evaluation of communication cost is introduced in Section
III, while Section IV describes the proposed energy model.
The result of the entire simulation are presented in Section V.
The section VI brings the conclusion and future work.
II. NETWORK TOPOLOGY
A network with N nodes can be modeled as a N-vertex
undirected graph G = (V = {1, ..., N}, E), where 2D/3D
Manuscript received December 15, 2010; revised January 11, 2010.
M. Simek and Patrik Moravek are with the Department of Telecom-
munication of Brno University of Technology, Czech Republic, e-
mail:simek@feec.vutbr.cz
Jorge sa Silva is with Department of Informatics, University of Coimbra,
Portugal, email:sasilva@dei.uc.pt.
position p of each vertice i is identied by the set of coordi-
nates p
i
= (x
i
, y
i
and z
i
respective). An euclidean length d
i,j
between two vertices i, j V is refferred to as E. The network
topology is then interpreted by a three/four row matrix, where
the 2D/3D position of nodes are stored in individual columns,
see Table I. Furthermore for a simplicity, only the 2D plane
is considered for the simulation.
TABLE I
TOPOLOGY MATRIX
ID 1 2 3 ... N
X coor x
1
x
2
x
3
... x
N
Y coor y
1
y
2
y
3
... y
N
For the simulations, the networks are considered to be fully
connected, meaning that all nodes are reachable due to the
multihop communication. The connectivity depends on the
radio range, thus the radio range of the nodes should be
congured optimally. One can estimate the optimal radio range
empirically or to use an Eq. 1 that estimates the minimum
radio range ensuring the full connectivity.
R =
log N
N
(1)
The parameter stands for a 2D plane diameter directly
proportional to the number of nodes N. Calculating the R
for the 100 nodes randomly placed in the 2D plane with the
300m x 500m dimension, the minimal R should be 82 meters.
According to the experiences with the Crossbow IRIS 2.4
GHz node [7], the radio range of 82 meters corresponds to
the transmitting power of 3.2 dBm.
Once the network matrix is created and radio range calcu-
lated, the network topology can be printed. The layout of the
network consists of the vertices and edges between vertices.
The edge or link between two nodes can be printed only in
case that the euclidean distance d
i,j
between two nodes i, j
is smaller than R of the considered nodes. Since the wireless
links are considered to be bidirectional and symmetric then
d
i,j
= d
j,i
. A pseudocode of the layout printing is introduced
in more details in the following section.
In the real wireless network, a distance between two nodes
can be derived from RSSI parameter (Receive Signal Strength
Indication) or estimated by methods such as ToA (Time of
Arrival) or AoA (Angle of Arrival) [11]. These techniques
suffer from the certain distance estimation error and thus this
error should be also implemented into the simulation model.
We consider that range-error of the distance measurement
methods has a Gaussian distribution. The range error
r
is
modeled by the Gaussian distribution with a mean = 0
and a standard deviation . In contrast to the many current
researchers dealing with the range errors modeling, it is
considered that is spread on the both sides from the
value. Thus, the distance r
i,j
measured under the
r
can
be calculated as shown in Eq. (2). The employed approach
expresses situations where the measured signal strength is
either strengthened by the interferences or suppressed by walls
and obstacles. A decision about adding or subtracting the error
portion to the distance should be made randomly.
r
i,j
= d
i,j
d
i,j
100
r
(2)
If some WSN algorithms are to be investigated and theirs
performance compared, they should be tested under the
identical conditions. Hence, it is recommended to use the
identical set of the networks graphs that should have different
topologies (grid, random, L-shape, T-shape), scales (ten
nodes up to thousands nodes) and node degrees (8 up to 26
neighbors per node). For the storing of all prepared networks,
the struct function can be used.
%STORE
someName=struct();
someName.network(:,:,1)=network_1;
save(file.mat,someName);
%LOAD
load file.mat;
network_1=someName.network(:,:,1);
In the previous paragraph we have mention that range of the
node degree should be between 8 and 26. This range was taken
from the work of Bettstetter [2] and Xue and Kumar [14].
They investigated the required R radio range and average node
degree m (average number of neighbors) to ensure the con-
nectivity of network. They stated that network is connected if
for every pair of nodes there exists one-hop link or one multi-
hop link respective. Results of these works showed that node
degree in WSNs considered for probability of the connectivity
greater than 0 has range of < 8, 26 > (see Fig. 1). Thus,
this node degree range was implemented into the network
models so that for each network size N = 50, 100, 400
nodes, ten degrees models were implemented, creating the set
of 30 networks with different network size and degrees. This
network database together with the demonstration Matlab les
can be found in [10].
III. ROUTING IN AD HOC NETWORK
The data routing in wireless sensor network is realized on
the links comparison base. The considered links between a
sender and a receiver can be compared in terms of the length,
link quality or residual energy of the node pairs. Nevertheless,
the path with the smallest investigated value is selected as the
route for the data delivery. For the discovering of the optimal
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
0
20
40
60
80
100
Average node degree []
P
r
o
b
a
b
i
l
i
t
y
o
f
c
o
n
n
e
c
t
i
v
i
t
y
[
%
]