edu.virginia.cs.mng.hypercast.HC
Class HC_Message

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.HC.HC_Message

public final class HC_Message
extends java.lang.Object
implements I_Message

This class encapsulates a HC protocol message.


Field Summary
static byte Beacon
          Hypercast protocol message type (used to beacon all)
private  HC_LogicalAddress DestLA
          Destination logical address
private  I_PhysicalAddress DestPA
          Destination physical address
private  HC_LogicalAddress HRootLA
          HRoot logical address
private  int HRootSeqNum
          HRoot sequence number
static byte Kill
          Hypercast protocol message type (used to kill a node)
private  int LASize
          Length of I_LogicalAddress in bytes
static byte Leave
          Hypercast protocol message type (used to leave the hypercube)
private  int overlayHash
          A hash of overlay properties.
private  int PASize
          Length of I_PhysicalAddress in bytes
static byte Ping
          Hypercast protocol message type (used to ping neighbor periodically)
private  HC_LogicalAddress SrcLA
          Source logical address
private  I_PhysicalAddress SrcPA
          Source physical address
private  int Type
          Hypercast protocol message type
 
Constructor Summary
HC_Message(byte[] data, int offset, I_UnicastAdapter adapter)
          Constructs a HC_Message with a byte array and an I_UnicastAdapter The following is the byte format followed
Byte 0 : Type
Bytes 1-4 : overlayHash
Bytes 5-10 : SrcPA
Bytes 11-14: SrcLA
BYtes 15-20: DestPA
Bytes 21-24: DestLA
Bytes 25-28: HRootLA
Bytes 29-32: HRootSeqNum
HC_Message(byte type, int gh, I_PhysicalAddress srcp, HC_LogicalAddress srcl, I_PhysicalAddress desp, HC_LogicalAddress desl, HC_LogicalAddress hrootl, int hrootsn, byte[] data, I_UnicastAdapter adapter)
          Constructs a HC_Message with all the components
 
Method Summary
 HC_LogicalAddress getDestLA()
          Returns the destination logical address of the message
 I_PhysicalAddress getDestPA()
          Returns the destination physical address of the message
 HC_LogicalAddress getHRootLA()
          Returns the HRoot logical address of the message
 int getHRootSeqNum()
          Returns the HRoot sequence number of the message
 int getOverlayHash()
          Returns the overlayHash of this message.
 HC_LogicalAddress getSrcLA()
          Returns the source logical address of the message
 I_PhysicalAddress getSrcPA()
          Returns the source physical address of the message
 int getType()
          Returns the type of the message
static HC_Message restoreMessage(byte[] recvbuff, int[] validBytesStart, int validBytesEnd, I_UnicastAdapter adapter, int thisOverlaysHash)
           
 byte[] toByteArray()
          Converts message to byte array
 java.lang.String toString()
          Converts the message object to String
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

Ping

public static final byte Ping
Hypercast protocol message type (used to ping neighbor periodically)

Kill

public static final byte Kill
Hypercast protocol message type (used to kill a node)

Beacon

public static final byte Beacon
Hypercast protocol message type (used to beacon all)

Leave

public static final byte Leave
Hypercast protocol message type (used to leave the hypercube)

Type

private int Type
Hypercast protocol message type

overlayHash

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

SrcLA

private HC_LogicalAddress SrcLA
Source logical address

DestLA

private HC_LogicalAddress DestLA
Destination logical address

SrcPA

private I_PhysicalAddress SrcPA
Source physical address

DestPA

private I_PhysicalAddress DestPA
Destination physical address

HRootLA

private HC_LogicalAddress HRootLA
HRoot logical address

HRootSeqNum

private int HRootSeqNum
HRoot sequence number

PASize

private int PASize
Length of I_PhysicalAddress in bytes

LASize

private int LASize
Length of I_LogicalAddress in bytes
Constructor Detail

HC_Message

public HC_Message(byte[] data,
                  int offset,
                  I_UnicastAdapter adapter)
Constructs a HC_Message with a byte array and an I_UnicastAdapter

The following is the byte format followed
Byte 0 : Type
Bytes 1-4 : overlayHash
Bytes 5-10 : SrcPA
Bytes 11-14: SrcLA
BYtes 15-20: DestPA
Bytes 21-24: DestLA
Bytes 25-28: HRootLA
Bytes 29-32: HRootSeqNum

Parameters:
data - an input byte array
adapter - an I_UnicastAdapter object
Throws:
if - the packet has an invalid type

HC_Message

public HC_Message(byte type,
                  int gh,
                  I_PhysicalAddress srcp,
                  HC_LogicalAddress srcl,
                  I_PhysicalAddress desp,
                  HC_LogicalAddress desl,
                  HC_LogicalAddress hrootl,
                  int hrootsn,
                  byte[] data,
                  I_UnicastAdapter adapter)
Constructs a HC_Message with all the components

Parameters:
type - the type
srcp - source PhysicalAddress object
srcl - source LogicalAddress object
desp - destination PhysicalAddress object
desl - destination LogicalAddress object
hrootl - HRoot LogicalAddress object
hrootsn - HRoot sequence number
data - payload data array
Throws:
if - the packet has an invalid type
Method Detail

restoreMessage

public static HC_Message restoreMessage(byte[] recvbuff,
                                        int[] validBytesStart,
                                        int validBytesEnd,
                                        I_UnicastAdapter adapter,
                                        int thisOverlaysHash)

toByteArray

public byte[] toByteArray()
Converts message to byte array
Specified by:
toByteArray in interface I_Message
Returns:
a byte array which represents a packet which can be sent out to the network

getType

public int getType()
Returns the type of the message
Returns:
Type of this message

getOverlayHash

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

getDestPA

public I_PhysicalAddress getDestPA()
Returns the destination physical address of the message
Returns:
the destication I_PhysicalAddress object

getSrcLA

public HC_LogicalAddress getSrcLA()
Returns the source logical address of the message
Returns:
the source HC_LogicalAddress object

getDestLA

public HC_LogicalAddress getDestLA()
Returns the destination logical address of the message
Returns:
the destination HC_LogicalAddress object

getHRootLA

public HC_LogicalAddress getHRootLA()
Returns the HRoot logical address of the message
Returns:
the HRoot HC_LogicalAddress object

getHRootSeqNum

public int getHRootSeqNum()
Returns the HRoot sequence number of the message
Returns:
the HRoot sequence number

getSrcPA

public I_PhysicalAddress getSrcPA()
Returns the source physical address of the message
Returns:
the source I_PhysicalAddress object

toString

public java.lang.String toString()
Converts the message object to String
Returns:
a string representation of the HC_Message object
Overrides:
toString in class java.lang.Object