|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--java.net.ANEPPacket
This class define an ANEP packet, and is used to send or receive data.
When receiving data, you need to specified the length of data you expect to receive, if there is less data the length will be changed, if there is more the data will be truncated.
There is not fundamental difference between constructors used for sending or receiving packet, except the fact that when receiving packet you need to specify less information.
For information the ANEP packet header looks like:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version | Flags | Type ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ANEP Header Length | ANEP Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ~ Options ~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | . | ~ Payload ~ | . | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field Summary | |
static int |
FLAG_DISCARD
Flag to discard the packet if the receiving node is not able to deal with the packet type, otherwise if able, the node will try to forward it. |
static int |
MAX_TYPE
Maximal TypeId for a packet |
static int |
USE_DEFAULT_FLAGS
This is used to indicate to use the system default value for the ANEP packet flag. |
| Fields inherited from interface java.net.ANEPPacketType |
ANAIS_Data, ANAIS_Management1, ANAIS_Management2, ANAIS_Multicast, ANAIS_Reserved, ANCORS_daemon, Anet, Anet_simulation, ANTS, DAN, MO_messengers, NetScript_ManagementTraffic, NetScript_PacketTraffic, NetScript_ProgramDeploymentPackets, PLAN, Spanner |
| Constructor Summary | |
ANEPPacket(byte[] payload,
int offset,
int length)
Constructs an ANEP packet for receiving packets of length length to the specified host. |
|
ANEPPacket(byte[] payload,
int offset,
int length,
ANEPOption[] options)
Constructs an ANEP packet for receiving packets of length length to the specified host. |
|
ANEPPacket(int type,
byte[] payload,
int offset,
int length,
ANEPOption[] options,
InetAddress addr)
Constructs an ANEP packet for sending packets of length length to the specified host. |
|
ANEPPacket(int type,
byte[] payload,
int offset,
int length,
InetAddress addr)
Constructs an ANEP packet for sending packets of length length to the specified host. |
|
ANEPPacket(int type,
int flags,
byte[] payload,
int offset,
int length,
ANEPOption[] options,
InetAddress address)
Constructs an ANEP packet for sending packets of length length to the specified host. |
|
| Method Summary | |
InetAddress |
getAddress()
Get the address of the destination. |
byte[] |
getData()
Get the packet payload. |
int |
getFlags()
Get the ANEP packet flags which are defined here as FLAG_*. |
int |
getLength()
Returns the length of the data to be sent or the length of the data received. |
int |
getOffset()
Returns the offset of the data to be sent or the offset of the data received. |
ANEPOption[] |
getOptions()
Get the ANEP packet options. |
int |
getType()
Get the packet type Id. |
void |
setAddress(InetAddress iaddr)
Set the address of the receiver. |
void |
setData(byte[] payload,
int offset,
int length)
Set the data buffer for this packet. |
void |
setFlags(int flags)
Set the flags for the ANEP packet. |
void |
setOptions(ANEPOption[] options)
Specify the options to be send with the main data. |
void |
setType(int type)
Set the ANEP type of the packet. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int FLAG_DISCARD
public static final int MAX_TYPE
public static final int USE_DEFAULT_FLAGS
| Constructor Detail |
public ANEPPacket(int type,
int flags,
byte[] payload,
int offset,
int length,
ANEPOption[] options,
InetAddress address)
length to the specified host.
The offset combined
with the length should not exced the size of the
payload buffer (payload.length).
Due to implementation constraints the only value
accepted (for now) for flags is
USE_DEFAULT_FLAGS
type - the packet type.flags - the packet flagspayload - the packet data.length - the length for the buffer.offset - the offset for the buffer.options - the ANEP options.addr - the destination address.ANEPPacketType,
InetAddress
public ANEPPacket(int type,
byte[] payload,
int offset,
int length,
InetAddress addr)
length to the specified host.
The offset combined
with the length should not exced the size of the
payload buffer (payload.length). type - the packet type.payload - the packet data.length - the length for the buffer.offset - the offset for the buffer.addr - the destination address.ANEPPacketType,
InetAddress
public ANEPPacket(int type,
byte[] payload,
int offset,
int length,
ANEPOption[] options,
InetAddress addr)
length to the specified host.
The offset combined
with the length should not exced the size of the
payload buffer (payload.length). type - the packet type.payload - the packet data.length - the length for the buffer.offset - the offset for the buffer.options - the ANEP options.addr - the destination address.ANEPPacketType,
InetAddress
public ANEPPacket(byte[] payload,
int offset,
int length,
ANEPOption[] options)
length to the specified host.
The offset combined
with the length should not exced the size of the
payload buffer (payload.length). payload - the packet data.length - the length for the buffer.offset - the offset for the buffer.options - the ANEP options.InetAddress
public ANEPPacket(byte[] payload,
int offset,
int length)
length to the specified host.
The offset combined
with the length should not exced the size of the
payload buffer (payload.length). payload - the packet data.length - the length for the buffer.offset - the offset for the buffer.InetAddress| Method Detail |
public void setData(byte[] payload,
int offset,
int length)
offset combined
with the length should not exced the size of the
payload buffer (payload.length). payload - the buffer to set for this packetoffset - the offset into the datalength - the length of the dataNullPointerException - if the argument is nullgetData(),
getOffset(),
getLength()public void setAddress(InetAddress iaddr)
iaddr - address of the receiverpublic void setType(int type)
type - ANEP type Idpublic void setFlags(int flags)
FLAG_DISCARD
is supported. For performance, it is better to set the flags on the socket level, and use the default value for the packet than setting the flags for every packet.
Due to implementation constraints the only value
accepted (for now) is USE_DEFAULT_FLAGS
flags - flags to useSocketOptions.ANEP_DISCARD,
USE_DEFAULT_FLAGS,
FLAG_DISCARDpublic void setOptions(ANEPOption[] options)
options - an array of options to send.public int getFlags()
USE_DEFAULT_FLAGS
value.ANEPSocket.receive(java.net.ANEPPacket)public ANEPOption[] getOptions()
public int getType()
ANEPPacketTypepublic InetAddress getAddress()
public byte[] getData()
public int getLength()
public int getOffset()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||