Wireless Sensor Networking in Matlab: Step-by-Step

Share Embed Donate


Short Description

A guide of matlab to simulate wireless sensor networks....

Description

Wireless Sensor Networking in Matlab: Step-by-Step Milan Simek, Patrik Moravek and Jorge sa Silva

Abstract—We 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 Terms—wireless sensor networks, Matlab, implementation, simulation, guide, matrix.

I. I NTRODUCTION HIS paper introduces step-by-step implementation of the wireless sensor networking in Matlab environment(particularly Matlab 2007b). It aims to bring detailed directions for under/postgraduate students and researches dealing with the wireless sensor simulation under the Matlab environment. Hence a longterm data gathering is the fundamental 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 defined 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 definition. In Section II, we show how to find 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.

T

II. N ETWORK T OPOLOGY 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 Telecommunication of Brno University of Technology, Czech Republic, email:[email protected] Jorge sa Silva is with Department of Informatics, University of Coimbra, Portugal, email:[email protected].

position p of each vertice i is identified by the set of coordinates pi = (xi , yi and zi respective). An euclidean length di,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 T OPOLOGY MATRIX ID

1

2

3

...

N

X coor

x1

x2

x3

...

xN

Y coor

y1

y2

y3

...

yN

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 configured 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 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 calculated, 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 di,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 di,j = dj,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.

100 Probability of connectivity [%] →

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 ri,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.   di,j × εr (2) ri,j = di,j ± 100

80

60

40

20

0

0

2

4

6

8

10 12 14 16 18 20 22 Average node degree [−] →

24

26

28

30

Fig. 1. Probability of connected network for 802.15.4 radio range (redrawn from [4]).

Algorithm: E=createNbrTable 1: row=1;

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 connectivity of network. They stated that network is connected if for every pair of nodes there exists one-hop link or one multihop 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 files can be found in [10]. III. ROUTING IN A D H OC N ETWORK 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

2: for all node pairs 3:

x=abs(xi -xj );

4:

y=abs(yi -yj );

5:

dist=sqrt(x2 + y 2 );

6:

if disti,j , whereas the BE value is incremented with each unsuccessful attempt [9]. Then the access time to the wireless medium can be calculated according to Eg. 4 [5]. The CCA detection time is defined as a period of a 8 symbols (16 µs/symbol).

= 7 × 320 µs + 128 µs

(4)

= 2.368 ms If the node successfully accesses to the medium, it first sends a Data Request message including ID of the demanded neighbor. The time that device spends in Rx/Tx mode during message processing is derived from the message size and the bitrate [kbps] of the radio chip (b =250 kbps for ATRF230). It was found by the analysis that size of the Data Request message is k =12 bytes, see Fig. 5.

Estimation of Data Request message size.

Thus, the process time of k size message is equal to tk = (k × 8)/(b × 1000) = 0.38 ms for Data Request message. Then the energy consumed during transmitting ET x equals to: U [V] × I[A] × t[s] = 2.4 V × 17 mA × 0, 32 ms = 15 µJ. Here U parameter stands for a voltage supplement and I parameter stands for the current consumption in Tx(power of 3.2 dBm) mode.

Zigbee NWK (8 B) IEEE 802.15.4 (9 B) Zigbee APS (8 B)

Fig. 6.

InitiallBackof f P eriod + CCA = = (2BE=3 − 1) × U nitBackof f P eriod + CCA

Fig. 5.

Payload (3 B)

FCS (2 B)

Analysis of Zigbee data packet.

When the Data Request message is received by the receiver device, it transits from Rx to Tx mode (192 µs) and sends back ACK message (size of ACK = 5 bytes). Once the ACK is received by the origin node it starts with transmitting of required data. Size of DATA message equals to the size of DATA PAYLOAD (data field) plus necessary OVERHEAD (headers of the APS, NWK, MAC, PHY layers). It was studied by means of the Daintree analyzer that APS and NWK layer add 8 bytes plus 8 bytes and MAC and PHY layer extend the message for 9+2(FCS) bytes, see Fig. 6. Thus the overall size of DATA message with the 3 bytes payload equals to

100-81%

81-60%

61-40%

41-20%

< 20%

110

100

90

80

70

60 y [m] →

30 bytes. The energy consumption during transmission of 30 bytes message equals to 3.9 mJ. The received data are again acknowledged by the ACK message. It is worthwhile no notice that Zigbee does not specify CCA and CSMA/CA method to applied for ACK messages. For illustration of the entire energy calculation, we assume only active mode to be included in the calculation together with the condition that IRx = IT x . Then the entire energy E consumed by the transmitting device can be derived from the time that it spends in the active mode:

50

40

ttotal

= (CCA)+(Tx data request)+(Rx/Tx receiver)+

30

+ (Rx ack)+(Rx/Tx sender)+(Tx data)+

20

+ (Rx/Tx receiver)+(Rx ack)=

10 R

= 2.368 + 0.32 + 0.192 + 0.16 + 0.192+

0 0

10

20

+ 0.96 + 0.192 + 0.16 = 4.54 ms

