Peer 2 Peer Programming



Peer 2 Peer Programming

Greg Gamm

Department of Computer Science and Software Engineering

University of Wisconsin-Platteville

gammg@uwplatt.edu

Abstract

With the introduction of file-sharing networks in 1999, Napster paved the way for peer-2-peer programming. As the only available server centralized program became obsolete, programmers immediately began to develop more efficient means to which to share files. The instant launch of the decentralized network made its way to the mainstream public and changed the way files are shared forever. Peer-2-Peer programming introduces new applications, code, and techniques, along with issues regarding legality and security. Discussed here is the history of peer-2-peer programming, application handling, developmental topics, framework architecture, and real-life file sharing. Peer-2-Peer programming has been an important addition to recent Internet history, and will be enjoyed among many for years to come.

Description

Many different applications use file-sharing protocols as their software. Applications such as email, instant messenger engines, FTP software, shared folders, and remote access ability all use file-sharing ideas to promote certain utilities. This quickly led to the introduction of peer-to-peer file sharing in 1999 [4]. Peer-to-peer file sharing uses a peer-to-peer network, which is a specific set of rules and regulations that allow clients to transfer files through a connected network of personal computers [5]. Even though, peer-to-peer protocols began as a hybrid version of a client/server network, peer-to-peer adapted extensively to a pure decentralized system the very next year. Figure 1 shows the progression of using a server to reference files on open peer computers, to the customary server-less network used now.

Figure 1: Progress to server-less networks

History

First Generation

The design of simple file-transfer has been used before peer-to-peer was introduced, but it wasn’t until the beginning of Napster that file-transfer among home users became popular. Napster was created by Shawn Fanning in late 1999, while attending Northeastern University in Boston [5]. Napster was created as a ‘hybrid’ peer-to-peer network, meaning there was a centralized server typical of client/server system seen throughout the Internet. However, unlike other HTTP protocols, Napster only used the server to reference peer locations of files searched. The end user would then download files from the peer directly. With this setup, files were easy to manage and created very small queries times. Furthermore, Napster was the independent king of the market as no other applications were designed yet to run off the Napster network. While this monopoly benefited the company, the users suffered from long connection times and a single point of failure [4]. Napster was released with so much popularity among students seeking and sharing mp3 song titles, that the RIAA immediately searched the software for illegalities and copyright infringement. The RIAA filed a suit against Napster in December 1999, and successfully shut down the company in December of 2001. Nevertheless, this would not deter other creative minds from creating an alternative.

Second Generation

As Napster gained popularity from the RIAA trial, Justin Frankel of Nullsoft set out to counter the potential shutdown of Napster, and improve the peer-to-peer protocol in 2000 [6]. The first priority was to create a decentralized version that would be more difficult to shutdown. This was established with the popular Gnutella network that incorporated many improvements. First, the server-less network would be impossible to shutdown because there was no single point of failure, and allowed for many users to quickly download from other users connected through a collection of different nodes. Second, the network allowed for many applications running the same protocols to connect to the Gnutella network. This allowed for several free open-source programs that were available to download. Even though, this new network was the answer, file-sharers were looking for, there were many difficulties associated with the giant system. With the onset of flooding users from Napster and the density of files, the Gnutella network experienced very slow search times, along with congestion while downloading during peak hours [4]. In addition, the new nodes could often become disconnected from the network and allow for ‘floating islands.’ While many problems arose, the second generation peer-to-peer networks only required a few fixes to guarantee robustness.

Fixed Second Generation

In 2001, a year after the Gnutella network emerged in the market, Niklas Zennström and Janus Friis, introduced FastTrack, the peer-to-peer network that greatly improved on the second generation protocol [3]. Immediate connections to FastTrack instantaneously setup up equal, super nodes, which allowed for a greater number of users and files without sacrificing bandwidth, download, or connection times. This also granted FastTrack extreme scalability for future benefit. Along with these necessary enhancements, FastTrack also incorporated the ability to resume interrupted downloads, which was not available from Gnutella, and the ability to cut download times in fractions by using segments from multiple peers at once [5]. This made the FastTrack network the most popular peer-to-peer protocol available.

Third Generation

While FastTrack was enjoying stardom, outside programmers were looking to increase encpytion, in case it was to fall victim to the same fate Napster endured. The third generation peer-to-peer programs, or Anonymous P2P, incorporated strong encryption to prevent outsiders from traffic sniffing, which would forbid them to see valuable information about a host or peer [5]. To do this, the network would hide each client as a separate node by labeling everyone as a universal sender and receiver. In addition, only virtual IP addresses were used, so as not to distinguish individual computers. In spite of this, this type of network is not used mainstream yet, out of fear of government prohibition, and the complexity as to which the software must be built.

Fourth Generation

To conclude with peer-to-peer networks, a breed of fourth-generation protocol is available, but disregarded frequently due to changing technology. Streaming P2P is often referred to as fourth generation because peer-to-peer networks send media streams instead of files [3]. However, this innovative idea is quickly becoming obsolete as websites are turning to streaming media for broadcasting. For example, many major television networks air their programs on standard websites to accommodate the wave of Internet users.

Programming

There are two very common languages to implement a peer-to-peer application. Each language is similar in the methods it calls, and differs only in the language itself. Discussed here is the execution of both Python and Java programming languages.

Python

