Search code examples
unetstack

How to add custom preamble to the signal?


We are having our custom preamble that we wish to add to the signal, Is there a way to save the custom preamble to the modem and load it to phy[3] as shown in UnetDocumentation(sec 16.4).

Is there any other method to load the preamble directly to the signal ?


Solution

  • If you simply need to transmit a preamble with the signal, you have two options:

    1. You could just include it as part of your signal directly.
    2. You could set the preamble on a specific indexed scheme (e.g. phy[3]) and then use that for your transmission.

    The advantage of method 1 is its simplicity. The advantage of method 2 is that you can also use the preamble for detection of signals in the water.

    Method 1 is trivial, and so I won't discuss it here in detail. I'll focus on showing you how method 2 works:

    Step 1. Set up your preamble.

    If you are using a standard signal such as a m-sequence or a chirp, you can set it up by specifying the parameters of the signal. Examples:

    phy[3].preamble = Preamble.hfmUpSweep(240)  // 240-sample long hyperbolic up sweep
    phy[3].preamble = Preamble.mseq(1023,2)     // 1023-chip m-sequence with 50% bandwidth
    

    (type help phy[].preamble on the unet shell, and refer to Preamble API docs for more information)

    If you have a custom signal as a preamble, you can specify the baseband signal directly:

    phy[3].preamble = new Preamble(pre)
    

    where pre contains the complex baseband samples.

    Step 2. Transmit using your preamble.

    When transmitting a baseband signal, you can specify a preamble to use. For example:

    phy << new TxBasebandSignalReq(preamble: 3, signal: signal)
    

    where 3 specifies that phy[3] preamble should be transmitted, and signal contains your baseband signal samples to transmit after the preamble.

    TIP: If you want to use the preamble for signal detection, you need to set the detection threshold for the scheme (e.g. phy[3].threshold = 0.25). Since this isn't the focus of this question, we won't dwell on it much.

    NOTE: While the Preamble class supports arbitrary length preamble signals, practical modems may have hard limits based on memory buffers, and soft limits based on computational load for detection. For most practical UnetStack-based modems today, you probably want to limit the preamble signals to 1024 samples or less (or check with your modem vendor on hardware limits).