|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--inria.net.lrmp.Lrmp
an implementation of the Light-weight Reliable Multicast Protocol which provides point-to-multipoint reliable and ordered data delivery service. This object works in multicast mode if the provided network address is a multicast group address, or in unicast mode if it is a classical host IP address. The configuration is set using LrmpProfile by which a number of transmission and reception parameters can be adjusted. Not ordered but reliable packet delivery is currently not implemented.
For performance reason, an application must not modify the packets received from and sent to LRMP. These packets are kept in the cache for possible retransmissions. If necessary, an application should make a local copy before the modification.
An application should implement the LrmpEventHandler interface for processing data packets and events received from LRMP. This event handler interface is also configured through LrmpProfile.
An application should set the data rate to a tolerable range. Lrmp keeps the data rate between the minimum rate and the maximum rate while adapting to the available network resources. Correct rate setting is very important for both reliability and congestion control. It is advised not to use an aggressive data rate in a large scale.
Received data flows from different senders are distinguished by the sender's ID and the network address. Under normal network conditions, Lrmp guarantees that the data packets delivered to the application are in good order. If serious network troubles make this guarantee impossible, Lrmp will notify the application if there is a break in the data sequence through processEvent() of the event handler. Upon this notification, the application may need to drop the current incomplete object.
A LRMP session has a TTL value which is used to limit the scope of the session and should be between 0 and 255. More meaningfully,
For better performance, it is advised to use a TTL value corresponding to the scope of the session. A TTL value which is unnecessarily large may degrade the performance.
The following is a simple example of how to use this object:
import inria.net.lrmp.*; public class Test implements LrmpEventHandler { private Lrmp lrmp; public Test(String group, int port, int ttl) { LrmpProfile profile = new LrmpProfile(); profile.setEventHandler(this); profile.minRate = 8; profile.maxRate = 16; try { lrmp = new Lrmp(group, port, ttl, profile); } catch (LrmpException e) { System.exit(1); } lrmp.start(); } public void quit() { lrmp.stopSession(); } public void sendTestData() { LrmpPacket pack = new LrmpPacket(); int maxLen = pack.getMaxDataLength(); pack.setDataLength(maxLen); try { lrmp.send(pack); } catch (LrmpException e) { } } public void processData(LrmpPacket pack) { System.out.println("got packet from " + pack.getSourceID() + "@" + pack.getAddress()); System.out.println("buffer " + pack.getDataBuffer() + " offset " + pack.getOffset() + " length " + pack.getDataLength()); } public void processEvent(int event, Object obj) { switch (event) { case LrmpEventHandler.UNRECOVERABLE_SEQUENCE_ERROR: System.out.println("reception failure!"); break; default: break; } } }
Field Summary | |
java.lang.String |
Version
the version of this LRMP implementation. |
Constructor Summary | |
Lrmp(java.net.InetAddress addr,
int port,
int ttl,
LrmpProfile prof)
creates and joins an LRMP multicast session. |
|
Lrmp(java.net.InetAddress addr,
int port,
LrmpProfile prof)
creates and joins an LRMP unicast session. |
|
Lrmp(java.lang.String group,
int port,
int ttl,
LrmpProfile prof)
creates and joins an LRMP multicast session. |
|
Lrmp(java.lang.String addr,
int port,
LrmpProfile prof)
creates and joins an LRMP unicast session. |
Method Summary | |
void |
flush()
Flushes the output queue. |
java.net.InetAddress |
getAddress()
Returns the destination address. |
LrmpDomainStats |
getDomainStats(int scope)
Returns the recovery domain statistics. |
LrmpStats |
getLrmpStats()
Returns the overall statistics. |
int |
getPort()
Returns the port number. |
int |
getTTL()
Returns the scope value. |
void |
send(LrmpPacket pack)
Sends a data packet to the session. |
void |
setProfile(LrmpProfile prof)
Sets the profile. |
void |
setTTL(int i)
Sets the scope value. |
void |
start()
Starts the session. |
void |
startSession()
Deprecated. it is replaced by start() . |
void |
stop()
Stops the session. |
void |
stopSession()
Deprecated. it is replaced by stop() . |
LrmpEntity |
whoami()
Returns the local user info. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final java.lang.String Version
Constructor Detail |
public Lrmp(java.net.InetAddress addr, int port, int ttl, LrmpProfile prof) throws LrmpException
addr
- the destination address.port
- the port to use.ttl
- the time-to-live value.prof
- the profile to use.LrmpException
- is raised if there is an error in joining or
bad profile.public Lrmp(java.net.InetAddress addr, int port, LrmpProfile prof) throws LrmpException
addr
- the destination address.port
- the port to use.prof
- profile to use.LrmpException
- is raised if there is an error in creating socket or
bad profile.public Lrmp(java.lang.String group, int port, int ttl, LrmpProfile prof) throws LrmpException
group
- the destination address.port
- the port to use.ttl
- the time-to-live value.prof
- profile to use.LrmpException
- is raised if there is an error in joining or
bad profile.public Lrmp(java.lang.String addr, int port, LrmpProfile prof) throws LrmpException
addr
- the destination address.port
- the port to use.prof
- profile to use.LrmpException
- is raised if there is an error in creating socket or
bad profile.Method Detail |
public void start()
public void stop()
public void startSession()
start()
.
public void stopSession()
stop()
.
public void setProfile(LrmpProfile prof) throws LrmpException
prof
- the profile to use.LrmpException
- is raised if this is a bad profile.public void setTTL(int i)
public java.net.InetAddress getAddress()
public int getPort()
public int getTTL()
public LrmpStats getLrmpStats()
public LrmpDomainStats getDomainStats(int scope)
scope
- the domain scope.public LrmpEntity whoami()
public void send(LrmpPacket pack) throws LrmpException
pack
- the packet to send.LrmpException
- is raised if the packet is too big.public void flush()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.