Python first initiates a Peer Module class that manages the overall operations of a single node. It contains a main loop that listens for incoming connections and creates separate threads to handle them. Figure 2 shows the traditional socket programming code that listens for a connection. First, a socket object is created with the option REUSEADDR to allow the port number to be immediately reusable after the socket is closed to allow for other peer connections [2]. Next, s.bind(port) is used to bind the socket to a port, where it will listen for open connections.

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

Figure 2: Listening for incoming connection

After listening, the Peer Module will attempt to connect to a single connection. In this loop, appropriate message handlers are used to send and receive data.

s = self.makeserversocket( self.serverport )

while 1:

clientsock, clientaddr = s.accept()

t = threading.Thread( target = self.__handlepeer, args = [clientsock] )

t.start()

Figure 3: Accepting connections with handlers

Registered handlers are used for various message types within the main loop for suitable incoming requests. A peer is initialized by supplying a port to listen for incoming requests, and will be placed in a list of known peer, which is also maintained in the Peer Module. The peers may be accessed using their identifiers or their sequential position in the list [2]. Besides a list of handlers for various method types, the node also stores a programmer-supplied function for deciding how to route messages, and can be set up to run stabilization operations at specific intervals [2].

When the Peer module receives an incoming connection request, it sets up a PeerConnection object, which encapsulates a socket connection to a peer node. Then the object reads in the message type and remainder of the message, and launches a separate thread to handle the data. The framework currently uses TCP/IP sockets for communication between nodes rather than UDP because TCP connections have proven reliability through ordered packets, congestion control, and packet tracking. A PeerConnection object provides methods that make it easy for the programmer to send and receive messages and acknowledgements. It ensures messages are encoded in the correct format and attempts to detect various error conditions [2].

Messages exchanged between nodes built on this framework are prefixed by a header composed of a 4-byte identifier for the type of the message and a 4-byte integer holding the size of the data in the message. The 4-byte message code can be viewed as a string, so the programmer may come up with appropriate strings of length 4 to identify the various types of messages exchanged in the system. When the main loop of a peer receives a message, it dispatches it to the appropriate handler based on the message type [2]. Figure 4 shows the process of connecting, starting the handler thread, sending data and acknowledgements, and finally messages.

[pic]

Figure 4: Peers sending and receiving data through message handler

Java

Java uses many of the same implementations that Python uses, but with different packages that contain connection methods.

An initial Peerbase package implements a PeerConnection class and PeerInfo class, along with Node and Handler classes. These classes are the primary class for all java-run peer-to-peer applications. The PeerConnection class encapsulates the socket connection much like the Peer Module does for Python. Similarly, a Stabilizer class is used to ensure network consistency, much like StartStabilizer() function in Python. Additionally, the PeerInfo maintains all the information related to the location of a peer node in the network along with a unique identifier.

A second PeerBase.Sample package is the backend for the GUI interface, which only includes two FileShare methods.

A third PeerBase.Socket package handles the simple socket programming associated with Java. It incorporates a NormalSocket class and SocketFactory class, along with SocketInterface for the Peerbase system.

Finally, the PeerBase.Util package sets up a simple router for sending and receiving data through the message handler. A SimpleRouter class will route the message by looking for the destination peer information in the list of peer nodes. The SimplePingStabilizer class will organize closed peers by sending ‘pings’ to every peer in the node’s list of peers, and will remove any that fail to connect, in the same way Python uses CheckLivePeers().

Legalities and Prevention

With the introduction of peer-to-peer applications in late 1999, many copyright issues were immediately raised. Most issues were raised by outside music talent that discovered their work was being distributed through the Internet via peer-to-peer applications without legal consent. While illegal copies of music and files violate copyright infringement laws, consumers and programmers were concerned with the fate of file-sharing programs. Laws provide that sharing public domain files are legal at the choice of the user, and free open-source programs are legal at the choice of the programmer. Therefore, peer-to-peer applications face no legal concerns, but it is the information provided over these networks that may continue to face discrepancy from rightful owners.

These owners have developed many methods to ensure the security of their work. Things to look for while using a peer-to-peer application are descriptions different from the actual file content. Also called ‘spoofing,’ this method will attempt to drive consumers away from certain files. Polluting has also become popular by including bad data packets within a download. Additionally, viruses have been seen throughout peer networks, as well, as identity attacks.

Conclusion

File-sharing systems have been around for a long time, and will be an indefinite part of the Internet future. While simple file-sharing can be seen with email attachments, ftp software, remote access, and instant message applications, peer-to-peer networks have proven popular, efficient, and very reliable. Even though, it is the choice of the end user to decide which material is legal to download, peer-to-peer programming was revolutionary in 1999 and includes many important features of programming languages that have been embraced rather than feared.

References

[1] File Sharing. Retrieved October 12, 2007 from

File_sharing

[2] Hamid, Nadeem Abdul. (2007, March 31). Peer-to-Peer Programming. Retrieved September 29, 2007 from

[3] McManus, Sean. (2003, August). A Short History of File Sharing. Retrieved October 02, 2007 from

[4] P2P Introduction and History. Retrieved October 02, 2007 from

[5] Peer-to-Peer. Retrieved October 11, 2007 from

Peer-to-peer

[6] File Sharing. Retrieved October 10, 2007 from

wiki/Peer-to-peer_file_sharing

[7] Saroui, Stefen, Gummadi, Krishna, & Gribble, Steven. (no date). A Measurement Study of Peer-to-Peer File Sharing Systems. Retrieved October 16, 2007 from

[8] Shirky, Clay. (2000, November, 27). What Is P2P…And What Isn’t? Retrieved September 27, 2007 from

whatisp2p.html

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download