Peer to Peer


Published on

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Peer to Peer

  1. 1. Peer to Peer Systems
  2. 2. P2P: Peer-to-Peer Networks <ul><li>Peer-to-Peer Networks are considered by many to be the next &quot; killer application &quot; for the Internet. </li></ul><ul><li>There are several important technology challenges and applications that vary from the sublime to the ridiculous. </li></ul><ul><li>Our goal is not to espouse any particular approach but rather to bring this area to the students' attention and suggest some emerging research areas and opportunities. </li></ul><ul><li>Like most such over-hyped concepts, P2P is rather loosely defined and covers a set of rather disparate ideas. </li></ul><ul><li>Perhaps the only common theme is a client oriented view of the world and P2P can be thought of as Power to the People . </li></ul><ul><ul><li>Clients do most of the work, communicate with each other and really are the most important computers; </li></ul></ul><ul><ul><li>Servers may be around and even essential but remain subservient to the clients. </li></ul></ul><ul><li>We will first discuss the most well-known and popular P2P system, Napster and then try to be a little more systematic in covering the other players in this field. </li></ul>
  3. 3. P2P References <ul><li>General discussions on P2P technology can be found at two good web sites; </li></ul><ul><ul><li> from the O'Reilly group and </li></ul></ul><ul><ul><li> as an industry working group originally initiated by Intel. </li></ul></ul><ul><li>There is a remarkable book Peer-to-Peer: Harnessing the Power of Disruptive Technologies by Andrew Oram, Nelson Minar, Clay Shirky, Tim O'Reilly (March 15, 2001, O'Reilly & Associates; ISBN: 059600110X) ; </li></ul><ul><ul><li>This has several articles describing key systems and key services </li></ul></ul><ul><li>Disruptive Technology (DT): One that does something (perhaps a new capability) far better than previous best practice; it does old things less well at the start but gradually catches up. </li></ul><ul><ul><li>The Web itself is a DT: hyperlinks empower new ways of doing things. Browsers are (initially) clumsier user interface than traditional GUI’s. </li></ul></ul>
  4. 4. Napster I <ul><li>Shawn Fanning developed the original Napster application and service in January 1999 while a freshman at Northeastern University. </li></ul><ul><li>Napster allowed any client to advertise any MP3 files stored on its disk and choose to download MP3 files from other clients connected to the Napster server network. </li></ul><ul><li>It is said that Shawn was taking a computer-programming course at Northeastern , but had to buy a programming book to build Napster …….. </li></ul><ul><li>Like most good ideas, Napster was designed to solve a real need - in this case to allow Shawn, a musician himself, to share his music with his friends on campus. </li></ul>
  5. 5. Napster II <ul><li>The system became staggeringly popular. Quoting a legal opinion from Summer 2000: approximately 10,000 music files were shared per second using Napster , and every second more than 100 users attempted to connect to the system. 75 million Napster users were expected by the end of 2000. </li></ul><ul><ul><li>Legal debate increased instantaneous use, but service currently suspended. Relaunch planned, but service will no longer be free. </li></ul></ul><ul><li>Napster had (will have?) some other typical P2P services: Instant Messenger, chat rooms, &quot;Buddy lists&quot; and information about &quot; hot music &quot; (music portal) but the key feature is the ability to share files between any Internet-connected, consenting clients. </li></ul><ul><li>This is roughly the Web version of NFS (Network File System) familiar from traditional computing environments. </li></ul>
  6. 6. Napster III: Key Features <ul><li>MP3 files are important as a popular digital encoding for audio files. </li></ul><ul><ul><li>It is straightforward to &quot;rip&quot; files off an audio CD and look up key meta-data (Artist, Title etc.) in a CDDB database on the Web ( </li></ul></ul><ul><ul><li>Length of songs uniquely identifies CD’s </li></ul></ul><ul><li>The audio and meta-data can be stored and accessed as a single unit. </li></ul><ul><ul><li>The added value of meta-data for files lies at the heart of the Semantic Web — a vision from the W3C Web Consortium related to P2P. </li></ul></ul><ul><li>Although a server is used to establish the initial connection, the file transfer is done efficiently - directly from client to client ; a P2P service. </li></ul><ul><ul><li>This is an improvement over most NFS systems where use of distributed files is not easy (except possibly for the originator who named file) as usually all you have is a cryptic filename. </li></ul></ul>
  7. 7. Napster IV <ul><li>Now Napster happens to be controversial as the audio files are typically copyrighted but the two key concepts </li></ul><ul><ul><li>Web-based NFS (content sharing), and </li></ul></ul><ul><ul><li>meta-data enhanced files </li></ul></ul><ul><li>are fundamental and broadly applicable. </li></ul><ul><li>The legal debate continues. However the legal problems are a feature of the particular content; the technology is lasting and in my opinion uncontroversial and one implementation of an essential P2P capability. </li></ul>
  8. 8. Napster Like Services I <ul><li>There some 200 available Napster clones to support this area </li></ul><ul><li>Currently the most popular is Imesh [], which has some 2 million users and can share any type of file. </li></ul><ul><li>Some of the best known file sharing systems are </li></ul><ul><ul><li>MojoNation [], </li></ul></ul><ul><ul><li>Freenet [] , </li></ul></ul><ul><ul><li>Gnutella [] </li></ul></ul><ul><li>These three are not server based like Napster but rather support waves of software agents expressing resource availability and interest propagating among an informal dynamic networks of peers. </li></ul>
  9. 9. Napster Like Services II <ul><li>There are many interesting ideas being explored; </li></ul><ul><ul><li>Breaking shared files into many parts to both increase bandwidth (parallel I/O) and increase security of content as no one site can access files without cooperation from its peers. This type of technology is controversial as it makes censorship very hard. </li></ul></ul><ul><ul><li>MojoNation has a load balancing and scheduling algorithm in the form of micro payments to reward those who contribute most to the community of peers. </li></ul></ul><ul><ul><li>Gnutella — which is a family of related products — is usually described as a P2P search engine as its interface is nearer that of a search engine than a Web file system. </li></ul></ul><ul><li>So far we have identified some basic P2P services ; file registration, access and search. </li></ul><ul><li>We can categorize other P2P systems in various ways; we will choose distributed computing , collaboration , and core technologies . </li></ul>
  10. 10. Distributed Computing
  11. 11. P2P for Distributed Computing or Web Computing I <ul><li>The distributed computing P2P applications are highlighted by </li></ul><ul><ul><li>the use of millions of Internet clients to analyze data looking for extraterrestrial life ( SETI@home ), and </li></ul></ul><ul><ul><li>the newer project examining the folding of proteins ( Folding@home ). </li></ul></ul><ul><li>These are building distributed computing solutions for a special class of applications: </li></ul><ul><ul><li>Those that can be divided into a huge number of essentially independent computations, and a central server system doles out separate work chunks to each participating client. </li></ul></ul><ul><ul><li>In the parallel computing community, these problems are called &quot; pleasingly or embarrassingly parallel &quot;. </li></ul></ul><ul><li>This approach is included in the P2P category because the computing is Peer based even though it does not have the &quot;Peer only communication&quot; characteristic of all aspects of Gnutella and Napster for information transfer. </li></ul><ul><li>SETI@home and Folding@home are elegantly implemented as screen savers that you download. </li></ul>
  12. 12. P2P for Distributed Computing or Web Computing II <ul><li>Other projects of this type include: </li></ul><ul><ul><li>United Devices ( based on SETI@home), </li></ul></ul><ul><ul><li>Avaki ( based on well known Legion project from the University of Virginia), </li></ul></ul><ul><ul><li>Parabon computation (, </li></ul></ul><ul><ul><li>Condor (from Wisconsin and </li></ul></ul><ul><ul><li>Entropia ( </li></ul></ul><ul><li>Other applications for this type of system include financial modeling, bio-informatics, measurement of web server performance and the scheduling of different jobs to use idle time on a network of workstations. </li></ul><ul><ul><li>Ian Foster has given a more detailed review of these activities at and related them to computational grids ( ). </li></ul></ul>
  13. 13. Parabon <ul><li>Pure Java model </li></ul><ul><li>Ensures Security </li></ul>
  14. 14. Entropia Financial Modeling I
  15. 15. Entropia Financial Modeling II <ul><li>Each basic financial instrument can be calculated independently </li></ul><ul><li>Central Server interprets the total simulation </li></ul><ul><li>Make Money or Learn what causes market swings or …. </li></ul>
  16. 16. Drug Structure Simulations
  17. 17. United Devices also does Drug Simulation <ul><li>Parameter Study : do billions of simulations – each with different parameters </li></ul><ul><li>Search Engine like interface to simulation </li></ul><ul><li>Works as each calculation fits in a PC – a detailed molecular model would usually not do this </li></ul>
  18. 18. Performance of Entropia Network (Vertical Axis should be Gigaflops??)
  19. 19. Collaboration
  20. 20. Collaboration with P2P Systems I <ul><li>Collaborative systems form a rather different type of P2P network. </li></ul><ul><li>We have a community of clients working together and sharing different Internet resources. </li></ul><ul><li>Probably the Instant Messenger (IM) or various forms of chat room are the most used capability in this arena. </li></ul><ul><ul><li>We have a set of clients exchanging messages with each other. </li></ul></ul><ul><ul><li>Unlike the file-sharing case, one typically needs to multicast the same message to multiple clients at the same time and the best architecture is still active research. </li></ul></ul><ul><ul><li>In fact it is area where your fearless presenter works (See the Garnet system at ). </li></ul></ul><ul><li>Groove Networks ( ) founded by the creator of Lotus Notes is the best-known P2P collaboration project and uses relay servers to implement the P2P multi-cast. </li></ul>
  21. 21. Peer to Peer P2P “Illusion” among collaborating clients For Napster like Services or Collaboration Server Server Server Server Server Server
  22. 22. Collaboration with P2P Systems II <ul><li>Collaboration systems form an &quot; illusion of P2P &quot; using some static or dynamic suite of servers to optimally route messages. </li></ul><ul><ul><li>Napster does same to “match” providers and consumers of MP3 files. However for Napster servers are not used in MP3 file transfer </li></ul></ul><ul><ul><li>Collaboration has different optimizations as “data-transfer” involves in general many not just 2 clients </li></ul></ul><ul><li>When the clients are scattered around the world , the relaying server(s) would perhaps be in the &quot;middle of the Web; when a group of clients are clustered together then their relay would be &quot; on the edge ” and perhaps dynamically created on a peer machine of this cluster. </li></ul><ul><li>Typically one also needs some sort of server to establish the initial session and manage the permanent state. So this type of P2P application gives a rich mix of true peers and servers. </li></ul><ul><li>Collaboration systems offer the IM/Chat/email capabilities but also other shared resources like white boards, shared documents and audio-video conferencing. </li></ul>
  23. 23. Collaboration with P2P Systems III <ul><li>All forms of collaboration are supported by some form of messaging with the message (typically called an event) carrying a variety of content including </li></ul><ul><ul><li>text of the IM, pixel changes to record a changed shared display (frame buffer) or digital audio packets. </li></ul></ul><ul><li>XML is the natural way of encoding such messages and the open source Instant Messenger Jabber ( ) provides a clean framework of this kind. </li></ul><ul><li>Several Napster-like systems have based their service on IM technology; </li></ul><ul><ul><li>Aimster , is one of the best known. </li></ul></ul><ul><li>OpenCola ( ) has a general XML framework to support P2P systems. </li></ul>
  24. 24. Core Technologies: JXTA
  25. 25. Core P2P technologies and services <ul><li>These include P2P management, messaging, security, client grouping as well as the file or more generally object registration, discovery and access capabilities already discussed for Napster. </li></ul><ul><li>Sun Microsystems has two somewhat related technology projects. </li></ul><ul><ul><li>JXTA (from “juxtaposition”) is a new project from Bill Joy aiming at core P2P capabilities including grouping of the peers and security. </li></ul></ul><ul><ul><li>Perhaps more tenuously, the Jini project ( jini / ) has a simple model for dynamic self defining objects that act something like Napster peers and register with distributed servers, allowing other peers to discover and access them. </li></ul></ul><ul><li>Above we already touched on the need for messaging services to implement collaborative P2P systems. </li></ul><ul><ul><li>There is also a Java message service JMS ( ) providing the core publish/subscribe mechanism on which most P2P services are built. </li></ul></ul><ul><ul><li>This needs some upgrading to join the P2P revolution; Sun should add XML, a more dynamic matching paradigm (of collaborating peers) and support for relay servers. </li></ul></ul>
  26. 26. JXTA Background <ul><li>Project JXTA was launched by Sun almost exactly a year ago. </li></ul><ul><ul><li>Its ambitious goal is to define a set of basic abstractions and services to support peer-to-peer computing. </li></ul></ul><ul><li>JXTA is carefully positioned as an open source project, operationally modelled on the Apache project. </li></ul><ul><ul><li>This is different from Jini or Java, for example, where the key specifications are controlled by Sun. </li></ul></ul><ul><li>Currently the core specification of JXTA is a set of XML message formats (so-called “protocols”) that should allow any device on the net (cell phone, PDA, PC, server) to participate in P2P applications. </li></ul><ul><li>The specification is supposed to be language and platform independent , although the only implementations available at the moment are for the Java platform. </li></ul>
  27. 27. JXTA Philosophy <ul><li>Keep it familiar: where practical, use stuff that's standard and has worked before </li></ul><ul><li>Leverage experts: engage a variety of experts early and often </li></ul><ul><li>Encourage open development: the design, the specs, the code, and whatever the result is. </li></ul><ul><li>Vision for the software </li></ul><ul><ul><li>promote communication (not isolation) among applications </li></ul></ul><ul><ul><li>develop administrative commands for peers, peer groups, and groups of peers in the spirit of UNIX pipes and shells </li></ul></ul><ul><ul><li>keep the core small and elegant: make an architectural distinction between core mechanisms and optional policies </li></ul></ul><ul><ul><li>support multiple platforms and languages, micro devices to servers </li></ul></ul><ul><ul><li>address security from the beginning. </li></ul></ul>
  28. 28. Basic JXTA Definitions <ul><li>Peer </li></ul><ul><ul><li>A Single participant in a JXTA network, e.g. your computer. </li></ul></ul><ul><li>Group </li></ul><ul><ul><li>A collection of peers. Peers join a group to participate in particular applications. </li></ul></ul><ul><li>Service </li></ul><ul><ul><li>Some capability running in a peer group. The service may run in all peers, of just a subset in the group. </li></ul></ul><ul><li>Pipe </li></ul><ul><ul><li>An abstraction of network connections. Pipes have individual identities and are not permanently bound to any single peer, or even peer group. </li></ul></ul><ul><li>Advertisement </li></ul><ul><ul><li>A description of a pipe or service (special kinds of advertisement also describe peers and peer groups). Essential to the JXTA discovery mechanism. </li></ul></ul><ul><li>Rendezvous Peer </li></ul><ul><ul><li>A special peer that caches advertisements and makes them available to other peers on the network. Essential in general discovery, and used as initial points of contact by newly booted peers. </li></ul></ul>
  29. 29. JXTA Architecture (From the whitepaper: Project JXTA: An Open, Innovative Collaboration )
  30. 30. The JXTA Virtual Network <ul><li>The Internet has become fragmented by Firewalls and NAT. One goal of the JXTA Virtual Network is to provide transparent mechanisms to circumvent Firewalls, thus virtually restoring the original flat topology of the Internet </li></ul><ul><ul><li>Not quite obvious whether this will please everybody! JXTA will have to fulfil promises of inherent security. . . </li></ul></ul><ul><li>In any case, routing (including routing around firewalls) is an important component of the JXTA network. </li></ul><ul><li>Another important component is rendezvous peers . </li></ul><ul><ul><li>These are peers that cache advertisements on the network, facilitating efficient publishing and discovery. </li></ul></ul><ul><ul><li>A newly booted peer may start out with a short list of known rendezvous points, then build up a knowledge of other rendezvous peers dynamically. </li></ul></ul>
  31. 31. JXTA Year One <ul><li>The JXTA anniversary page </li></ul><ul><ul><li> </li></ul></ul><ul><li>includes a good interview with Bill Joy and Mike Clary about the current status and future of JXTA. </li></ul>
  32. 32. JXTA Search I <ul><li>JXTA Search is a meta-search capability </li></ul><ul><li>It allows multiple “providers” to register and respond to queries </li></ul><ul><li>There is an XML query language which is mapped into that of each provider </li></ul>
  33. 33. JXTA Search II <ul><li><?xml version=’1.0’?> </li></ul><ul><li><request id=&quot;1C8DAC3036A811D584BEC2C63&quot; </li></ul><ul><li>query-space =&quot;; </li></ul><ul><li>xmlns =&quot;; </li></ul><ul><li>xmlns:b =&quot;; > </li></ul><ul><li><b:query> </li></ul><ul><li><b:author> </li></ul><ul><li><quote> Bill Joy </quote> </li></ul><ul><li></b:author> </li></ul><ul><li><b:title> </li></ul><ul><li>Java </li></ul><ul><li></b:title> </li></ul><ul><li></b:query> </li></ul><ul><li></request> </li></ul>
  34. 34. JXTA Search III <ul><li><?xml version=’1.0’?> </li></ul><ul><li><responses xmlns =&quot;; </li></ul><ul><li>xmlns:b =&quot;; </li></ul><ul><li>query-uuid =&quot;1C8DAC3036A811D584BCC2C23&quot;> </li></ul><ul><li><response> </li></ul><ul><li><data> </li></ul><ul><li><b:author> Bill Joy, Guy Steel, James Gosling, Gilad Bracha </b:author> </li></ul><ul><li><b:URL> </b:URL> </li></ul><ul><li><b:title> The Java Language Specification, Second Edition (The Java Series) </b:title> </li></ul><ul><li><b:price> $39.95 </b:price> </li></ul><ul><li><b:abstract> A definitive technical reference for the Java programming language, written by the inventors of the technology. </b:abstract> </li></ul><ul><li></data> </li></ul><ul><li></response> </responses> </li></ul>
  35. 35. JXTA Search IV <ul><li>As an example consider a distributed digital library consisting of a variety of material </li></ul><ul><li>Google with its new API provides best way of searching the material presented as web pages and links </li></ul><ul><li>Oracle 9i provides best database (including XML) search capability </li></ul><ul><li>But it can’t search my laptop which is not in “central domain” </li></ul><ul><ul><li>Here GOXML or another Google or Oracle instance is best </li></ul></ul><ul><ul><li>In fact grep is pretty good </li></ul></ul><ul><li>JXTA search integrates these differene capabilities </li></ul><ul><li>This is JXTA in the middle tier </li></ul>
  36. 36. Computing Models I <ul><li>In the beginning, we had computers which did everything with input from a paper tape or something … </li></ul><ul><li>Then we had client-server with usually most of the work done on the server </li></ul><ul><ul><ul><li>The initial Web was roughly this model </li></ul></ul></ul><ul><li>Then we had multi-tier architectures where we could divide </li></ul><ul><ul><li>Client: user interface </li></ul></ul><ul><ul><li>Portal: Construction of user interface </li></ul></ul><ul><ul><li>Middle Tier: Decision and Control (Broker) </li></ul></ul><ul><ul><li>Back-end: Do the work </li></ul></ul><ul><li>Then we had Napster and Entropia, SETI@home .. with </li></ul><ul><ul><li>Clients doing the work </li></ul></ul><ul><ul><li>Servers providing control function </li></ul></ul>
  37. 37. Computing Models II <ul><li>Then we had Gnutella and JXTA where everything does everything </li></ul><ul><ul><li>As Clients dominate, they are most interesting? </li></ul></ul><ul><li>Then we had the Service model (Web Services, OGSA – Open Grid Service Architecture) </li></ul><ul><ul><li>We have a “query” “decision” “portal” “do the work” “control” services </li></ul></ul><ul><ul><li>We put the services where they are most effective </li></ul></ul><ul><ul><li>You don’t run or set-up a computer center; you operate computing and information services </li></ul></ul><ul><li>Using JXTA Search in middle tier is an example of this </li></ul><ul><li>This is what I call a Peer-to-peer Grid …… </li></ul>
  38. 38. Marriages made in Heaven? <ul><li>Java and XML … </li></ul><ul><li>Web Services and P2P (JXTA) </li></ul><ul><li>Web Services are a message based service model with a rather clumsy ill thought of registration mechanism (UDDI) to match consumers and providers </li></ul><ul><li>JXTA (Gnutella) is a message based registration and subscription model which is agnostic as to services advertised and matched </li></ul><ul><li>So JXTA naturally provides the dynamic mechanisms to match consumers and providers of Web Services </li></ul><ul><ul><li>Need to allow JXTA to access providers using centralized registration services for relatively static services </li></ul></ul>
  39. 39. Broker Network Resource Broker Broker Broker Broker Broker Broker Software multicast (P2P) Community (P2P) Community For message/events service (P2P) Community (P2P) Community Data base
  40. 40. Event Web Service <ul><li>Filter is mapping to PDA or slow communication channel (universal access) – see our PDA adaptor </li></ul><ul><li>Workflow natural as all messages “intercepted” by Event Web Service </li></ul><ul><li>Routing illustrated by JXTA </li></ul><ul><li>Destination-Source matching illustrated by JMS </li></ul><ul><ul><li>Publish-subscribe </li></ul></ul>Web Service 1 (Virtual) Queue Web Service 2 Destination Source Matching Filter Routing workflow WSDL Ports WSDL Ports Broker
  41. 41. Messaging/Events as a Web Service <ul><li>We can implement messaging subsystem (between WSDL resources) with either direct messages or by a queued system where you publish messages to queues and subscribe as receiver to particular queues </li></ul><ul><ul><li>events are time stamped messages </li></ul></ul><ul><li>There are many different publish/subscribe models </li></ul><ul><ul><li>JMS is a classic Grid-like cluster of central servers </li></ul></ul><ul><ul><li>JXTA is a very dynamic Peer to Peer model where pipes are queues and topics (metadata) are service advertisements </li></ul></ul><ul><li>JXTA naturally supports local dynamic structure but </li></ul><ul><li>JMS is long distance “carrier” between JXTA peers and supports global relatively static resources </li></ul>
  42. 42. Narada P2P Grid Event Service <ul><li> </li></ul><ul><li>Is a network of event brokers which can reliably deliver XML specified events with UDP or TCP/IP </li></ul><ul><li>Using openJMS selection module, becomes a distributed or conventional Java Message Service </li></ul><ul><li>Linking selected JXTA rendezvous’s, it also supports multiple JXTA communities </li></ul><ul><li>Think of JXTA JMS and Narada as different bindings for a event/messaging web service </li></ul>
  43. 43. The JXTA Shell
  44. 44. The JXTA Shell <ul><li>The JXTA shell is a command-line interface to basic JXTA operations on peer groups, pipes, services and so on. </li></ul><ul><ul><li>We present shell examples in some detail here, because this allows us to explore many of the basic features of JXTA (peer groups, pipes, advertisements, etc), without actually having to read or write code, or discuss formal specs. </li></ul></ul><ul><li>The relationship between the JXTA shell and the JXTA Platform is something like that between UNIX shells and the UNIX system calls . </li></ul><ul><ul><li>The JXTA shell has a similar syntax of redirection and pipelining, which allows commands and applications to be composed together through JXTA pipes. </li></ul></ul><ul><li>However. . . </li></ul>
  45. 45. . . . Notes for the Unwary! <ul><li>The current JXTA shell does not really provide a high-level scripting language like the UNIX shells. </li></ul><ul><ul><li>No built-in control constructs, for example. </li></ul></ul><ul><li>It has so-called environment variables , but their values are opaque references to underlying JXTA objects. </li></ul><ul><ul><li>Many JXTA shell commands require arguments to be names of environment variables referring to the right type of object —very different to UNIX, where arguments are just text strings. </li></ul></ul><ul><ul><li>There is no $ prefix to extract values within the shell—only commands can act on values. </li></ul></ul><ul><li>Essentially any JXTA command might modify the environment variables of the shell that invokes it (very different to UNIX!): </li></ul><ul><ul><li>Some JXTA shell commands define environment variables whose names are passed as arguments. . . </li></ul></ul><ul><ul><li>. . .others just add variables with some fixed naming convention to the environment of the shell. </li></ul></ul>
  46. 46. Configurator
  47. 47. Remarks <ul><li>The configurator application appears whenever the JXTA platform starts up, e.g. because the shell or myJXTA applications are started when JXTA is not already running. </li></ul><ul><li>At this time you must specify a logical name for the peer defined by this session. </li></ul><ul><ul><li>Note this is not the implementation level peer ID , and it is not required to be globally unique. It is a “nickname”. </li></ul></ul><ul><li>Under the advanced menu you can also specify features like the basic port number this JXTA platform uses. </li></ul><ul><ul><li>By redefining this from its default, you can run multiple JXTA platforms on the same host. </li></ul></ul><ul><li>For our current purposes: </li></ul><ul><ul><li>one instantiation of the JXTA platform = one “peer” </li></ul></ul>
  48. 48. JXTA Shell Initial Screen shell1
  49. 49. whoami Command shell1
  50. 50. Remarks <ul><li>The unadorned whoami command displays fragmentary XML describing this peer. </li></ul><ul><ul><li>You might expect this is the advertisment for the peer. A ctually it is an abbreviated version. You can get the full advertisement using the peers command (see later). </li></ul></ul><ul><li>The Peer element is the logical name chosen earlier. </li></ul><ul><li>The PeerId element contains the important globally unique identifier for this peer. </li></ul><ul><ul><li>Technically it is a URN with an embedded UUID (Universally Unique Identifier). </li></ul></ul><ul><li>The several Transport elements define network addresses for accessing this peer. </li></ul><ul><ul><li>First and most useful is TCP/IP number and port number. </li></ul></ul>
  51. 51. whoami –g Command shell1
  52. 52. Remarks <ul><li>With the –g option, the whoami command describes the current default group for shell commands. </li></ul><ul><li>When the shell starts up this is a global group called NetPeerGroup . </li></ul><ul><li>In general the PeerGroup element contains a nickname for the group; the PeerGroupId element contains the true globally unique ID of the group. </li></ul>
  53. 53. Finding Peers shell1
  54. 54. Remarks <ul><li>The simple peers command displays a list of all peers this peer currently knows about. </li></ul><ul><ul><li>The first time it is invoked here, it just returns itself. At this time this peer only knows about itself. </li></ul></ul><ul><ul><li>(Applying the cat command (see later) to the created environment variable peer0 would now give the full advertisement for the local peer.) </li></ul></ul><ul><li>With the –r option, the peers command broadcasts a query to the JXTA network, searching for peers. </li></ul><ul><ul><li>Peers reply with their own identities plus the identities of other peers they know about. The results are placed in the local peer’s cache as they arrive asynchronously. </li></ul></ul><ul><li>Subsequent use of the simple peers command displays all peers discovered so far. </li></ul>
  55. 55. Finding Peer Groups shell1
  56. 56. Remarks <ul><li>The groups command works in a very similar way to the peers command, but searches for or displays peer groups rather than individual peers. </li></ul>
  57. 57. Creating a New Group shell1
  58. 58. Remarks <ul><li>This slide shows how the local peer can create a completely new peer group. </li></ul><ul><ul><li>It is a two-stage process —first one should create an advertisment for the new group. The group itself is then “created” using this advertisement. </li></ul></ul><ul><li>The mkadv –g mygroup command creates a peer group advertisement for a peer group with name mygroup. </li></ul><ul><ul><li>The result is an object stored in an environment variable called mygroupadv </li></ul></ul><ul><ul><li>The example illustrates the general syntax for initializing environment variables </li></ul></ul><ul><li>The shell cat command can be used to display the contents of most kinds of environment variable. </li></ul><ul><ul><li>In this case it displays the literal XML of the advertisement, as defined in the JXTA Protocol Specification . </li></ul></ul><ul><li>The group is actually created with the mkpgrp command. </li></ul><ul><ul><li>What this means operationally is that the group advertisement is now available for discovery by other peers. </li></ul></ul>
  59. 59. Joining a New Group shell1
  60. 60. Remarks <ul><li>When a peer group is initially created it is empty (it doesn’t even include the peer that created it). </li></ul><ul><li>The shell command join can be used to place the current peer in a specified group. </li></ul><ul><ul><li>Here the group is specified by nickname; later we will see how to specify it by advertisment. </li></ul></ul><ul><li>The join command also changes the shell’s current default group to the joined group. </li></ul><ul><ul><li>To change the default group back to NetPeerGroup , use the shell leave command. </li></ul></ul>
  61. 61. Discovering a Group Remotely <ul><li>The next couple of screens are captured from a shell executing in a different peer, with nickname shell2 . </li></ul><ul><li>We will see how to discover the group mygroup created by shell1 , and how to join it. </li></ul>
  62. 62. Groups Known to shell2 shell2
  63. 63. Remarks <ul><li>This is screen capture is presumably made after an earlier groups –r command. </li></ul><ul><li>We see that there are several groups with name mygroup </li></ul><ul><ul><li>This is quite possible: the nickname or logical name is not required to be globally unique. </li></ul></ul><ul><li>The names group0 , group1 , . . . at the left of the display are names of environment variables where the groups command places the full advertisement of the groups it discovers. </li></ul><ul><ul><li>By cat ’ing these variables and inspecting the globally unique contents of the <PID/> element, we can determine which mygroup corresponds to the one recently created in peer shell1 . </li></ul></ul>
  64. 64. Joining a Discovered Group shell2
  65. 65. Remarks <ul><li>This assumes that we ascertained that the last displayed group was the one we are interested in. </li></ul><ul><li>The –d option on join allows us to join a group whose advertisment is available as a document (environment variable). </li></ul><ul><li>The peers in the new default group are now correctly displayed as shell1 and shell2 . </li></ul>
  66. 66. Pipes and Messages <ul><li>Two peers in the same group can communicate by using a pipe . </li></ul><ul><li>The peer who wants to receive messages needs to open an input pipe . The peer who wants to send out messages needs to open output pipe . </li></ul><ul><li>The message will be properly routed between the two provided the input pipe and output pipe bind to the same advertisement . </li></ul><ul><ul><li>The next screen is assumed to be executed back in the first peer, shell1 . </li></ul></ul>
  67. 67. Creating a Pipe Advertisment and Input Pipe shell1
  68. 68. Remarks <ul><li>The previous screen shot shows one peer making a pipe advertisement with the name senderPipeAdv . </li></ul><ul><ul><li>This is done using the shell command mkadv with option –p , for “pipe”. </li></ul></ul><ul><ul><li>The advertisement is save in the pipeAdv environment variable </li></ul></ul><ul><li>As usual, we can check the content of the advertisement using the shell command cat . </li></ul><ul><li>General advertisments, including pipe advertisements, can be published the using the shell command share , which interacts with the JXTA discovery service. </li></ul><ul><li>We create an input pipe bound to this advertisement using shell command mkpipe with the –i option, and save it in the environment variable inputPipe , for later use. </li></ul>
  69. 69. The Discovery Service <ul><li>The Discovery Service is a fundamental service for publishing and searching for all kinds of resource. </li></ul><ul><li>Resources are published through advertisements , for example: </li></ul><ul><ul><li>Our peers automatically publish their own peer advertisements when they boot up. </li></ul></ul><ul><ul><li>Peer group advertisements can be published from the shell by the mkpgrp command. </li></ul></ul><ul><li>In the shell, any other kind of advertisement (including pipe advertisements) can be published with the share command. </li></ul><ul><li>These general adverts can be discovered with the search command. </li></ul>
  70. 70. Discovering a Pipe shell2
  71. 71. Remarks —Search <ul><li>Like peers and groups, the simple form of search just looks for advertisements in the local cache. </li></ul><ul><ul><li>We must issue a search –r command to send out a request for advertisements on the network. </li></ul></ul><ul><ul><li>This returns immediately, then the local cache asynchronously fills up with discovered advertisements. </li></ul></ul><ul><li>In this example we happened to guess correctly that the last advertisement ( adv2 ) discovered was the pipe advertisment we were looking for. </li></ul><ul><li>More generally one can be selective in the search, for example specifying attribute-value pairs that should be matched </li></ul><ul><ul><li>E.g. we might specify name: senderPipeAdv . </li></ul></ul>
  72. 72. Remarks —Creating an Output Pipe <ul><li>Once the pipe advertisement is discovered, an output pipe is created with the mkpipe –o command. </li></ul><ul><li>The pipe (stored in the environment variable outputPipe ) is now available for sending messages. </li></ul><ul><li>Note that the pipe advertisement did not include any network address. </li></ul><ul><ul><li>Somehow, the JXTA platform is responsible for binding pipes to physical endpoints at a later stage (presumably when the mkpipe commands are invoked). </li></ul></ul>
  73. 73. Sending a Message shell2
  74. 74. Remarks —Importing Documents to the Shell <ul><li>We need a payload for our example message —some arbitrary XML fragment. </li></ul><ul><li>The JXTA shell does not have much built-in support for manipulating text content —t he easiest thing is to import a prepared document from the local file system. </li></ul><ul><li>This illustrates the use of the shell command importfile . </li></ul><ul><ul><li>The local file d:hello.txt contains the XML: </li></ul></ul><ul><ul><li><?xml version=“1.0”?> </li></ul></ul><ul><ul><li><content> </li></ul></ul><ul><ul><li>Greetings from Pervasive Technology Labs, Indiana University </li></ul></ul><ul><ul><li></content> </li></ul></ul><ul><ul><li>This content is imported as a JXTA object, a reference to which is stored in the environment variable, mydata , passed as the final argument of the command (UNIX shell programmers shudder. . .) </li></ul></ul><ul><ul><li>We can now cat the object mydata . Note we cannot directly cat unimported files from the JXTA shell: files are “second class entities”! </li></ul></ul>
  75. 75. Remarks —Creating and Sending a Message <ul><li>We can create a new message object using the shell command mkmsg . </li></ul><ul><li>We then put our document into the message object, identifying it by the tag “ mytag ”, using the shell command put . </li></ul><ul><ul><li>A message to contain several parts identified by different tags. </li></ul></ul><ul><ul><li>The tags will become element names in the XML wire format of the message. </li></ul></ul><ul><li>The message is sent on outputPipe using the shell command send . </li></ul>
  76. 76. Receiving a Message shell1
  77. 77. Remarks <ul><li>Now we are back in shell1 . </li></ul><ul><li>We apply the shell command recv to the inputPipe object created earlier. </li></ul><ul><ul><li>This returns a message msg . </li></ul></ul><ul><li>We extract the expected document from message the using shell command get , specifying tag name mytag , and save it into the environment variable called data . </li></ul><ul><li>We check our document content with shell command cat . </li></ul>
  78. 78. Defining New Shell Commands <ul><li>package ; </li></ul><ul><li>public class myHelloWorld extends ShellApp { </li></ul><ul><li>private ShellEnv myEnv ; </li></ul><ul><li>public int startApp(String [] args) { // args is command arguments </li></ul><ul><li>myEnv = getEnv() ; // Retrieve the command environment </li></ul><ul><li>// Extract the current peer group from the environment </li></ul><ul><li>ShellObject obj = myEnv.get(“stdgroup”) ; </li></ul><ul><li>PeerGroup group = (PeerGroup) obj.getObject() ; </li></ul><ul><li>if(args == null) { // Print to console: </li></ul><ul><li>println(“Hello my peer group is ” + group) ; </li></ul><ul><li>} else { // No arguments are expected: </li></ul><ul><li>println(“Sorry no arguments are supported!”) ; </li></ul><ul><li>} </li></ul><ul><li>return ShellApp.appNoError ; // Everything went OK! </li></ul><ul><li>} </li></ul><ul><li>public void stopApp() {} </li></ul><ul><li>} </li></ul>
  79. 79. Remarks <ul><li>It is relatively easy to define a new shell command in Java, by extending the class ShellApp . </li></ul><ul><ul><li>Hopefully the example is transparent to most people familiar with Java applications. </li></ul></ul><ul><li>Once the class file is copied to the proper directory, the myHelloWorld command immediately becomes available for execution from the shell. </li></ul><ul><ul><li>The shell does not have to be restarted. </li></ul></ul><ul><li>In general the Java code will interact with the JXTA platform through the JXTA API (briefly discussed in the next section). </li></ul>
  80. 80. myJXTA and Other JXTA Applications
  81. 81. JXTA Applications and Demos <ul><li>Although many JXTA projects have been announced, the set of functional demos available right now seems to be comparatively small. </li></ul><ul><ul><li>Perhaps too early; the platform itself is barely stable. </li></ul></ul><ul><ul><li>Maybe this should be seen as a window of opportunity for application developers. . . </li></ul></ul><ul><li>Three categories of application, promising in the near term, were identified by Bill Joy in a recent Webcast: </li></ul><ul><ul><li>1. Collaboration tools </li></ul></ul><ul><ul><li>2. Shared content or content distribution </li></ul></ul><ul><ul><li>3. Games and entertainment </li></ul></ul><ul><li>We will briefly mention the simple collaborative environment myJXTA (formerly known as “ IntstantP2P ”), and a project developing a JXTA application for Internet chess tournaments. </li></ul>
  82. 82. myJXTA
  83. 83. Open (Group) Chat Session
  84. 84. A Private Chat Session
  85. 85. Private Chat Session
  86. 86. Sharing Content
  87. 87. Shared Content
  88. 88. Searching for Shared Content
  89. 89. Saving Discovered Content
  90. 90. Viewing the File (Gary Trudeau comic reproduced without permission . . .)
  91. 91. JXTA chess
  92. 92. Remarks <ul><li>JXTA chess is a online peer to peer game. </li></ul><ul><ul><li>It runs in the JXTA peer to peer network without a central server. </li></ul></ul><ul><ul><li>It is supposed to support distributed chess tournaments involving many games and players. </li></ul></ul><ul><li>Seems like a promising sort of application for P2P technologies. </li></ul>
  93. 93. JXTA Projects in Categories <ul><li>Applications </li></ul><ul><ul><li>Configurator : A GUI configuration tool for the JXTA platform </li></ul></ul><ul><ul><li>Instantp2p :JXTA Demonstration GUI (now renamed to myJXTA ). </li></ul></ul><ul><ul><li>Shell : JXTA Command Line Shell for interactive access to the JXTAP2P platform </li></ul></ul><ul><li>Core JXTA </li></ul><ul><ul><li>Platform : JXTA P2P platform infrastructure building blocks and protocols. </li></ul></ul><ul><ul><ul><li>This project defines the JXTA core P2P building blocks: peers, peer groups, pipes, codats and peer group policies. Includes specifications and reference implementations for core JXTA protocols (peer and peer group discovery, peer group membership, peer group pipes and codat sharing). </li></ul></ul></ul><ul><ul><li>Security : JXTA P2P Security Project </li></ul></ul><ul><li>JXTA Services </li></ul><ul><ul><li>Cms : JXTA Content Management System </li></ul></ul><ul><ul><li>Monitoring : Monitoring and Metering </li></ul></ul><ul><ul><li>Rvmanager : RendezVous Manager </li></ul></ul>
  94. 94. JXTA API Examples
  95. 95. JXTA API <ul><li>Eventually the JXTA protocols and platform should be accessible from many different programming languages, but for now the only available API is for Java. </li></ul><ul><li>We cannot discuss the API in detail here. Instead we will just exhibit some Java fragments taken from the implementation of myJXTA . </li></ul><ul><li>If you know Java, you may notice that there is a rather direct mapping between the Java operations, and the sequence of operations we went through in the shell examples. </li></ul>
  96. 96. How myjxta Works — Creating Pipes <ul><li>public synchronized void login() { </li></ul><ul><li>PipeAdvertisement myPipeAdvt = (PipeAdvertisement)AdvertisementFactory . </li></ul><ul><li>newAdvertisement( PipeAdvertisement.getAdvertisementType()); </li></ul><ul><li>myPipeAdvt.setPipeID(getUniquePipeID()); </li></ul><ul><li>myPipeAdvt.setName(CHATNAMETAG + &quot;.&quot; + CHATNAME); </li></ul><ul><li>myPipeAdvt.setType(PipeService.PropagateType); </li></ul><ul><li>try { </li></ul><ul><li>discovery.publish(myPipeAdvt, DiscoveryService.ADV); </li></ul><ul><li>discovery.remotePublish(myPipeAdvt, DiscoveryService.ADV); </li></ul><ul><li>inputPipe = pipe.createInputPipe(myPipeAdvt, this); </li></ul><ul><li>outputPipe = pipe.createOutputPipe(myPipeAdvt,100); </li></ul><ul><li>opTable.put(group.getPeerGroupID().toString(), outputPipe); </li></ul><ul><li>ipTable.put(group.getPeerGroupID().toString(), inputPipe); </li></ul><ul><li>sendMsg(&quot;*** has joined &quot;+group.getPeerGroupName() ); </li></ul><ul><li>} catch (Exception e) { </li></ul><ul><li>e.printStackTrace(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  97. 97. Remarks <ul><li>First, we create a pipe advertisement from our advertisement Factory </li></ul><ul><li>Second, we set some properties for the pipe advertisement. If we want do group chat, we need to invoke the setType() method with constant PipeService.PropagateType() as parameter. </li></ul><ul><li>Third, we need to publish our advertisement both locally and remotely. </li></ul><ul><li>We can create inputPipe and outputPipe use this advertisement. </li></ul><ul><li>Because each peer can open multiple input pipe and output pipe at the same time. So we can keep into hash table. </li></ul>
  98. 98. Preparing a Message to Send Out <ul><li>public void sendMsg(String gram) { </li></ul><ul><li>try { </li></ul><ul><li>Message msg = pipe.createMessage(); </li></ul><ul><li>msg.setString(SENDERMESSAGE, gram); </li></ul><ul><li>msg.setString(SENDERNAME, userName); </li></ul><ul><li>msg.setString(SENDERGROUPNAME, </li></ul><ul><li>group.getPeerGroupName()); </li></ul><ul><li>queue.push(msg); </li></ul><ul><li>} catch (Exception ex) { </li></ul><ul><li>ex.printStackTrace(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  99. 99. Remarks <ul><li>First, we create a message object using the pipe. </li></ul><ul><li>Second, we set some properties for the message </li></ul><ul><li>Third, we put it into queue for sending out. </li></ul>
  100. 100. Create a Thread to Send the Message <ul><li>public void run() { </li></ul><ul><li>while (true) { </li></ul><ul><li>try { </li></ul><ul><li>Message msg = queue.waitForMessage(); </li></ul><ul><li>outputPipe.send(msg); </li></ul><ul><li>} catch (InterruptedException e) { </li></ul><ul><li>// we should never get this so printStackTrace(); </li></ul><ul><li>e.printStackTrace(); </li></ul><ul><li>} catch (IOException e) { </li></ul><ul><li>// print stack trace for now </li></ul><ul><li>e.printStackTrace(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  101. 101. Remarks <ul><li>We can see this method will run in another thread. </li></ul><ul><li>It will get the message out of our private queue if it is available. </li></ul><ul><li>It will use the output pipe to send the message out. </li></ul>
  102. 102. Receiving the Message <ul><li>public void pipeMsgEvent(PipeMsgEvent event) { </li></ul><ul><li>Message msg = event.getMessage(); </li></ul><ul><li>try { </li></ul><ul><li>String sender = getTagString(msg, SENDERNAME, </li></ul><ul><li>&quot;anonymous&quot;); </li></ul><ul><li>String groupname = getTagString(msg, SENDERGROUPNAME, </li></ul><ul><li>&quot;unknown&quot;); </li></ul><ul><li>String senderMessage = getTagString(msg, SENDERMESSAGE, </li></ul><ul><li>null); </li></ul><ul><li>String msgstr; </li></ul><ul><li>if (groupname.equals(group.getPeerGroupName()) ) { </li></ul><ul><ul><ul><ul><li>msgstr = sender + &quot;> &quot; + senderMessage; </li></ul></ul></ul></ul><ul><li>} else { </li></ul><ul><li> return; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  103. 103. Remarks <ul><li>When the input pipe created, we add this listener. So, when a message arrives, the PipeMsgEvent will be trigger. This method will be called. </li></ul><ul><li>We first get the message object, and from the message object, we can get the other information such as sender name, group name and message content. </li></ul>
  104. 104. Search for Advertisement <ul><li>public void searchAdvertisements(String attr, String value) </li></ul><ul><li>throws IOException { </li></ul><ul><li>discover.getRemoteAdvertisements(null, adType, </li></ul><ul><li>attr, value, THRESHOLD,null); </li></ul><ul><li>// and retrieve the local values </li></ul><ul><li>Enumeration enum = discover.getLocalAdvertisements(adType, </li></ul><ul><li>attr, </li></ul><ul><li>value); </li></ul><ul><li>ArrayList result = new ArrayList(); </li></ul><ul><li>while (enum != null && enum.hasMoreElements()) { </li></ul><ul><li>Advertisement adv = (Advertisement) enum.nextElement(); </li></ul><ul><li>addAdToList(adv,result); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  105. 105. Remarks <ul><li>First, we use the discovery service to do the remote discovery for our special attributes and value pair. When it finds the advertisement, it will be put into the local cache. </li></ul><ul><li>Second, we use discovery service to do the local search for our special attributes and value pair. </li></ul><ul><li>Third, we build an array list to keep the advertisement we found. </li></ul>
  106. 106. Wrap-up
  107. 107. Other Core P2P technologies or services <ul><li>Digital Cash or “Digital Reputation” implemented with Digital Cash is an important area as even in “free systems” need mechanism to limit abuse of resources </li></ul><ul><ul><li>“Tragedy of the Commons” </li></ul></ul><ul><li>Digital Cash has many very clever implementations </li></ul><ul><ul><li>Public Key based “coins” issued by digital banks – issues of safety (no overdrafts or forgery) and anonymity (cash is anonymous, credit cards are not) </li></ul></ul><ul><ul><li>POW (Proofs of Work) to stop DOS (Denial of Service) </li></ul></ul><ul><li>Network Architecture </li></ul><ul><ul><li>Create the Small World effect where only a few hops needed to get from any A to any B </li></ul></ul><ul><ul><li>Intelligent (bad worse case) versus random (bad average) strategies </li></ul></ul>
  108. 108. Future of P2P technologies <ul><li>I expect research and commercial experience to identify more base services, as we understand better the common needs of P2P systems </li></ul><ul><li>These core capabilities are where we need to develop the community standards to enable different projects to interoperate. </li></ul><ul><li>Management of resources in such a network must be an important challenge; it is our Nirvana - the Web Operating System . </li></ul><ul><li>Maybe society can live in a Gallimaufry of unstructured knowledge swept back and forth by armies of Gnutella agents. </li></ul><ul><ul><li>However this will not do for what the Gartner Group ( ) and O'Reilly term Enterprise P2P needed by a Fortune 500 organization. </li></ul></ul><ul><ul><li>Here we will need to manage structured information within a dynamic P2P grouping. We see the right approach is to generalize Napster and Jini ; ensure that all objects are tied to meta-data (possibly in a separate record) that define the discovery, rendering, access and sharing characteristics. </li></ul></ul><ul><li>One homely example is family photos; usually these are indeed a Gallimaufry of folders haphazardly stuffed in shoeboxes which gets even worse for a community event recorded in shoeboxes across the nation. </li></ul><ul><ul><li>With the proper metadata and Enterprise P2P support such photos could be nicely organized and presumably of greater value. </li></ul></ul>
  109. 109. Conclusions <ul><li>We can finish by pointing out another important characteristic of P2P networks. </li></ul><ul><li>Namely the clients can be quite heterogeneous with the P2P session including basic desktops but also hand-held devices, cell phones and special interfaces for those having physical handicaps. </li></ul><ul><ul><li>This requires the copied files or shared objects to be differently rendered on each peer. </li></ul></ul><ul><li>This is quite possible with careful design of the XML meta-data for both clients and display devices. </li></ul><ul><li>P2P networks can and will unite us all. </li></ul><ul><li>There are lots of good research topics and obviously lots of business opportunities. P2P as part of the next wave of the Web is intellectually challenging to design and socially and intellectually rewarding to use. </li></ul>