Download - A simple model for analyzing P2P streaming protocols.

Transcript
Page 1: A simple model for analyzing P2P streaming protocols.

1

A simple model for analyzing P2P streaming protocols.

Seminar on advanced Internet applications and systemsAmit Farkash.

Page 2: A simple model for analyzing P2P streaming protocols.

The problem:

Streaming video from a server to a single client is well studied and understood.

Not scalable to serve a large number of clients simultaneously.

P2P streaming tries to achieve scalability (like P2P file distribution) while at the same time meet real time playback requirements.

It is a challenging problem still not well understood.

2

Page 3: A simple model for analyzing P2P streaming protocols.

IntroductionP2P Streaming System -P2P resolves this scalability problem by using all resources of all clients. It is like using

multiple trees simultaneously to deliver content.

Server

Peer

Peer

Peer

Peer

Peer

Peer

Fully connected

Peers maintain: * buffer * neighbor list

Page 4: A simple model for analyzing P2P streaming protocols.

4

P2P streaming vs. P2P file sharing:

• P2P streaming is less demanding – no need for entire file.

1) Peers join the video session from the point of their arrival times.

2) Missing “just a few” frames is tolerable.

• P2P streaming is more demanding - real time requirements!

Page 5: A simple model for analyzing P2P streaming protocols.

Basic model

• How buffer works?

Server sends out chunks sequentially.

Peer downloads one chunk every time slot

Buffer shits ahead one position one time slot

playback

server

1

t=1

2 1

t=2

3 2 1

t=3

Buffer

……….

Page 6: A simple model for analyzing P2P streaming protocols.

Model & Chunk Selection Strategies

• M peers with the same playback requirement

• Each has a playback buffer• In each time slot, the server

randomly selects one peer and uploads one chunk

• Users’ metric is the continuity, defined as p(n) , the probability chunk n available

• To compute p(n), recursively compute p(i). p(i) is defined as:

p(i)=prob(position i filled)

1 2 …………… n

1 2 …………… n

1 2 …………… n

… M peers

playback

server

1/M

1/M

1/M

Page 7: A simple model for analyzing P2P streaming protocols.

7

Basic model• Pk(i)[t] – probability that B(i) of peer k is filled (with the correct) chunk at

time t.• Assumption: this probability reaches a steady state for large t, namely

Pk(i)[t] = Pk(i).• We call Pk(i) the buffer occupancy probability of peer k.

• Simple case - only server is distributing chunks:

Pk(1) = P(1) = 1/M. ∀ k.

Pk(i+1) = P(i+1) = P(i). i=1,…,n-1. ∀ k.

Obviously very poor playback for any M>1.

Page 8: A simple model for analyzing P2P streaming protocols.

8

Improvement:• Each peer selects another peer in each time slot to try and

download a chunk not already in its buffer.• If the selected peer has no useful chunk, no chunk is

downloaded in that time slot• All peers use the same selection strategy, therefore have the

same distribution P(i)• Assume peers are selected randomly.

Page 9: A simple model for analyzing P2P streaming protocols.

9

Improvement:

Since peers are selected randomly the probability for apeer, A ,to be selected by K≥0 peers is:

A(k) =

• If M=100, A(3) is only about 1.8 % • assume A's peer's upload capacity is large enough to serve

all requests in each time slot.

Page 10: A simple model for analyzing P2P streaming protocols.

P2p technology effect

Model & Chunk Selection Strategies

• Each peer’s buffer is a sliding window

• In each time slot, each peer downloads a chunk from server or its neighbor

• q(i) = the probability Buf[i] gets filled at this time slot, for i>1

1 2 …………… n

p(1)=1/M p(n)=?

time=t

1 2 …………… n t+1

p(1)=1/M

sliding window

)()()1( iqipip P(1) = 1/M (Boundary)

Page 11: A simple model for analyzing P2P streaming protocols.

11

Chunk selection policy:• P(i+1) = P(i) + Q(i) =

P(i) + Pr[WANT(K,i)∩Pr[HAVE(H,i)]∩Pr[SELECT(H,K,i)]

• Assume all peers are independent so P(i) is the same for each K, therefore: WANT(K,i) = 1-P(i).

• Assume large enough number of peers so that knowing the state of one does not significantly affect the probability of the state of another peer, therefore: Pr[HAVE(H,i)|WANT(K,i)] ≈ Pr[HAVE(H,i)]=P(i).

• Assume chunks are independently distributed in the network, so the probability distribution for position i is not strongly affected by the knowledge of the state of other positions, therefore: Pr[SELECT(H,K,i)|WANT(K,i) ∩ HAVE(H,i)] ≈ Pr[SELECT(H,K,i)] = SELECT(i).

Page 12: A simple model for analyzing P2P streaming protocols.

Model & Chunk Selection Strategies

w(i) = probability peer wants to fill Buf[i]

w(i)=1-p(i) h(i) = probability the selected

peer has the content for Buf[i]

h(i)=p(i) s(i) = Buf[i] determined by

chunk selection strategy P(i) + [1-P(i)] P(i) SELECT(i)

)()()()( isihiwiq

1 2 …… i … n

p(1)=1/M p(n)

peer

1 2 .….. i … n neighbor

p(1)=1/M

sliding window)()()()( isihiwiq

Page 13: A simple model for analyzing P2P streaming protocols.

Buffer map X X X X

1 2 3 4 5 6 7 8playback

Model & Chunk Selection Strategies

• Greedy Strategy -try to fill the empty buffer closest to playback• Rarest First Strategy -try to fill the empty buffer for the newest chunk since p(i) is an increasing

function, this means “Rarest First”• An example

RF Selection Greedy Selection

Page 14: A simple model for analyzing P2P streaming protocols.

14

Performance metrics:

We will compare downloading strategies based on two

performance metrics:

• Continuity – probability of continues playback.

• Startup latency – expected time to start playback.

Page 15: A simple model for analyzing P2P streaming protocols.

15

Greedy:Pr[chunk isn't downloaded to B(j)] =¬Pr[WANT(K,j)HAVE(H,j)] = Pr[K has j] + Pr[K doesn't have j] * Pr[H doesn't have j] = Pk(j) + (1-Pk(j)) (1-Ph(j)) = P(j) + (1-P(j))²

Therefore: SELECTG(i)

Proposition: SELECTG(i) = 1 - (P(n) - P(i+1)) - P(1)

For Proof see paper, proposition 1.

Page 16: A simple model for analyzing P2P streaming protocols.

16

Rarest firstPeer K will select to download chunk to B(i) if B(j) arefilled for every 1≤j<i and it was not distributed a chunkby the server:

Therefore: SELECTRF(i)

Proposition: SELECTRF(i) = 1 – P(i)

For Proof see paper, proposition 2

Page 17: A simple model for analyzing P2P streaming protocols.

Difference equation & Differential equation

• Greedy p(i+1)=p(i)+ (1-p(i)) * p(i) * (1-p(1)-p(n)+p(i+1))

• Rarest first p(i+1)=p(i)+ (1-p(i)) * p(i) * (1-p(i))

• Derive differential equation from difference equation

s(i)h(i)w(i)

w(i) h(i) s(i)

Page 18: A simple model for analyzing P2P streaming protocols.

Differential equations

• Solve previous differential equations , derive continuous model

• Based on continuous model , derive partial differential equation

• Greedy :

• Rarest First :

Page 19: A simple model for analyzing P2P streaming protocols.

19

Mixed strategy Partition the buffer at point m. • Try to download a chunk using Rarest first to

positions 1…m. • If no chunk can be downloaded using Rarest first, use

Greedy for positions m+1…n.

• For B(1) to B(m) same as Rarest first:P(1) = 1/M.P(i+1) ≈ P(i) + P(i) [1-P(i)]²

• For B(m+1) to B(n) same as Greedy but substitute B(m) for B(1):P(i+1) ≈ P(i) + P(i) [1-P(i)] [ 1-P(m)-P(n)+P(i+1)]

Page 20: A simple model for analyzing P2P streaming protocols.

20

Evaluating performances:• We already have Continuity: P(n)• Start up latency:time a peer should wait before starting playback.

• Assuming all other peers have already reached steady states

• A newly arriving peer should wait until its buffer has reached steady state as well

Page 21: A simple model for analyzing P2P streaming protocols.

21

Models from comparison: • Discrete model – The solution for the buffer state distribution P(i) is derived

numerically Greedy Strategy :given P(n) a fixed value, substitutes n steps inversely from P(n) to P(1) and compare P(1)

with 1/M Greedy Strategy : substitute p(i) from p(l) until p(n) Mixed Strategy :

• Continuous model – Generally solved numerically using MatLab.• Simulation model – Based on the discrete model.

o One server and M peers. o In each time slot the server distributes one chunk to a random peer. o Each peer selects one random peer to download one chunk from and can upload up to two

peers.

Page 22: A simple model for analyzing P2P streaming protocols.

Validation

• M=1000• N=40• In simulation,

– # neighbors=60– Uploads at most 2 in

each time slot for one peer

• Validate our model

Page 23: A simple model for analyzing P2P streaming protocols.

SimRarest first vs. Greedy vs. Mixed

• 1000 peers, 40 buffer• Compare three strategies, especially the curve for Mixed.

Rarest First

Greedy

Mixed

Page 24: A simple model for analyzing P2P streaming protocols.

Rarest first vs. Greedy vs. Mixed:

1000 peers, buffer length varies from 20 to 40.

For different buffer sizes Mixed achieves best continuity than both RF and Greedy Mixed has better start-up latency than RF

Mixed

RF

Greedy

RF

Mixed

Greedy

Page 25: A simple model for analyzing P2P streaming protocols.

25

Optimizing the Mixed Strategy:Fix n to 40 and vary m:

Page 26: A simple model for analyzing P2P streaming protocols.

Performance for Small Scale Networks

• n=15• Timeslot= 3000

Page 27: A simple model for analyzing P2P streaming protocols.

Performance for Small Scale Networks

• For (a), there are 40 peers. Greedy is better.• For (b), the continuity requirement is fixed at 0.93. RF is

better

RF

Greedy

Greedy

RF

Page 28: A simple model for analyzing P2P streaming protocols.

Study of Dynamics

Simulate 1000 peers, 2000 time slots, n=40

Continuity is the average continuity of all peers

Continuity for Mixed is more consistent, as well highest

Mixed

Page 29: A simple model for analyzing P2P streaming protocols.

Study of Dynamics

Start up latency = 16Arrive at t = 1000 – 16Start playback at t = 1000

Page 30: A simple model for analyzing P2P streaming protocols.

30

Optimizing the Mixed Strategy:Adapting to peer population:One way is to observe the value of P(m). • Set a target value, say Pm = 0.3 • When a peer finds the average of P(m) to be less than Pm the peer

increases m, else the peer decreases m

Simulation:• Initial value of m is 10. • Calculate average of P(m) for 20 time slots and then set new value of

m. • Initially M = 100 and every 100 time slots add another

100 peers (with empty buffers).

Page 31: A simple model for analyzing P2P streaming protocols.

Optimizing the Mixed Strategy:

Adjust m so that p(m) achieves a target probability (e.g. 0.3) In simulation study, 100 new peers arrive every 100 slots m adapts to a larger value as population increases

How to adapt m for the mixed strategy Mixed

RF