Class LinkState
java.lang.Object
LinkState
public class LinkState
- extends java.lang.Object
This manages a link state packet, to convey a list of neighbors around the
network for building routing tables.
The format of the link state packet is very simple:
a variable length array of
Note that this header is assumed to be the "payload" contents of a class Packet,
so it does not need source, destination, TTL, sequence #, etc., information.
Constructor Summary |
LinkState(int[] neighbors)
Creates a new LinkState packet |
Method Summary |
int[] |
getNeighbors()
|
byte[] |
pack()
Packs the LinkState packet |
static LinkState |
unpack(byte[] linkState)
Unpacks a packed representation of a LinkState packet |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_NEIGHBORS
public static int MAX_NEIGHBORS
LinkState
public LinkState(int[] neighbors)
throws java.lang.IllegalArgumentException
- Creates a new LinkState packet
- Parameters:
neighbors
- An array of ints containing the neighbors' addresses
- Throws:
java.lang.IllegalArgumentException
getNeighbors
public int[] getNeighbors()
- Returns:
- An int[] containg the neighbors' addresses
pack
public byte[] pack()
- Packs the LinkState packet
- Returns:
- A byte[] containing a packed representaion of this packet
unpack
public static LinkState unpack(byte[] linkState)
- Unpacks a packed representation of a LinkState packet
- Parameters:
linkState
- A packed representation of a LinkState packet
- Returns:
- A LinkState object