FreeCalypso > hg > gsm-net-reveng
view d144/atrau-parse.c @ 94:f9ef582c199c
tfo-ut: check in tfo-fr.bin and tfo-efr.bin
Each of these binary files is an extract from MSC-side E1 timeslot
recording in a Nokia TCSM2 TFO session involving a cross-connect
between two TRAU channels. The extracts have been chosen to begin
at the point where the TRAU starts emitting TFO frames, thereby
beginning with a series of TFO frames that contain an embedded
TFO_TRANS message. In each experiment, one of the two cross-connected
TRAU channels emitted two "plain" TFO frames (not containing embedded
TFO messages) in between the initial embedded TFO_TRANS and the
subsequent embedded TFO_REQ_L; this channel was chosen for the
present extracts. Each extract is thus 2560 PCM samples, containing
16 aligned TFO frames: 5 carrying TFO_TRANS, 2 plain, 9 carrying
TFO_REQ_L.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 18 Mar 2025 22:56:23 +0000 |
parents | 323a4b75a32d |
children |
line wrap: on
line source
/* * This program reads a binary file containing a capture of 64 kbit/s output * of a TRAU in 14.4 kbit/s data mode. Per GSM specs this output is supposed * to contain A-TRAU frames of TS 48.020 chapter 11 (RAA' function); * this program looks for such frames and parses them. */ #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> static void decode_ra2(ts_bytes, frame_bits) uint8_t *ts_bytes, *frame_bits; { uint8_t *ip, *op; unsigned n; ip = ts_bytes; op = frame_bits; for (n = 0; n < 160; n++) { *op++ = (*ip & 0x80) >> 7; *op++ = (*ip & 0x40) >> 6; ip++; } } static int check_sync_zeros(frame_bits) uint8_t *frame_bits; { int i; for (i = 0; i < 16; i++) { if (frame_bits[i]) return 0; } return 1; } static unsigned gather_nibble(bits) uint8_t *bits; { unsigned n, acc; acc = 0; for (n = 0; n < 4; n++) { acc <<= 1; acc |= *bits++; } return acc; } static void dump_subframe(bits) uint8_t *bits; { unsigned n, d; printf(" %u ", *bits++); for (n = 0; n < 9; n++) { d = gather_nibble(bits); printf("%x", d); bits += 4; } putchar('\n'); } static void dump_frame(frame_bits) uint8_t *frame_bits; { unsigned n; if (!check_sync_zeros(frame_bits) || !frame_bits[16]) printf(" Bad sync bits!\n"); printf(" C1-C5: %u%u%u%u%u\n", frame_bits[17], frame_bits[18], frame_bits[19], frame_bits[20], frame_bits[21]); printf(" M1=%u M2=%u\n", frame_bits[22], frame_bits[23]); for (n = 0; n < 8; n++) dump_subframe(frame_bits + 24 + n * 37); } main(argc, argv) char **argv; { FILE *binf; uint8_t frame_in[160], frame_bits[320]; u_long file_offset; int cc; if (argc != 2) { fprintf(stderr, "usage: %s capture.bin\n", argv[0]); exit(1); } binf = fopen(argv[1], "r"); if (!binf) { perror(argv[1]); exit(1); } for (file_offset = 0; ; file_offset += 160) { cc = fread(frame_in, 1, 160, binf); if (cc <= 0) break; if (cc != 160) { fprintf(stderr, "error: %s is not a multiple of 160 bytes\n", argv[1]); exit(1); } printf("Frame at 0x%lx:\n", file_offset); decode_ra2(frame_in, frame_bits); dump_frame(frame_bits); putchar('\n'); } exit(0); }