client-server vs p2p or, http vs bittorrent. client-server architecture server client
TRANSCRIPT
Client-Server vs P2P
or, HTTP vs Bittorrent
Client-Server Architecture
SERVER
client
client
client client
client
CLIENT SERVER
Many clients One server
Program starts and stops Program runs continuously
Initiates connection – one server at a time.
Responds – many clients at 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.1Accept-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 bytesContent-Type: text/html
<html><body> …the text of the page in html…
HTTPEight types of client request messages:
1. GET: request a file from server2. HEAD: just send me the headers that would be sent3. POST: send input to a server program that generates
pages4. PUT: upload a file to server 5. DELETE: delete a file on server6. TRACE: echo this request 7. OPTIONS: what services does server offer8. CONNECT: open a TCP-like connection
HTTP
Five categories of server response:
1xx information2xx success3xx redirection4xx client error5xx server error
Examples:
200 OK301 Moved Permanently403 Forbidden404 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
client
server
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 P2pClient-Server
Centralized & less robust. Efficiency and reliability depend on server.
Popular data = more congestion = slower.
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 well- known port numbers.
P2P
Decentralized & more robust. No single point of failure.
Popular data = more distribution = faster.
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.