summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-02-28 19:01:56 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-02-28 22:34:36 +0700
commitf09989b1fb2f2c0aa6797bc1d004bc27a4e43f17 (patch)
treefe16e985444457af672cb68342ef3bf3f8e6d1cc
parentd9cb0654179b3d3bcd2878a001593e95f0a22f80 (diff)
fake_trx: handle SETTA (Timing Advance) indicated by MS
Timing Advance value is a timing correction value, indicated by the network to MS, which is used to compensate UL signal delay. In other words, the network instructs a phone to transmit bursts N=TA symbol periods earlier than expected. Since we are in virtual environment, let's use TA value to calculate the ToA (Timing of Arrival) value for BTS. Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
-rw-r--r--src/target/fake_trx/burst_fwd.py19
-rw-r--r--src/target/fake_trx/ctrl_if_bb.py14
2 files changed, 33 insertions, 0 deletions
diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 4a0e9bbb..bcf2257e 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,11 @@ class BurstForwarder:
bts_freq = None
bb_freq = None
+ # Timing Advance value indicated by MS (0 by default)
+ # Valid range: 0..63, where each unit means
+ # one GSM symbol advance.
+ ta = 0
+
# Constants
# TODO: add options to change this
RSSI_RAND_TRESHOLD = 10
@@ -57,6 +62,17 @@ class BurstForwarder:
self.toa256_min = self.TOA256_RAND_BASE - self.TOA256_RAND_TRESHOLD
self.toa256_max = self.TOA256_RAND_BASE + self.TOA256_RAND_TRESHOLD
+ # Calculates ToA value for Uplink bursts (coming to a BTS)
+ def calc_toa_ul(self):
+ # Generate a random ToA value
+ toa256 = random.randint(self.toa256_min, self.toa256_max)
+
+ # Apply TA value
+ ta256 = self.ta * 256
+ toa256 -= ta256
+
+ return toa256
+
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
# Attempt to parse a message
@@ -128,6 +144,9 @@ class BurstForwarder:
if msg is None:
return None
+ # Emulate ToA value for BTS
+ msg.toa256 = self.calc_toa_ul()
+
# Validate and generate the payload
payload = msg.gen_msg()
diff --git a/src/target/fake_trx/ctrl_if_bb.py b/src/target/fake_trx/ctrl_if_bb.py
index 47c70484..74fb242e 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -115,6 +115,20 @@ class CTRLInterfaceBB(CTRLInterface):
return 0
+ # Timing Advance
+ elif self.verify_cmd(request, "SETTA", 1):
+ print("[i] Recv SETTA cmd")
+
+ # Parse and check TA value
+ ta = int(request[1])
+ if ta < 0 or ta > 63:
+ print("[!] TA value should be in range: 0..63")
+ return -1
+
+ # Save to the BurstForwarder instance
+ self.burst_fwd.ta = ta
+ return 0
+
# Wrong / unknown command
else:
# We don't care about other commands,