jist.swans.route
Class RouteZrpZdp.MessageZdp

java.lang.Object
  extended by jist.swans.route.RouteZrpZdp.MessageZdp
All Implemented Interfaces:
JistAPI.Timeless, Message, RouteInterface.Zrp.MessageIarp, RouteInterface.Zrp.MessageZrp
Enclosing class:
RouteZrpZdp

public static class RouteZrpZdp.MessageZdp
extends java.lang.Object
implements RouteInterface.Zrp.MessageIarp

ZDP (Zone Discovery Protocol) packet.

    todo: TBD (see draft ZDP specification)
  


Field Summary
private  byte compress
          type of packet compression/structure.
private  boolean[] drops
          link failure indicators.
private  boolean frozen
          whether packet is immutable.
private  short[] ids
          link identifiers.
private  Link[] links
          link source-destination pairs.
private  int num
          number of links in packet.
private  int size
          precomputed packet size.
 
Fields inherited from interface jist.swans.misc.Message
NULL
 
Constructor Summary
RouteZrpZdp.MessageZdp(int capacity, byte compress)
          Create new packet with given initial capacity.
 
Method Summary
 void addLink(Link link, short id, boolean drop)
          Add link to the packet structure.
private  void ensureCapacity()
          Expand internal arrays to ensure room for one more link.
 void freeze()
          Freeze packet; make it immutable.
 void getBytes(byte[] b, int offset)
          Store packet into byte array.
 Link getLink(int i)
          Return link source-destination pair.
 boolean getLinkDrop(int i)
          Return whether link has drop bit set.
 short getLinkId(int i)
          Return link identifier.
 int getNumLinks()
          Return number of links in packet.
 int getSize()
          Return packet size or Constants.ZERO_WIRE_SIZE.
private  int getSizeCompressNode()
          Compute size of link state compressed at the node level.
private  int getSizeCompressNone()
          Compute size of uncompressed link state delta.
private  int getSizeCompressZone()
          Compute size of link state compressed at the zone level.
private  int getSizeCompressZoneReverse()
          Compute size of link state compressed at the zone level, with reversal bit.
private  int getUniqueAddresses()
          Return number of unique addresses in packet.
private  int getUniqueDstAddresses()
          Return number of unique link destinations in packet.
 boolean isFrozen()
          Return whether packet is immutable.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

num

private int num
number of links in packet.


links

private Link[] links
link source-destination pairs.


ids

private short[] ids
link identifiers.


drops

private boolean[] drops
link failure indicators.


frozen

private boolean frozen
whether packet is immutable.


compress

private byte compress
type of packet compression/structure.


size

private int size
precomputed packet size.

Constructor Detail

RouteZrpZdp.MessageZdp

public RouteZrpZdp.MessageZdp(int capacity,
                              byte compress)
Create new packet with given initial capacity.

Parameters:
capacity - initial packet link capacity
compress - packet compression mode/format
Method Detail

ensureCapacity

private void ensureCapacity()
Expand internal arrays to ensure room for one more link.


addLink

public void addLink(Link link,
                    short id,
                    boolean drop)
Add link to the packet structure.

Parameters:
link - source-destination pair
id - destination sequenced link identifier
drop - whether link is up or down

freeze

public void freeze()
Freeze packet; make it immutable.


isFrozen

public boolean isFrozen()
Return whether packet is immutable.

Returns:
whether packet is immutable

getNumLinks

public int getNumLinks()
Return number of links in packet.

Returns:
number of links in packet

getLink

public Link getLink(int i)
Return link source-destination pair.

Parameters:
i - link number
Returns:
link source-destination pair

getLinkId

public short getLinkId(int i)
Return link identifier.

Parameters:
i - link number
Returns:
link identifier

getLinkDrop

public boolean getLinkDrop(int i)
Return whether link has drop bit set.

Parameters:
i - link number
Returns:
whether link has drop bit set

getSize

public int getSize()
Return packet size or Constants.ZERO_WIRE_SIZE.

Specified by:
getSize in interface Message
Returns:
packet size

getSizeCompressNone

private int getSizeCompressNone()
Compute size of uncompressed link state delta.
 - added links count     1 byte
 - dropped links count   1 byte
 - array of links:
   - src address         4 bytes
   - dst address         4 bytes
   - seq-id              1 byte
 

Returns:
size of link state without any comrpession

getSizeCompressNode

private int getSizeCompressNode()
Compute size of link state compressed at the node level.
 - number of unique dsts    1 byte
 - list of dst entries:
   - dst address            4 bytes
   - seq-id                 1 byte
   - number of added        1 byte
   - number of dropped      1 byte
   - list of src addresses:
     - src address          4 bytes
 

Returns:
size of link state compressed at the node level

getUniqueDstAddresses

private int getUniqueDstAddresses()
Return number of unique link destinations in packet.

Returns:
number of unique link destinations in packet

getUniqueAddresses

private int getUniqueAddresses()
Return number of unique addresses in packet.

Returns:
number of unique addresses in packet

getSizeCompressZone

private int getSizeCompressZone()
Compute size of link state compressed at the zone level.
 - number of unique addr     k byte(s)
 - list of addr entries:
   - addr                    4 bytes
   - seq-id                  1 byte
 - list of links:
   - dst index               k byte(s)
   - list list srcs:   
     - src index             k byte(s)
     - flags                 1 byte
       - drop 
       - another-src
       - another-dst
 

Returns:
size of link state compressed at the zone level

getSizeCompressZoneReverse

private int getSizeCompressZoneReverse()
Compute size of link state compressed at the zone level, with reversal bit.
 - number of unique addr     k byte(s)
 - list of addr entries:
   - addr                    4 bytes
   - seq-id                  1 byte
 - list of links:
   - dst index               k byte(s)
   - list list srcs:   
     - src index             k byte(s)
     - flags                 1 byte
       - drop 
       - and-reverse ******  ADDITONAL FLAG
       - another-src
       - another-dst
 

Returns:
size of link state compressed at the zone level with link reversal

getBytes

public void getBytes(byte[] b,
                     int offset)
Store packet into byte array.

Specified by:
getBytes in interface Message
Parameters:
b - destination byte array
offset - byte array starting offset

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object