cknowledgements First, I would like give my sincere thank to my instructor, Dr. Dai Tho Nguyen, Department of Networks and Computer Communications - who has give me guidance and support during the time I work on this thesis. Next, I would like to thank the University of Technology and Engineering - Hanoi National University, the school that has given me a perfect environment to study and train myself for four years. Finally, thanks to my family and friends who have always supported and encouraged me a lot throughout my student life. They were, are, and will be the endless source of encouragement, ambition of my life. Ha Noi, June 2010 Khanh Toan Do INTRODUCTION MANETs and P2P file sharing systems are two areas that have long been studied based on a same principle: P2P paradigm. This paradigm aims to build the services of large-scale distributed systems without any infrastructure. In this model, users have an equal role. Global services are guaranteed thanks to the collaboration of users with each other. For wireless ad hoc networks, the network is a collection of wireless nodes without any central control or any base station. The network node acts as both router and host. Multi-hop routing method is used to ensure connectivity between nodes. For P2P file sharing applications, peers work together to share data and multimedia content. Each participating node will share a portion of its upload capacity to serve other nodes. The global productivity of the system increases exponentially with the number of nodes involved. Gnutella, Freenet, and BitTorrent are examples of P2P file sharing applications on the Internet. Both the file-sharing applications and ad hoc networks are all long been studied. They have been studied very much, but are independent of each other. Only very few studies try to find out if they work well together. These studies only focus on finding contents in MANETs without attention to the efficiency of content sharing. Studying the performances of file-sharing applications on mobile ad hoc networks is really challenging because of wireless channels’ diverse constraints. In fact, when the peers play a role of both routers and end users, then the routing overhead must be considered. Moreover, the performance of the transport layer protocol such as TCP decreases markedly when multi-hop paths are used. That is why file-sharing applications are not expected to work well when deployed on mobile ad hoc networks. Designing an efficient solution for the file sharing problem in wireless ad hoc networks is an important part of our study. In this work, we try to develop a file sharing application for wireless ad hoc networks. My aim is to come up with solutions that reduce the content download time while at the same time improving the distribution ratio in the network by enforcing fair sharing among peers. As efficient and fair content sharing is targeted, we choose BitTorrent given its large usage. We are interested in two main parts of the BitTorrent protocol, which are node discovering and downloading mechanisms. 1 The main framework of our study is based on [8], but the solution proposed in this paper still contains some problems with its node discovery mechanism: - - Cannot detect if a node has left the network or not. Node discovery mechanism need too much time. Because of these limitations, we replace the old presence detection method with another one introduced in [3]. The performances of our approach are proven through the ns-2 simulator to be better than the one in [8]. The remaining of this thesis is divided into 4 chapters: Chapter 1: P2P networks We present an overview of P2P networks, their architecture, benefits and disadvantages. Chapter 2: BitTorrent file sharing system This chapter describes about BitTorrent protocol and its installation over wired networks and mobile ad hoc networks Chapter 3: An improvement in BitTorrent on MANETs Here is the main part of this thesis, which offers an innovative solution to BitTorrent over MANETs. Chapter 4: Simulation results The last chapter shows the results of our simulation, in order to check the correctness arguments made above. Conclusion and perspectives In this section, we draw a summary of our work and some plans to do in the future. TABLE OF CONTENTS INTRODUCTION 1 CHAPTER 1: PEER TO PEER NETWORKS .3 1.1 Overview .3 1.2 Definitions . 3 1.3 Comparison with client/server architecture 4 1.4 Benefits and weaknesses of P2P networks .5 1.5 Classifying P2P networks .6 1.5.1 Pure P2P networks 6 1.5.2 Hybrid P2P networks 7 CHAPTER 2: BITTORRENT FILE SHARING SYSTEM .10 2.1 Overview .10 2.2 Benefits of the BitTorrent protocol 11 2.3 Limitations 13 2.4 Comparison with other file sharing protocols 13 2.5 Original BitTorrent for wired networks 14 2.5.1 Description .14 2.5.2 Operation .15 2.5.3 Creating and publishing torrents .16 2.5.4 Downloading torrents and sharing files . .17 2.6 BitTorrent variant for wireless ad hoc networks 18 2.6.1 Trackerless BitTorrent 18 2.6.2 Packets exchanged between peers . 18 2.6.3 Downloading mechanism .19 2.6.4 Selecting a neighbor at random .20 2.6.5 Piece selection strategy .21 2.7 Performance metrics 21 CHAPTER 3: AN IMPROVEMENT OF BITTORRENT ADAPTATION TO MANETS 24 3.1 General ideas 24 3.2 Node presence detection mechanism . 24 3.2.1 Soft state bloom filter .25 3.2.2 Bloom filter operations .26 3.2.3 Decoupling information decay and BEACON Intervals 27 3.3 Integration of node presence detection mechanism into BitTorrent 28 3.4 Conclusion 30 CHAPTER 4: SIMULATION RESULTS 31 4.1 Network simulator (NS-2) 31 4.2 Main scenario .31 4.2.1 Estimate the average finish time 34 4.2.2 Estimate the average sharing ratio 35 4.2.3 Estimate the network traffic .36 4.2.4 Impact of the number of network nodes .37 CONCLUSIONS AND PERSPECTIVES 38 REFERENCES .39