1. Peer-to-Peer Communication Framework on Android Platform
Liu Tianwei, National University of Singapore, Electrical and Computer Engineering
Abstract— With Smartphone penetration reaching investment, network outrages are common for
37%(Nelson,2011) worldwide and predicted to reach smartphone users and thus in many ways limiting
55% by the year 2014, the availability of powerful mobile
devices in the pocket of every consumer is fast becoming the capabilities of these devices.
a nom. However, the capabilities of these devices are
often limited by data network in which they have access III. MOTIVATION
to, which are often old and are not designed to support At such there is a need to redesign the current
the huge no of increasingly data hungry mobile devices.
This paper aims to explore the alternatives to traditional
network architectures to allow for greater network
network architecture focusing mainly on the P2P scalability and more importantly a lower
network architecture on mobile devices. infrastructure cost for each additional
To reach out to wider audiences, the open-source devices(clients) added to the network.
framework implemented in this project is based on the
widely popular open-source framework for mobile device
- Android. The framework allows developers to easily
leverage on in-built hardware communication capability IV. OBJECTIVES
of these devices(3G/Wifi/Bluetooth) without having to The objectives of the projects are therefore to
deal with the underlying networking implementation. explore and experiment on other means of
I. INTRODUCTION
network infrastructures suitable for usage on
Smartphone. The projects aims to provide a
Ipenetration ratereport is predicted toSmartphone
In a recent
in US
by Nielsen,
reach over
prototype open-source communication framework
suitable for usage in the below scenario.
50% reaching over 95 millions units in the
2011(Nielsen 2011). A Smartphone, is defined V. SERVER-CLIENT VS PEER-TO-PEER
here as a mobile phone “that offers more advanced To better evaluate the performance of Server-
computing ability and connectivity than a Client network design versus that of a Peer-to-
contemporary feature phone”(Nusca 2009). The Peer network design, let us that looks at a typical
high growth rate of these devices brings about network operation: File Distribution
many opportunities for entrepreneurs and
developer to leverage on the extra computing and
communication power of these devices. However,
the high growth rate of these data hungry devices
is not without it problems.
II. PROBLEM
The suddenly increase in the demand for mobile
data bandwidth brought by these devices took Fig 1
many mobile network providers by surprise. Many
of these network providers relies heavily on Objective:
traditional network architectures that are not - Distribute a large file from a single server to
designed to handles these kinds of traffics a large N number of host(peers). As shown in the
requirements. As network infrastructure expands Fig1 above.
takes times and also a huge amount of capital
2. Server-Client: architecture scales nicely with the increase in the
no of clients. The MTD tends towards the
maximum time of 1 hour, which is the maximum
time taken for the server to upload one file.
-- Eq(1)
VI. PROPOSED APPROACH
For a typical server client architecture, the server
would need to send N copies of the file. In conclusion, we can see that a Peer-to-Peer
The slowest client takes at least F/dmin time to architecture design has significant advantage in
download the given file. terms of scalability and cost as compared to a
Given a network as depicted in Fig1, Eq(1) show traditional client-server architecture design. This
the total time required for the server to complete suits our requirement for a new architecture
the task of distributing all the files. design. At such, the proposed framework would
Peer-to-Peer: be based on a Peer-to-Peer that allows developers
For a Peer-to-Peer architecture, the server would to build scalable applications on top of it.
need to send at least one copy of the file: F/us
The slowest client would take at least F/dmin to VII. USE CASES
download the given file.
The total number of bits that must be downloaded
would be NF bits, but the total upload capacity is
now .
This would means that the minimum time taken
for the task of distributing the files would be:
-- Eq(2)
Therefore, the total time taken for the task of
distributing the file in a P2P network would be:
--Eq(3)
Fig 3: P2P Mobile Network
The figure above shows how the framework can
serve as a support to the current mobile
communication architecture. By leveraging on the
Peer-to-Peer capability of the framework, the
network stress on the traditional Architecture can
be greatly reduced.
Some of the propose used case for the framework
would be:
Fig 2: MDT vs No. Of Clients - Ad-hoc gaming network.
Fig 2 shows a comparison of the two methods - Instant Messaging Application.
plotted by Minimum Distribution Time(MDT) - File sharing.
against N(no of clients). As shown in the graph, - Video Streaming.
we can see that the Client-Server architecture does - Internet Sharing / booster.
not scale well and MTD increase linear as the - Geo-Location Triangulation.
required no of clients increases. - Others applications which require data transfer
On the other hand, we can see that Peer-to-Peer within a network.
3. VIII. APPROACH resource has been acquired, the next time would
In order to meet the requirements for a network be establish a direct connection to the respective
that is scalable and lower on infrastructure cost, a nodes so that the actual resource acquisition can
Peer-to-Peer approach is adopted. The network begin.
communication architecture adopted for this Since Bluetooth™ on android devices has a range
framework is a Peer-to-Peer one based on a limit of up to 10 meters, unlike traditional Peer-to-
modified Gnutella Peer-to-Peer architecture. Due peer network design; a direct connection between
to the ease of implementation and also the ability any 2 devices in the network might not be
possible. Taking that into account, a little
to reach a wider open-source community, the
modifications to the traditional Peer-to-Peer
Open-Source Android Operating System for
network design have to made.
mobile devices is adopted as the platform for this After the information with regards to the nodes
framework implementation. Extra efforts were which contains the desired resources has been
also put in to the architecture design so that it obtained, nodes within a Bluetooth™ Peer-to-Peer
would not require a “Rooted” android device. By scatternet/piconet has to assist in routing data
doing so, the author hopes that it would be more packets between the 2 nodes.
appropriate for mass-market adoptions. Taking into the account of the framework design
objectives of supporting ah-hoc network creation
IX. NETWORK
DESIGN
and the hardware limitation of the Bluetooth™
communication protocol, the author favored a
modified version of the Gnutella Peer-to-Peer
design.
Fig 5: Data Packets Design
In order to implement a Gnutella Peer-to-Peer
network on a Bluetooth™ Scatter net, a 1024 byte
size data packet is used for data transmission
Fig 4: Bluetooth Scatter Net between devices on the network. The data packet
Bluetooth™ is a packet-based protocol with uses 60 bytes for header, leaving a dynamic data
Master-slave structure. A Master device can allow size of up to 964 bytes. Below is a break down of
up to 7 slave devices to connect to it forming a each field in the header.
piconet. When one or more piconets is bridge by Control Byte
one or more devices in their individual piconet, a The first byte of the data packet is used to
Scatter net is formed. Fig 4 shows a example of 2 differentiate between a normal data packet and a
piconets forming a Scatter net. control data packets. Control data packets are
A device in a Peer-to-Peer network usually currently used in the network for query flooding.
acquire it’s resource in 2 steps. First, it would They have higher priority as compared to normal
need to find out which are the nodes in the data packets.
network that contain the resource that it desires. Source address
Depending on the network architectural, this is This field contains the 17 characters hardware
achieved by either by doing a query with some MAC address of the Bluetooth™ device which the
form of index server(Central Indexing, DHT, packets originated from.
Hierarchical Overlay) or through Query Flooding Destination address
(Gnutella). After the required information with This field contains the 17 characters hardware
regards to the nodes which contain the desired MAC address of the Bluetooth™ device that the
4. packets target at. Due to resource limitations, the framework has
Hop Count been tested on the following phones only:
This 1 byte contains the no of time the data packet - HTC Magic
has jumped across nodes in the network. This is - HTC Device Z
necessary for Query Flooding technique to work - Samsung Galaxy S
in a Gnutella network. Current, the cap is 10 count - Nexus One
before the packet is no longer forwarded.
Packet Id XI. RESULT OF IMPLEMENTATION AND
EXPERIMENT
This is a 21 characters string generated by joining
the MAC address of the device which generate the An Open Source Peer-to-Peer framework focusing
packet with 4 characters string generated from the on Bluetooth Communication has been
system clock time. This allows repeated packets to implemented on Android O.S.
be recognized and discard at each nodes and thus It comprises of the following Key Features:
reducing unnecessary network traffic and also No Rooting Required
repeat data at the destination node. The 4 The framework does not required developer/users
characters string generated only repeats once to “root” their android phones in order to use its
every 10 seconds. features. It’s designed to work off the shelf and
Data Size integrates easily with other existing projects. It
This 2 bytes field contains the information leverage on the Android Interface Definition
regarding the size of the data field. This value can Language (AIDL) to provide a clean and easy to
varies from 1 to 964. integrate interface for developer to work with.
Sequence No Packet Routing
This is a 1-byte field that stores that Sequence No All devices connected to a network clusters double
of a packet. Since the path taken by each packets up as router for the network. Once a device has
to it’s destination might not be in order, this been connected successfully to a device within a
Sequence No will allow the destination node to network cluster, it can communicate directly with
rebuild the data in sequence. This value current any nodes in the network.
varies from 0 - 99. No need for a centralized indexing server
The framework implements a modified “Gnutella”
X. ASSUMPTION AND LIMITATION P2P network. This means that the network is
purely decentralized and does not require an
Due to the time constraints and also hardware indexing server. Through the use of Query
limitations, the framework currently only relies on Flooding techniques, similar to that found in
bluetooth for it’s Peer-to-Peer communications. classic “Gnutella” P2P network, a device would be
This in turn means that the framework is currently able to communicated with any node within the
limited by the hardware capability of the bluetooth network.
chipsets. At the time of this writing, majority of Flow Control
the android devices available in the market is still As every device double up as a router within the
using Bluetooth 2.1 + EDR, with some newer network, it is crucial that flow control is
devices supporting Bluetooth 3.0. At such, testing implemented at each node to ensure a fair usage
and performance benchmarking for this for each node. A “Fair weighted Queuing” Traffic
framework is currently done only on Bluetooth policer is currently implemented at each node to
2.1+EDR, however there should not be any ensure Quality of Service.
problem using the framework on Bluetooth 3.0 Auto-Connection
chipset. This is an experimental feature of the framework.
The framework should work with Android O.S Due to the security limitation of the Bluetooth™
2.0 and above and has been tested across Android framework on android, where a device cannot be
2.0/2.1(Eclair), Android 2.2(Froyo) and Android set to be “always discoverable”, there is no way
2.3(GingerBread for a device to detect a nearby device and
5. automatically setup an connection with it. To soon become a term of the past. All mobile
overcome this, an indexing server is implemented devices would soon have the computation power
to allow devices to query for nearby devices in of a laptop or desktop that we are using today. As
which they can connect to and form a network. the power of these devices increase, the demand
Using geo-location information coming from the for faster data connectivity and higher bandwidth
devices, the server would suggest a list of devices would definitely continue to increase at an
in which the device can connect to. Suggestion are exponential rate. At such there would be a need
made so that the Bluetooth™ Scatter net topology for us to reconsider the current network
is maintained. infrastructure design to allow for better scalability.
Open-Source
The prototype framework that was
This framework is currently developed as open
developed as part of this paper provided us a
source project. It’s source can be found at
platform to evaluate the feasibility of using Peer-
http://code.google.com/p/p2p-communication-
to-Peer communication between mobile devices as
framework-for-android/.
an alternative to traditional mobile communication
Found together with the framework is a multi-user
method.
Bluetooth™ Chat application that demonstrates
From the result of the implementation, namely
the Apis capabilities of the framework.
the success demonstrated in the multi-user chat
A Peer-to-Peer network multiplayer game based
application and also the multi-player game both
on the framework developed by the author
implemented using the Peer-to-Peer framework,
together with a good of android enthusiasts can
we can conclude that a Peer-to-Peer
also be found.
implementation more than exceed our expectation
Performance Metrics
as an alternative to support or even replace the
According to the experimental measurements
current mobile communication architecture. With
obtained from the transferring of multiple Image
the increasing adoption rate of the Android
files of 350 - 380 kbytes, we observed that the
platform and also its recognition for the potential
throughput rate stabilizes at around 54Kbits/s for
in Peer-to-Peer communication (revision 2.3.3),
nodes that are more than 1 jump away from the
we can concluded that the future for Peer-to-Peer
original node. The figure below shows the
communication on mobile devices is a bright one.
throughput rate obtained from readings measured
The author hope that the framework developed in
from these experiments.
this thesis would provide a start for more
innovation in this field.
324#565'789)6:8-6$'
+!"
ACKNOWLEDGMENT
*!"
)!"
The Author would like to express his heart-felt
(!"
gratitude to Associate Professor Tay Teng Tiow
'!" for his invaluable guidance and support through
!"#$%&%'
&!" the entire project. He would also like to thank the
%!" ECE department for the use of the facilities and
$!" the provision of android devices used for the
#!"
experiments. He would also express his gratitude
!"
!" !,'" #" #,'" $" $,'" %" %,'" &" &,'"
to my group of peers who had work with me and
()*')+',)-'$)'./%0120)1' developed the Peer-to-Peer Multiplayer Android
Game based the framework developed in the
thesis. Their inputs have allow him to stress test
XII. CONCLUSION and improve on the stability of the framework.
As the computation power of mobile devices
continue to increase and the cost of these devices
continue to falls, the term “Smartphone” would
6. Methodist University, Dallas, TX
[13] Always Best Connected, EVA
GUSTAFSSON AND ANNIKA JONSSON,
ERICSSON RESEARCH
REFERENCES [14] MobiClique: Middleware for Mobile Social
Networking, Anna-Kaisa Pietillainen(Thomson),
[1] 2.3.3, A. (2010). "Android 2.3.3." RetrievedEarl Oliver(University of waterloo), Jason
31 March, 2010, fromLeBrun(University of California, Davis), George
http://developer.android.com/sdk/android- Varghese(University of California, San Diego)
2.3.3.html. and Christophe Diot(Thomson)
[2] IMT-2000 (2000).
[3] Microsystem, S. (2009). "Distributed
Application Architecture." Retrieved 06-16,
2009, from
http://java.sun.com/developer/Books/jdbc/ch0
7.pdf.
[4] Nielsen (2011). "US Smartphone Penetration
and forecast 2011."
[5] Nusca, A. (2009). "Smartphone Vs feature
phone arms race heats up; which did you
buy?", from
http://www.zdnet.com/blog/gadgetreviews/sm
artphone-vs-feature-phone-arms-race-heats-
up-which-did-you-buy/6836.
[6] Scholmeier, R. (2002). A definition of Peer-
to-Peer Networking for the Classificiation of
Peer-to-Peer Architectures and Applications,
Proceedings of the First International
Conference on Peer-to-Peer Computing.
IEEE.
[7] Wikipedia. "3G." Retrieved 31 march, 2010,
from http://en.wikipedia.org/wiki/3G.
[8] Wikipedia. "Bluetooth." Retrieved 31
March, 2010, from
http://en.wikipedia.org/wiki/Bluetooth#cite_n
ote-0.
[9] Wikipedia. "IEEE 802.11." Retrieved 31
March, 2010, from
http://en.wikipedia.org/wiki/IEEE_802.11#cit
e_note-80211timeline-6.
[10] Broadcast-Based Peer-to-Peer Collaborative
Video Streaming Among Mobiles, Man-Fung
Leung and S-H Gary Chan
[11] Integrating Bluetooth with Wireless and
Ricocheting, David J.Y Lee and William
C.Y.Lee
[12] Dynamic Topology Management in Bluetooth
Networks, Suresh Srinivasan, Keyur Desai,
Akash Tilak Choudhari, Dinesh Rajan, South