Net.tinyos.packet BuildSource Make a new PhoenixSource over a specified PacketSource. Note...

advertisement
Net.tinyos.packet
BuildSource
Make a new PhoenixSource over a specified PacketSource. Note that a PhoenixSource must be started before use, and that resurrection
is off by default (the default error calls System.exit).
Packetizer
The Packetizer class implements the new mote-PC protocol, using a ByteSource for low-level I/O
The Packetizer class implements the new mote-PC protocol, using a ByteSource for low-level I/O
Protocol inspired by, but not identical to, RFC 1663. There is currently no protocol establishment phase, and a single byte ("packet
type") to identify the kind/target/etc of each packet. The protocol is really, really not aiming for high performance. There is however a
hook for future extensions: implementations are required to answer all unknown packet types with a P_UNKNOWN packet.
To summarise the protocol:
the two sides (A & B) are connected by a (potentially unreliable) byte stream
- the two sides exchange packets framed by 0x7e (SYNC_BYTE) bytes
- each packet has the form
<packet type> <data bytes 1..n> <16-bit crc>
where the crc (see net.tinyos.util.Crc) covers the packet type and bytes 1..n
- bytes can be escaped by preceding them with 0x7d and their value xored with 0x20; 0x7d and 0x7e bytes must be escaped, 0x00 0x1f and 0x80-0x9f may be optionally escaped
- There are currently 5 packet types:
P_PACKET_NO_ACK: A user-packet, with no ack required
P_PACKET_ACK: A user-packet with a prefix byte, ack required. The receiver must send a P_ACK packet with the prefix byte as its
contents.
P_ACK: ack for a previous P_PACKET_ACK packet
P_UNKNOWN: unknown packet type received. On reception of an unknown packet type, the receicer must send a P_UNKNOWN
packet, the first byte must be the unknown packet type.
- Packets that are greater than a (private) MTU are silently dropped.
SFSource
Packet source (tcp/ip client) for the new serial forwarder protocol
NetworkByteSource
A tcp/ip (client) byte-source; imports the javax.comm packet
SerialByteSource
A serial port byte source, with extra special hack to deal with broken javax.comm implementations (IBM's javax.comm does not set the
port to raw mode, on Linux, at least in some implementations - call an external program (tinyos-serial-configure) to "fix" this)
AbstractSource
Provide a standard, generic implementation of PacketSource. Subclasses need only implement low-level open and close operations, and
packet reading and writing. This class provides the automatic close-on-error functionality, general error checking, and standard
messages.
ByteSource
Simple byte I/O interface for use with PacketSource packetizers
PacketSource
This interface specifies the generic behaviour of a packet mediator. The read and write operations are blocking. Reads and writes may
fail (e.g., for communications failure), which implicitly closes the mediator. It is not possible to reopen a mediator after it is closed
(instead, a new mediator should be created).
The packet byte array must have the following format:
- a TinyOS TOS_Msg header (5 bytes):
address: 2 bytes, little endian
AM type: 1 byte
group: 1 byte
length: 1 byte
- 'length' data bytes
PacketSources are point-to-point and have "at most once" semantics. writePacket should return true only if the packet has been
received. Note that checking this is not possible with some of our broken, legacy protocols, and that we will optimistically assume that
packets sent over reliable links (e.g., tcp/ip socket to a serial forwarder) will be reliably delivered by tcp/ip.
PheonixSource
A PhoenixSource builds upon a PacketSource to provide the following features:
- automatic reading and dispatching of packets (registerPacketListener and deregisterPacketListener)
- automatic source restarting (via setResurrection), off by default
PhoenixSources are threads and hence need to be started. PhoenixSources are not PacketSources (direct reads are no longer allowed,
open and close is less meaningful with automatic restart).
net.tinyos.message.MoteIF builds upon a PhoenixSource, not a PacketSource. PhoenixSources are built using the makePhoenix
methods in BuildSource.
Download