hypercast.SPT
Class SPT_Message

java.lang.Object
  |
  +--hypercast.SPT.SPT_Message
All Implemented Interfaces:
I_Message

public class SPT_Message
extends java.lang.Object
implements I_Message

This class encapsulates a SPT protocol message. The message contains a type (byte), a Overlay hash(int) and 4 AddressPairs. Other fields are related to SPT protocol


Field Summary
static byte Goodbye
          Goodbye message.
static byte Hello
          Beacon message
static byte PROTONUM_SPT30
          Protocol Number value in the Protocol field of a SPT3.0 protocol message
static byte RouteReply
          Sent to reply a route request message
static byte RouteRequest
          Sent when the routing information for some destination is unknown
 
Constructor Summary
SPT_Message(byte[] A, hypercast.I_UnicastAdapter adapter)
          Creates a message from a byte array.
SPT_Message(byte proto_sub, byte T, int gh, hypercast.SPT.SPT_AddressPair ma)
          Constructor for Goodbye message
SPT_Message(byte proto_sub, byte T, int gh, hypercast.SPT.SPT_AddressPair ma, hypercast.SPT.SPT_LogicalAddress pd)
          Constructor for RouteRequest message
SPT_Message(byte proto_sub, byte T, int gh, hypercast.SPT.SPT_AddressPair ma, hypercast.SPT.SPT_LogicalAddress nh, hypercast.SPT.SPT_LogicalAddress pd)
          Constructor for RouteReply message
SPT_Message(byte proto_sub, byte T, int gh, hypercast.SPT.SPT_AddressPair ma, hypercast.SPT.SPT_LogicalAddress ra, hypercast.SPT.SPT_LogicalAddress pa, int ct, long ts, java.util.Hashtable sl, short reli)
          Constructor for Hello message.
SPT_Message(hypercast.SPT.SPT_Message A)
          Constructor a new SPT_Message A from an existing message
 
Method Summary
 boolean containsSender(hypercast.SPT.SPT_LogicalAddress la)
          To do adjacency test
 int getCost()
           
 java.lang.String getLabel()
          Returns the name of the message according to its type.
 hypercast.SPT.SPT_LogicalAddress getNextHop()
          for RouteReply message
 int getOverlayHash()
          Returns the overlayHash of this message.
 hypercast.SPT.SPT_LogicalAddress getParent()
           
 hypercast.SPT.SPT_LogicalAddress getPathDst()
          for RouteRequest/RouteReply message
 int getPathMetric()
           
 int getReversedOneHopReliability(hypercast.SPT.SPT_LogicalAddress la)
          get one hop reversed reliability
 hypercast.SPT.SPT_LogicalAddress getRoot()
           
 int getRootId()
           
 hypercast.SPT.SPT_AddressPair getSelf()
           
 int getSenderSize()
           
 hypercast.SPT.SPT_AddressPair getSrc()
           
 int getSrcId()
           
 hypercast.SPT.SPT_LogicalAddress getSrcLA()
           
 hypercast.I_PhysicalAddress getSrcPA()
           
 long getTimeStamp()
           
 boolean isNeighbor(hypercast.SPT.SPT_LogicalAddress la)
           
static hypercast.SPT.SPT_Message restoreMessage(byte[] A, int[] beginValidBytes, int endValidBytes, hypercast.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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Hello

public static final byte Hello
Beacon message

See Also:
Constant Field Values

Goodbye

public static final byte Goodbye
Goodbye message. Send when leaving the overlay

See Also:
Constant Field Values

RouteRequest

public static final byte RouteRequest
Sent when the routing information for some destination is unknown

See Also:
Constant Field Values

RouteReply

public static final byte RouteReply
Sent to reply a route request message

See Also:
Constant Field Values

PROTONUM_SPT30

public static final byte PROTONUM_SPT30
Protocol Number value in the Protocol field of a SPT3.0 protocol message

See Also:
Constant Field Values
Constructor Detail

SPT_Message

public SPT_Message(hypercast.SPT.SPT_Message A)
Constructor a new SPT_Message A from an existing message

Parameters:
A - the existing message

SPT_Message

public SPT_Message(byte proto_sub,
                   byte T,
                   int gh,
                   hypercast.SPT.SPT_AddressPair ma,
                   hypercast.SPT.SPT_LogicalAddress ra,
                   hypercast.SPT.SPT_LogicalAddress pa,
                   int ct,
                   long ts,
                   java.util.Hashtable sl,
                   short reli)
Constructor for Hello message.


SPT_Message

public SPT_Message(byte proto_sub,
                   byte T,
                   int gh,
                   hypercast.SPT.SPT_AddressPair ma)
Constructor for Goodbye message


SPT_Message

public SPT_Message(byte proto_sub,
                   byte T,
                   int gh,
                   hypercast.SPT.SPT_AddressPair ma,
                   hypercast.SPT.SPT_LogicalAddress pd)
Constructor for RouteRequest message


SPT_Message

public SPT_Message(byte proto_sub,
                   byte T,
                   int gh,
                   hypercast.SPT.SPT_AddressPair ma,
                   hypercast.SPT.SPT_LogicalAddress nh,
                   hypercast.SPT.SPT_LogicalAddress pd)
Constructor for RouteReply message


SPT_Message

public SPT_Message(byte[] A,
                   hypercast.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 hypercast.SPT.SPT_Message restoreMessage(byte[] A,
                                                       int[] beginValidBytes,
                                                       int endValidBytes,
                                                       hypercast.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.

getSenderSize

public int getSenderSize()

toByteArray

public byte[] toByteArray()
Converts the message into a byte array for transmission.

Specified by:
toByteArray in interface I_Message
Returns:
the byte array of the message

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLabel

public java.lang.String getLabel()
Returns the name of the message according to its type. It's for displaying purpose

Returns:
the label of the message type, or "ERROR" if current type is invalid

getSrcPA

public hypercast.I_PhysicalAddress getSrcPA()
Returns:
the message's source's physical address

getSrcLA

public hypercast.SPT.SPT_LogicalAddress getSrcLA()
Returns:
the message's source's logical address

getOverlayHash

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

Returns:
overlayhash

getRoot

public hypercast.SPT.SPT_LogicalAddress getRoot()
Returns:
the root's logical address

getRootId

public int getRootId()
Returns:
the root's ID

getSelf

public hypercast.SPT.SPT_AddressPair getSelf()
Returns:
the address pair of message's source

getSrc

public hypercast.SPT.SPT_AddressPair getSrc()
Returns:
the address pair of message's source

getSrcId

public int getSrcId()
Returns:
the ID of the message's source

getParent

public hypercast.SPT.SPT_LogicalAddress getParent()
Returns:
the parent's logical address

getCost

public int getCost()
Returns:
the path cost to the root

getTimeStamp

public long getTimeStamp()
Returns:
the time stamp

getNextHop

public hypercast.SPT.SPT_LogicalAddress getNextHop()
for RouteReply message

Returns:
the unicast path source address

getPathDst

public hypercast.SPT.SPT_LogicalAddress getPathDst()
for RouteRequest/RouteReply message

Returns:
the unicast path destination address

containsSender

public boolean containsSender(hypercast.SPT.SPT_LogicalAddress la)
To do adjacency test

Parameters:
la - a spt logical address
Returns:
whether this address is contained in the sender list of this message

isNeighbor

public boolean isNeighbor(hypercast.SPT.SPT_LogicalAddress la)

getPathMetric

public int getPathMetric()

getReversedOneHopReliability

public int getReversedOneHopReliability(hypercast.SPT.SPT_LogicalAddress la)
get one hop reversed reliability