inria.net.lrmp
Class LrmpPacket

java.lang.Object
  |
  +--inria.net.lrmp.LrmpPacket
All Implemented Interfaces:
java.lang.Cloneable

public final class LrmpPacket
extends java.lang.Object
implements java.lang.Cloneable

encapsulates an LRMP data packet. Applications should use this object to send data to and receive data from LRMP. LRMP provides packet-level reliability, i.e., a packet can be sent either reliably or at best effort. The packet reliability should be specified at creation.

Packet segmentation/reassembly is not supported. Upper layers should properly segment large data blocks to LRMP packets.

Application data is contained in the buffer returned by the method getDataBuffer() and starts at the offset returned by the method getOffset().

When sending a packet, application data should be filled from this offset with the maximum length returned by getMaxDataLength(). The effective length of application data should be set using setDataLength().

When a packet is received, the application data length can be obtained by getDataLength().


Field Summary
protected  byte[] buff
          the data buffer.
protected  int datalen
          the length of application data in the packet.
protected  boolean end
          the end marker.
protected static int endBit
           
protected  boolean first
          the start marker.
protected  int maxDataLen
          the maximum length (bytes) available in the allocated buffer for application data.
static int MTU
          LRMP maximum transmission unit including the packet header.
protected  int offset
          offset to application data.
protected static int padBit
           
protected  long rcvSendTime
          time of transmission.
protected  boolean reliable
          per-packet reliability, default value is true.
protected  boolean retransmit
          retransmission flag.
protected  int retransmitID
          retransmission id.
protected  int scope
          scope of transmission.
protected  LrmpEntity sender
          The packet sender.
protected  long seqno
          sequence number.
protected  LrmpEntity source
          The original packet sender.
protected static int strtBit
           
 
Constructor Summary
  LrmpPacket()
          Constructs a reliable LrmpPacket.
  LrmpPacket(boolean reliable)
          Constructs an LrmpPacket.
protected LrmpPacket(boolean reliable, byte[] buff, int offset, int len)
          Constructs an LrmpPacket from received data.
  LrmpPacket(boolean reliable, int length)
          Constructs an LrmpPacket.
  LrmpPacket(int length)
          Constructs a reliable LrmpPacket.
 
Method Summary
protected  void appendNack(inria.net.lrmp.LrmpLossEvent ev)
           
protected  void appendNack(inria.net.lrmp.LrmpLossEvent[] evs)
           
protected  void appendNackReply(inria.net.lrmp.LrmpLossEvent ev, LrmpSender whoami, int firstReply, int bitmReply)
           
protected  void appendReceiverReport(LrmpSender sender, LrmpSender whoami)
           
protected  void appendRRSelection(LrmpSender whoami, int prob, int period)
           
protected  void appendSenderReport(LrmpSender whoami)
           
 java.lang.Object clone()
          Creates a new object of the same class as this object.
protected  boolean equals(LrmpPacket pack)
           
protected  int formatDataPacket(boolean resend)
           
 java.net.InetAddress getAddress()
          Returns the network address of the original packet sender.
 byte[] getDataBuffer()
          Returns the data buffer.
 int getDataLength()
          Returns the length of application data.
 int getMaxDataLength()
          Returns the maximum length available for application data in the buffer.
 int getOffset()
          Returns the offset to application data.
 LrmpEntity getSource()
          Returns the packet source, i.e., the original packet sender.
 int getSourceID()
          Returns the identifier of the original packet sender.
 boolean isFirst()
          Deprecated. it is removed.
 boolean isFirstOfBlock()
          Deprecated. it is removed.
 boolean isLast()
          Deprecated. it is removed.
 boolean isLastOfBlock()
          Deprecated. it is removed.
 boolean isReliable()
          Returns the reliable flag.
 void setDataLength(int i)
          Sets the length of application data.
 void setFirst(boolean f)
          Deprecated. it is removed.
 void setLast(boolean f)
          Deprecated. it is removed.
protected  void setReliable(boolean b)
          sets the reliable flag.
protected  void setSource(LrmpEntity s)
          prepares the packet to be delivered to the application.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

padBit

protected static final int padBit

strtBit

protected static final int strtBit

endBit

protected static final int endBit

MTU

public static final int MTU
LRMP maximum transmission unit including the packet header. The header length is 16 bytes for reliable packets and 8 bytes for unreliable packets.

source

protected LrmpEntity source
The original packet sender.

sender

protected LrmpEntity sender
The packet sender. It may be different from the original sender if it's a retransmission.

buff

protected byte[] buff
the data buffer.

offset

protected int offset
offset to application data.

datalen

protected int datalen
the length of application data in the packet.

maxDataLen

protected int maxDataLen
the maximum length (bytes) available in the allocated buffer for application data.

reliable

protected boolean reliable
per-packet reliability, default value is true.

first

