Title: JXTA: Tech Brief
1JXTA Tech Brief
- Dan Berger, Suvidhean Dhirakaosal, Essia Hamouda,
Demetris Zeinalipour - CS 202 Spring 2003
2Outline
- Problem Statement/Motivation
- Architecture Overview
- Experiments/Demonstrations
- Conclusions
3Motivation
- Existing P2P solutions have had rapid adoption
and success so why build another? - JXTA attempts to address 3 key shortcomings of
typical P2P systems - Interoperability
- Platform Independence
- Ubiquity
4Interoperability
- Gnutella for file sharing, ICQ/AIM/Yahoo/Jabber/MS
N for instant messaging - But none of them can talk to each other.
- This has led to the development of apps like Gaim
(linux) and Trillian (windows) that provide a
single front-end to multiple protocols. - JXTA aims to standardize at the protocol level.
5Platform Independence
- JXTA is independent of programming language,
operating system, and networking platform. - The core of JXTA are protocol definitions, not
APIs.
6Ubiquity
- JXTA was designed to be scalable to any device
with a network heartbeat cited examples are - Sensors
- Consumer electronics (toasters, cell phones)
- PDAs
- Etc.
7The Grand Vision
8Enough Buzzwords, Already
- JXTA proposes a set of services to enable
building a securable logical overlay network
linking peers - Peer Discovery
- Peer Resolution
- Rendezvous
- Pipe Binding
- Endpoint Routing
9Gratuitous Architecture Picture
10Just the Facts
- Each node in the JXTA network
- has a peer id - a globally unique ID (UUID)
- Urnjxtaidform3-3108664267912473
- Is Autonomous and may operate independently of
all peers - Peers (self)organize into peer groups loosely
hierarchical. - All peers belong to the World group.
- Peers and services are advertised with
advertisements (XML documents)
11Advertisements
- Used to describe peers, peers groups, pipes,
content, services and resources - Used to pass info between peers
- Are presented in XML
- Peer Adv.
- Peer group Adv.
- Module Class Adv.
- Module Spec. Adv.
- Module Implementation Adv.
12Discovery Query
- ltxselement name"DiscoveryQuery"
type"jxtaDiscoveryQuery"/gt - ltxsdsimpleType name"DiscoveryQueryType"gt
- ltxsdrestriction base"xsdstring"gt
- lt!-- peer --gt
- ltxsdenumeration value"0"/gt
- lt/xsdrestrictiongt
- lt/xsdsimpleTypegt
- ltxscomplexType name"DiscoveryQuery"gt
- ltxssequencegt
- ltxselement name"Type" type"jxtaDiscoveryQuer
yType"/gt - ltxselement name"Threshold" type"xsunsignedIn
t" minOccurs"0"/gt - ltxselement name"Attr" type"xsstring"
minOccurs"0"/gt - ltxselement name"Value" type"xsstring"
minOccurs"0"/gt - lt!-- The following should refer to a peer adv,
but is instead a whole doc for historical reasons
--gt - ltxselement name"PeerAdv" type"xsstring"
minOccurs"0"/gt - lt/xssequencegt
- lt/xscomplexTypegt
13Discovery
- LAN-based (broadcast)
- Invitation (in or out of band, via an
advertisement) - Cascaded (controlled view across discovered
peers) - Rendezvous (napster-esqe)
14Resolution
- In general a service that resolves
advertisements into endpoints. - JXTA ships with one implementation Rendezvous
in which hosts serve as switchboards for
messages. - More complex/decentralized resolvers are
possible, but not specified/provided.
15Pipes
- Pipes are unidirectional communication channels.
- Peers can host input pipes (incoming messages),
or output pipes (outgoing messages). - Pipes can be chained to link peers across
multiple logical hops, and can be one-to-many. - Pipes are bound to peer ids, not IP address.
16Pipe
17Routing
- Allows peers to discover routes for reaching a
peer which can not be directly connected to. - I.e. behind a firewall, NAT device, different
network platform, etc.
18Experiments
19Required Components
- www.jxta.org has Java and C implementations of
the core protocols. - The C version is based on the APR (apache
portable runtime) and trails behind the JAVA
version in terms of functionality and ease of
use. - For Java requires the J2SE JDK
20Installation Configuration
- Install a JRE/JDK (e.g. Sun 1.3.1_1)
- Download the latest JXTAInst_VM.exe
- InstallAnywhere installer (JXTA v2.0)
- http//download.jxta.org/easyinstall/install.ht
ml (4.71MB) - (Or download JXTAInst.exe which contains VM)
- Download tutorials/code from
- http//www.jxta.org/project/www/Tutorials.htm
l
21JXTA Jars
- JXTAs core uses 13 other JAR files like Jetty
portable Web/Servlet Server, Log4J apaches
generic logging API. - Directory Structure so far
- /InstantP2P -gt A full-fledged instant P2P
application - /lib -gt The JAR Files
- /lib/jxta.jar -gt Contains the JXTA Programming
API - /Shell -gt Command-line Interface to JXTA
- /tutorials -gt Tutorials that we downloaded
individually
22Step 0 Source/CompilingCreating a PeerGroup
java -classpath jxta.jarOTHER_JAR_FILES.jar
Hello
import net.jxta.peergroup. import
net.jxta.impl.id.UUID. import
net.jxta.impl.id.binaryID. public class
Hello static PeerGroup netPeerGroup null
static DigestTool digestTool new DigestTool()
public static void main(String args) try
netPeerGroup PeerGroupFactory.newNetPee
rGroup() System.out.println("Hello from
JXTA group " netPeerGroup.getPeerGroupName()
) System.out.println(" Group ID "
netPeerGroup.getPeerGroupID().toString())
System.out.println(" Peer name "
netPeerGroup.getPeerName())
System.out.println(" Peer ID "
netPeerGroup.getPeerID().toString())
catch(Exception e) e.printStackTrace()
23Step 1 Running the code
1
2
Now a .jxta directory is created on disk which
contains all settings On the next run we
only fill in an authentication box
3
4
24Step 2 JXTA Sockets! (as of v2.0)
- JXTA introduces a Socket API which is similar to
the familiar sockets. - The Socket API attempts to make JXTA Pipe
programming easier. (JxtaSocket is a
bi-directional Pipe) - JxtaServerSocket Server socket that waits for
connections from clients. - JxtaSocket Socket class used to create the I/O
streams for both clients and servers.
25Step 3 JXTA Sockets Example
- In this example we use to types of
advertisement Discovery Services - LAN-based discovery Local broadcast over the
subnet. (224.0.0.0 to 239.255.255.255) - Works if peers are within the same subnet or if
multicast-enabled routers are connecting the
peers - Discovery via rendezvous points A peer at a
well-known address has the task of knowing and
disseminating locations of peers. - Works if peers are fire-walled in which case
direct connection between peers is not feasible.
26Step 3 JXTA Sockets Example
27JXTA Sockets Code Snippets
- Server (main snippets)
- // create, and Start the default jxta
NetPeerGroup - PeerGroup netPeerGroup PeerGroupFactory.newNetPe
erGroup() - // Read file from disk
- FileInputStream is new FileInputStream("socket.a
dv") - // Generate Pipe Advertisment
- PipeAdvertisement pipeAdv (PipeAdvertisement)Adv
ertisementFactory. new Advertisement(is) - // Launch ServerSocket
- JxtaServerSocket serverSocket new
JxtaServerSocket(netPeerGroup,
socEx.pipeAdv) - // if client connects, spawn two new Threads
(input/output). - JxtaSocket socket serverSocket.accept()
- OutputStream out socket.getOutputStream()
- InputStream in socket.getInputStream()
// receive message back in.read(inbuf, 0,
bufsize)
28JXTA Sockets Code Snippets
- Client (main snippets)
- // create, and Start the default jxta
NetPeerGroup - PeerGroup netPeerGroup PeerGroupFactory.newNetPe
erGroup() - // Read file from disk
- FileInputStream is new FileInputStream("socket.a
dv") - // Generate Pipe Advertisment
- PipeAdvertisement pipeAdv
- (PipeAdvertisement)AdvertisementFactory. new
Advertisement(is) - // Launch Socket along with 2 new Threads
(input/output). - JxtaSocket socket new JxtaSocket(netPeerGroup,
pipeAdv) - OutputStream out socket.getOutputStream()
- InputStream in socket.getInputStream()
- // receive message
- read in.read(inbuf, 0, bufsize)
// send message back out.write(inbuf, 0, read)
29JXTA Sockets Code Snippets
Server acting also as Rendezvous
Client connecting to Rendezvous
30Conclusions
31Ongoing JXTA Projects
Full list available at http//apps.jxta.org/serv
lets/ProjectHome Gnougat A Fully decentralized
file caching RossetChat Localized JXTA Peer
Text Messaging Radiojxta delivering audio
content over JXTA networks P2Pconference A tool
to conduct remote, text-based conferences InstantP
2P To be interactively displayed.