Ejemplo n.º 1
0
// print gmskframegen object internals
void gmskframegen_print(gmskframegen _q)
{
    // plot
    printf("gmskframegen:\n");
    printf("  physical properties\n");
    printf("    samples/symbol  :   %u\n", _q->k);
    printf("    filter delay    :   %u symbols\n", _q->m);
    printf("    bandwidth-time  :   %-8.3f\n", _q->BT);
    printf("  framing properties\n");
    printf("    preamble        :   %-4u symbols\n", _q->preamble_len);
    printf("    header          :   %-4u symbols\n", _q->header_len);
    printf("    payload         :   %-4u symbols\n", _q->payload_len);
    printf("    tail            :   %-4u symbols\n", _q->tail_len);
    printf("  packet properties\n");
    printf("    crc             :   %s\n", crc_scheme_str[_q->check][1]);
    printf("    fec (inner)     :   %s\n", fec_scheme_str[_q->fec0][1]);
    printf("    fec (outer)     :   %s\n", fec_scheme_str[_q->fec1][1]);
    printf("  total samples     :   %-4u sampels\n", gmskframegen_getframelen(_q));
}
Ejemplo n.º 2
0
// benchmark regular frame synchronizer with short frames; effectively
// test acquisition complexity
void benchmark_gmskframesync(struct rusage *     _start,
                             struct rusage *     _finish,
                             unsigned long int * _num_iterations)
{
    *_num_iterations /= 128;
    unsigned long int i;

    // options
    unsigned int payload_len = 8;       // length of payload (bytes)
    crc_scheme check = LIQUID_CRC_32;   // data validity check
    fec_scheme fec0  = LIQUID_FEC_NONE; // inner forward error correction
    fec_scheme fec1  = LIQUID_FEC_NONE; // outer forward error correction
    float SNRdB = 30.0f;                // SNR

    // derived values
    float nstd  = powf(10.0f, -SNRdB/20.0f);

    // create gmskframegen object
    gmskframegen fg = gmskframegen_create();

    // frame data
    unsigned char header[14];
    unsigned char payload[payload_len];
    // initialize header, payload
    for (i=0; i<14; i++)
        header[i] = i;
    for (i=0; i<payload_len; i++)
        payload[i] = rand() & 0xff;
    framedata fd = {header, payload, 0, 0, 0, 0};

    // create gmskframesync object
    gmskframesync fs = gmskframesync_create(callback,(void*)&fd);
    //gmskframesync_print(fs);

    // generate the frame
    gmskframegen_assemble(fg, header, payload, payload_len, check, fec0, fec1);
    gmskframegen_print(fg);
    unsigned int frame_len = gmskframegen_getframelen(fg);
    float complex frame[frame_len];
    int frame_complete = 0;
    unsigned int n=0;
    while (!frame_complete) {
        assert(n < frame_len);
        frame_complete = gmskframegen_write_samples(fg, &frame[n]);
        n += 2;
    }
    // add some noise
    for (i=0; i<frame_len; i++)
        frame[i] += nstd*(randnf() + _Complex_I*randnf());

    // 
    // start trials
    //
    getrusage(RUSAGE_SELF, _start);
    for (i=0; i<(*_num_iterations); i++) {
        gmskframesync_execute(fs, frame, frame_len);
    }
    getrusage(RUSAGE_SELF, _finish);

    // print results
    fd.num_frames_tx = *_num_iterations;
    printf("  frames detected/header/payload/transmitted:   %6u / %6u / %6u / %6u\n",
            fd.num_frames_detected,
            fd.num_headers_valid,
            fd.num_payloads_valid,
            fd.num_frames_tx);

    // destroy objects
    gmskframegen_destroy(fg);
    gmskframesync_destroy(fs);
}