VI. S IMULATION OF DESCRIBED MODEL The introduced model was implemented in the Matlab environment to validate its performance. We have configured a scenario with N = 100 randomly deployed node, where each node had energy storage of 1 J. The data from all nodes is unicasted in rounds meaning that during one round, all nodes unicast data toward the base station (randomly selected node). The residual energy of the nodes should be visualized by the color of nodes. The result of simulation is the energy colored topology and graph of the live nodes number in dependency on the number of rounds. As was mentioned in the Introduction section, the simulation ends when there is no way how to route data to the base station. It means that all one-hop nodes around base station depleted own energy. Results of the simulation are shown in Fig.7 and Fig. 8. One can notice from Fig. 7 that nodes placed close to the base station (placed on the x-axis) are loaded with the enormous network traffic since their residual energy is half in comparison to the far-away nodes. The simulation statistics showed that nodes with one Joule transmitted 2243 messages. We can see from Fig. 8 that network operated more than 160 rounds while the first nodes depleted energy before the 80th round (2243 messages transmitted). From the mentioned implies that with the 1 Joule origin energy, the entire wireless sensor network can transmit maximally 160 measurements. VII. C ONCLUSION This paper does not aim to bring the novel results from the wireless sensor networking. Instead it aims to serve as

Fig. 7.

40

50

60

70

80

90

100

110

x [m] →

Energy map after simulation. 100 99

percentage of alive nodes [−] →

(5) The entire energy dissipated by the sender radio chip equals to: Esender = 2.4 [V] × 17 [mA] × 4.54 [ms] = 185 µJ. Detailed description of the IEEE 802.15.4 time processing can be found in [5]. In same way, the energy consumption for all nodes in the unicast route can be estimated. However, the energy model should be optimized with the exact current consumption of the Rx and Tx processes, we have showed only simplified calculation.

30 Base station

98 97 96 95 94 93 92 91 90

Fig. 8.

0

20

40

60

80 100 rounds [−] →

120

140

160

180

Percentage of live nodes during simulation.

the guideline for the student and researchers that want to validate in Matlab environment own algorithm proposed for the WSN applications. We have showed how to proposed and visualize WSN topology and how to route data through the multihop paths. We have also proposed energy model that can be used for transformation of the communication cost to the energy consumption. The ideas in proposed energy model were supported by the analysis of the real Zigbee network. We notify, that only simplified energy model was stated here. The nodes spent most of time in the sleep mode and thus the significant attention should be devoted to this factor. ACKNOWLEDGMENT This paper was prepared within the framework of No. FRVS IS18049001 project of the Czech Ministry of Education, Youth and Sports and No. FRTI2/571 grant project of the Ministry of Industry and Trade of the Czech Republic R EFERENCES [1] P. Basu and J. Redi, “Effect of Overhearing Transmissions on Energy Efficiency in Dense Sensor Networks,”

[2]

[3]

[4]

[5] [6]

[7] [8]

[9] [10]

[11]

[12]

[13]

[14]

in IPSN ’04: Proceedings of the 3rd international symposium on Information processing in sensor networks. New York, NY, USA: ACM, 2004, pp. 196–204. C. Bettstetter, “On the Minimum Node Degree and Connectivity of a Wireless Multihop Network,” in MobiHoc ’02: Proceedings of the 3rd ACM international symposium on Mobile ad hoc networking & computing. New York, NY, USA: ACM, 2002, pp. 80–91. Daintree Networks. (2010) Sensor Network Analyzer(SNA)@ONLINE. [Online]. Available: http://www.daintree.net/sna/sna.php J. C. Hou, N. Li, and I. Stojmenovic, “Topology construction and maintanance in wireless sensor networks,” in Handbook of Sensor Networks: Algorithms and Architectures, I. Stojmenovic, Ed. John Wiley and Sons, Sep. 2005, pp. 311–341. Jennic., “Jennic Inc., Calculating 802.15.4 Data Rates,” 2006. M. Koutny, J. Misurec, and P. Mlynek, “The new approaches of a multicasting in the wireless sensor networks,” in 33rd International Conference on TELECOMMUNICATIONS AND SIGNAL PROCESSING TSP 2010. Budapest, Szent Istvn krt. 7.: Asszisztencia Szervezo Kft., 2010, pp. 342–345. Memsic Technology Inc., “IRIS XM2110CA Data Sheet.” [Online]. Available: http://www.memsic.com I. Sergii. (2009) grTheory - Graph Theory Toolbox, MATLAB CENTRAL@ONLINE. [Online]. Available: http://www.mathworks.com/matlabcentral/fileexchange/4266 F. Shanin, Zigbee Wireless Networks and Transceivers. Oxford: Elsevier, 2008. M. Simek. (2010) Low Power Wireless & Sensor Laboratory@ONLINE. [Online]. Available: http://wsnbase.utko.feec.vutbr.cz ——, “Reference Node Selection for Anchor free Localization in Wireless Sensor Networks,” Ph.D. dissertation, Brno University of Technology, Purkynova 118, 612 00, Brno, Czech Republic, September 2010. S. Singh and C. S. Raghavendra, “PAMAS—Power Aware Multi-Access Protocol with Signalling for Ad hoc Networks,” SIGCOMM Comput. Commun. Rev., vol. 28, no. 3, pp. 5–26, 1998. J. E. Wieselthier, G. D. Nguyen, and A. Ephremides, “On the Construction of Energy-Efficient Broadcast and Multicast Trees in Wireless Networks,” in INFOCOM 2000. Nineteenth Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings. IEEE, vol. 2, 2000, pp. 585–594 vol.2. [Online]. Available: http://dx.doi.org/10.1109/INFCOM.2000.832232 F. Xue and P. R. Kumar, “The Number of Neighbors Needed for Connectivity of Wireless Networks,” Wirel. Netw., vol. 10, no. 2, pp. 169–181, 2004.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF