Your SlideShare is downloading. ×
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply



Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Peer-to-Peer Communication Framework on Android Platform Liu Tianwei, National University of Singapore, Electrical and Computer EngineeringAbstract— With Smartphone penetration reaching investment, network outrages are common for37%(Nelson,2011) worldwide and predicted to reach smartphone users and thus in many ways limiting55% by the year 2014, the availability of powerful mobiledevices in the pocket of every consumer is fast becoming the capabilities of these devices.a nom. However, the capabilities of these devices areoften limited by data network in which they have access III. MOTIVATIONto, which are often old and are not designed to support At such there is a need to redesign the currentthe huge no of increasingly data hungry mobile devices.This paper aims to explore the alternatives to traditional network architectures to allow for greater networknetwork architecture focusing mainly on the P2P scalability and more importantly a lowernetwork 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 thewidely popular open-source framework for mobile device- Android. The framework allows developers to easilyleverage on in-built hardware communication capability IV. OBJECTIVESof these devices(3G/Wifi/Bluetooth) without having to The objectives of the projects are therefore todeal 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 aIpenetration 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 the2011(Nielsen 2011). A Smartphone, is defined V. SERVER-CLIENT VS PEER-TO-PEERhere 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 typicalhigh growth rate of these devices brings about network operation: File Distributionmany opportunities for entrepreneurs anddeveloper to leverage on the extra computing andcommunication power of these devices. However,the high growth rate of these data hungry devicesis not without it problems. II. PROBLEM The suddenly increase in the demand for mobiledata bandwidth brought by these devices took Fig 1many mobile network providers by surprise. Manyof these network providers relies heavily on Objective:traditional network architectures that are not - Distribute a large file from a single server todesigned to handles these kinds of traffics a large N number of host(peers). As shown in therequirements. 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 APPROACHFor a typical server client architecture, the serverwould need to send N copies of the file. In conclusion, we can see that a Peer-to-PeerThe slowest client takes at least F/dmin time to architecture design has significant advantage indownload the given file. terms of scalability and cost as compared to aGiven a network as depicted in Fig1, Eq(1) show traditional client-server architecture design. Thisthe total time required for the server to complete suits our requirement for a new architecturethe task of distributing all the files. design. At such, the proposed framework wouldPeer-to-Peer: be based on a Peer-to-Peer that allows developersFor 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/usThe slowest client would take at least F/dmin to VII. USE CASESdownload the given file.The total number of bits that must be downloadedwould be NF bits, but the total upload capacity isnow .This would means that the minimum time takenfor the task of distributing the files would be: -- Eq(2)Therefore, the total time taken for the task ofdistributing 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 respectivethat is scalable and lower on infrastructure cost, a nodes so that the actual resource acquisition canPeer-to-Peer approach is adopted. The network begin.communication architecture adopted for this Since Bluetooth™ on android devices has a rangeframework 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 betweento the ease of implementation and also the ability any 2 devices in the network might not be possible. Taking that into account, a littleto reach a wider open-source community, the modifications to the traditional Peer-to-PeerOpen-Source Android Operating System for network design have to devices is adopted as the platform for this After the information with regards to the nodesframework implementation. Extra efforts were which contains the desired resources has beenalso put in to the architecture design so that it obtained, nodes within a Bluetooth™ Peer-to-Peerwould not require a “Rooted” android device. By scatternet/piconet has to assist in routing datadoing 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 packetBluetooth™ is a packet-based protocol with uses 60 bytes for header, leaving a dynamic dataMaster-slave structure. A Master device can allow size of up to 964 bytes. Below is a break down ofup 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 Byteone or more devices in their individual piconet, a The first byte of the data packet is used toScatter net is formed. Fig 4 shows a example of 2 differentiate between a normal data packet and apiconets forming a Scatter net. control data packets. Control data packets areA 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 normalneed to find out which are the nodes in the data that contain the resource that it desires. Source addressDepending on the network architectural, this is This field contains the 17 characters hardwareachieved by either by doing a query with some MAC address of the Bluetooth™ device which theform 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 hardwareregards 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 hasHop Count been tested on the following phones only:This 1 byte contains the no of time the data packet - HTC Magichas jumped across nodes in the network. This is - HTC Device Znecessary for Query Flooding technique to work - Samsung Galaxy Sin a Gnutella network. Current, the cap is 10 count - Nexus Onebefore the packet is no longer forwarded.Packet Id XI. RESULT OF IMPLEMENTATION AND EXPERIMENTThis is a 21 characters string generated by joiningthe MAC address of the device which generate the An Open Source Peer-to-Peer framework focusingpacket with 4 characters string generated from the on Bluetooth Communication has beensystem clock time. This allows repeated packets to implemented on Android recognized and discard at each nodes and thus It comprises of the following Key Features:reducing unnecessary network traffic and also No Rooting Requiredrepeat data at the destination node. The 4 The framework does not required developer/userscharacters string generated only repeats once to “root” their android phones in order to use itsevery 10 seconds. features. It’s designed to work off the shelf andData Size integrates easily with other existing projects. ItThis 2 bytes field contains the information leverage on the Android Interface Definitionregarding the size of the data field. This value can Language (AIDL) to provide a clean and easy tovaries from 1 to 964. integrate interface for developer to work with.Sequence No Packet RoutingThis is a 1-byte field that stores that Sequence No All devices connected to a network clusters doubleof a packet. Since the path taken by each packets up as router for the network. Once a device hasto it’s destination might not be in order, this been connected successfully to a device within aSequence No will allow the destination node to network cluster, it can communicate directly withrebuild 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 anDue to the time constraints and also hardware indexing server. Through the use of Querylimitations, the framework currently only relies on Flooding techniques, similar to that found inbluetooth for it’s Peer-to-Peer communications. classic “Gnutella” P2P network, a device would beThis in turn means that the framework is currently able to communicated with any node within thelimited by the hardware capability of the bluetooth network.chipsets. At the time of this writing, majority of Flow Controlthe android devices available in the market is still As every device double up as a router within theusing Bluetooth 2.1 + EDR, with some newer network, it is crucial that flow control isdevices supporting Bluetooth 3.0. At such, testing implemented at each node to ensure a fair usageand performance benchmarking for this for each node. A “Fair weighted Queuing” Trafficframework is currently done only on Bluetooth policer is currently implemented at each node to2.1+EDR, however there should not be any ensure Quality of Service.problem using the framework on Bluetooth 3.0 Auto-Connectionchipset. 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 be2.0/2.1(Eclair), Android 2.2(Froyo) and Android set to be “always discoverable”, there is no way2.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 mobileovercome this, an indexing server is implemented devices would soon have the computation powerto allow devices to query for nearby devices in of a laptop or desktop that we are using today. Aswhich they can connect to and form a network. the power of these devices increase, the demandUsing geo-location information coming from the for faster data connectivity and higher bandwidthdevices, the server would suggest a list of devices would definitely continue to increase at anin which the device can connect to. Suggestion are exponential rate. At such there would be a needmade so that the Bluetooth™ Scatter net topology for us to reconsider the current networkis maintained. infrastructure design to allow for better scalability.Open-Source The prototype framework that wasThis framework is currently developed as open developed as part of this paper provided us asource project. It’s source can be found at platform to evaluate the feasibility of using Peer- to-Peer communication between mobile devices asframework-for-android/. an alternative to traditional mobile communicationFound together with the framework is a multi-user method.Bluetooth™ Chat application that demonstrates From the result of the implementation, namelythe Apis capabilities of the framework. the success demonstrated in the multi-user chatA Peer-to-Peer network multiplayer game based application and also the multi-player game bothon 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-Peeralso be found. implementation more than exceed our expectationPerformance Metrics as an alternative to support or even replace theAccording to the experimental measurements current mobile communication architecture. Withobtained from the transferring of multiple Image the increasing adoption rate of the Androidfiles of 350 - 380 kbytes, we observed that the platform and also its recognition for the potentialthroughput 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-Peeroriginal 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 infrom these experiments. this thesis would provide a start for more innovation in this field. 324#565789)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 devicescontinue to increase and the cost of these devicescontinue 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 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 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 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[8] Wikipedia. "Bluetooth." Retrieved 31 March, 2010, from ote-0.[9] Wikipedia. "IEEE 802.11." Retrieved 31 March, 2010, from 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