Back to Overview
Core Specification and Implementation
Welcome to the world of JPPP.
■Transport Layer
The "transport layer"sits directly beneath the JPPP core and supports interaction
with the network itself. The way in which the transport layer is
implemented should not influence the JPPP Profile API, and profile development
rests on the assumption that Profile Programmers can act independently
of how the transport layer is implemented. The current transport
layer consists of SOAP/HTTP, as indicated in the following diagram showing
the Protocol Stack:

Since the transport layer consists of SOAP/HTTP, JPPP requires the presence
of a SOAP processor and an HTTP server. Servlet support is also required
since the SOAP method dispatcher is a Servlet.
The current JPPP comes bundled with Jasper, a light open source web server;
making the JPPP package a very small web server. The JPPP network
is thus a distributed processing system composed of multiple communicating
web servers.
It is not difficult to switch from Jasper to an external Servlet engine
such as Tomcat, which in turn can work in tandem with a robust web server
like Apache. This option should be considered by JPPP servers that
expect to support heavy loads.

■SOAP and RPC
There are several reasons for using SOAP/HTTP for the JPPP transport layer:
-
The serialization process allows us to abstract away from how the data
is expressed during transmission.
-
Alternatives such as RMI and HORB are specific to Java. JPPP is intended
to be multi-programming language as well as multi-platform, and so a programming
language neutral implementation is required.
-
HTTP has the advantage of being widespread and is allowed through many
firewalls that would block other protocols.
Conceptually, JPPP transmissions are thought of in terms of "remote method
calls", rather than communication between the nodes (individual JPPP servers
in the network).
A typical approach to extending the core is as follows:
-
Define the public SOAP method. This method is directly called by the core
code of other nodes, and this corresponds to the JPPP protocol.
-
Re-examine the internal structure and type of the public method's arguments
and return value, and re-implement them appropriately.
-
Work out a bite stream expression of the arguments and return value.
The objects that are used for the arguments and return values of the SOAP
method are considered to be the "primitive types" of JPPP. These JPPP primitive
types get written to the network stream and must be consistently represented
by the same structure.
■Core protocol
The methods currently in use are as follows:
・Message Transmission
public String push(BasicMessage msg, ForwarderImpl condition,
int session);
・Message Sendback via routing stack
public String sendback(BasicMessage msg, int session);
・Connection Negotiation between 2 nodes
public NegotiatorImpl negotiate(NegotiatorImpl hope);
・Session creation involving 2 nodes
public RemoteNode establish(RemoteNode from, int id);
Additional methods that are intended for future implementation:
・Request to stop message forwarding
public String stopForwarding(Node target, String selectorName);
・Request to resume mesasge forwarding
public String restartForwarding(Node target, String selectorName);
・Setting maximum width of message transmission rate
public String setMaxRate(int bitPerSec);
・Default routing protocol
Under Consideration.....
■JPPP primitive type
Primitive type fields are serialized using the Big endian network byte
order, the most significant byte has the lowest address.
○return valueのString
<String> ::= <letter> { <letter> | <number> | <special> | <space> } CR(0xd) LF(0xa)
<letter> ::= 'a' ... 'z' | 'A' ... 'Z'
<number> ::= '0' ... '9'
<space> ::= ' ' { ' ' }
<special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}' |
<NUL> ::= 0x0
○Parameter String(=PString)
<PString> ::= <letter> { <letter> | <number> | <special> | <space> } <NUL>
○Message
final public class BasicMessage implements Message {
protected int TTL = 5; //32bit
protected int hops = 0; //32bit
protected int payloadLength = 0; //32bit
protected int stackSize = 0; //32bit
protected String selector; //PString
protected byte[16] destinationID; //128 bit
protected byte[16] originID; //128 bit
protected byte[16] previousID; //128 bit
protected byte[16] messageID; //128 bit
protected byte[] payload; //Variable length
protected int[] stack; //Variable length
}
Note:
A selector is a parameter character sequence and by definition ends
with a null.
○Node
public class RemoteNode implements org.jnutella.jppp.core.Node {
protected byte[16] nodeID; //128 bit
protected NodeProperty property;
}
○NodeProperty
public class RemoteNodeProperty implements NodeProperty {
protected int slotSize = 0; // 32 bit
protected int slotLength = 0; // 32 bit
protected String[] properties; //Variable length
}
Note:
Node properties are expressed by a single key associated with a number
of values. The keys and their values are represented as follows:
new String[]{ key name, value number , value, value...,
key name, value number, value... };
Example:
| Key |
Values |
| "selectors" |
"ping", "pong", "query" |
| "locale" |
"JP_ja" |
| "profiles" |
"GNUTELLA", "NAPSTER" |
This is arranged as follows;
new String[] {
//all of PStrings
"selectors", "3", "ping", "pong", "query",
"locale", "1", "JP_ja",
"profiles", "2", "GNUTELLA", "NAPSTER" }
The number of individual strings is called slot size and it is given
by the slotSize field. slotLength is total length of all the strings together.
Each character sequence is a PString and terminates with a null. The relative
positions of keys in the array are not fixed, and although keys must not
be duplicated, they may be associated with multiple values.
○Forwarder
public class ForwarderImpl implements Forwarder {
public int mode; //32bit
public String key = ""; //PString
public String value = ""; //PString
}
○Negotiator
public class NegotiatorImpl implements Negotiator {
protected int costRequest = 0;//32bit
protected int agreementID = -1; //32bit
protected String result; //PString
}
Note:
It has not yet been completely decided what negotiation items require.
Back to Overview
日本語はこちら |