A social network based on android phones

116 156 0
A social network based on android phones

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

A SOCIAL NETWORK BASED ON ANDROID PHONES A Doctoral Dissertation Submitted to The School of Engineering In Partial Fulfillment for the Degree of Doctor of Computer Engineering By Tuan Viet Le Prepared Under the Direction of Dr Glen Qin School of Engineering Northwestern Polytechnic University 47671 Westinghouse Dr., Fremont, CA 94539 August 2012 ii iii ACKNOWLEDGMENTS I owe my deepest gratitude to my advisor, Dr Glen Qin He gave many valuable counsels, and encouraged and guided me through these years In addition, I offer my sincerest thanks to my committee members, Dr Henry Chang and Dr David Li, for their time and advice Lastly, I offer my regards and blessing to my parents, for their understanding and gracious support iv ABSTRACT With the improvement of the smartphone CPU, the smartphone is as powerful as a computer In other words, smartphones can run many applications that a computer does Therefore, in recent years, people have changed their habit of using computers and started using smartphones to access the Internet This trend has created a new direction in the software industry Software companies have built many mobile phone applications These applications are preferred to be implemented on the Android platform because of its availability, scalability, and convenience The social network is a new trend of communication There are more and more people joining and sharing their information on social networks With smartphones, people can maintain their relationship with high convenience In order to reduce the communication cost of phones, sharing information between phones using Peer-to-Peer networks is recommended This project applies a Peer-to-Peer network model to share a file between Android smartphones The file sharing could be any type of format Furthermore, users also share the information in the database, such as a personal profile, contact list, current position, etc If the contact information is inconsistent among the users, the application will automatically synchronize the contact information based on the time stamps of the contact, assuming the most recent information is correct, or let the users decide which version is the correct information This application is an important step in building a fully functional social network based on Android mobile phones v CONTENTS Section Page ACKNOWLEDGMENTS iv  ABSTRACT v  CHAPTER ONE: INTRODUCTION 1  1.1 The Concept 1  1.2 Motivation 2  1.3 Objectives 3  1.4 Requirements 3  1.5 Contributions 4  1.6 Background 4  1.6.1 Smartphone Definition 4  1.6.2 Smartphone Operating System (OS) 4  1.6.3 Firewall 12  1.6.4 Network Address Translation (NAT) 14  1.6.5 Unicast, Broadcast, Multicast 18  1.6.6 Social Network 18  1.6.7 Mobile Social Networking 18  CHAPTER TWO: LITERATURE REVIEW 22  2.1 P2P Overview 22  2.1.1 Architecture of P2P 22  2.1.2 P2P Characteristics 23  vi 2.1.3 Types of P2P 24  2.1.4 Popular P2P Application 26  2.2 Peer-to-Peer Communication 27  2.2.1 P2P Discovery 27  2.2.2 The Peer-to-Peer Software Structure 32  2.2.3 P2P File-sharing 33  2.2.4 The Risk of P2P File Sharing 34  2.2.5 The Issue of Direct Communication 34  2.2.6 Communication between Peers over Firewall/NAT 34  2.3 Peer-to Peer Protocols 39  2.3.1 SIP 40  2.3.4 Juxtapose (JXTA) 49  CHAPTER THREE: RESEARCH DESIGN 50  3.1 Research Design 50  3.2 Why Android Platform 50  3.3 Hardware and Software Consideration 51  3.4 Protocol Used 52  3.5 Application Development Process 52  CHAPTER FOUR: IMPLEMENTATION AND RESULTS 66  4.1 Application Implementation 67  4.1.1 Node ID 67  vii 4.1.2 Network Implementation 68  4.1.3 Database Implementation 73  4.1.4 Data Exchange Implementation 79  4.1.5 Message Chatting Implementation 86  4.1.6 File Exchange Implementation 88  4.2 Results 96  CHAPTER FIVE: SUMMARY AND FUTURE WORK 98  5.1 Summary 98  5.2 Future Work 101  BIBLIOGRAPHY 103  viii LIST OF ILLUSTRATIONS Figure Page Figure 1-1: Architecture of the Symbian Platform .5 Figure 1-2: iOS Architecture Figure 1-3: Major Components of the Android Operation System .10 Figure 1-4: Network Topology Using a Firewall 14 Figure 1-5: Network Topology Using Network Address Translation 16 Figure 2-1: Server-Based Network and Decentralized Network 23 Figure 2-2: Pure P2P, Centralized Peer-to-Peer and Hybrid P2P System .26 Figure 2-3: Peer Discovery Using the Passive Method 28 Figure 2-4: Peers Using the Direct Discovery Technique .29 Figure 2-5: Indirect Discovery via a Rendezvous Peer 30 Figure 2-6: Discovery Propagation Chaos .31 Figure 2-7: Using TTL to Avoid Loopbacks 32 Figure 2-8: Message Traversing a Firewall/NAT 36 Figure 2-9: Message Traversing Two Firewalls/NATs 37 Figure 2-10: STUN Protocol 39 Figure 2-11: Mobility Register 41 Figure 2-12: Registrar Process .42 Figure 2-13: Session Establish .43 Figure 2-14: SIP Server 44 ix Figure 2-15: Message Transfers over Two Domains .46 Figure 2-16: Message Proxy with Record Routing 47 Figure 2-17: Redirect Server 48 Figure 3-1: Android OS Using Virtual Machine 53 Figure 3-2: Setting IP Address for Testing .54 Figure 3-3: Setup Android OS in VM 55 Figure 3-4: Start Android OS 56 Figure 3-5: Non GUI of Android OS .56 Figure 3-6: Connecting Two Android phones (VM) .56 Figure 3-7: Mobile Testing on a Wireless Network 57 Figure 3-8 NPU Android Project Architecture, the Hybrid Network 58 Figure 3-9: Entity Relationship Diagram .61 Figure 3-10: Add 54 Bytes at the Beginning of the Data File .64 Figure 3-11: File Receiving Process 65 Figure 4-1: Calculating Broadcast Address 69 Figure 4-2: Application Starts and Gets IP Address 71 Figure 4-3: Get Data Cache of Bootstrap 73 Figure 4-4: Edit a User Profile .76 Figure 4-5: Default Group Name and Custom Group Name 78 Figure 4-6: Import Data from NPU Project Database to Android Contact Database 79 Figure 4-7: Add New Profile 80 x File file = files[i]; if (file.isDirectory()) { // a directory then content name, path file_folder_name = file.getName() + "/"; is_file = "folder"; filepath = file.getPath(); FolderInfo folder = new FolderInfo(file_folder_name, filepath,is_file); list.add(folder); } else {// file_folder_name = file.getName(); filepath = file.getPath(); FileUtility fu = new FileUtility(filepath); filesize_lastmodify = fu.getFileSize() + ", " + fu.getLastModified(); is_file = "file"; FolderInfo folder = new FolderInfo(file_folder_name, filepath,is_file, filesize_lastmodify); list.add(folder); } } 90 Display by ListView this.adapter = new ListViewFolderAdapter(this,android.R.layout.simple_list_item_1, list); adapter.notifyDataSetChanged();// refresh listview ltvDisplay.setAdapter(adapter); ltvDisplay.invalidateViews(); Each file (or folder) is managed with five attributes, including: name, type, size, path, and last modified While using copy or move operations, if the file has existed at the same directory, the application will automatically change the name by adding one unit at the end of the file For example, file AAA.txt exists in folder BBB; if the user copies and pastes file AAA.txt to the same folder, the new file is automatically renamed AAA(+1).txt If the user does this action again, the new file is renamed AAA(+2).txt, and so on This function is very useful for tracking the file during file transfer back and forth between phones Option to rename a file The application will auto bold old file names (without extension) for reducing manipulation Thus, the user only needs to type the new name If the new file name exists in the current directory, there is no action for this file Otherwise, the file name will change Notice that the user should not move a file to the root directory because of Android security 91 Figure 4-19 Auto Highlight of Old File Name In order to use external storage such as SDCard, the user needs to accept WRITE_EXTERNAL_STORAGE permission Figure 4-20 File Management 92 • File exchange The application uses UDP protocol (Port number: 5556) for exchanging short messages, but it uses TCP protocol (port number: 5557) for exchanging files between phones In order to be ready to receive a file, each phone needs to check on the check box “allow receive file” This check box will uncheck whenever the user does not want any phone to keep sending messages (spamming) The application also uses a multithreading technique for sending multiple files The receiving file is stored in the SDCard In case a new file name exists in the SDCard already, the application will automatically rename the file by adding (+1) at the end of the file name Before sending a file, the sender reads the file in byte array and adds 38 bytes (at version2: use 54 bytes), which contains the file name, file type, and file size at the beginning At the receiver side, the first 38 bytes is extracted in order to control the progress bar as well as create a temporary file After receiving the file, the application renames the temporary file if necessary, with a hidden progress bar and makes an alert The following shows the implementation of extracting 38 bytes and renaming the file if the name exists InputStream is = client.getInputStream(); byte[] bfilename = new byte[30]; byte[] bfilelength = new byte[8]; is.read(bfilename, 0, bfilename.length); String get30;get30 = new String(bfilename); //file name filelength = Convert.bytearray2long(bfilelength); stream(is, bos);// get the rest of file byte into bos 93 Rename the file if name already exists String filepathnew = "/sdcard/" + get30; //"sdcard/abc.txt" int dotposition = get30.lastIndexOf("."); String filenamewithout_ext = get30.substring(0, dotposition); String ext = get30.substring(dotposition, get30.length()); File myFile1 = new File(filepathnew); int i = 0; while (myFile1.exists()) { i++; filepathnew = "/sdcard/" + filenamewithout_ext + "("+i+")"+ ext; myFile1 = new File(filepathnew); } if (myFile.exists()) { myFile.renameTo(myFile1); } There is an alert dialog to let the user open the file after the receiving process Similar to other operating systems, Android OS supports reading some basic file types, such as html, txt, mp3, jpeg For reading a special file type such as pdf, or epub, Android needs to set up third-party applications 94 Figure 4-21 Sending/Receiving Files between Phones In order to save the screen space for chatting, the progress bar only appears during sending or receiving the file process It will disappear after seconds after the exchanging file process is finished The example code explains it in more detail 95 if(percentsend ==100){ PeerActivity.handler.postDelayed((new Runnable() { public void run() { invisible_progressbar_percenttext(pgbSendMyInstanceMsg, txtPercentSendMyInstanceMsg);} }),5000); } 4.2 Results This research is for an application running on an Android phone The application helps these Android phones communicate directly A broadcast message is used when a peer wants to discover all currently peers inside a local network Also, the application allows users to get IP addresses of other peers by setting up a bootstrap IP address The bootstrap peer will send the list of IP addresses (which it knows) to the new peer The application allows creating a database and sample form in order to save the user profile The user profile includes basic information, such as name, phone number, email address, post address, group, etc Furthermore, it also validates each data field when inputting information as well as inserting into it into the database For instance, there is an alert when a phone number field is blank or an email address field is required to be entered again until it is in the correct format There are many options for manipulating profile rows The user can insert, update, delete profile, or classify into pre-defined group names or custom group names Moreover, the application allows importing an application database into the Android contact database, which is built in the Android operating system Using this database, furthermore, the user can invite other phones to get its contact information or request the contact information of all users within the group 96 Similar to applications running on personal computers, such as Yahoo Messenger, or MSN, the application allows message chatting between Android phones Users can send messages directly without using a server The user and IP address will be filled automatically into a spinner (dropbox) after the discovery process By default, the first IP address in the IP address list of each phone will be chosen for chatting The message chatting displays name, IP address, and receiving time The chat content is erased when the user chats with another user In addition, the application also provides a tool for file browsing within a phone The default path when starting an activity is /root A list view is used for displaying folders and files of the current directory While the folder appears with its name and absolute path, the file has a file size, file name with extension, and last modified time If the current path is not /root, the listview displays the parent directory, subdirectories, as well as all files The user can handle the file, such as copy, move, delete or rename with an administrator role One of the highlights of this application function is file exchange between phones Users can send a file with any format while chatting For receiving a file, the user needs to enable the allow-receive-file checkbox The incoming file is saved at /mnt/SDCard directory Whenever a duplicate name happens, the application will automatically rename it and send an alert to the user Moreover, the application also provides a progress bar to help the user monitor the exchange file process 97 CHAPTER FIVE: SUMMARY AND FUTURE WORK The research goal is to provide a tool for mobile phones social network on peer-to-peer topology It includes the process of joining new clients, discovery of clients, and communication between clients under firewalls The research focuses on communication between Android phones on a P2P network Based upon the research, an application is implemented in order for users to build up and maintain their social network on Android phones At the end of this research, the author implemented an application for demonstrating these concepts The application uses an SIP protocol and runs on Android phones, which provide many features for using mobile phone social networks In the first version, the application allows for chatting, file exchange, and sharing database contacts, which are used for maintaining group relationships 5.1 Summary In Peer-to-Peer topology, each client is considered a “peer” and each sharing file is called a “seed’ The peer is determined by a unique identifier There are many methods for a peer to discover other peers within network The easiest method sends a broadcast message to all peers The peer discovers the network based on the message response from others This method is only used with a local area network In order to discover peers in WAN, each peer needs to register its profile at a rendezvous of peers The rendezvous peer could be a server The rendezvous peer can forward messages between simple peers or just provide the current address of destination peers Depending on the service provider, the rendezvous has a different name, for example, the rendezvous is called proxy server when it forwards messages between peers It is also called redirect server when it provides the current address of destination peers In reality, each peer could belong to a private network The message exchange between peers could be blocked by firewalls of each domain In order to solve this problem, STUN and TURN protocols are recommended because of their simplicity and integration with the SIP protocol 98 STUN is a protocol to help the peer inside network get a public address, port number, and learn NAT devices automatically Although STUN has an advantage in that is doesn’t require any changes on NAT devices, it does not work with symmetric NAT Thus, it is not commonly used in enterprises TURN is introduced to overcome this limitation TURN allows devices behind a NAT to receive incoming data through a TURN server However, this protocol has many disadvantages, such as bandwidth costs and increased latency This research area focuses on the method of P2P network discovery Based upon the research, an application was implemented to prove the concept This application can be deployed on a mobile social network on Peer-to-Peer topology The application allows for discovery of all current Android phone addresses within a local network area It can calculate the broadcast address and send a ping message to this address Once a phone receives a ping broadcast message, it sends the ACK message back to the initiate phone By doing this, the new joining phone not only gets the IP address of other phones, but also gets the phone names of them After getting names and IP addresses, the application provides two others types of distribution, such as unicast and multicast By using a multithreading technique, the user can send a multicast message in order to request the current IP address phone list from many phones at the same time The peer, which contains the IP address phone list, is called the bootstrap peer Thus, a bootstrap peer could be a simple phone or a server A discovery phone within LAN has a contributing function of this application, which does not exist on many applications in the Android Store However, the discovery function of this application does not work properly in WAN topology Therefore, it is necessary to build a server (or also call bootstrap) which provides IP addresses of all phones joining the network One useful application function is that the user can get, share, and update profiles with each other with a single button click, instead of exchanging too many business cards in a first meeting For instance, a new employee can get names, phone numbers, emails and other information of all employees within the marketing department even though he/she knows only one person in this department After discovering other phones within the network, the user can create and save the 99 profile into the application database The information of one user might change after several months Therefore, the data contact of these phones could be different In order to solve this issue, the application has detected and has alerted a data confliction once the data contact is synchronized The current version does a great job in data conflict solving, but it does not provide a tool for defining different policies between groups For instance, one user just wants to share names, emails, and phones number to all members in friend group, but the user wants to share names, phone numbers and post addresses to a family group The message chatting part works perfectly by supporting detailed information, such as name, current IP address, and timestamp of sending However, this is for single chatting The next application version will add functions for group chatting and video calling Additionally, the file control function is very convenient for users The user can handle the file with an administrator role This means the user can access and modify these files at sensitive directories such as /root, /dev, /lib, /system, /sys, or /mnt It is implied that the user can uninstall any application, even though these applications are built in the Android OS Compared with the “OI File Manager” application, which reached 1,000,000 downloads, the browse file function of this project is more advantageous than the IO File Manager For instance, the IO File Manager often crashes or has a late response to big file reading operations (file size bigger than 30 MB) The trick is the application reads these bytes into a buffer when the user chooses the file operation options While the application uses the UDP protocol for message exchange, it use the TCP protocol for sending a file in order to be more reliable because the sender will put the file information into 54 bytes at the head file content Thus, the receiver side can use this information for validating the pre-conditions before continuing with the rest of the bytes For example, the condition accepts any file size less than 30 MB The receiver will deny the file size bigger than 30 MB The current application version accepts all types of files However, it is possible to set the constraints for receiving a file based on this design Compared with “Wi-Fi File Transfer”, the application has 100 many advantages, such as discovery of peers, and allowing chatting during sending/receiving files Although the application has many advantages, it still has limitations The IP address of each peer changes very often Therefore, servers need to be able to update IP addresses as well as support negotiating the communication between peers which are behind the NAT 5.2 Future Work In recent years, the number of smartphone users has increased dramatically This trend requires a huge number of applications for mobile phones However, while there are numerous security applications as well as data strategy protection on personal computers, there are few applications to protect mobile phones from viruses or malware The survey of IT professional (www.checkpoint.com) on January, 2012 shows that “65% allow personal devices to connect to corporate networks” and “the Android mobile platform is considered to introduce the greatest security risks” Because of these reasons, the need for mobile phone security applications on P2P networks is more urgent than ever This research can lead to further development in network security In a peer-to-peer network, two peers can communicate directly Therefore, authentication is the first consideration issue One peer needs to authenticate the other before sending a file or any other transaction In fact, people can use two strategies for authentication First, these peers can have a pre-shared key Second, these peers can have a trusted third party Choosing the strategy depends on the available resources and application type Another important issue of network security is data integrity and data confidentiality Data integrity is the protection of transmitted data from active attacks, such as modification of a message or replay Confidentiality is the protection of transmitted data from passive attacks, such as traffic analysis or release of message content The current version of this application does not 101 contain security parts Encrypting messages and file content with AES before sending between peers is considered a new function to be added in the next project version 102 BIBLIOGRAPHY Dehora, Bill, Jabber and JXTA, 2003 http://dehora.net/journal2003/07 Guezouri, Mustapha, Ahmed Blaha and Mokhtar Keche, Adaptation of TURN protocol to SIP protocol , 2010 Jantunen, Alex, Sami Peltotalo, Jani Peltotalo, Peer-to-Peer Analysis, Tampere University of Technology, 2006 Johnston, Alan B., Understanding the session initiation Protocol, 2009 Mallick, Martyn, Mobile And Wireless Design Essentials Wiley Publishing, 2003 Liang, J., R Kumar, and K.W Ross, “The KaZaA Overlay: A Measurement Study”, September 15 2004 http://cis.poly.edu/~ross/papers/KazaaOverlay.pdf Liang, J., R Kumar, Y.Xi and K.W Ross, “Pollution in P2P File Sharing Systems” Retrieved from http://cis.poly.edu/~ross/papers/pollution.pdf (17.2.2006) Lua, E K., J Crowcroft, M Pias, R Sharma and S Lim, “A Survey and Comparison of Peer-toPeer Overlay Network Schemes”, IEEE Communications Survey and Tutorial, March 2004 http://www.cl.cam.ac.uk/Teaching/2004/AdvSysTop/ieee-P2P-survey.pdf Niyomthum, Kobchai, File Sharing using Peer to peer technologies, Northwestern Polytechnic University, 2011 Reto, M Professional Android Application Development Indianapolis, Indiana: Wiley Publishing, 2010 Rosenberg, J., Understanding Peer-to-Peer, 103 www.cachelogic.com/p2p/p2punderstanding.php June 2002 Sugiharto, Hendika, Current and Future Mobile Platforms, Berlin Institute of Technology, Germany, 2010 Taha, Hadeel H., Architecture for a SIP-Based Conferencing Server, 2004, T-Systems Nova GmbH Technology Center Traversat, B., The Project JXTA Virtual Network, 2003 www.jxta.org/docs/JXTAprotocols Bittorrent (2009) Bittorent Protocol http://en.wikipedia.org/wiki/BitTorrent_%28protocol%29 Friend of a Friend (FOAF) Project.http://www.foaf-project.org/ Gnutella Developer Forum (2004) Gnutella http://groups.yahoo.com/group/the_gdf/ hCard 1.0 http://microformats.org/wiki/hcard O-exchange, http://www.oexchange.org/ SIP: Session Initiation Protocol”, http://www.ietf.org/rfc/rfc3261.txt White Paper on Mobile Social Network Work Item Investigation - Open Mobile Alliance (May 2011) Wikipedia (2011) Social Network Wikipedia Retrieved March 23, 2011 104 [...]... digital assistant (PDA) A mobile phone has two main functions: make a phone call and text message A PDA has functions similar to a personal computer The combination of mobile phone and PDA create a smartphone that has mobile capacity as well as computer power A modern smartphone, nowadays, has added many types of sensors, such as a camera and Global Positioning System (GPS) These additional features... Major Components of the Android Operation System • Application framework layer: The application framework is a framework used to make a standard structure of an application for a specific operating system The Android Application framework contains some important components, such as Content Providers, Resource Manager, Notification Manager, Activity Manager, Windows Manager, View System, Package Manager,... buttons, text boxes and so on in order to handle event dispatching, layouts and drawing Seventh, the Package Manager maintains information on the available applications on the device Eighth, for the Telephony Manager, APIs are needed to build the phone application and SMS Last, the Location Manager manages the position by GPS or cell tower and Wi-Fi signals • The libraries layer Although Android applications... Middleware Layer, OS Layer, Adaptation Layer, and Cellular Platform Figure 1-1 Architecture of the Symbian Platform The Applications Layer includes application-specific user interface and engine components, such as the organizer application suite, multimedia applications, telephony, and applications for controlling device settings It is separated into two types of applications, normal application and... Telephony Manager, and Location Manager First, Content Providers control the sharing of data from other applications In addition, Content Providers are also used for reading and writing private data Second, a Resource Manager helps to manage the storing of strings and layout files and bitmaps Third, the Notification Manager enables one to tell something that has happened in the background, for example, alerts... after the gateway validates the user ID and authentication information, it contacts the application on the remote host Fourth, the gateway relays TCP segments containing the application data between the two endpoints This type of firewall has both advantages and disadvantages It is not only securer than the packet filter type, but it is also easy to log and audit all incoming traffic at the application... File System Aaccess, Standard I/O, Bonjour and DNS Services, Locale Information Memory Allocation, and Math Computation The second layer is the Core Service This layer provides service for applications use and frameworks use The frameworks contain the Core Foundation framework, CFNetwork framework, and Security framework The Core Foundation framework manages Collection data types, Application Bundle... This set of system programs can be cataloged into four different layers • Application layer: The Application layer is a set of core applications, such as browser, email client, SMS program, maps, calendar, contacts, and others All these applications are written by Java programming language Android has been supported in order for these applications to run simultaneously That means it is possible to listen... phones on a hybrid peerto-peer network architecture The outcome of this research is an application which can be used for exchanging and synchronizing contact information, sharing files on Android phones, and exchanging short messages using a platform 1.6 Background 1.6.1 Smartphone Definition The smartphone is a mobile device which has the combined ability of a mobile phone and ability of a personal... Google social search, Social Mention, Wink, WhosTalkin.com, Sightix, and yoName • Data Portability Currently, no popular social networking has supported data portability Data portability is reregistering user information such as user profile and contact list When a new social network is coming, the user could import its data in order to reuse previous contents, social graphs, or have similar authorization

Ngày đăng: 14/05/2016, 09:24

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan