310 likes | 438 Views
A simple model for analyzing P2P streaming protocols. Seminar on advanced Internet applications and systems Amit Farkash. 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.
E N D
A simple model for analyzing P2P streaming protocols. Seminar on advanced Internet applications and systems Amit Farkash.
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.
Server Peer Peer Peer Fully connected Peer Peer Peer Introduction P2P Streaming System -P2P resolves this scalability problem by using all resources of all clients. It is like using multiple trees simultaneously to deliver content. Peers maintain: * buffer * neighbor list
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 timerequirements!
t=1 1 t=2 2 1 t=3 3 2 1 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 server playback ………. Buffer
server 1/M playback 1 2 …………… n 1 2 …………… n 1 2 …………… n 1/M … M peers 1/M Model & Chunk Selection Strategies • M peerswith 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)
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.
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.
Improvement: Since peers are selected randomly the probability for a peer, 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.
1 2 …………… n 1 2 …………… n P2p technology effect Model & Chunk Selection Strategies • Each peer’s buffer is a sliding window • In each time slot, each peer downloads a chunk fromserver or its neighbor • q(i) = the probability Buf[i] gets filled at this time slot, for i>1 p(1)=1/M p(n)=? time=t sliding window t+1 p(1)=1/M P(1) = 1/M(Boundary)
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).
Model & Chunk Selection Strategies • w(i) = probability peer wants to fillBuf[i] w(i)=1-p(i) • h(i) = probability the selected peer hasthe 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) sliding window p(1)=1/M p(n) peer 1 2 …… i … n neighbor 1 2 .….. i … n p(1)=1/M
playback 1 2 3 4 5 6 7 8 Buffer map X X X X RF Selection Greedy Selection Model & Chunk Selection Strategies • GreedyStrategy -try to fill the empty buffer closest to playback • Rarest FirstStrategy -try to fill the empty buffer for the newest chunksince p(i) is an increasing function, this means “Rarest First” • An example
Performance metrics: We will compare downloading strategies based on two performance metrics: • Continuity – probability of continues playback. • Startup latency – expected time to start playback.
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.
Rarest first Peer K will select to download chunk to B(i) if B(j) are filled for every 1≤j<i and it was not distributed a chunk by the server: Therefore: SELECTRF(i) Proposition: SELECTRF(i) = 1 – P(i) For Proof see paper, proposition 2
w(i) h(i) h(i) s(i) w(i) s(i) 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
Differential equations • Solve previous differential equations , derive continuous model • Based on continuous model , derive partial differential equation • Greedy : • Rarest First :
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)]
Evaluating performances: • We already have Continuity: P(n) • Start up latency: time a peer should wait before startingplayback. • Assuming all other peers have already reached steady states • A newly arriving peer should waituntil its buffer has reached steady state as well
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. • One server and M peers. • In each time slot the server distributes one chunk to a random peer. • Each peer selects one random peer to download one chunk from and can upload up to two peers.
Validation • M=1000 • N=40 • In simulation, • # neighbors=60 • Uploads at most 2 in each time slotfor one peer • Validate our model
SimRarest first vs. Greedy vs. Mixed Rarest First • 1000 peers, 40 buffer • Compare three strategies, especially the curve for Mixed. Mixed Greedy
Rarest first vs. Greedy vs. Mixed: RF Mixed Mixed RF Greedy Greedy • 1000 peers, buffer length varies from 20 to 40. • For different buffer sizes • Mixed achieves bestcontinuity than both RF and Greedy • Mixed has better start-up latency than RF
Optimizing the Mixed Strategy: Fix n to 40 and vary m:
Performance for Small Scale Networks • n=15 • Timeslot = 3000
Performance for Small Scale Networks RF Greedy • For (a), there are 40 peers. Greedy is better. • For (b), the continuity requirement is fixed at 0.93. RF is better RF Greedy
Study of Dynamics Mixed • 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
Study of Dynamics Start up latency = 16 Arrive at t = 1000 – 16 Start playback at t = 1000
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).
Optimizing the Mixed Strategy: How to adapt m for the mixed strategy Mixed RF • 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