|
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
A capsule is a combination of a packet and its forwarding routine; the forwarding routine is executed at every active node the packet visits in the network.
This is an abstract, an actual Capsule is created by subclassing this class and filling in the missing routines.
Subclasses must implement the mid(), pid(), and evalutate() methods.
All ANTS capsules have the following format:
header 4-byte ANTS version number 16-byte MethodID (The MD5 hash over the class bytecode) 4-byte logical source address 4-byte logical destination address 4-byte logical previous-hop address 4-byte TTL field. ... Capsule-specific data ...
Field Summary | |
static int |
MAX_TTL
|
Constructor Summary | |
Capsule()
Create a dull capsule. |
Method Summary | |
static Capsule |
create(java.lang.Class cl,
Xdr xdr)
Create a new Capsule from the given Xdr. |
Xdr |
decode()
Decode a capsule header from this Capsule's xdr field. |
Xdr |
encode()
Encode this capsule's header into a new Xdr. |
Xdr |
encodeCapsuleForSend(Node node)
Encode an outgoing capsule. |
abstract boolean |
evaluate(Node node)
The forwarding routine for the Capsule. |
static int |
findExtension(java.lang.String name)
Find a given extension. |
static byte[] |
findMID(java.lang.String name)
Access point to initialze capsule methodIDs. |
static byte[] |
findPID(java.lang.String name)
Access point to initialze capsule protocolID. |
int |
getDst()
Return the destination IP address of this capsule. |
int |
getPrevious()
Get the 32-bit IP address of the active node this packet just came from. |
int |
getSrc()
Return the source IP address of this capsule. |
int |
getTTL()
Return the TTL-like counter for this capsule. |
int |
length()
Return the length of the capsule header that all capsule encodings will include. |
void |
prime(Capsule parent)
Prime this capsule for transmission. |
void |
setDst(int dst)
Set the destination IP address of this capsule. |
java.lang.String |
toString()
String representation of a Capsule. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int MAX_TTL
Constructor Detail |
public Capsule()
Method Detail |
public int getPrevious()
public int getTTL()
public static byte[] findMID(java.lang.String name)
XXX its probably bad that the actual underlying byte[] is returned and not a copy... Who uses this?
name
- the name of the Capsule classNode#findMID(java.lang.String)
public static byte[] findPID(java.lang.String name)
name
- the name of the Capsule classNode#findPID(java.lang.String)
public static int findExtension(java.lang.String name)
XXX This interface will need to be replaced to allow extensions to be reference counted (and unloaded).
name
- The name of the extension to load.public abstract boolean evaluate(Node node)
This method should not access other Java classes, and should only interact with the local system through the local node interface. This routine should "terminate quickly."
XXX perhaps default to forwarding the Capsule?
node
- the local node interfacepublic int getSrc()
public int getDst()
public void setDst(int dst)
dst
- the destination IP address of this capsule.public int 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 encodeCapsuleForSend(Node node)
This writes the ANEP and ANTS header for an outgoing capsule in its associated Xdr. A new Xdr is created if the Capsule doesn't already have one. Then the per-capsule encoding is called.
This function should be invoked immediately before pushing the capsule out the door.
XXX: rename to 'encodeForSend()'
node
- the node interfacepublic Xdr decode()
public final void prime(Capsule parent)
Does not maintain zero-sum ttl. This capsule gets parent's ttl minus 1. Parent loses one hop.
parent
- the capsule to take src and ttl (minus 1)
from.public java.lang.String toString()
public static Capsule create(java.lang.Class cl, Xdr xdr) throws java.lang.Exception
cl
- the subtype of capsule to createxdr
- the encoding of the actual capsule
|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |