trx_toolkit/burst_fwd.py: document and refactor BurstForwarder
Instead of having all configuration variables of BurstForwarder initialized in the class heading, let's introduce two functions for initialization (resetting to defaults) of both UL/DL params. This would allow to reset a BurstForwarder instance from the control interface in follow-up patches. Let's also introduce some basic documentation for the class fields, which were defined in the heading previously. Change-Id: I6b1bf41cf22f01a7e7ecc91c625fb0d2bf4bfeac
This commit is contained in:
parent
9fd173b179
commit
8d70f9d9fe
|
@ -4,7 +4,7 @@
|
||||||
# TRX Toolkit
|
# TRX Toolkit
|
||||||
# BTS <-> BB burst forwarding
|
# BTS <-> BB burst forwarding
|
||||||
#
|
#
|
||||||
# (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>
|
# (C) 2017-2018 by Vadim Yanitskiy <axilirator@gmail.com>
|
||||||
#
|
#
|
||||||
# All Rights Reserved
|
# All Rights Reserved
|
||||||
#
|
#
|
||||||
|
@ -27,58 +27,136 @@ import random
|
||||||
from data_msg import *
|
from data_msg import *
|
||||||
|
|
||||||
class BurstForwarder:
|
class BurstForwarder:
|
||||||
# Timeslot filter (drop everything by default)
|
""" Performs burst forwarding and preprocessing between MS and BTS.
|
||||||
ts_pass = None
|
|
||||||
|
|
||||||
# Freq. filter
|
== Pass-filtering parameters
|
||||||
bts_freq = None
|
|
||||||
bb_freq = None
|
|
||||||
|
|
||||||
# Randomization of RSSI
|
BurstForwarder may drop or pass an UL/DL burst depending
|
||||||
randomize_dl_rssi = False
|
on the following parameters:
|
||||||
randomize_ul_rssi = False
|
|
||||||
|
|
||||||
# Randomization of ToA
|
- bts_freq / bb_freq - the current BTS / MS frequency
|
||||||
randomize_dl_toa256 = False
|
that was set using RXTUNE control command. By default,
|
||||||
randomize_ul_toa256 = False
|
both freq. values are set to None, so nothing is being
|
||||||
|
forwarded (i.e. bursts are getting dropped).
|
||||||
|
|
||||||
# Timing Advance value indicated by MS (0 by default)
|
FIXME: currently, we don't care about TXTUNE command
|
||||||
# Valid range: 0..63, where each unit means
|
and transmit frequencies. It would be great to distinguish
|
||||||
# one GSM symbol advance.
|
between RX and TX frequencies for both BTS and MS.
|
||||||
ta = 0
|
|
||||||
|
|
||||||
# Timing of Arrival values indicated by transceiver
|
- ts_pass - currently active timeslot, configured by the MS.
|
||||||
# in units of 1/256 of GSM symbol periods. A pair of
|
It can be activated or deactivated using SETSLOT control
|
||||||
# base and threshold values defines a range of ToA value
|
command from the MS.
|
||||||
# randomization: from (base - threshold) to (base + threshold).
|
|
||||||
toa256_dl_base = 0
|
|
||||||
toa256_ul_base = 0
|
|
||||||
|
|
||||||
toa256_dl_threshold = 128
|
FIXME: only a single timeslot can be activated!
|
||||||
toa256_ul_threshold = 128
|
FIXME: there is no such list for the BTS side.
|
||||||
|
|
||||||
# RSSI values indicated by transceiver in dBm.
|
== Preprocessing and measurement simulation
|
||||||
# A pair of base and threshold values defines a range of RSSI
|
|
||||||
# randomization: from (base - threshold) to (base + threshold).
|
|
||||||
rssi_dl_base = -60
|
|
||||||
rssi_ul_base = -70
|
|
||||||
|
|
||||||
rssi_dl_threshold = 10
|
Since this is a virtual environment, we can simulate different
|
||||||
rssi_ul_threshold = 5
|
parameters of a virtual RF interface:
|
||||||
|
|
||||||
# Path loss simulation: DL/UL burst dropping
|
- ToA (Timing of Arrival) - measured difference between expected
|
||||||
# Indicates how many bursts should be dropped
|
and actual time of burst arrival in units of 1/256 of GSM symbol
|
||||||
# and which dropping period is used. By default,
|
periods. A pair of both base and threshold values defines a range
|
||||||
# period is 1, i.e. every burst (fn % 1 is always 0)
|
of ToA value randomization:
|
||||||
burst_dl_drop_amount = 0
|
|
||||||
burst_ul_drop_amount = 0
|
DL: from (toa256_dl_base - toa256_dl_threshold)
|
||||||
burst_dl_drop_period = 1
|
to (toa256_dl_base + toa256_dl_threshold),
|
||||||
burst_ul_drop_period = 1
|
UL: from (toa256_ul_base - toa256_ul_threshold)
|
||||||
|
to (toa256_ul_base + toa256_ul_threshold).
|
||||||
|
|
||||||
|
- RSSI (Received Signal Strength Indication) - measured "power" of
|
||||||
|
the signal (per burst) in dBm. A pair of both base and threshold
|
||||||
|
values defines a range of RSSI value randomization:
|
||||||
|
|
||||||
|
DL: from (rssi_dl_base - rssi_dl_threshold)
|
||||||
|
to (rssi_dl_base + rssi_dl_threshold),
|
||||||
|
UL: from (rssi_ul_base - rssi_ul_threshold)
|
||||||
|
to (rssi_ul_base + rssi_ul_threshold).
|
||||||
|
|
||||||
|
Please note that the randomization of both RSSI and ToA
|
||||||
|
is optional, and should be enabled manually.
|
||||||
|
|
||||||
|
=== Timing Advance handling
|
||||||
|
|
||||||
|
The BTS is using ToA measurements for UL bursts in order to calculate
|
||||||
|
Timing Advance value, that is then indicated to a MS, which in its turn
|
||||||
|
shall apply this value to the transmitted signal in order to compensate
|
||||||
|
the delay. Basically, every burst is transmitted in advance defined by
|
||||||
|
the indicated Timing Advance value. The valid range is 0..63, where
|
||||||
|
each unit means one GSM symbol advance. The actual Timing Advance value
|
||||||
|
is set using SETTA control command from MS. By default, it's set to 0.
|
||||||
|
|
||||||
|
=== Path loss simulation - burst dropping
|
||||||
|
|
||||||
|
In some cases, e.g. due to a weak signal or high interference, a burst
|
||||||
|
can be lost, i.e. not detected by the receiver. This can also be
|
||||||
|
simulated using FAKE_DROP command on both control interfaces:
|
||||||
|
|
||||||
|
- burst_{dl|ul}_drop_amount - the amount of DL/UL bursts
|
||||||
|
to be dropped (i.e. not forwarded towards the MS/BTS),
|
||||||
|
|
||||||
|
- burst_{dl|ul}_drop_period - drop every X DL/UL burst, e.g.
|
||||||
|
1 - drop every consequent burst, 2 - drop every second burst, etc.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, bts_link, bb_link):
|
def __init__(self, bts_link, bb_link):
|
||||||
self.bts_link = bts_link
|
self.bts_link = bts_link
|
||||||
self.bb_link = bb_link
|
self.bb_link = bb_link
|
||||||
|
|
||||||
|
# Randomization of RSSI
|
||||||
|
randomize_dl_rssi = False
|
||||||
|
randomize_ul_rssi = False
|
||||||
|
|
||||||
|
# Randomization of ToA
|
||||||
|
randomize_dl_toa256 = False
|
||||||
|
randomize_ul_toa256 = False
|
||||||
|
|
||||||
|
# Init default parameters
|
||||||
|
self.reset_dl()
|
||||||
|
self.reset_ul()
|
||||||
|
|
||||||
|
# Initialize (or reset to) default parameters for Downlink
|
||||||
|
def reset_dl(self):
|
||||||
|
# Unset current DL freq.
|
||||||
|
self.bts_freq = None
|
||||||
|
|
||||||
|
# Indicated RSSI / ToA values
|
||||||
|
self.toa256_dl_base = 0
|
||||||
|
self.rssi_dl_base = -60
|
||||||
|
|
||||||
|
# RSSI / ToA randomization threshold
|
||||||
|
self.toa256_dl_threshold = 0
|
||||||
|
self.rssi_dl_threshold = 0
|
||||||
|
|
||||||
|
# Path loss simulation (burst dropping)
|
||||||
|
self.burst_dl_drop_amount = 0
|
||||||
|
self.burst_dl_drop_period = 1
|
||||||
|
|
||||||
|
# Initialize (or reset to) default parameters for Uplink
|
||||||
|
def reset_ul(self):
|
||||||
|
# Unset current DL freq.
|
||||||
|
self.bb_freq = None
|
||||||
|
|
||||||
|
# Indicated RSSI / ToA values
|
||||||
|
self.rssi_ul_base = -70
|
||||||
|
self.toa256_ul_base = 0
|
||||||
|
|
||||||
|
# RSSI / ToA randomization threshold
|
||||||
|
self.toa256_ul_threshold = 0
|
||||||
|
self.rssi_ul_threshold = 0
|
||||||
|
|
||||||
|
# Path loss simulation (burst dropping)
|
||||||
|
self.burst_ul_drop_amount = 0
|
||||||
|
self.burst_ul_drop_period = 1
|
||||||
|
|
||||||
|
# Init timeslot filter (drop everything by default)
|
||||||
|
self.ts_pass = None
|
||||||
|
|
||||||
|
# Reset Timing Advance value
|
||||||
|
self.ta = 0
|
||||||
|
|
||||||
# Converts TA value from symbols to
|
# Converts TA value from symbols to
|
||||||
# units of 1/256 of GSM symbol periods
|
# units of 1/256 of GSM symbol periods
|
||||||
def calc_ta256(self):
|
def calc_ta256(self):
|
||||||
|
|
Loading…
Reference in New Issue