CafNet (carry and forward network) is a delay-tolerant stack that enables mobile data muling and allows data to be sent across an intermittently connected network. The CafNet protocols allow cars to serve as data mules, delivering data between nodes that are otherwise not connected to one another. For example, these protocols could be used to deliver data from sensor networks deployed in the field to Internet servers without requiring anything other than short-range radio connectivity on the sensors (or at the sensor gateway node).
Cafnet depends on:
Download the latest release of CafNet from http://cartel.csail.mit.edu/cafnet/cafnet-0.1.tgz.
Cafnet is a standard setuptools package. To install it with the default options, simply run setup.py install.
Cafnet is a Twisted daemon plugin. Start it by running twistd cafnet <args>. See cafnet-server.bash and cafnet-client.bash for examples. To see all options and their default values, look at the file cafnet/tap.py.
All Cafnet addresses are strings.
The RPC interface to Cafnet consists of the following functions.
bind(addr: str, url: str): int
The client must call this after its own RPC server starts listening and before calling any other Cafnet procedures.
bindregisters the given Cafnet addressaddrwith the given RPC callback URLurlso that Cafnet knows where to direct its callbacks. Always returns the integer 0.
schedule(src_addr: str, dst_addr: str, priority: int, ack_type: str, size: int): int
Schedules an ADU for delivery and returns an integer handle to the ADU.
src_addrmust be the application’s previously bound Cafnet address.dst_addris the destination Cafnet address.priorityis an integer where a larger value corresponds to higher priority.ack_typeis a string, either ‘END-TO-END’ or ‘NONE’.sizeis the length of the ADU in bytes.
The following user callback RPC interface is expected by Cafnet.
get_msg(id: int): binary
Must return the actual ADU bytes associated with
id, as bound by theschedulecall.
msg_received(src_addr: str, dst_addr: str, priority: int, ack_type: str, id: int, msg: binary): int
Called when an incoming ADU is received. Must return 0.
src_addris the sender’s Cafnet address.dst_addris the destination’s Cafnet address (should be the local Cafnet address).priorityis the priority of the incoming message.ack_typeis a string, either ‘END-TO-END’ or ‘NONE’.idis the integer ID of the ADU.msgis the body of the ADU.
ack_received(id: int): int
idis the integer ID of the message that was returned. Must return 0.
Each RPC invocation consists of the name of the procedure and the arguments, followed by the return value from the callee to the caller. The name is a string, and arguments and return values can only be integers or (byte) strings. All integers are 4 bytes and big-endian. All strings consist of an integer length followed by that many bytes.
A single TCP connection is maintained for the duration of the RPC; this may be lazily established (i.e., the first time a call needs to be made, establish the connection). The order of return results must correspond to the order of their respective calls.
The protocol was designed to be fast and simple. Once upon a time, Cafnet used XMLRPC, but that proved to be too slow on the CPU-constrained Soekris boxes, particularly since binary blobs had to be sent around and thus base64-encoded, and since a separate TCP connection was made per call. FastRPC was also considered, but it bears overhead in its use of HTTP and thus per-invocation TCP connections, as well as the extra serialization of type information.
To notify Cafnet that network connectivity has been lost, send the Cafnet daemon the signal RTMAX-9. To notify it when connectivity has been re-established, send signal RTMAX-10. The cell-down.bash and cell-up.bash scripts do this.
http://yz.mit.edu/http://cartel.csail.mit.edu/cafnet/http://cartel.csail.mit.edu/