protected boolean first
the start marker.

end

protected boolean end
the end marker.

seqno

protected long seqno
sequence number.

scope

protected int scope
scope of transmission.

rcvSendTime

protected long rcvSendTime
time of transmission.

retransmit

protected boolean retransmit
retransmission flag.

retransmitID

protected int retransmitID
retransmission id.
Constructor Detail

LrmpPacket

public LrmpPacket()
Constructs a reliable LrmpPacket. The data buffer is initialized for application data with the maximum length possible. The available size in the allocated buffer for application data can be obtained through the getMaxDataLength() method. The application should fill data in the buffer from the offset LrmpPacket.getOffset().

LrmpPacket

public LrmpPacket(boolean reliable)
Constructs an LrmpPacket. The data buffer is initialized for application data with the maximum length possible. The available size in the allocated buffer for application data can be obtained through the getMaxDataLength() method. The application should fill data in the buffer from the offset LrmpPacket.getOffset().
Parameters:
reliable - the reliability.

LrmpPacket

public LrmpPacket(int length)
Constructs a reliable LrmpPacket. The data buffer is initialized for application data with the given length. If this length plus Lrmp header length is larger than the maximum transmission unit (MTU) of LRMP, it will be set to the LRMP MTU. The available size in the allocated buffer for application data can be obtained through the getMaxDataLength() method. The application should fill data in the buffer from the offset LrmpPacket.getOffset().
Parameters:
length - the length of application data.

LrmpPacket

public LrmpPacket(boolean reliable,
                  int length)
Constructs an LrmpPacket. The data buffer is initialized for application data with the given length. If this length plus Lrmp header length is larger than the maximum transmission unit (MTU) of LRMP, it will be set to the LRMP MTU. The available size in the allocated buffer for user application can be obtained through the getMaxDataLength() method. The application should fill data in the buffer from the offset LrmpPacket.getOffset().
Parameters:
reliable - the reliability.
length - the application data length.

LrmpPacket

protected LrmpPacket(boolean reliable,
                     byte[] buff,
                     int offset,
                     int len)
Constructs an LrmpPacket from received data.
Parameters:
buff - the data buffer.
offset - the offset.
len - the packet length including the packet header.
Method Detail

setDataLength

public void setDataLength(int i)
Sets the length of application data.
Parameters:
i - the length of application data in number of bytes.

getOffset

public int getOffset()
Returns the offset to application data. It should be used to put application data to the data buffer when sending, and as the starting offset of application data for received packets.

getMaxDataLength

public int getMaxDataLength()
Returns the maximum length available for application data in the buffer.

getDataLength

public int getDataLength()
Returns the length of application data.

getDataBuffer

public byte[] getDataBuffer()
Returns the data buffer.

getAddress

public java.net.InetAddress getAddress()
Returns the network address of the original packet sender.

getSource

public LrmpEntity getSource()
Returns the packet source, i.e., the original packet sender.

getSourceID

public int getSourceID()
Returns the identifier of the original packet sender.

isReliable

public boolean isReliable()
Returns the reliable flag.

setFirst

public void setFirst(boolean f)
Deprecated. it is removed.

Sets the start merker.

setLast

public void setLast(boolean f)
Deprecated. it is removed.

Sets the end merker.

isFirstOfBlock

public boolean isFirstOfBlock()
Deprecated. it is removed.

Returns the start merker.

isLastOfBlock

public boolean isLastOfBlock()
Deprecated. it is removed.

Returns the end merker.

isFirst

public boolean isFirst()
Deprecated. it is removed.

Returns the start merker.

isLast

public boolean isLast()
Deprecated. it is removed.

Returns the end merker.

setReliable

protected void setReliable(boolean b)
sets the reliable flag.

setSource

protected void setSource(LrmpEntity s)
prepares the packet to be delivered to the application.

formatDataPacket

protected int formatDataPacket(boolean resend)

appendNack

protected void appendNack(inria.net.lrmp.LrmpLossEvent[] evs)

appendNack

protected void appendNack(inria.net.lrmp.LrmpLossEvent ev)

appendNackReply

protected void appendNackReply(inria.net.lrmp.LrmpLossEvent ev,
                               LrmpSender whoami,
                               int firstReply,
                               int bitmReply)

appendSenderReport

protected void appendSenderReport(LrmpSender whoami)

appendRRSelection

protected void appendRRSelection(LrmpSender whoami,
                                 int prob,
                                 int period)

appendReceiverReport

protected void appendReceiverReport(LrmpSender sender,
                                    LrmpSender whoami)

equals

protected boolean equals(LrmpPacket pack)

clone

public java.lang.Object clone()
Creates a new object of the same class as this object. The new object has a new buffer which holds the same data as this object. To increase the efficiency, the length of buffer in the new object is determined from the effective data length of this object.
Overrides:
clone in class java.lang.Object


JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.