|
SatCat5
|
AeroCube File Transfer Protocol (AeroFTP) transmitter.
This file implements the transmit portion of a lightweight file-transfer protocol that can operate over unidirectional links. Transport is over raw-Ethernet or UDP.
For a matching receiver,
Since data transmission is unidirectional, reliable file transfer requires an asynchronous side-channel that can request retransmission of missing blocks. This may be real-time, or it may occur hours or days later. If no such side-channel exists, sending the file multiple times may provide an acceptable chance of receiving the complete file.
Incoming and outgoing files are divided into non-overlapping "blocks". Blocks are numbered from zero, starting on 1,024-byte boundaries. (i.e., All except the final block are exactly 1,024 bytes long.) Files whose length is not a multiple of four bytes will be zero-padded. In theory the protocol supports files up to 16 GiB; this implementation has not been tested beyond 2 GiB.
By default, the client sends one block every millisecond (~8.1 Mbps). To reduce this rate, call throttle(N) to wait N msec before sending each subsequent packet, yielding 8192000/N bps.
Definition at line 42 of file net_aeroftp.h.
#include <net_aeroftp.h>
Public Member Functions | |
| bool | busy () const |
| Is there already a transfer in progress? | |
| bool | done () const |
| Is the current transfer completed? | |
| bool | send (u32 file_id, satcat5::io::Readable *src, satcat5::io::Readable *aux=0) |
| Begin transmission of the designated file. More... | |
| void | close () |
| Close connection and abort transfer in progress. | |
| void | throttle (unsigned msec_per_pkt) |
| Set throttle (one packet every N msec). | |
Protected Member Functions | |
| AeroFtpClient (satcat5::net::Address *dst) | |
| Constructor is only available to child classes. More... | |
| void | end_of_file () |
| End-of-file cleanup. | |
| void | skip_ahead () |
| Skip to next requested block. | |
| void | timer_event () override |
| Callback for timer events. | |
Protected Attributes | |
| satcat5::net::Address *const | m_dst |
| satcat5::io::Readable * | m_src |
| Source for file data. | |
| satcat5::io::Readable * | m_aux |
| Source for retransmit control. | |
| u32 | m_file_id |
| ID for this file. | |
| u32 | m_file_len |
| Length (bytes) | |
| u32 | m_file_pos |
| Current read index (bytes) | |
| u32 | m_bytes_sent |
| Count transmission length. | |
| unsigned | m_throttle |
| Delay per packet (msec) | |
Private Member Functions | |
| void | timer_once (unsigned msec) |
| Configure a one-time notification after X milliseconds. | |
| void | timer_every (unsigned msec) |
| Configure a repeating notification every X milliseconds. | |
| void | timer_stop () |
| Stop all future notifications. | |
| unsigned | timer_interval () const |
| Accessor for recurring timer interval, if one is set. | |
| unsigned | timer_remaining () const |
| Accessor for time to next event, if one is set. | |
| void | query (unsigned elapsed_msec) |
Static Private Member Functions | |
| static unsigned | count_timer () |
| Count all objects of this type, including idle timers. | |
Private Attributes | |
| satcat5::poll::Timer * | m_next |
| unsigned | m_trem |
| unsigned | m_tnext |
|
explicitprotected |
Constructor is only available to child classes.
Definition at line 42 of file net_aeroftp.cc.
| bool AeroFtpClient::send | ( | u32 | file_id, |
| satcat5::io::Readable * | src, | ||
| satcat5::io::Readable * | aux = 0 |
||
| ) |
Begin transmission of the designated file.
The "src" stream contains the file data. The optional "aux" stream indicates whether to transmit each 1,024-byte block (0 = no, 1+ = yes). If no aux source is provided, then the client transmits the entire file.
Definition at line 73 of file net_aeroftp.cc.