Client-Server vs P2P

Download Report

Transcript Client-Server vs P2P

Client-Server vs P2P
or, HTTP vs Bittorrent
Client-Server Architecture
client
client
client
client
client
SERVER
CLIENT
SERVER
Many clients
One server
Program starts and stops
Program runs continuously
Initiates connection – one server at Responds – many clients at a time.
a time.
Requests services
Responds to requests
(Usually) closes connection
Holds the files / data
Any port number will do
Needs a well-known port number,
well known IP number
Clients never communicate with one another.
Example: The HTTP Protocol
CLIENT: send
request
message
SERVER:
respond to
request
HTTP
1. Client initiates connection by sending a
request message, then headers, then a blank
line, then an optional message.
GET ccm/index.html HTTP/1.1
Accept-Lang: en
--no message --
HTTP
2. Server responds with a status line (status code
and text), headers, a blank line, and optional
text or data. Example:
HTTP1.1 200 OK
Server: Apache/1.3.3.7 (Unix)
Content-Length: 345 bytes
Content-Type: text/html
<html><body> …the text of the page in html…
HTTP
Eight types of client request messages:
1. GET: request a file from server
2. HEAD: just send me the headers that would be sent
3. POST: send input to a server program that generates
pages
4. PUT: upload a file to server
5. DELETE: delete a file on server
6. TRACE: echo this request
7. OPTIONS: what services does server offer
8. CONNECT: open a TCP-like connection
HTTP
Five categories of
server response:
1xx information
2xx success
3xx redirection
4xx client error
5xx server error
Examples:
200 OK
301 Moved Permanently
403 Forbidden
404 Not Found
Other Client-Server Protocols
•
•
•
•
TCP
DNS
eMail (POP/IMAP and SMTP)
Amazon, eBay, most sites for commercial
transactions
Note: Ethernet and IP are in a different category of so-called connectionless protocols:
the sender does not contact the receiver before sending the data. Client-server and
peer-to-peer are both connection-oriented protocols.
Peer to Peer Architecture
server
client
Peer to Peer Network
• Every node can act as both client and server
(called a peer, or client).
• The ``overlay topology’’ is the topology imposed
by the connectivity tables.
• Nodes communicate directly (usually using http)
with neighbors.
• Data / files are distributed (sometimes in pieces)
over all the network
• Need a directory protocol to find data.
• Need a transfer protocol to transfer data.
Client-Server vs P2p
Client-Server
P2P
Centralized & less robust. Efficiency and
reliability depend on server.
Decentralized & more robust. No
single point of failure.
Popular data = more congestion = slower.
Popular data = more distribution =
faster.
Centralized data repository: easier to
maintain, more accountability, better
security.
Server can control and record transactions
by clients.
One server can work with a wider variety of
client capabilities.
Server must be easy to find: Hence wellknown port numbers.
Decentralized data: more
redundancy, harder to maintain, less
accountability, less security.
Transactions are not recorded, harder
to trace.
Peers need to be fairly compatible.
Peers need to find each other.
Example: BitTorrent
• One large file (MB,GB) broken into many
pieces (64kB ..4MB), pieces broken into
blocks.
• Pieces are distributed to many peers. A block
is a unit of file transfer.
• Peers can run in leech mode
(downloading/client) or seed mode
(uploading/server).
• The tracker is a server of directory information
(where to find the peers and pieces you want).
BitTorrent Protocol Overview
1. Visit website to obtain a .torrent file for the song you
want. This file contains info about the pieces.
2. Open the file: This contacts a tracker who gives you a
(random) list of peers to connect to. The peers have
the pieces you want.
3. Handshake to open a connection to each peer.
4. File transfer: peers send you pieces (leech), or you
send complete files in pieces to peers (seed). Possibly
both at the same time.
5. Endgame: close connections to peers.
BitTorrent Protocol
2. Visit tracker to get a (random) list of peers
holding pieces you want.
• This imposes a random topology on the
network, connectivity depending on what
files users request. Difficult to model and
predict performance.
• Trackers do not remember peer lists; peers
do not reveal their own peer lists. Difficult to
trace connectivity.
BitTorrent Protocol
4. File transfer:
• Tit-for-tat philosophy: The more you give, the
more you get. The quality of your download
experience depends on your quality as an
uploader.
• After you have acquired an entire file, keep the
connections open so you can seed to new peers.
• You can also seed new content by contacting a
tracker, which will hook you up with new peers.
BitTorrent Protocol
3. File transfer protocol exchanges information
about peers.
• A is Interested. If B has something A does
not have, and wants.
• A is Choked. B may choke A and refuse to
send content. (Perhaps A is a seed, or B is
busy).
• A is Snubbed. If B is supposed to be sending
but has not communicated for 60 seconds.
P2P Problems
• Lots of malicious code (viruses, worms, Trojan
horses, back door…) in P2P sites.
• Can suck up all the bandwidth in a network.
Other network nodes experience slowdown.
– Many ISP’s limit download volume per user per
month. Some accused of squashing P2P packets.
– AC will throttle (slow down) a node that takes a
too high percentage of bandwidth. (AC prevents
uploading P2P packets from leaving campus.)
P2P and Copyright Infringement
• Sony v. Universal Studios: Sony is not liable if users use Betamax
video recorders to infringe.
• RIAA v. Napster: Shut down because the central server held illegal
content, and the site advertised and encouraged infringement.
• MGM v. Grokster: Non-infringing uses must be significant
compared to infringing ones. Grokster induced users to infringe.
• LimeWire: Users must agree not to use software for infringement
before downloading.
• BitTorrent: Has licenses for all content at the company website.
Trackers do not protect anonymity of clients.
• Other sites using BitTorrent code have been targets of legal action.
P2P Legal File Sharing
• Open source software
• Publications with Creative Commons license
• Weedshare files (can play 3 times for free
before deciding to buy)
• Copyright-free songs and recordings
• Exchanging data within a company or group.
• Estimate legal use growing by 400 percent per
year.