Skip to content
UoL CS Notes

Peer-to-Peer (P2P) Applications

COMP211 Lectures

This lecture continues from The Application Layer - Network Applications.

File Distribution for Client-Server Model

To send a file to $N$ clients the server must upload $N$ file copies:

  • Time to send one copy: $\frac F {u_s}$
  • Time to send $N$ copies $\frac{NF}{u_s}$

Each client must download a file copy:

  • $d_\min=$ minimum client download rate.
  • Minimum client download time: $\frac F{d_\min}$

Therefore the time to distribute $F$ to $N$ clients using the client-server approach is:

\[D_{\text{client to server}}\geq\max\{\frac{NF}{u_s},\frac F{d_\min}\}\]

File Distribution for P2P

Server transmission must upload at least one copy:

  • Time to send one copy: $\frac F{u_s}$

Each client must download a file copy:

  • Minimum cloent download time: $\frac F{d_\min}$

Additional Clients as aggregate must download $NF$ bits:

  • Max upload rate (limiting max download rate) is: $u_s +\sum u_i$

Therefore the time to distribute $F$ to $N$ client using a P2P approach is:

\[D_\text{P2P}>\max\{\frac F{u_s},\frac F{d_\min},\frac{NF}{u_s+\sum u_i}\}\]

As the service capacity increases linearly with $N$ the service is self-scaling.

BitTorrent

  • File is divided into 256Kb chunks.
  • Peers in the torrent send and receive file chinks.

There are two parties:

  • Tracker - Tracks peers participating in the torrent.
  • Torrent - The group of peers exchanging chunks of a file.

When a new peer arrives:

  1. They obtain a list of peers from the tracker.
  2. Begin exchanging file chunks with the peers in the torrent.

File Chunks

Requesting chunks:

  • At any given time, different peers have different chunks.
  • Periodically, you ask each peer for a list of chunks that they have.
  • You request missing chunks from peers, rares first.

Sending chunks (tit-for-tat):

  • You send chunks to those sending you chunks at the highest rate.
    • Other peers are choked.
    • Re-evalulate to peers every 10 seconds.
  • Every 30 seconds, randomly seelct another peer to start sending chunks.
    • Optimistically un-choke this peer.
    • This new peer may gain rate.

Higher upload rate gets better trading partners, allowing you to get the file faster.