0% found this document useful (0 votes)
10 views32 pages

P2P vs Client-Server File Distribution

Uploaded by

kkr795707
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views32 pages

P2P vs Client-Server File Distribution

Uploaded by

kkr795707
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 2

Application
Layer
Part 3

presented by
Dr. Mohammed Abdul Majeed

Computer Networking: A Top-


Down Approach
8th edition n
Jim Kurose, Keith Ross
Pearson, 2020 Application
Layer: 2-1
Peer-to-peer (P2P) architecture
 no always-on server mobile network

 arbitrary end systems directly national or global ISP

communicate
 peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, and new service demands home network content
provider
 peers are intermittently connected network datacenter

and change IP addresses


network

• complex management
 examples: P2P file sharing (BitTorrent), enterprise
network
streaming (KanKan), VoIP (Skype)
Application Layer: 2-2
File distribution: client-server vs P2P
Q: how much time to distribute file (size F) from one server to
N peers?
• peer upload/download capacity is limited resource
us: server upload
capacity
di: peer i download
file, size F u1 d1 u2 capacity
us d2
server
di
uN network (with abundant
bandwidth) ui
dN
ui: peer i upload
capacity
Introduction: 1-3
File distribution time: client-server
 server transmission: must sequentially
send (upload) N file copies:
F
• time to send one copy: F/us us
• time to send N copies: NF/us di
network
ui
 client: each client must download
file copy
• dmin = min client download rate
• min client download time: F/dmin

time to distribute F
to N clients using Dc-s > max{NF/us,,F/dmin}
client-server approach

increases linearly in N Introduction: 1-4


File distribution time: P2P
 server transmission: must upload at
least one copy:
F
• time to send one copy: F/us us

 client: each client must download di


network
file copy ui
• min client download time: F/dmin
 clients: as aggregate must download NF bits
• max upload rate (limiting max download rate) is us + Σui

time to distribute F
to N clients using DP2P > max{F/us,,F/dmin,,NF/(us + Σui)}
P2P approach
increases linearly in N …
… but so does this, as each peer brings service capacity Application Layer: 2-5
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
3.5
P2P

Minimum Distribution Time


3
Client-Server
2.5

1.5

0.5

0
0 5 10 15 20 25 30 35

N
Application Layer: 2-6
P2P file distribution: BitTorrent
 file divided into 256Kb chunks
 peers in torrent send/receive file chunks
tracker: tracks peers torrent: group of peers
participating in torrent exchanging chunks of a file

Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent

Application Layer: 2-7


P2P file distribution: BitTorrent
 peer joining torrent:
• has no chunks, but will accumulate them
over time from other peers
• registers with tracker to get list of peers,
connects to subset of peers
(“neighbors”)
 while downloading, peer uploads chunks to other peers
 peer may change peers with whom it exchanges chunks
 once peer has entire file, it may (selfishly) leave or (altruistically) remain
in torrent

Application Layer: 2-8


BitTorrent: requesting, sending file chunks
Requesting chunks: Sending chunks: Alice sends chunks
 at any given time, different to those four peers currently sending
peers have different her chunks at highest rate
subsets of file chunks • other peers are choked by Alice (do
 periodically, Alice asks not receive chunks from her)
each peer for list of chunks • re-evaluate top 4 every10 secs
that they have  every 30 secs: randomly select
 Alice requests missing another peer, starts sending
chunks from peers, rarest chunks
first • “optimistically unchoke” this peer
• newly chosen peer may join top 4

Application Layer: 2-9


BitTorrent: tit-for-tat
(1) Alice “optimistically unchokes” Bob
(2) Alice becomes one of Bob’s top-four providers; Bob reciprocates
(3) Bob becomes one of Alice’s top-four providers

higher upload rate: find better trading


partners, get file faster !

Application Layer: 2-10


Application layer: overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-11


Video Streaming and CDNs: context
 stream video traffic: major
consumer of Internet bandwidth
• Netflix, YouTube, Amazon Prime: 80% of
residential ISP traffic (2020)
 challenge: scale - how to reach
~1B users?
 challenge: divergency
 different users have different capabilities (e.g., wired
versus mobile; bandwidth rich versus bandwidth poor)
 solution: distributed, application-level infrastructure
Application Layer: 2-12
Multimedia: video spatial coding example: instead
of sending N values of same
color (all purple), send only two
values: color value (purple) and

 video: sequence of images number of repeated values (N)

displayed at constant rate ……………………..


……………….…….
• e.g., 24 images/sec
 digital image: array of pixels
• each pixel represented by bits
 coding: use redundancy within and frame i
between images to decrease # bits
used to encode image
• spatial (within image) temporal coding example:
instead of sending
• temporal (from one image to complete frame at i+1,

next) send only differences from


frame i frame i+1

Application Layer: 2-13


Streaming stored video
simple scenario:

Internet
video server
client
(stored video)

Main challenges:
 server-to-client bandwidth will vary over time, with changing network
congestion levels (in house, access network, network core, video
server)
 packet loss, delay due to congestion will delay playout, or result in
poor video quality
Application Layer: 2-14
Streaming stored video

2. video
sent
1. video 3. video received, played out at client
recorded (30 frames/sec)
(e.g., 30 time
network delay
frames/sec) (fixed in this
example)
streaming: at this time, client playing out
early part of video, while server still sending
later part of video
Application Layer: 2-15
Streaming stored video: challenges
 continuous playout constraint: during client
video playout, playout timing must match
original timing
• … but network delays are variable (jitter), so will
need client-side buffer to match continuous playout
constraint
 other challenges:
• client interactivity: pause, fast-forward, rewind,
jump through video
• video packets may be lost, retransmitted
Application Layer: 2-16
Streaming stored video: playout buffering
constant bit
rate video client video constant bit
transmission reception rate video
playout at client
variable
network

buffered
video
delay

client playout time


delay

client-side buffering and playout delay: reward for network-


added delay, delay jitter
Application Layer: 2-17
Streaming multimedia: DASH Dynamic, Adaptive
Streaming over HTTP
DASH uses adaptive bit rate, allowing the video player to
automatically adjust to network conditions and switch to lower or
higher quality resolution ...
server: ...
 divides video file into multiple chunks ?
 each chunk encoded at multiple different rates
...
 different rate encodings stored in different files client

 CDN is content delivery network


 files replicated in various CDN nodes
client: manifest file: provides URLs for different chunks
 requests one chunk at a time
• chooses maximum coding rate supportable given current bandwidth
• can choose different coding rates at different points in time (depending
on available bandwidth at time), and from different servers Application Layer: 2-18
Streaming multimedia: DASH
“intelligence” at client: client
determines ...
• when to request chunk (so that buffer ...

starvation, or overflow does not occur) ?


• what encoding rate to request (higher ...
client
quality when more bandwidth
available)
• where to request chunk (can request
from URL server that is “close” to
client or has high available
bandwidth)

Application Layer: 2-19


Content distribution networks (CDNs)
challenge: how to stream content (selected from millions of
videos) to hundreds of thousands of simultaneous users?
 option 1: single, large “mega-
server”
• single point of failure
• point of network crowding
• long (and possibly crowded) path
to distant clients

….quite simply: this solution doesn’t scale


Application Layer: 2-20
Content distribution networks (CDNs)
challenge: how to stream content (selected from millions of
videos) to hundreds of thousands of simultaneous users?
 option 2: store/serve multiple copies of videos at multiple
geographically distributed sites (CDN)

Application Layer: 2-21


How does Netflix work?
 Netflix: stores copies of content (e.g., MADMEN) at its
(worldwide) OpenConnect CDN nodes
 subscriber requests content, service provider returns manifest
• using manifest”, client retrieves content at highest supportable rate
• may choose different rate or copy if network path crowded
*manifest file provides the DASH player metadata to conduct the adaptive video streaming. It acts as a
roadmap for the media player, providing details on retrieving and playing back the video content. The
manifest file typically includes information on the stream's container format, codecs, bitrates, resolution,
and other critical details necessary for proper playback.

manifest file
where’s Madmen?

Application Layer: 2-22


Case study: Netflix
Amazon cloud upload copies of
multiple versions of
video to CDN servers
CDN
server
Netflix registration,
accounting servers
Bob browses
Netflix video CDN
2 Manifest file, server
requested
1 3 returned for
Bob manages specific video
Netflix account
CDN
4 server

DASH server
selected, contacted,
streaming begins
Application Layer: 2-23
Application Layer: Overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-24


Socket programming
goal: learn how to build client/server applications that
communicate using sockets
socket: door between application process and end-end-transport
protocol
application application
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

Application Layer: 2-25


Socket programming
Two socket types for two transport services:
 UDP: unreliable datagram
 TCP: reliable, byte stream-oriented

Application Layer: 2-26


Socket programming with UDP
UDP: no “connection” between
client and server:
 no handshaking before sending data
 sender clearly attaches IP destination
address and port # to each packet
 receiver extracts sender IP address and
port# from received packet

UDP: transmitted data may be lost or received out-of-order


Application viewpoint:
 UDP provides unreliable transfer of groups of bytes (“datagrams”)
between client and server processes
Application Layer: 2-27
Client/server socket interaction: UDP
server (running on serverIP) client
create socket:
create socket, port= x: clientSocket =
serverSocket = socket(AF_INET,SOCK_DGRAM)
socket(AF_INET,SOCK_DGRAM)
Create datagram with serverIP address
And port=x; send datagram via
read datagram from clientSocket
serverSocket

write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Application Layer: 2-28
Socket programming with TCP
Client must contact server  when contacted by client, server
 server process must first be TCP creates new socket for server
running process to communicate with that
 server must have created socket particular client
(door) that welcomes client’s • allows server to talk with multiple
contact clients
Client contacts server by: • client source port # and IP address used
to distinguish clients (more in Chap 3)
 Creating TCP socket, specifying IP
address, port number of server
process Application viewpoint
 when client creates socket: client TCP provides reliable, in-order
TCP establishes connection to byte-stream transfer (“pipe”)
server TCP between client and server
processes
Application Layer: 2-29
Client/server socket interaction: TCP
server (running on hostid) client
create socket,
port=x, for incoming
request:
serverSocket = socket()

wait for incoming create socket,


connection request
TCP connect to hostid, port=x
connectionSocket = connection setup clientSocket = socket()
[Link]()

send request using


read request from clientSocket
connectionSocket

write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Application Layer: 2-30
Chapter 2: Summary
our study of network application layer is now complete!
 application architectures  specific protocols:
• client-server • HTTP
• P2P • DNS
• P2P: BitTorrent
 application service requirements:
• reliability, bandwidth, delay
 video streaming, CDNs
 socket programming:
 Internet transport service model
TCP, UDP sockets
• connection-oriented, reliable: TCP
• unreliable, datagrams: UDP

Application Layer: 2-31


Chapter 2: Summary
Most importantly: learned about protocols!
 typical request/reply message important themes:
exchange:  centralized vs. decentralized
• client requests info or service  stateless vs. stateful
• server responds with data, status code  scalability
 message formats:  reliable vs. unreliable
• headers: fields giving info about data message transfer
• data: info(payload) being  “complexity at network
communicated
edge”

Application Layer: 2-32

You might also like