aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-19 14:23:21 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-07-19 14:32:35 +0700
commit1d6b628c5a3760e28d92546de7b04e27f63e9b8d (patch)
tree782cf0d6ba0ca4ee47b94128becaf0895a611228 /lib
parent780816d12a88780a41c0d6c74b4f7f2a6c3497eb (diff)
trx_interface: set proper burst type in GSMTAP header
If received burst is a RACH burst, one should contain the RACH synchronization sequence (GSM 05.02 Chapter 5.2.7) and long guard period filled by 0x00.
Diffstat (limited to 'lib')
-rw-r--r--lib/trx_interface/trx_impl.cc34
-rw-r--r--lib/trx_interface/trx_impl.h1
2 files changed, 32 insertions, 3 deletions
diff --git a/lib/trx_interface/trx_impl.cc b/lib/trx_interface/trx_impl.cc
index 48ef51a..8847278 100644
--- a/lib/trx_interface/trx_impl.cc
+++ b/lib/trx_interface/trx_impl.cc
@@ -33,6 +33,16 @@
#define BURST_SIZE 148
#define DATA_IF_MTU 160
+/**
+ * 41-bit RACH synchronization sequence
+ * GSM 05.02 Chapter 5.2.7 Access burst (AB)
+ */
+static uint8_t rach_synch_seq[] = {
+ 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0,
+ 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
+};
+
namespace gr {
namespace grgsm {
@@ -90,6 +100,24 @@ namespace gr {
}
/*
+ * Check if burst is a RACH burst
+ */
+ bool trx_impl::detect_rach(uint8_t *burst)
+ {
+ // Compare synchronization sequence
+ for (int i = 0; i < 41; i++)
+ if (burst[i + 8] != rach_synch_seq[i])
+ return false;
+
+ // Make sure TB and GP are filled by 0x00
+ for (int i = 0; i < 63; i++)
+ if (burst[i + 85] != 0x00)
+ return false;
+
+ return true;
+ }
+
+ /*
* Create an UDP payload with clock indication
*/
void
@@ -204,9 +232,9 @@ namespace gr {
header->timeslot = payload[0];
header->frame_number = htobe32(fn);
- // HACK: use GSMTAP_BURST_NORMAL for now
- // FIXME: We will need to distinguish between RACN and NORMAL
- header->sub_type = GSMTAP_BURST_NORMAL;
+ // Check if one is a RACH burst
+ header->sub_type = detect_rach(payload + 6) ?
+ GSMTAP_BURST_ACCESS : GSMTAP_BURST_NORMAL;
// Copy burst bits (0 & 1) for source message
memcpy(buf + sizeof(gsmtap_hdr), payload + 6, BURST_SIZE);
diff --git a/lib/trx_interface/trx_impl.h b/lib/trx_interface/trx_impl.h
index 29545b1..65b4d97 100644
--- a/lib/trx_interface/trx_impl.h
+++ b/lib/trx_interface/trx_impl.h
@@ -37,6 +37,7 @@ namespace gr {
udp_socket *d_data_sock;
udp_socket *d_clck_sock;
+ bool detect_rach(uint8_t *burst);
void clck_ind_send(uint32_t frame_nr);
void burst_pack(pmt::pmt_t msg, uint8_t *buf);