The document describes a simulator for peer-to-peer networks created as a bachelor's thesis. The simulator models peers and files, simulates chunk transfers between peers in a discrete event format, and collects data on download times and peer load. The simulator was designed to be flexible and extensible to research the impact of free-riders and other factors in peer-to-peer networks like BitTorrent.
WordPress Websites for Engineers: Elevate Your Brand
A Peer-to-Peer Simulator
1. Introduction Model Simulation Application Summary
A Peer-to-Peer Simulator
Uwe Schmidt
Bachelor Thesis
August 17, 2006
Uwe Schmidt: A Peer-to-Peer Simulator 1 / 28
2. Introduction Model Simulation Application Summary
Outline
Introduction
1
Model
2
Simulation
3
Application
4
Uwe Schmidt: A Peer-to-Peer Simulator 2 / 28
3. Introduction Model Simulation Application Summary
Outline
Introduction
1
Model
2
Simulation
3
Application
4
Uwe Schmidt: A Peer-to-Peer Simulator 3 / 28
4. Introduction Model Simulation Application Summary
Peer-to-Peer File-Sharing
Gaining Importance
Less expensive in comparison to dedicated file servers
Exploit bandwidth of users
Resilient to flashcrowds
BitTorrent
Files are separated into chunks
Popular (also for legal purposes)
Microsoft Avalanche
Uses network coding for chunk distribution
Uwe Schmidt: A Peer-to-Peer Simulator 4 / 28
5. Introduction Model Simulation Application Summary
Motivation
Freeriding
Common problem of all P2P systems
Large fraction of peers are free-riders
BitTorrent tries to restrain it by enforcing a tit-for-tat strategy
Primary purpose of the simulator:
Research the impact of the amount of free-riders on ...
Download times
Peer load
Uwe Schmidt: A Peer-to-Peer Simulator 5 / 28
6. Introduction Model Simulation Application Summary
Outline
Introduction
1
Model
2
Simulation
3
Application
4
Uwe Schmidt: A Peer-to-Peer Simulator 6 / 28
7. Introduction Model Simulation Application Summary
General
Similar to BitTorrent (chunk-based file-sharing)
Global knowledge of all other peers in the system
No incentives to upload are given (such as tit-for-tat)
Peers wait random time between downloads
Peer
Chunk Selection
Download Behavior File
Multiple Downloads Chunk#1 Chunk#2 ... Chunk#n Peer Selection
Queued Requests
Peer Lists for Chunks
Chunk Selection Peer#13
Peer#11
Peer Selection Peer#6 Peer#2
List List List Peer#5
Peer#40 Peer#77
Peer#8
Peer#19
Uwe Schmidt: A Peer-to-Peer Simulator 7 / 28
8. Introduction Model Simulation Application Summary
General Configuration GUI
Uwe Schmidt: A Peer-to-Peer Simulator 8 / 28
9. Introduction Model Simulation Application Summary
Peers
Separated into peer groups:
Peer Group
Number of members
Number of free-riders
Bandwidth (upstream & downstream)
Maximum number of simultaneous uploads & downloads
Disconnect probability after successful file download
Uwe Schmidt: A Peer-to-Peer Simulator 9 / 28
10. Introduction Model Simulation Application Summary
Peers Configuration GUI
Uwe Schmidt: A Peer-to-Peer Simulator 10 / 28
11. Introduction Model Simulation Application Summary
Files
Separated into file types:
File Type
Number of files
Number of copies (per file)
File size (determines number of chunks)
File distribution to peer groups
Popularity distribution of files among type
Global Chunk Size
Applies to all file types
Uwe Schmidt: A Peer-to-Peer Simulator 11 / 28
12. Introduction Model Simulation Application Summary
Files Configuration GUI
Uwe Schmidt: A Peer-to-Peer Simulator 12 / 28
13. Introduction Model Simulation Application Summary
Requests
Mean request period
Request distribution to file types
Uwe Schmidt: A Peer-to-Peer Simulator 13 / 28
14. Introduction Model Simulation Application Summary
Requests Configuration GUI
Uwe Schmidt: A Peer-to-Peer Simulator 14 / 28
15. Introduction Model Simulation Application Summary
Outline
Introduction
1
Model
2
Simulation
3
Application
4
Uwe Schmidt: A Peer-to-Peer Simulator 15 / 28
16. Introduction Model Simulation Application Summary
Preliminaries
Factories
Create peers and files
Deploy files to peers
File Request Generator
Uses request configuration and file popularity settings
Creates empirical distributions for file indexes
Replays this distributions during the simulation
Uwe Schmidt: A Peer-to-Peer Simulator 16 / 28
17. Introduction Model Simulation Application Summary
Discrete Event Simulation Concept
Ordered Event List Simulation Executive
removes executes
Next Event
inserted changes state appends data
Entities
schedule append data
New Events Data Collection
Uwe Schmidt: A Peer-to-Peer Simulator 17 / 28
18. Introduction Model Simulation Application Summary
Simulation Cycle
File Request Generator
Peer
Download Part Upload Part
Download File Incoming Chunk Request
Add Chunks to More Uploads
Download Complete
Download Queue possible?
yes no
Last Chunk
Process Download Queue Upload Chunk Queue Chunk Request no
of File?
yes
More Downloads Maybe
Chunk Download started Chunk Request Queued Upload Complete Update Uploads
possible? go Ofline
yes no
Maybe start
Select Chunk Update Downloads Process Upload Queue
new Request
Select Peer Download Chunk
Uwe Schmidt: A Peer-to-Peer Simulator 18 / 28
19. Introduction Model Simulation Application Summary
Control
Uwe Schmidt: A Peer-to-Peer Simulator 19 / 28
20. Introduction Model Simulation Application Summary
Collected Data
Before the Simulation
Peer groups
File types
List of files with chunk mapping
List of peers with file mapping
During the Simulation
Completed chunk transfers
Completed file downloads
Miscellaneous (e.g. peer goes offline)
After the Simulation
List of peers with file mapping
Uwe Schmidt: A Peer-to-Peer Simulator 20 / 28
21. Introduction Model Simulation Application Summary
Outline
Introduction
1
Model
2
Simulation
3
Application
4
Uwe Schmidt: A Peer-to-Peer Simulator 21 / 28
22. Introduction Model Simulation Application Summary
Overview
Written in Java SE 5
Used Eclipse 3
58 classes in 8 packages
≈ 8000 lines of code and comments (JavaDoc)
Used Libraries
Jakarta Commons Math → Random Number Generators
Jakarta Commons Configuration → XML Configuration
JFreeChart → Charts
Uwe Schmidt: A Peer-to-Peer Simulator 22 / 28
23. Introduction Model Simulation Application Summary
Structure
User
starts starts
Graphical User Interface Console Mode
controls controls
Simulator
changes uses executes
File Request Generator Factories Next Event
uses uses use create create writes controls
returns Files
Configuration Files Peers
to download
save load uses use consist of transfer use schedule write removes
Config File Chunks Strategies New Events Log Files
use inserted
Random Number Generators Event List
Uwe Schmidt: A Peer-to-Peer Simulator 23 / 28
24. Introduction Model Simulation Application Summary
Used Design Patterns
Observer Pattern
Simulator → Simulation State Progress
Configuration → Changes
Singleton Pattern
Implemented by frequently used components
Single point of access from everywhere
No need to pass references on to other components
Command Pattern
Hashtable that maps an ActionString to a Command
Avoid code duplication
Uwe Schmidt: A Peer-to-Peer Simulator 24 / 28
25. Introduction Model Simulation Application Summary
Extensions
General modular design
Selection strategies are easy to change and extend
Example (Chunk Selection)
Select rarest chunk among 50 randomly selected ones to
reflect that peers have no global knowledge in reality
Example (Peer Selection)
Select peer with most upstream left
Select peer with smallest upload queue (if all are busy)
Uwe Schmidt: A Peer-to-Peer Simulator 25 / 28
26. Introduction Model Simulation Application Summary
Demo
Uwe Schmidt: A Peer-to-Peer Simulator 26 / 28
27. Introduction Model Simulation Application Summary
Summary
Easy and flexible way to simulate P2P systems (similar to
BitTorrent)
Tool to research the impact of free-riders, and other
parameters, on a P2P system
Modular designed and extendable
Uwe Schmidt: A Peer-to-Peer Simulator 27 / 28
28. Thank you for your attention
Questions?
Uwe Schmidt: A Peer-to-Peer Simulator 28 / 28