|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ants.core.Capsule | +--ants.core.DataCapsule
Data capsule. Data capsules simply forward themselves to their destination. Each DataCapsule contains source and destination application ports (in addition to the source and destination node addresses kept by the superclass). Also, an arbitrary ByteArray payload is attached to the capsule.
XXX This doesn't need to be a builtin capsule type. Its convenient and all, but its not critical. Move it out to the apps/ directory. (Well, the fact that its builtin means the ID is fixed, so this is handy in a backwards-compatiblity way.)
Field Summary | |
short |
dpt
Destination application's port. |
short |
spt
Source application's port. |
static java.lang.String |
VERSION
WARNING: this is a builtin capsule, whose version number must be manually kept in synch with its functionality. |
Fields inherited from class ants.core.Capsule |
MAX_TTL |
Constructor Summary | |
DataCapsule()
|
|
DataCapsule(short s,
short d,
int n,
ByteArray p)
Construct a new DataCapsule. |
Method Summary | |
Xdr |
decode()
Decode a capsule header from this Capsule's xdr field. |
Xdr |
encode()
Encode this capsule's header into a new Xdr. |
boolean |
evaluate(Node n)
Forwarding function for DataCapsules. |
ByteArray |
getData()
Get the payload associated with this DataCapsule. |
int |
length()
Return length of this data capsule. |
void |
setData(ByteArray data)
Set the payload associated with this DataCapsule. |
java.lang.String |
toString()
String representation of a Capsule. |
Methods inherited from class ants.core.Capsule |
create,
encodeCapsuleForSend,
findExtension,
findMID,
findPID,
getDst,
getPrevious,
getSrc,
getTTL,
prime,
setDst |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String VERSION
BuiltinProtocol#addCapsule(java.lang.String,java.lang.String)
public short spt
Not used by the DataCapsule, but its assumed that most users of this type will want to know where the capsule came from.
public short dpt
Constructor Detail |
public DataCapsule()
public DataCapsule(short s, short d, int n, ByteArray p)
s
- the source application's portd
- the destination application's portn
- the address of the destination node.p
- the payload.Method Detail |
public int length()
Capsule.length()
public Xdr encode()
Because this header must go first in the Xdr, this encoder unilaterally sets the xdr buffer pointer to the beginning of the buffer and writes its data there.
The format of the Xdr is:
MethodID (16 bytes) src address ( 4 bytes) dst address ( 4 bytes) previous address ( 4 bytes) TTL ( 4 bytes)
#xdr
public Xdr decode()
public ByteArray getData()
public void setData(ByteArray data)
public boolean evaluate(Node n)
node
- the local node interfacepublic java.lang.String toString()
|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |