Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 1
Chapter 7: P2P Application
development
Chapter goal:
? P2P application model
? P2P application design
? P2P example
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 2
Chapter 7: P2P Application
development
Chapter goal:
? P2P application model
? P2P application design
? P2P example
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 3
What is Peer-To-Peer? (1/3)
? P2P is a class of applications that:
? Takes advantage of resources – (storage, CPU,
etc,..) – available at the edges of the Internet.
? Because accessing these decentralized
resources means operating in an environment of
unstable connectivity and unpredictable IP
addresses, P2P nodes must operate outside the
DNS system and have significant or total
autonomy from central servers.
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 4
What is Peer-To-Peer? (2/3)
? P2P computing is:
? The sharing of computer resources and
services by direct exchange between
systems.
? Peer-to-peer computing takes advantage
of existing computing power and
networking connectivity, allowing
economical clients to leverage their
collective power to benefit the entire
enterprise.
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 5
What is Peer-To-Peer? (3/3)
? P2P computing is distributed
computing with the following
desirable properties:
? Resource Sharing
? Dual client/server role
? Decentralization/Autonomy
? Scalability
? Robustness/Self-Organization
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 6
A Brief History of P2P
? P2P is not a new technology
? It has existed since the Internet was taking form in the 1970s
? Recent changes in technology and the improved computing
capability of desktops have brought about P2P’s revival on a
larger scale
? P2P model-based application is confined to sharing files
? As a result of the increased demand for Web-base services,
users felt the need to control, exchange, and share resources
directly
? Meanwhile, in the late 1990s, PCs became increasingly powerful
in terms of speed and processing power
? Software developers realized that they could put server
software on individual PCs and initiate a direct two-way data
flow between two peers
? Led to the revival of P2P
? Interestingly, the IP routing infrastructure is still P2P
? 1999-2000, Napster shows the true potential of P2P
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 7
Application Architecture
? Client-server
? P2P
? Hybrid
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 8
Client-server architecture
server:
? always-on host
? permanent IP address
? server farms for scaling
clients:
? communicate with server
? may be intermittently
connected
? may have dynamic IP
addresses
? do not communicate directly
with each other
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 9
Pure P2P architecture
? no always on server
? arbitrary end systems
directly communicate
? peers are intermittently
connected and change IP
addresses
? example: Gnutella
Highly scalable
But difficult to manage
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 10
Hybrid of client-server and P2P
Napster
? File transfer P2P
? File search centralized:
? Peers register content at central server
? Peers query same central server to locate content
Instant messaging
? Chatting between two users is P2P
? Presence detection/location centralized:
? User registers its IP address with central server
when it comes online
? User contacts central server to find IP addresses of
buddies
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 11
From the Client/Server Model to P2P
? P2P-based models decrease the dependency on the
server
? Some P2P models do not requires servers
? No single point of failure problems in P2P
? Both models have advantages as well as
disadvantages
? Another advantage of P2P is that companies can
build collective computing powers
? P2P has shaken the boundaries of networking in
terms of sharing resources and costs incurred on
servers
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 12
Various P2P Models
? P2P models can be divided into the
following categories:
? Pure P2P
? P2P with a simple discovery server
? P2P with discovery and lookup servers
? P2P with discovery, lookup, and content
servers
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 13
Pure P2P Model
? Pure P2P model entirely
depends on computers (clients
in the C/S model)
? Peers find other connected
peers on the network
dynamiclly
? The entire communication
occurs among connected peers
without any assistance from a
server
? Pure P2P models provide almost
plug-and-play features for
working with the Internet
? The only problem with the pure
P2P model is finding peers
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 14
P2P with Simple Discovery Server
? Such P2P models do not actually involve a
server
? The role of the server is restricted to
providing the names of already connected
peers to the incoming peer
? The server only assists peers by
providing a list of connected peers
? Establishing connection and
communication still remains the job of
the peers
? This model increases the chances of
finding a larger number of peers
? To download a resource, a peer has to
approach each connected peer individually
? May need more time
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 15
P2P with a Discovery and Lookup
Server
? The server is used to provide the
list of connected peers along with
the resources available
? This model reduces the burden on
peers
? The server initiates communication
between two peers
? Once again, the two connected
peers establish communication,
and perform various activities
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 16
P2P with a Discovery, Lookup,
and Content Server
? The server dominates as in a
typical client/server architecture
? Peers are not permitted to
connect with each other directly
? All resources are stored in the
database of the server
? Major disadvantage of this model
is that the server slows down if
too many requests come up
simultaneously
? There is single point of failure in
server
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 17
Existing P2P Applications
? Napster
? Gnutella
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 18
Centralized: Napster
? Napster used centralized servers to keep a
catalog of available files. (3rd model)
1. User sends out
request Napster
searches central
database
Search request
2. The central server sends
back a list of available files
for download
Search response
Napster
server
user
user
user
user
3. Requesting user downloads
the file directly from another
Napster user computer
Download
from user
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 19
Centralized: pros and cons
? pros
? More effective, comprehensive searches
? Access is controlled
? cons
? System has single points of entry; one
fails could bring whole system down
? Broken links, out of date information.
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 20
Decentralized
? Every user acts as a client, a server or
both (servent).
? User connects to framework and becomes a
member of the community, allowing others
to connect through him/her
? Users speak directly to other users with no
intermediate or central authority
? Not one entity controls the information
that passes through the community
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 21
GNUTELLA
? Gnutella works more or less like a pure P2P model
? Gnutella is downloaded and installed on the
computer
? A message is sent to a computer, which passes it
to the other computers
? Gnutella is a client-based software that has a file-
sharing service and a mini search engine
? A machine which installed Gnutella can serve the
requests of other users, and can find the desired
content by sending requests
? Searching on Gnutella is almost like working with
any other search engine
? Gnutella facilitates to share all kinds of files
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 22
GNUTELLA
? Key terms:
? Servent: client+server
? Horizon: a group of servents, not entire Gnutella
? Firewall: a shield that protects users inside the Gnutella
? Broadcasting: messaging service between servents in
Gnutella
? Dropped Packets: packages of data that have been lost of
dropped across the Gnutella nerwork
? Push Request: whenever a client behind the firewall is
unable to download a file from a servent, the firewall send
a request to the servent for uploading the file. This is
called a push request.
? Port: default port number for Gnutella servents is 6346
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 23
Example: GNUTELLA
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 24
Example: GNUTELLA
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 25
Example: GNUTELLA
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 26
Example: GNUTELLA
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 27
Napster vs GNUTELLA
? Napster +
? Gives material to its customer in the form of MP3 music
files all across the continents. This is the key reason for
its popularity.
? Provides a protective layer to its user due to the
involvement of a server. Fully authenticated data travels
on Napster network.
? User friendly and easy to download on your computer
? Napster -
? Server presence slows down or brings services to a halt in
case of a technical problem
? Server can easily become the bottleneck
? Works for only MP3 files
? Facing copyright lawyers and the music industry
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 28
Napster vs GNUTELLA
? Gnutella +
? Truly decentralized network (pure P2P)
? No single point of failure
? Share all kinds of files
? Has a provision for redirecting the request, and
supports HTTP protocol
? Gnutella -
? No provision for stopping the flood of requests
? Absence of the server makes user feel unsafe
? Encounters many bugs in its application, such as
lost packets
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 29
Working of Various P2P Models
? The way an application works matters a lot
? A typical P2P-based application can be based
on any of the models
? Some of the key features every model P2P
application should have:
? Tracing out other peers
? Querying peers for required content
? Sharing content/resources with other peers
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 30
Tracing out Other Peers
? Essential feature of every P2P-based application
? Discovering other peers in pure P2P-based model
? Peers find others dynamically and communicate between
themselves directly
? Affects security
? Discovering peers in P2P with simple discovery
server-based model
? The database of the server stores the information related
to all registered users
? Any query for searching a particular peer is processed by
the server
? Enhanced security
? Availability of a large number of peers
? Single point of failure of server
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 31
Tracing out Other Peers
? Discovering peers in P2P with discovery and lookup
server-based model
? Server provides a list of services as well as a list of peers
? All users are required to notify their presence to the
server while they log in
? The server not only discovers other peers but also returns
vital information regarding all logged in peers
? Reduces time consumption
? Discovering peers in P2P with discovery, lookup, and
content server-based model
? This model traces out peers in response to a request much
like the others
? The server maintains all the vital information and also
furnishes the content to requesting peers
? Each peer is registered with the server
? The dependency on the server is therefore very high
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 32
Querying Peers for Required
Content
? The user initiates the request for content
? Any application can make a request for
content to a peer once a peer has been
traced and located
? Only a peer can provide the content
required
? A peer might not entertain the query the
user presents or might not have the
information the user seeks
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 33
Querying Peers for Required
Content
? Querying peers for content in pure P2P-based model
? A peer passes its request for content to another peer
(host peer)
? If the host peer contains the required information, it
satisfies the query
? This model provides an interchangeability of role of peers
(client or server)
? Querying peers for content in P2P with simple
discovery server-based model
? This model uses a server to provide the list of logged-in
peers to a requesting peer
? A requesting peer always gets a large number of peers of
interest so it can communicate with them
? The requesting peer has to contact each peer in the list by
itself and individually
? Processing time is large
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 34
Querying Peers for Required
Content
? Querying peers for content in P2P with discovery
and lookup server-based model
? The server not only maintains a list of registered users,
but also process queries for the content
? The requesting peer passes its query to the server
? The searching path of a peer seeking content is thereby
shortened
? Querying peers for content in P2P with discovery,
lookup, and content server-based model
? The role of the server is the most significant
? The server not only processes the request but also
procures the result and returns it back
? This method protects information from invasion
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 35
Sharing Contents with other
Peers
? Sharing resources with peers in pure P2P-based
model
? A peer sends a request for content to another peer
? Peer is the service provider which has shared resources
? It is the peer that has the requested information that
opens the connection
? Sharing resources with peers in P2P with simple
discovery server-based model
? A peer sends a request for content to the server
? The server returns the list of all connected peers
? The requesting peer approaches peers individually from
this list for required content
? Once the requesting peer locates the content required, the
server connect them
? The requesting peer downloads the required content from
the network
? Uploading content cannot occur in this model
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 36
Sharing Contents with other
Peers
? Sharing resources with peers in P2P with discovery
and lookup server-based model
? The server doesn’t just furnish the list of peers
? The server carries out the search
? The requesting peer downloads the requested content
from the network stream
? Uploading is also possible with this method
? Sharing resources with peers in P2P with discovery,
lookup, and content server-based model
? This P2P model is almost like the C/S computing
architecture
? All information is housed in the server
? The server processes the request, procures the result,
and returns back
? Both uploading and downloading capable
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 37
Searching for Shared
Resources
? Important to P2P applications
? Two distinct categories:
? Server-side searching
? A server acts as the reservoir of all
information
? The greatest advantage is that the user need
not worry about the location of a file
? Connection may be made of only to peers that
possess required content
? May send an avalanche of requests and may
slow down server’s services
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 38
Searching for Shared
Resources
? Two distinct categories:
? Client-side searching
? Comes into play when peers are connected
with each other and are communicating
without the involvement of any other machine
or server
? Client-side searching is limited to the user’s
machine
? Faster than server-side searching
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 39
Searching Technique in P2P
Models
? Searching for content in pure P2P-based model
? Client-side searching
? Searching for content in P2P with simple discovery
server-based model
? Client-side searching also
? Searching for content in P2P with discovery and
lookup server-based model
? Both server-side and client-side searching can be adopted
? Searching for content in P2P with discovery, lookup,
and content server-based model
? Only server-side searching can be adopted
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 40
Chapter 7: P2P Application
development
Chapter goal:
? P2P application model
? P2P application design
? P2P example
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 41
Case P2P Application
? File sharing takes place between two
connected peers regardless of file
extensions
? Three components:
? Listener: Handles requests of incoming
peer connections
? Server: Maintains the database required
for the application
? Browser: Shows results to the peer
through a user-friendly interface and
acts as an interactive layer for the client
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 42
Structure of the P2P Application
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 43
Listener to Server Communication
Using ASP
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 44
Browser to Server Using ASP
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 45
Listener to Browser Using ASP
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 46
XML Request and Response
DesignSpecifications
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 47
Server Design-DB
Peer Table
Share
Table
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 48
Server Design-
login.asp
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 49
Server Design-logout.asp
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 50
Server Design-userlist.asp
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 51
Server Design-
search.asp
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 52
Listener Design-1
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 53
Listener
Design-2
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 54
Browser
Design-1
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 55
Browser
Design-2
Download Process
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 56
Browser
Design-3
Upload Process
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 57
Browser Design-4
Global Searching
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 58
Chapter 7: P2P Application
development
Chapter goal:
? P2P application model
? P2P application design
? P2P example
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 59
Client: A Comprehensive View
The peer to peer login window
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 60
Client: A Comprehensive View
Share Dialog allows the user to
share files of folders
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 61
Client: A Comprehensive View
Select the file you want to share
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 62
Client: A Comprehensive View
Share dialog to let the user share
his files or folders
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 63
Client: A Comprehensive View
Select the folder you want to
share
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 64
Client: A Comprehensive View
Connected peers get listed in this
window
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 65
Client: A Comprehensive View
One can specify the search
criteria in this window
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 66
Client: A Comprehensive View
The number of times of
information
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 67
Client: A Comprehensive View
Resources shared by the peer you are
connected with are shown in this window
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 68
Client: A Comprehensive View
File dialog to specify the location and the
name where downloaded file to save
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 69
Client: A Comprehensive View
File dialog to select the file to upload
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 70
Client: A Comprehensive View
Searching dialog
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 71
Client: A Comprehensive View
Listener logout
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 72
Example Application Source
Codes
? Coded by Java
? Downloadable
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 73
Summary
? P2P application model
? P2P application design
? P2P example
Wyv9
?Dy ù?
C Network Application Development
P2P Application Development 74
End of This Course!
Thanks for your cooperation!