edu.virginia.cs.mng.hypercast.DT
Class DT_Message

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.DT.DT_Message

class DT_Message
extends java.lang.Object
implements I_Message

This class encapsulates a DT protocol message. The message contains a type (byte), a Overlay hash(int) and 4 AddressPairs. The Src and Dst AddressPairs can not both be null.

It is immutable.


Field Summary
private  DT_AddressPair CCW
          Logical and Physical address of the neighbor of the sender immediately counterclockwise (CCW) of the destination.
private  DT_AddressPair CW
          Logical and Physical address of the neighbor of the sender immediately clockwise (CW) of the destination.
private  DT_AddressPair Dst
          Logical and Physical address of the destination.
static byte Goodbye
          A message type
static byte HelloNeighbor
          A message type
static byte HelloNotNeighbor
          A message type
static byte NewNode
          A message type
static byte NodePing
          A message type
static byte NodePong
          A message type
private  int overlayHash
          A hash of Overlay properties.
static byte ServerReply
          A message type
static byte ServerRequest
          A message type
private  DT_AddressPair Src
          Logical and Physical address of the sender.
static byte TestMessage
          A test type
private  byte Type
          The protocol message type.
 
Constructor Summary
DT_Message(byte[] A, I_UnicastAdapter adapter)
          Creates a message from a byte array.
DT_Message(DT_Message A)
          Copy Constructor.
DT_Message(int T, int gh, DT_AddressPair Src_arg, DT_AddressPair Dst_arg, DT_AddressPair CW_arg, DT_AddressPair CCW_arg)
          Construct a new DT_Message.
 
Method Summary
 DT_AddressPair getCCW()
           
 DT_LogicalAddress getCCWLA()
           
 I_PhysicalAddress getCCWPA()
           
 DT_AddressPair getCW()
           
 DT_LogicalAddress getCWLA()
           
 I_PhysicalAddress getCWPA()
           
 DT_AddressPair getDst()
           
 DT_LogicalAddress getDstLA()
           
 I_PhysicalAddress getDstPA()
           
 java.lang.String getLabel()
          Returns a string dependant on the message type.
 DT_AddressPair getLeader()
          the same as getCW
 DT_LogicalAddress getLeaderLA()
           
 I_PhysicalAddress getLeaderPA()
           
 int getOverlayHash()
          Returns the overlayHash of this message.
 DT_AddressPair getSrc()
           
 DT_LogicalAddress getSrcLA()
           
 I_PhysicalAddress getSrcPA()
           
(package private)  byte getType()
          Returns the type of the message.
static DT_Message restoreMessage(byte[] A, int[] beginValidBytes, int endValidBytes, I_UnicastAdapter adapter, int thisOverlayHash)
          Creates a message, if possible, from a byte array.
 byte[] toByteArray()
          Converts the message into a byte array for transmission.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

HelloNeighbor

public static final byte HelloNeighbor
A message type

HelloNotNeighbor

public static final byte HelloNotNeighbor
A message type

Goodbye

public static final byte Goodbye
A message type

ServerRequest

public static final byte ServerRequest
A message type

ServerReply

public static final byte ServerReply
A message type

NewNode

public static final byte NewNode
A message type

NodePing

public static final byte NodePing
A message type

NodePong

public static final byte NodePong
A message type

TestMessage

public static final byte TestMessage
A test type

Type

private byte Type
The protocol message type.

overlayHash

private int overlayHash
A hash of Overlay properties. It is used to detect either conflicting Overlays or detect bad packets.

Src

private DT_AddressPair Src
Logical and Physical address of the sender.

Dst

private DT_AddressPair Dst
Logical and Physical address of the destination.

CW

private DT_AddressPair CW
Logical and Physical address of the neighbor of the sender immediately clockwise (CW) of the destination. For the LeaderIs messages, this contains the Leader's addresses.

CCW

private DT_AddressPair CCW
Logical and Physical address of the neighbor of the sender immediately counterclockwise (CCW) of the destination.
Constructor Detail

DT_Message

public DT_Message(DT_Message A)
Copy Constructor.

DT_Message

public DT_Message(int T,
                  int gh,
                  DT_AddressPair Src_arg,
                  DT_AddressPair Dst_arg,
                  DT_AddressPair CW_arg,
                  DT_AddressPair CCW_arg)
Construct a new DT_Message. For LeaderIs messages, the Leader's AddressPair should go in the place of CW.

DT_Message

public DT_Message(byte[] A,
                  I_UnicastAdapter adapter)
Creates a message from a byte array.
Parameters:
adapter - used to create new PhysicalAddress from the byte array.
Method Detail

restoreMessage

public static DT_Message restoreMessage(byte[] A,
                                        int[] beginValidBytes,
                                        int endValidBytes,
                                        I_UnicastAdapter adapter,
                                        int thisOverlayHash)
Creates a message, if possible, from a byte array. If a message is read, the value of beginValidBytes is incremented to the index of the first byte not in the message.
Parameters:
adapter - used to create new PhysicalAddress from the byte array.

toByteArray

public byte[] toByteArray()
Converts the message into a byte array for transmission.
Specified by:
toByteArray in interface I_Message

getLabel

public java.lang.String getLabel()
Returns a string dependant on the message type.

getType

byte getType()
Returns the type of the message.

getOverlayHash

public int getOverlayHash()
Returns the overlayHash of this message.

getSrcPA

public I_PhysicalAddress getSrcPA()

getDstPA

public I_PhysicalAddress getDstPA()

getCCWPA

public I_PhysicalAddress getCCWPA()

getCWPA

public I_PhysicalAddress getCWPA()

getLeaderPA

public I_PhysicalAddress getLeaderPA()

getSrcLA

public DT_LogicalAddress getSrcLA()

getDstLA

public DT_LogicalAddress getDstLA()

getCCWLA

public DT_LogicalAddress getCCWLA()

getCWLA

public DT_LogicalAddress getCWLA()

getLeaderLA

public DT_LogicalAddress getLeaderLA()

getSrc

public DT_AddressPair getSrc()

getDst

public DT_AddressPair getDst()

getCCW

public DT_AddressPair getCCW()

getCW

public DT_AddressPair getCW()

getLeader

public DT_AddressPair getLeader()
the same as getCW