TMRh20/RF24Network — pull request #13 by reixd (2014-09-05 15:31:47+00:00)
Title: Feature: fragmentation/reassembly

Fully functional fragmentation and reassembly implementation for large payloads.
Fragmentation is transparent to calling application.

TODO:
- multicast fragmentation
- test with multiple nodes in a larger network
- use a circular queue for the frame_queue data structure
- use a LRUCache data structure for the frame reassembly
- lower memory consumption
- arduino porting
- cleanup code
- remove redundant and unnecessary code

- Based on IPv4 fragmentation https://tools.ietf.org/html/rfc791.
- Tested only on Raspberry Pi, may not work in Arduinos due to memory usage
Tested only with two raspberries using NRF24L01+ 10 meters apart.
- The lib is capable to detect if the message payload is bigger than frame_size-sizeof(Header)
and split the payload into chucks and send them separately.
- This commit introduces two new flag types:
- NETWORK_MORE_FRAGMENTS
- NETWORK_LAST_FRAGMENT
- As of IPv4 fragmentation this flags are used to mark the frames to notify the receiver if more
fragments will come or this is the last fragment.
- The previous _write() function to transmit the frames is used.
- Changes in payload size management were made to allow dynamic payload sizes without the need
to define a field in the header.
- Introduce a new struct type "RF24NetworkFrame" for better frame handling inside the lib.
This type encapsulates the header, the current size of the payload and a (fixed size) array
containing the payload.
- The frame_buffer data structure was changes in favor of a std::queue for better handling.
- Make some changes renaming variables and defining the values.
- Use a std::map with double key (header.to_from,header.id) to identify the incoming fragments,
allowing the reassembly of multiple transmission simultaneously.
- The reassembly of frames happens in the enqueue(frame) function.
Based on the fragment_id and header.id the fragments are handled differently and in the end
the completely assembled frames are queued in the frame_queue presenting them to the calling
application.
- Introduce a new debug flag to print fragmentation debug messages.
- Use definitions for static values like frame size or payload max size.
- Strip trailing spaces and fix some indentation issues.