Close

Data link layer

A project log for digital-walkie-talkie

long range, low power, modular

christoph-tackChristoph Tack 04/22/2021 at 18:083 Comments

Packeting

Packet interval

Codec2 1200bps has been selected, it needs to be fed 6 bytes every 40ms.

dPMR uses packets that are (Header (80ms) + 4* super frame(320ms) + end (20ms)) = 1.38s long!  Using such long packets has the advantage that the overhead is relatively small for the payload.  This also implies that the FIFO is refilled as the transmission is ongoing. 

SCIP-210, Revision 3.6 §2.1.3 : Transport framing : All frames are split up in 20 byte frames, of which 13 bytes are data.

Packet size

The raw data rate of Codec2 is 1200baud.  If consider that raw data will only make up 25% of the total packet interval, then we'lll need to send at least at 4800baud.  The remainder of the packet interval goes up on:

If we want to adhere more or less to dPMR, we'll want to use 6.25kHz channels.  4800baud FSK needs more than 6.25kHz bandwidth, so we'll need more bits/symbol : 4(G)FSK.

This only leaves the SI4463 and AX5043 as options.

For the 1200bps, FSK and OOK are still options:

  1. SX1278 : FSK : 2.4kbps BR, 4.8kHz freq.dev., 7.8kHz Rx BW.
  2. SX1278 : OOK : 3.0kbps, 5.2kHz Rx BW.

Is there a suitable library for the SI4463?

So I decided to merge Zak's code and the official WDS3 code into my favorite radio library : RadioLib.

Now with the library working (based on Zak Kemble's code), I noticed that sending the 10byte packes from Zak Kemble's example takes 57ms.  That's measured from the end of the 0x31 START_TX command to the falling edge of IRQ that signals a PACKET_SENT.  For 1200bps, we need to send 6 bytes every 40ms.  If we can't get the TX-time down, we'll have to group codec2 frames in a single wireless packet.  Sending 6 bytes takes 51ms (as verified with the logic analyser: time between end of START_TX and falling PACKET_SENT IRQ).  This matches with the theoretical limit: 4 bytes in 6ms = 32 bit/6ms = 5.3kbps.  The radio is configured for 2.4ksymbols/s (=4.8kbps for 4GFSK).

SI446x potential packet structure

The following settings are used in Zak Kemble's library:

  1. Preamble : 8 bytes (sine wave) : 2.4kbps encoded, not 4.8kbps as the rest of the packet. 
  2. Sync word : 2 bytes
  3. Field 1 : 1 byte (length of the packet)
  4. CRC-Field 1 : 2 bytes
  5. Field 2 : data bytes (e.g. 6 bytes)
  6. CRC-Field 2 : 2 bytes

So we have 15 bytes overhead for our packet.  With respect to time, we even have 23 bytes overhead, because the preamble is sent out at half the bit rate.  So the total packet time = (23 + N) * 8 / 4800 [s], where N is the number of data bytes. 

Recording taken with RSP1A and CubicSDR opened in Audacity.  The selected length in the image is 51ms.

It takes 48.3ms to send a packet with 6 data bytes.  Codec2_1200 generates 6 bytes every 40ms.  So Codec2 generates the packets faster than they are transmitted.

The following condition must be met:

23 = OH = overhead = the number of bytes that are sent, but are not Codec2 data.  This includes preamble, sync, encryption, ...

Which can be simplified and generalized to:

N = number of data bytes, OH = number of equivalent bytes in overhead

The upper communication layers will generate overhead as well.  Authenticated encryption adds 20 bytes to the packet.  Let's provision another 20 bytes for the higher OSI-layers.

So a number of data bytes should be at least N ≥ (23+40)/3 = 21.  N must be a multiple of six, because of CODEC2_1200.  So N becomes 24.

The downside of adding more data bytes in a packet is that the latency will increase.  We have to find an optimum.

Two frames with 20 bytes of user data, separated by 7ms of noise (the high amplitude in the middle). See how much time goes into the transmission of the preamble at the start of every frame.

Discussions

Christoph Tack wrote 04/23/2021 at 18:15 point

Hi Simon,  there's no error in Zak's library that makes the message so long.  The message length is simply the result of the configured parameters.  The preamble could be shortened, but that might make it more difficult for the receiver to get the message.  The receiver uses the preamble to synchronize itself to the transmitter.
dPMR as well as SCIP chain lots of messages together in a single stream.  The receiver only needs to synchronize at the start of the stream.  As a result, the overhead of the preamble becomes relatively small with regard to the payload size.
I might have to work like that as well.  It's much more complicated than sending a series of small packages because the FIFO needs to be refilled as the packet is being transmitted.

  Are you sure? yes | no

Simon Merrett wrote 04/24/2021 at 00:25 point

Thanks for the explanation - makes sense but I can see the challenges for audio.

  Are you sure? yes | no

Simon Merrett wrote 04/23/2021 at 08:43 point

Interesting. Why do you think Zak's library takes this long and should it be possible to speed it up? 

  Are you sure? yes | no