22
A P2P file distribution system ——BitTorrent John C.S. Lui

A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

A P2P file distribution system ——BitTorrent

John C.S. Lui

Page 2: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Outline

• 1 Advantages• 2 BitTorrent Components• 3 Publishing Content• 4 Internal Mechanism

Page 3: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Problems

• Traditional Client/Server Sharing– Performance deteriorates rapidly as the

number of clients increases• Free-riding in P2P network

– Free riders only download without contributing to the network.

Page 4: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

BitTorrent

• Good Scalability

• Strong incentives to prevent free-riding.

Page 5: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Outline

• 1 Advantages• 2 BitTorrent Components• 3 Publishing Content• 4 Internal Mechanism

Page 6: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Critical Elements

• 1 A web server– To provide the ‘metainfo’ file by HTTP– For example:

• http://bt.btchina.net• http://bt.ydy.com/ Web Server

The Lord of Ring.torrent

Troy.torrent

Page 7: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Critical Elements

• 2 The .torrent file– Static ‘metainfo’ file to contain necessary

information :• Name• Size• Checksum• IP address of the Tracker• …

Matrix.torrent

Page 8: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Critical Elements

• 3 A BitTorrent tracker– Non-content-sharing node– Track peers– For example:

• http://bt.cnxp.com:8080/announce• http://btfans.3322.org:6969/announce

Page 9: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Critical Elements

• 4 An end user (peer)– Guys who want to use BitTorrent must install

corresponding software or plug-in for web browsers.

– Downloader (leecher) : Peer has only a part ( or none ) of the file.

– Seeder: Peer has the complete file, and chooses to stay in the system to allow other peers to download

Page 10: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Outline

• 1 Advantages• 2 BitTorrent Components• 3 Publishing Content• 4 Internal Mechanism

Page 11: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Connectivity

Web ServerFan Bin

Tracker

Matrix.torrent

Downloader:Joe

Seeder:John

Downloader:Haibin

Page 12: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Piece

• A file is cut into pieces of fixed size, typically 256Kb

• Each downloader reports to all of its peers what pieces it has.

• To verify data, Hash codes are used for all the pieces, included in .torrent files.

Page 13: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

A trivial example

Seeder:John

DownloaderFan Bin

{1,2,3,4,5,6,7,8,9,10}

{}{1,2,3}

DownloaderJoe

{}{1,2,3}

{1,2,3,4}

{1,2,3,5}

{1,2,3,4,5}

Page 14: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Outline

• 1 Advantages• 2 BitTorrent Components• 3 Publishing Content• 4 Internal Mechanism

Page 15: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Piece Selection

• Strict Priority• First Priority

• Rarest First• General rules

• Random First Piece• Special case, at the beginning

• Endgame Mode• Special case, in the end

Page 16: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Peer Selection

• Built-in incentive mechanism (where all the magic happens):– Choking Algorithm– Optimistic Unchoking– Anti-snubbing

Page 17: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Choking Algorithm

• Choking is a temporal refusal to upload• Each peer unchokes a fixed number of

peers (default = 4)

Page 18: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Reasons for Choking

• TCP congestion control.

• To ensure the peers to get a consistent download rate.

Joe

Fan Bin

ChokedChoked

Page 19: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Optimistic Unchoking

• a BitTorrent peer has a single ‘optimistic unchoke’ which is uploaded regardless of the current download rate from it. This peer rotates severy 30s

• Reason:– To discover currently unused connections are

better than the ones being used

Page 20: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Anti-snubbing

• When a peer received no data in 60s, we assume it is choked by all other peers, and refuse to upload to it except for the optimistic unchoking.

• Reason– It may cause several concurrent optimistic

unchokes.

Page 21: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Example

Fan Bin

Downloader:John

Downloader:HaibinDownloader:

Wang Hui Downloader:Gao yan

40kb/s

30kb/s

10kb/s

100kb/s

20kb/s

70kb/s

15kb/s

10kb/s

70kb/s

110kb/s

70kb/s

5kb/s

DownloaderJoe

Page 22: A P2P file distribution system ——BitTorrentcslui/CSC7221/BT_intro.pdfCritical Elements • 4 An end user (peer) – Guys who want to use BitTorrent must install corresponding software

Conclusion

• BitTorrent is a well thought-out protocol that embraces aspects of cooperation and self-optimizing mechanisms.

• BitTorrent propose solutions for current optimization and scalability problems