Supervisor: Hai Vortman
Technion Networked Software Systems Lab
Page 1
Acknowledgments
We would like to begin by thanking Hai Vortman, our project advisor and
mentor for the past year. Hai has been a wonderful advisor, providing us
with support, encouragement, and an endless source of ideas. His breadth of
knowledge and his enthusiasm for the sensor network subject amazes and
inspires us. We thank him for the countless hours he has spent with us. We
would also like to thank Dr. Ilana who gave us the opportunity to conduct
our project in her laboratory and for her advices and feedback during the
project.
Page 2
Contents
Acknowledgments ........................................................................................................ 2
Abstract ...................................................................................................................... 5
Introduction ................................................................................................................ 6
Project goals ............................................................................................................................ 6
Bluetooth Overview .................................................................................................................. 7
So what is Bluetooth exactly? .................................................................................................... 7
Bluetooth Advantages............................................................................................................... 8
Bluetooth Disadvantages........................................................................................................... 8
How Bluetooth fits in the seven layer model (Bluetooth stack) ...................................................... 9
Piconet and Scatternet technology ........................................................................................... 10
Other technology comparison.................................................................................................. 11
The SIG ................................................................................................................................. 12
Wireless Sensors Technologies ..................................................................................... 13
Wireless Sensors Network Tradeoff .......................................................................................... 14
Wireless Sensors Network Tradeoff ............................................... Error! Bookmark not defined.61
Our Sensor Network Algorithm .................................................................................... 15
General Algorithm Overview.................................................................................................... 15
Sensor Diagram Flow .............................................................................................................. 16
Initialization ........................................................................................................................... 18
The Device Discovery Process .................................................................................................. 19
The Service Discovery Process.................................................................................................. 20
The “Father” Discovery Process................................................................................................ 21
Relay Service.......................................................................................................................... 22
Connection failure .................................................................................................................. 22
Event detection ...................................................................................................................... 22
Software design specifications ..................................................................................... 23
Introduction .......................................................................................................................... 23
Design Considerations............................................................................................................. 23
System Architecture ............................................................................................................... 25
USER MANUAL ........................................................................................................... 27
Base Station vs. Sensor......................................................................................... 27
Start/Stop the application ....................................................................................................... 27
Create an Event...................................................................................................................... 28
Page 3
Sensor Connection Example .................................................................................................... 29
Conclusion ................................................................................................................. 34
Bibliography 35
Page 4
Abstract
This project consists in a software based implementation of a wireless sensor
using the Bluetooth technology for communication. This project permits to
build a real wireless sensor network in any laboratory which has at least two
computers with Bluetooth hardware enabled.
The reason why the Bluetooth protocol was chosen for the communication
was the very low cost of the hardware, the amazing commonness of the
various devices using it and the easiest way future projects and researches
will be able to use our implementation.
Because most of the gadgets, computers and mobiles contain the JVM, the
development was done using the Java language.
The algorithm we have implemented is a very simple one, used in a quasi
static network. This Algorithm consists in a unique base station that manages
and collects all the events in the network.
Although the algorithm of the sensor network we have developed is a very
simple and basic one, it can be easily widen to a much complex one.
Our project can be used for researches in the computer network field and
especially can be useful for real simulation and testing of a wireless
computer network.
Another usage of this project can be in completely different fields where the
sensor network is not the main but it is part of an event detection system
whatsoever. For this kind of usages we have developed a special
Environment Event API to relieve the usage of our software.
Page 5
Introduction
If we were to describe the Bluetooth as one of the most important new
technology we would not be exaggerating. Bluetooth is an open wireless
protocol for exchanging data over short distances from fixed and mobile
devices.
Founded in September 1998, the Bluetooth SIG is a unification of leaders in
the telecommunications, computing, network, industrial automation, and
automotive industries. Today, the Bluetooth SIG is responsible for
encouraging and supporting research and development in Bluetooth
technology. In our project we had took advantage of this technology to solve
one of the most interesting problems of today, from a commercial and
technological point of view, a wireless sensor network.
Project goals
The main project goal is to implement a wireless sensor algorithm which
uses the Bluetooth technology. Sub-goals are developing a work area in
order to testing various wireless network protocols such as Gradient
Algorithm PIF, CT3 and CT2. Another sub goal is to create an Event
Management API to letting event detection project to transmit easily and
reliably event in a wireless sensor network.
The application should implement the sensor algorithm which includes, by
the way, the different ways the sensor deals with communication lost and
event detection.
Page 6
Bluetooth Overview
Bluetooth is an open wireless protocol for exchanging data over short
distances from fixed and mobile devices, creating personal area networks
(PANs). It was originally conceived as a wireless alternative to RS232 data
cables. It can connect several devices, overcoming problems of
synchronization.
So what is Bluetooth exactly?
Bluetooth is a very simple type of wireless networking that can allow up to
seven devices to be connected together in a mini-network.
The typical range is reported in the next paragraph but we can say that
because it is a very short range is considered to be for 'personal' networking.
Bluetooth is a moderately slow type of networking, but it can transfer data
sufficiently fast enough for most typical applications. Bluetooth is a very low
cost type of networking, and, as it becomes more widespread, the cost of
adding Bluetooth to devices is getting always lower and lower. Bluetooth is
designed to be compatible across a range of very different operating systems
and devices, including things that you would not normally think of as being
'computer' type items - for example, some types of headset. Bluetooth
networking can enable the headset to connect with other devices such as
your phone, your MP3 player, your computer, or you’re PDA.
Page 7
Bluetooth Advantages
The Bluetooth main advantages are the low power consumption.
In the following table we can comprehend the approximate size of the
power usage of the Bluetooth hardware.
Class Maximum Range [m]
Permitted Power
[mW]
Class 1 100 [mW] 100 [m]
Class 2 2.5 [mW] 10 [m]
Class 3 1 [mW] 1 [m]
As the table shows there are three main Bluetooth classes (types) which
differ by their communication range.
Another advantage is the wide usage of this technology; as already said
more than 1.5 billion Bluetooth devices in the last decade. The commonness
of this technology results also in a very low cost of the Bluetooth products.
Bluetooth Disadvantages
One of the clearest disadvantages of the Bluetooth technology is the low
bandwidth that it permits. The limit is 3Mbit/s .Normally a Bluetooth device
can communicate with maximum other eight Bluetooth devices. Each of this
connection is called a piconet. Sensor networks contain maybe thousands of
sensors and therefore these restrictions can throughput and bandwidth
problems.
Page 8
How Bluetooth fits in the seven layer model (Bluetooth stack)
This section provides a brief overview of the Bluetooth protocol stack. The
Bluetooth protocol stack can be broadly divided into two components: The
Bluetooth host and the Bluetooth controller. The Host Controller Interface
(HCI) provides a standardized interface between the Bluetooth host and the
Bluetooth controller. L2CAP adapts upper-layer protocols to the baseband. It
multiplexes between the various logical connections made by the upper
layers. RFCOMM emulates RS-232 control and data signals over Bluetooth
baseband, providing transport capabilities for upper level services that use a
serial interface as a transport mechanism. The following is a basic diagram
describing the main layer in the Bluetooth stack.
Software
Obex
RFCOMM
L2CAP
HCI
Baseband
Bluetooth Radio
Page 9
Piconet and Scatternet technology
A piconet is the type of connection that is formed between two or more
Bluetooth-enabled devices such as modern cell phones or PDAs. All
Bluetooth enabled devices are "peer units" in that they have identical
implementations. However, when a piconet is formed between two or more
devices, one device is dynamically elected to take the role of 'master', and all
other devices assume a 'slave' role for synchronization reasons. Piconets
have a 3-bit address space, which limits the maximum size of a piconet to 8
devices (23 = 8), i.e. 1 master and 7 slaves. A scatternet is a number of
interconnected piconets that supports communication between more than 8
devices. Scatternets can be formed when a member of one piconet (either
the master or one of the slaves) elects to participate as a slave in a second,
separate piconet. The device participating in both piconets can relay data
between members of both ad-hoc networks. Using this approach, it is
possible to join together numerous piconets into a large scatternet, and to
expand the physical size of the network beyond Bluetooth's limited
range.Currently there are very few actual implementations of scatternets
due to limitations of Bluetooth and the MAC address protocol. However,
there is a growing body of research being conducted with the goal of
developing algorithms to efficiently form scatternets. The following diagram
rapresent a simple Bluetooth scatternet:
Page
10
Other technology comparison
Wi-Fi is primarily used as an alternate to traditional cable based networks. It
has a longer range than Bluetooth, and supports faster data transfer speeds,
and so it might seem better than Bluetooth. But, in reality, Bluetooth and
Wi-Fi have different purposes. Bluetooth is intended for limited data transfer
between many different types of devices, Wi-Fi is more focused on faster
data transfer between computers on a network. One of the distinctive
elements of Bluetooth is that is uses very much less power than Wi-Fi.
Wi-Fi, on the other hand, consumes a great deal of power, and so for any
type of portable battery operated device.
Page
11
The SIG
The Bluetooth Special Interest Group was founded in September 1998 and
his main tasks are to publish Bluetooth specifications, administer the
qualification program, protect the Bluetooth trademarks and evangelize
Bluetooth wireless technology. The SIG has more than 11,000 member
companies. Another very interesting data regarding the wide spread of this
technology is the fact that last decade 1.5 billion Bluetooth enabled devices
have been shipped.
Page
12
Wireless Sensors Technologies
A wireless sensor network (WSN) is a computer network consisting of
distributed autonomous devices using sensors to detect events and spread
data.
The development of wireless sensor networks is motivated by the large
usage and advantages that such system can provide in fields like military
applications, agriculture, vehicle detection, greenhouse monitoring,
environmental monitoring and more.
The requirements from a wireless sensor network system usually are usage
with limited power, ability to withstand different environmental conditions,
ability to cope with node failures, mobility of nodes, dynamic network
topology, communication failures, and compactness.
Wireless sensor networks are likely to be widely deployed in the future
because they greatly extend our ability to monitor and control the physical
environment from remote locations. There are several main obstacles that
need to be overcome before when designing a wireless sensor network:
Energy: Because networked sensors can use up their limited supply of
energy simply performing computations and transmitting information in a
wireless environment, energy-conserving forms of communication and
computation are essential.
Computation: Sensors have limited computing power, and therefore may
not be able to run sophisticated network protocols.
Page
13
Communication: The bandwidth of the wireless links connecting sensor
nodes is often limited, on the order of a few hundred Kbps, further
constraining inter-sensor communication.
Wireless Sensors Network Tradeoff
Generally the main trade-off that is taken under consideration when
designing a wireless sensor networks is between energy and communication
overhead saving in every routing solution. In our case, in spite of that, we
didn’t concentrate on these problems and we tried to give answers to much
more basic routing issues. First of all we tried to understand the physical
restrictions. Then, resolve how a certain device transfers packets in the
network. Then we tried to give an answer to how a device resolves a failure
connection/transmission of packets. To each of these questions there is no
one “right” solution but many and often the physical restrictions leads us to
improve routing algorithms using software solutions.
Page
14
Our Sensor Network Algorithm
General Algorithm Overview
The protocol that we have implemented in our project is the gradient
algorithm.
The main reason of this choice is because this algorithm can be used in a
quasi static network and his simplicity permits to overcome disconnections
events. The gradient algorithm required no central routing table because
every sensor, after establish a connection with the network, knows exactly
to who it must transfer the data. The wireless sensor network presumes that
a central server exists where the entire event must be recorded. Each sensor
in the network is connected to one “father” which is a sensor that his
distance from the central server is smaller than the other neighbors.
When a sensor detects an event all he has to do is to transmit the data to his
unique “father”. Then the “father” must transmit the event to his “father”
until the data arrives to the server. In case of communication failure the
sensor searches for a neighbor which has a smaller distance from the server
after have disconnected also his “sons”.
Page
15
Base Station Diagram Flow
The following is the Base Station diagram flow which describes the main
functionality of the Base Station:
Check Device
Hardware
Start Server
Service
Wait for event
and collect them
Page
16
Sensor Diagram Flow
The following is the Sensor logical flow which describes the basic loop of the
sensor:
Senosr is disconnected
Distance = infinity
No Service Available
If Connection failed Inquiry - Find BT device
close Server Service around
Start Relay and Event
Find Sensor around
Detection Service
Choose Father
According to Distance
Start Server Service
Note: If not available
distance = infinity
Page
17
Initialization
Every time a sensor starts its first goal is to understand the environment. In
our case, the sensor needs to explore and to collect all the potential devices
he can communicate with.
After collecting all the potential devices, the sensor has to set up the
connection with the most suitable device. In the algorithm protocol the most
suitable device is the one witch his distance from the base station is the
smaller.
Very Important Note: Many times, especially in a network of more than 4/5
devices, it can happen that some sensors are not connected to the optimal
neighbor. The reason is that during the BT inquiry and service search a BT
sensor cannot simultaneously send data. Moreover, after a sensor has
established a communication, it does not search periodically for a better
connection.
After the sensor is connected to the network he can lets other sensors to
connect through him.
Page
18
The Device Discovery Process
The environment understanding, conducted by the sensor as the first step, is
lead by the device discovery process. A list of all Bluetooth devices is
obtained and then the service search starts1.
1
A future implementation could be, in case of connection failure, to use the pre-known devices list to save inquiry
time. For more information on the pre-known devices JSR-82 support please refer to Appendix A.
Page
19
The Service Discovery Process
After collecting into a list the Bluetooth devices in its own area, the sensor
must understand witch Bluetooth devices are part of the network2. To do
that, the sensor must verify which device support RFCOMM and the service
represented by a specific UUID.
In this project the specific UUID that represent the service is
“102030405060708090A1B1C1D1E100”. It can easily be change from the
service configuration.
The result of the service search process is a list of all sensors in the area.
For every service (device) in the list, the sensor set up a connection trying to
understand witch sensor is the closer one to the base station.
2
A very common scenario is getting in the devices list mobiles. The service discovery shouldn’t obviously marker
these devices as part of the network.
Page
20
The “Father” Discovery Process
This stage begins after the sensor got the entire relevant devices list.
For every device he set up a connection asking for the distance from the
base station. The sensor set to be his father the device that is the closest one
to the base station. When the sensor knows exactly his “father” the sensor
is considered as connected.
Page
21
Relay Service
Only when the sensor is considered as connected (that means that in case of
an event message it knows to who transfer the message) he can start to give
the relay service to other/future sensors.
The relay service consists in adding the network service record to the SDDB3.
After record the service, other devices can be connected to the network
through this sensor.
Connection failure
Connection failure can be detected in 2 ways:
1. When processing a formal check.
2. When, trying to send a message, it failed twice.
The reparation is obtained by restart the sensor completely. A more
sophisticated and future implementation could take advantage from a pre-
known or cached device list supported by the jsr-82 API.
Event detection
When a connected sensor detects an event he composes the relevant
message and sends to his “father”. In case a message is received by one of its
son all it has to do is to transmit the same message to his father.
3
See Appendix A
Page
22
Software design specifications
Introduction
The purpose of this detailed specification is to permit to future project to
take advantage of our software or to develop it farther rapidly. The Sensor
entity (henceforth called the system) is a software application responsible to
implement a pre-defined state machine in order to enable event
identification and reliable communication with other sensors entities. Such a
system could be helpful testing or simulating buildings security and
administration implementations, army systems, event propagation systems
etc. The software is controllable through a GUI.
Design Considerations
Before starting developing the system we have asked our self what are the
main consideration to take to permit very easy usage of the system and very
easy development of more complicated algorithms.
In order to permit a very easy usage of our software we have decided that
one of the most important things is the compatibility of the system and this
because the hardware required is found almost in every computer and
mobile. Each of these devices of course can have different Operating
Systems. That led us to the conclusion that the best way to implement the
software is using java.
Another point that we had considered to facilitate the usage of the system is
to provide a GUI which will provide a visual view of the connections and a log
file with the algorithm description and phases.
Page
23
To facilitate future implementation of other algorithms we decided not to
give the user any interaction with the algorithm except start it and stop it.
That means that the software was design in such a way that it can be seen as
a black box with only two options: start the algorithm flow and stop it. Of
course we have added other configuration possibilities to help the user
debug and understand the Algorithm flow but it is very important to
remember that one of the advantages of our design is that the user cannot
interact with the algorithm.
Figure 1 - Black Box Design
Page
24
System Architecture
The system was partitioned to four main components: Device, Sensor, Server
and the Gui. The “Device” component is responsible for checking the
hardware compatibility and describes its characteristics. This component is
responsible also of the network constrains such as the time to wait between
inquiry and other parameters.
The Sensor is responsible to start/stop the algorithm implemented. It
contains all the algorithm implementation but also components responsible
for inquiry, service searches and connections.
The Server component is responsible to accept new connection after the
sensor is part of the network and to received new events from the different
sons. The last software component is of course the GUI which help the user
define and follow the flow.
Device SEnsor
Server Gui
Page
25
The following is a visual description of the software packages:
Definition
Device
Device
Sensor
Inquiry
Sensor
Service Search
System
connection
serviceregistration
Server
connection
gui
Gui visual connection
menu
Page
26
USER MANUAL
Base Station vs. Sensor
The first thing the user is required to do in order to start the application is to
decide whether the computer will act as a sensor or as a base station. When
starting the application the user sees the following window:
Note: If the Bluetooth hardware and stack are not available the software
will not start.
Start/Stop the application
Page
27
To start the application the user must select in the menu Action->Start.
Create an Event
To create an event the user must select in the menu Event Tools->Create
Event
Page
28
Sensor Connection Example
Here we present the different screen which describes the connection
process and the failure management. The following is the initialized status.
As shown the visual connection screen shows the initialized distance which is
infinity, the MAC address and the rule of the sensor.
Page
29
We bring here the equivalent figure for the base station witch distance is set
to zero at the beginning.
The sensor looks for a connection to the network and finds the BS. It
establishes the connection and here the following are the screen that shows
Page
30
the connection established as seen by the sensor and by the BS accordingly.
Page
31
Page
32
When an event occurs in the sensor the BS received it and shows the source
of the event even if the connection is not direct.
Page
33
Conclusion
We have tested our software on seven computers simultaneously verified
that the network was created as excepted. Therefore the latest release of
the software which is called WSN2.0 is a stable version.
Future development can consist in a large variety of WSN algorithm taking
advantage of our software design structure.
Page
34
Bibliography
[1] Jennifer Bray, C. F. (2002). Bluetooth 1.1.
[2] Sun Microsystems, I. 2. (2008). Java Apis for Bluetooth Wireless Technology (JSR 82).
[3] Team, B. (2008). BlueCove Project - JSR82. http://bluecove.org.
[4] Wireless sensor network. http://en.wikipedia.org.
Page
35