This multihop packet-communiction library allows nodes to communicate, even if they are not within each others communication range. RFC works with any routing protocol that provides its functionality through the CC1000 routing interface.
If an application wants to send and receive packets, it should register a packet handler and an error handler with RFC. To do this, it must choose a free port that it attaches to. It then can begin sending packets to other nodes.
Sending packets to other nodes is done byu calling rfc_send(...). This will start a route discovery if no route to the destination is known. As soon as the next hop is known, the packet is sent on it's way. Sending packets works asynchronously, which means that there can be several pending packets for different destinations at the same time. Packets for destinations with an available route a processed right away, they do not have to wait for packets that were queued earlier to finish.
Received packets are delivered to the port listener, if the receiving node is the final destination. If the receiving node is not the final destination, it is forwarded on the route.
In case of error, corrective action is taken. If the node that receives the error is the originating node, the applicatino is informed. If it is not, The packet is silently discarded. There exist hooks in the source code, that allow to easily add end-to-end and intermediate node error reporting. This should be implemented in the next version.
When reading the sourcecode, you will find IMPROVE-tags. This means, that the source code could/should be improved at this point in a later version.
|State that marks a destination as unreachable (packets are dropped). |
|Error that is returned, when the receive queue is full. |
|Error that is returned, when the send queue is full. |
|If set, this packet must be acknowledged by it's final destination. |
|If set, this packet must be acknowledged by next hop. |
|Defines which led to use to show where data lies. |
|Standard return value for successfull processing. |
|Number of available ports that applications can bind to. |
|Size of the queue for packets that are received and not yet processed. |
|Size of the status buffer for received packets. |
|Time in ms that rfc packet information is cached to detect duplicates. |
|Minimum time in ms until send retry if send failed. |
|Size of the queue for packets to be sent or forwarded. |
|Maximum number of retries. |
|State that marks packet as dropped because of processing errors. |
|State that marks packet as waiting for processing. |
|State that marks packet as ready for sending. |
|State that marks packet as rejected by destination. |
|State that marks packet as successfully delivered to destination. |
|State that marks packet as successfully sent to next hop. |
|Undefined state. |
|State that marks packet as waiting for an ack of next hop. |
|State that marks packet as waiting for a message. |
|Defines the CCC packet type that RFC data packets use. |
|rfc_packet_t *||new_rfc_packet (int data_len)|
|void||rfc_deregister_packet_handler (u_char port)|
|void||rfc_enable_ack (char enable_ack)|
|void||rfc_enable_led (int enable_led)|
|int||rfc_init (routing_interface_t *routing_interface)|
|int||rfc_register_packet_handler (u_char port, rfc_packet_handler_t *handler)|
|u_short||rfc_send (u_short dst, u_char type, rfc_packet_t *pkt)|
|Number of failed RFC packets passing through node. |
|Number of RFC packets targeted for this node. |
|#define RFC_FLAG_ACK 2|
If set, this packet must be acknowledged by it's final destination.
Structure describing a port listener for an application
Structure of an rfc packet.
Check the MTU with rfc_get_mtu(). Since RFC does not yet support fragmenting packets, this MUST be done at application level.
Allocates space for a new RFC packet
|data_len||[in] length of the data to be transmitted|
Deregisters a port listener
Enables data ACKs
|enable_ack||[in] 0 to disable, 1 to enable|
Enables LED flashing when data is transmitted.
The node's LEDs shines yellow, whenever a data packet is being processed in the node. Whenever a delivery fails, the red LED flashes.
|enable_led||[in] 0 to disable, 1 to enable.|
Returns the configured mac address
Get the maximal transfer unit
SHOULD be used to decide maximum size of a packet that can be sent.
|int rfc_init||(||routing_interface_t *||routing_interface||)|
Initialises the RFC library.
This function initializes the RFC communication library and MUST be called first. You must provide it a valid interface to the routing protocol you want to use. This requires, that routing is already initialized and running.
|address||[in] interface to the routing protocol that RFC should use|
Registers a port listener
|type||[in] packet type to handle|
|handler||[in] packet handler to use|
Sends a Packet to the destination
Calling this starts sending a packet towards its destination. If a packet can not be delivered, the application will be notified, if it has registired an error handler.
|dst||[in] destination address|
|type||[in] port number at which target application listens|
|pkt||[in] pointer to the packet that should be sent|