|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPacket
public class Packet
Packet defines the Fishnet packet headers and some constants.
Field Summary | |
---|---|
static int |
BROADCAST_ADDRESS
|
static int |
HEADER_SIZE
|
static int |
MAX_ADDRESS
|
static int |
MAX_PACKET_SIZE
|
static int |
MAX_PAYLOAD_SIZE
|
static int |
MAX_TTL
|
Constructor Summary | |
---|---|
Packet(int dest,
int src,
int ttl,
int protocol,
int seq,
byte[] payload)
Constructing a new packet. |
Method Summary | |
---|---|
int |
getDest()
|
byte[] |
getPayload()
|
int |
getProtocol()
|
int |
getSeq()
|
int |
getSrc()
|
int |
getTTL()
|
boolean |
isValid()
Tests if this Packet is valid or not |
byte[] |
pack()
Convert the Packet object into a byte array for sending over the wire. |
void |
setTTL(int ttl)
Sets the TTL of this packet |
java.lang.String |
toString()
Provides a string representation of the packet. |
static Packet |
unpack(byte[] packedPacket)
Unpacks a byte array to create a Packet object Assumes the array has been formatted using pack method in Packet |
static boolean |
validAddress(int addr)
Tests if the address is a valid one |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BROADCAST_ADDRESS
public static final int MAX_ADDRESS
public static final int HEADER_SIZE
public static final int MAX_PACKET_SIZE
public static final int MAX_PAYLOAD_SIZE
public static final int MAX_TTL
Constructor Detail |
---|
public Packet(int dest, int src, int ttl, int protocol, int seq, byte[] payload) throws java.lang.IllegalArgumentException
dest
- The destination fishnet address.src
- The source fishnet address.ttl
- The time-to-live value for this packet.protocol
- What type of packet this is.seq
- The sequence number of the packet.payload
- The payload of the packet.
java.lang.IllegalArgumentException
- If the given arguments are invalidMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public int getDest()
public int getSrc()
public int getTTL()
public void setTTL(int ttl)
ttl
- TTL to setpublic int getProtocol()
public int getSeq()
public byte[] getPayload()
public byte[] pack()
public static Packet unpack(byte[] packedPacket)
packedPacket
- String representation of the packet
public static boolean validAddress(int addr)
addr
- Address to check
public boolean isValid()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |