peer-2-peer programming greg gamm senior seminar fall 2007
TRANSCRIPT
![Page 1: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/1.jpg)
Peer-2-Peer ProgrammingPeer-2-Peer Programming
Greg GammGreg Gamm
Senior Seminar Senior Seminar
Fall 2007Fall 2007
![Page 2: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/2.jpg)
What is a P2P NetworkWhat is a P2P Network
Specific set of rules and regulations Specific set of rules and regulations that allow clients to transfer files that allow clients to transfer files through connected network of through connected network of
personal computerspersonal computers
![Page 3: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/3.jpg)
P2P NetworkP2P Network
![Page 4: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/4.jpg)
Client/Server NetworkClient/Server Network
![Page 5: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/5.jpg)
LimeWire
![Page 6: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/6.jpg)
Morpheus
![Page 7: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/7.jpg)
Ares
![Page 8: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/8.jpg)
HistoryHistory
First Generation – Napster (1999)First Generation – Napster (1999) ‘‘Hybrid’ Hybrid’ Easy to control networkEasy to control network Easy to manage filesEasy to manage files Single point of failureSingle point of failure Single applicationSingle application Used centralized serverUsed centralized server Long connection times to serverLong connection times to server
![Page 9: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/9.jpg)
![Page 10: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/10.jpg)
NapsterNapster
Created by Shawn Fanning in JulyCreated by Shawn Fanning in July Immediately RIAA sued Napster for Immediately RIAA sued Napster for
copyright infringement copyright infringement Napster shutdown in December 2001Napster shutdown in December 2001 Gnutella was released in 2000 to counter Gnutella was released in 2000 to counter
shutdown of Napstershutdown of Napster By 2003, 14 programs were using Gnutella By 2003, 14 programs were using Gnutella
network alonenetwork alone Napster releases paid version in 2004Napster releases paid version in 2004
![Page 11: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/11.jpg)
History (cont.)History (cont.)
Second Generation – Gnutella (2000)Second Generation – Gnutella (2000) ‘‘Pure’Pure’ DecentralizedDecentralized Giant network of connected usersGiant network of connected users Many different applications on networkMany different applications on network Slow searchSlow search BottlenecksBottlenecks Unconnected ‘islandsUnconnected ‘islands’’ Uses a lot of bandwidthUses a lot of bandwidth
![Page 12: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/12.jpg)
![Page 13: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/13.jpg)
GnutellaGnutella
Created by Justin Frankel and Tom Pepper
Project dropped due to legal concerns In 2001, client LimeWire became open
source increasing popularity In 2002, FastTrack client, Morpheus,
dropped current network for Gnutella
![Page 14: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/14.jpg)
History (cont.)History (cont.)
‘‘Fixed’ Second Generation – Fixed’ Second Generation – FastTrack (2001)FastTrack (2001)
Equal Super nodesEqual Super nodes Faster searchesFaster searches Most popularMost popular ScalabilityScalability Download segments from multiple peersDownload segments from multiple peers Resume interrupted downloadsResume interrupted downloads
![Page 15: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/15.jpg)
FastTrackFastTrack
Created by Niklas Zennström and Janus Friis
Most popular for mp3 sharingAutomatically creates and uses
supernodes before creating list for future use
![Page 16: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/16.jpg)
History (cont.)History (cont.)
Third GenerationThird Generation – Anonymous P2PAnonymous P2PStrong encryption to resist traffic sniffingUses clients as nodes for routingEveryone acts as universal sender/receiverUses virtual IP addressesNot used mainstream yetCould ban all applications
![Page 17: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/17.jpg)
History (cont.)History (cont.)
Fourth Generation – Streams P2PFourth Generation – Streams P2PSends streams instead of filesMulticastTV, radio, movies
![Page 18: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/18.jpg)
Ideal P2P FeaturesIdeal P2P Features
Fully distributableFully distributable Totally Server lessTotally Server less Fully ScalableFully Scalable Globally SearchableGlobally Searchable Bandwidth EfficientBandwidth Efficient RobustRobust EncryptedEncrypted AnonymousAnonymous
![Page 19: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/19.jpg)
Peer ModulePeer Module
Manages overall operations of single nodeManages overall operations of single node Creates separate threads for different Creates separate threads for different
connectionsconnections Main Loop listens for:Main Loop listens for:
Incoming ConnectionsIncoming Connections Node IdentifiersNode Identifiers Host AddressHost Address
Will then set up PeerConnection ObjectWill then set up PeerConnection Object
![Page 20: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/20.jpg)
ListeningListening
def makeserversocket( self, port, backlog=5 ):
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
s.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
s.bind( ( '', port ) )
s.listen( backlog )
return s
![Page 21: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/21.jpg)
AcceptingAccepting
s = self.makeserversocket( self.serverport )
while 1:
clientsock, clientaddr = s.accept()
t = threading.Thread( target = self.__handlepeer, args = [clientsock] ) t.start()
![Page 22: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/22.jpg)
ConnectionConnection
host, port = clientsock.getpeername()
peerconn = BTPeerConnection( None, host, port, clientsock, debug=False )
![Page 23: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/23.jpg)
Functions of Peer NodesFunctions of Peer Nodes startstabilizer(): Runs the provided 'stabilizer' function in a
separate thread, activating it repeatedly after every delay seconds, until the shutdown flag of the Peer object is set.
addhandler(): Registers a handler function for the given message type with the Peer object. Only one handler function may be provided per message type. Message types do not have to be defined in advance of calling this method.
addrouter(): Registers a routing function with this peer. Read the section on routing above for details.
addpeer(): Adds a peer name and IP address/port mapping to the known list of peers.
getpeer(): Returns the (host,port) pair for the given peer name.
![Page 24: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/24.jpg)
Removepeer(): Removes the entry corresponding to the supplied peerid from the list of known pairs.
addpeerat(): Analogous to the prior three methods, except that they access direct (numeric) positions within the list of peers (as opposed to using the peerid as a hash key). These functions should not be used concurrently with the prior three.
getpeerids(): Return a list of all known peer ids.
numberofpeers():
maxpeersreached():
checklivepeers(): Attempt to connect and send a 'PING' message to all currently known peers to ensure that they are still alive. For any connections that fail, the corresponding entry is removed from the list. This method can be used as a simple 'stabilizer' function for a P2P protocol.
![Page 25: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/25.jpg)
PeerConnection ModulePeerConnection Module
Encapsulates a socket connected to a Encapsulates a socket connected to a peer nodepeer node
Uses TCP/IPUses TCP/IP Makes sending/receiving messages easierMakes sending/receiving messages easier Uses 9 different message handlersUses 9 different message handlers
![Page 26: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/26.jpg)
Message HandlingMessage Handling NAME: NAME: Requests a peer to reply with its "official" peer id. Requests a peer to reply with its "official" peer id.
LISTLIST: : Requests a peer to reply with the list of peers that it knows Requests a peer to reply with the list of peers that it knows
about. about.
JOIN pid host portJOIN pid host port: : Requests a peer to add the supplied host/port Requests a peer to add the supplied host/port
combination, associated with the node identified by pid, to its list of combination, associated with the node identified by pid, to its list of
known peers. known peers.
QUER return-pid key ttlQUER return-pid key ttl: : Queries a peer to see if the peer has any Queries a peer to see if the peer has any
record of a file name matching key. If so, send a RESP message record of a file name matching key. If so, send a RESP message
back to the node identified by return-pid; if not, propagate the query back to the node identified by return-pid; if not, propagate the query
to all known peers with a decreased ttl (time-to-live) value, unless ttl to all known peers with a decreased ttl (time-to-live) value, unless ttl
is already 0. is already 0.
![Page 27: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/27.jpg)
Message Handling (Cont.)Message Handling (Cont.) RESP file-name pidRESP file-name pid: : Notifies a peer that the node specified by pid Notifies a peer that the node specified by pid
has a file with the given name. has a file with the given name.
FGET file-nameFGET file-name: : Request a peer to reply with the contents of the Request a peer to reply with the contents of the
specified file. specified file.
QUIT pidQUIT pid: : Indicate to a peer that the node identified by pid wishes to Indicate to a peer that the node identified by pid wishes to
be unregistered from the P2P system. be unregistered from the P2P system.
REPL ...: REPL ...: Used to indicate an acknowledgement of the other Used to indicate an acknowledgement of the other
message types above or to send back results of a successful message types above or to send back results of a successful
request. request.
ERRO msgERRO msg: : Used to indicate an erroneous or unsuccessful Used to indicate an erroneous or unsuccessful
request.. request..
![Page 28: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/28.jpg)
Java ImplementationJava Implementation
PeerbasePeerbase.samplePeerbase.socketPeerbase.util
![Page 29: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/29.jpg)
PeerBase
Classes Interfaces
LoggerUtil Handler
Node Router
PeerConnection Stabilizer
PeerInfo
PeerMessage
![Page 30: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/30.jpg)
PeerBase.sample
Classes
Fileshareapp
Filesharenode
![Page 31: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/31.jpg)
PeerBase.socket
Classes Interfaces
Normalsocket Socket
Socketfactory
![Page 32: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/32.jpg)
PeerBase.util
Classes
SimplePingStabilizer
SimpleRouter
![Page 33: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/33.jpg)
Peer-2-Peer ArchitecturePeer-2-Peer Architecture
![Page 34: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/34.jpg)
![Page 35: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/35.jpg)
LegalitiesLegalities
Sharing public domain filesFree open-source applicationsSharing copyrighted songsSharing copyrighted software
Targeting FastTrack networksPopular, large files
![Page 36: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/36.jpg)
PreventionPrevention
SpoofingSpoofing PollutingPolluting VirusesViruses Denial of ServiceDenial of Service FilteringFiltering Identity attacksIdentity attacks
![Page 37: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/37.jpg)
Other file-sharing programsOther file-sharing programs
Shared folders within network Instant Messaging File TransferFTP SoftwareRemote Access SoftwareEmail
![Page 38: Peer-2-Peer Programming Greg Gamm Senior Seminar Fall 2007](https://reader030.vdocuments.us/reader030/viewer/2022032607/56649ec75503460f94bd3515/html5/thumbnails/38.jpg)
ReferencesReferences Shirky, Clay. (2000, November, 27). What Is P2P…And What Isn’t?
Retrieved September 27, 2007 from http://www.openp2p.com/pub/a/p2p/2000/11/24/shirky1-whatisp2p.html
Hamid, Nadeem Abdul. (2007, March 31). Peer-to-Peer Programming. Retrieved September 29, 2007 from http://cs.berry.edu/~nhamid/p2p/index.html
P2P Introduction and History. Retrieved October 02, 2007 from http://www.mac-p2p.com/p2p-history
McManus, Sean. (2003, August). A Short History of File Sharing. Retrieved October 02, 2007 from http://sean.co.uk/a/musicjournalism/var/historyoffilesharing.shtml