[MERGED] osmocom-bb[fixeria/trx]: fake_trx: handle SETTA (Timing Advance) indicated by MS

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Feb 28 18:05:56 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: fake_trx: handle SETTA (Timing Advance) indicated by MS
......................................................................


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
---
M src/target/fake_trx/burst_fwd.py
M src/target/fake_trx/ctrl_if_bb.py
2 files changed, 33 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 4a0e9bb..bcf2257 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,11 @@
 	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
@@ -56,6 +61,17 @@
 		# Generate a random ToA range
 		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):
@@ -128,6 +144,9 @@
 		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 47c7048..74fb242 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -115,6 +115,20 @@
 
 			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,

-- 
To view, visit https://gerrit.osmocom.org/6999
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list