|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectEmulatorPacket
public class EmulatorPacket
Packet used by emulated nodes to send data to each other via UDP
Field Summary | |
---|---|
static int |
HEADER_SIZE
|
static int |
MAX_PACKET_SIZE
|
Constructor Summary | |
---|---|
EmulatorPacket(int destAddr,
int srcAddr,
byte[] payload)
Constructing a new packet |
Method Summary | |
---|---|
int |
getDest()
Get the address of the destination node |
byte[] |
getPayload()
Get the payload |
int |
getSrc()
Get the address of the source node |
byte[] |
pack()
Convert packet into byte[] for sending over UDP Socket Format: destination address: 8 bits source address: 8 bits packet length: 8 bits payload: <= (MAX_PACKET_SIZE - HEADER_SIZE) bytes |
java.lang.String |
toString()
Return a string representation of this packet |
static EmulatorPacket |
unpack(byte[] packet)
Unpacks a byte array to create a EmulatorPacket object Assumes the array has been formatted using pack method |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int HEADER_SIZE
public static int MAX_PACKET_SIZE
Constructor Detail |
---|
public EmulatorPacket(int destAddr, int srcAddr, byte[] payload) throws java.lang.IllegalArgumentException
destAddr
- The fishnet address of the destination nodesrcAddr
- The fishnet address of the source nodepayload
- The payload of the packet
java.lang.IllegalArgumentException
- If the size of the payload is too bigMethod Detail |
---|
public int getDest()
public int getSrc()
public byte[] getPayload()
public java.lang.String toString()
toString
in class java.lang.Object
public byte[] pack()
public static EmulatorPacket unpack(byte[] packet)
packet
- String representation of the packet
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |