Bittorrent & P2P - Peer-to-Peer Network Applications | Computer Networks Ep. 2.5 | Kurose & Ross

42.43k views1500 WordsCopy TextShare
Epic Networks Lab
Answering the question, “How does bittorrent work?”. Includes principles of peer-to-peer applicatio...
Video Transcript:
in this video we'll be talking about the principles of peer-to-peer applications and looking at bittorrent as an example let's get started [Music] let's look at peer-to-peer applications and bittorrent the characteristic features of a peer-to-peer application is that they do not rely on an always-on server listening for connections instead arbitrary end systems are able to communicate with each other directly in this model peers request service from other peers and provide service to other peers it is important for the sustainability of the peer-to-peer network that the service provided scales at least as well as the service requested
there are two main challenges to the operations of peer-to-peer networks one is that the peers may join or leave the network so the service provided by a particular peer will come and go the second is that over time the psip address is likely to change the most common peer-to-peer application today is bittorrent so we'll look at that as an example in a few slides first let's look at a couple calculations to see the potential benefits of a peer-to-peer file transfer in the traditional model the file originates at the server and it needs to be distributed
to a number of clients the limiting factor here is the bandwidth available for the server to upload the file and for the clients to download the file for all of the clients to receive the file directly from the server the server will have to upload n copies of the file we can calculate the time required to accomplish this by dividing n times the file size by the upload bandwidth that the server is using we can also look at the download rates of the clients and determine if those will be the bottleneck each client will only
need to download the file one time so the file size divided by the slowest download bandwidth will be the maximum time that it would take for any of the clients to download the file from the server so the total time to distribute the file will either be the time it takes the server to upload all the copies or if longer the time for the slowest client to download one copy this assumes that all the clients make the request at the same time so in terms of scalability we see that this time to download will increase
linearly with the number of clients now let's look at the peer-to-peer scenario the file still starts out in one place on the server the server has to upload at least one copy of the complete file each client also needs to end up with their own copy of the file so we know that as an aggregate all the clients need n times f bits but now in the peer-to-peer model the upload bandwidth of all the clients will also contribute to the rate at which the file can be distributed the whole file distribution process cannot be completed
any faster than the server can upload the one copy or any faster than the slowest client can download one copy however in the typical case we have the numerator increasing linearly with n but the denominator is also increasing as additional peers join the network because they'll contribute to uploading the file to additional peers so let's compare those on a plot we see the linear growth of the time it takes for a server to distribute the file to end peers and we also see that as more peers join the peer-to-peer network the time added to transfer
the file to each additional peers decreases so the marginal increase gets lower and this performs much better than a linearly increasing distribution time so that's the principle how does it work in practice let's take bittorrent as an example as part of the bittorrent protocol each file is divided into 256 kilobit chunks this allows the peers to begin sharing bits of the file more quickly as opposed to having to wait for entire file transfer operations to complete as soon as the first chunk is uploaded to one peer that player can begin sharing it while they're downloading
another chunk there are a couple of key terms to keep in mind with bittorrent the torrent is the set of peers that are exchanging a particular file so a given peer can participate in many different torrents at the same time there is also a tracker which is a server maintaining a list of which peers are participating in a particular torrent so from that explanation we can see that bittorrent is not a pure peer-to-peer protocol because it still hasn't always on server ie the tracker and if the tracker goes away the protocol will no longer work
that being said there have been enhancements to bittorrent that allow it to work with a distributed tracker instead of a tracker centralized on one server so let's go through the process of what happens when a new peer wants to join the torrent alice now wants to join the torrent that is already active first she has to contact the tracker to obtain the list of peers that are participating in this torrent this means that the tracker must be available in a predictable place because otherwise alice won't be able to find it once she has the list
of peers then alice can start exchanging chunks at first alice has no chunks to contribute so she needs a way to get some chunks from the peers once she has one or more chunks then she can begin uploading those chunks while continuing to download more chunks the process of piers coming and going from the torrent is known as churn the more churn that happens in the network the more challenging it is to deliver all the chunks to all the peers in a timely manner once appear has the entire file it might leave the torrent which
is generally considered selfish if it has not yet uploaded at least as many chunks as it has downloaded remaining in the torrent after downloading all the chunks is known as seeding i.e providing an additional seed or copy of the entire file from which other peers can collect chunks as the process progresses different peers will have different chunks of the file it is important that at any given time all the chunks are still present in the torrent periodically each peer will ask the neighbors that they're connected to for a list of chunks that they have alice
requests chunks that she doesn't already have from her peers starting with the most rare so for example if there's only one copy of a particular chunk amongst all her peers alice would request that first once she's gotten a copy of it then there's at least two copies of that chunk amongst the same group of peers this helps preserve the torrent and prevent the case where the only copy of a particular chunk is on a peer that decides to leave the torrent at which point none of the other peers would be able to finish downloading the
torrent the peers are selective about which peers they send chunks of the file to they prioritize the peers that are currently sending at the highest rate periodically the peer will re-evaluate which of their peers are the fastest this encourages peers to upload rapidly if they want to be able to download chunks rapidly there is another component to the process called optimistic unchoke whereby alice selects a random peer and sends it one of the chunks that it's requesting this is the bootstrapping process by which peers that have no chunks can get started downloading the torrent let's
see an example of this tit-for-tat process bob is asking for chunks but he doesn't have any to upload or maybe he just doesn't have any that alice needs in either case alice randomly picks bob and optimistically unchokes him this means she begins sending him one of the chunks that he still needs at this point bob recomputes his top four providers and alice is one of them so bob reciprocates by sending alice a chunk it turns out that alice and bob are well connected and so bob is now one of alice's top four providers as well
and they both benefit by getting chunks of the file faster this improves overall peer-to-peer network efficiency by having peers that are well connected to one another exchange more chunks with each other that completes our brief overview of peer-to-peer applications in the next video we will look at the topic of video streaming and content distribution networks see you then we hope you enjoyed this video if you found it to be useful please click the like button to be notified when more videos are posted for this class to subscribe to our channel and click the bell you
Copyright © 2025. Made with ♥ in London by YTScribe.com