Communication Protocols

In a previous post, we examined the different options we had (Layer 3 in the OSI Model) for transmitting data.

We’ve focused our efforts so far on working with ESP-NOW for a few reasons:

  1. ESP-NOW does not require devices to be connected to the same Wi-Fi network
  2. TCP has overheads (eg handshakes) which we do not fully need.

Working with UDP would allow us to customise the later protocols to suit our needs, but UDP is still built for communication over an IP network.

ESP-NOW suits our use case perfectly:

  1. Devices do not need to be connected to the same Wi-Fi network
  2. Conceptually, it performs the same higher-throughput-no-features role that UDP does
  3. ESP-NOW supports basic encryption
  4. ESP-NOW has built-in error detection
  5. ESP-NOW supports basic re-transmission of packets that are not received

Our application has the following requirements:

  1. Guaranteed, in-order transmission of files
  2. Ability to discover available files on a remote node
  3. Ability to resume transmission from an arbitrary offset in a file

With these in mind, we implemented a modified version of the Trivial File Transfer Protocol (TFTP). TFTP is a very simple protocol used in resource-constrained environments which makes it particularly suitable for our application. Customisations:

Window Size: We implement the Window size option. TFTP’s default behavior of acknowledging every data packet is known to affect throughput. Acknowledging multiple data packets at a time improves throughput.

Binary Packing: TFTP’s use of ASCII strings is inefficient, limiting how much information we can pack into a single packet in certain situations. We opt to identify files by a number as filenames are not important in our application.

File Offsets: Read requests specify not only the file index, but also the offset at which to start transfers at. This will allow resuming of data transfers (eg the UAV goes out of range).

The work-in-progress implementation discussed above can be found here. A test project integrating both client and server together can be found here.

Leave a Reply

Your email address will not be published. Required fields are marked *