[MERGED] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately
Harald Welte has submitted this change and it was merged. Change subject: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately .. fake_trx/burst_fwd.py: calculate both RSSI and ToA separately In order to be able to simulate and randomize both RSSI and ToA values for Uplink and Downlink separately, let's calculate them in separate methods of the BurstForwarder. Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c --- M src/target/fake_trx/burst_fwd.py 1 file changed, 62 insertions(+), 30 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 bcf2257..503d035 100644 --- a/src/target/fake_trx/burst_fwd.py +++ b/src/target/fake_trx/burst_fwd.py @@ -39,42 +39,75 @@ # one GSM symbol advance. ta = 0 - # Constants - # TODO: add options to change this - RSSI_RAND_TRESHOLD = 10 - RSSI_RAND_MIN = -90 - RSSI_RAND_MAX = -60 + # Timing of Arrival values indicated by transceiver + # in units of 1/256 of GSM symbol periods. A pair of + # base and threshold values defines a range of ToA value + # randomization: from (base - threshold) to (base + threshold). + toa256_dl_base = 0 + toa256_ul_base = 0 - # TODO: add options to change this - TOA256_RAND_TRESHOLD = 128 - TOA256_RAND_BASE = 0 + toa256_dl_threshold = 128 + toa256_ul_threshold = 128 + + # RSSI values indicated by transceiver in dBm. + # 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 + rssi_ul_threshold = 5 def __init__(self, bts_link, bb_link): self.bts_link = bts_link self.bb_link = bb_link - # Generate a random RSSI range - rssi = random.randint(self.RSSI_RAND_MIN, self.RSSI_RAND_MAX) - self.rssi_min = rssi - self.RSSI_RAND_TRESHOLD - self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD + # Calculates a random ToA value for Downlink bursts + def calc_dl_toa256(self): + # Calculate a range for randomization + toa256_min = self.toa256_dl_base - self.toa256_dl_threshold + toa256_max = self.toa256_dl_base + self.toa256_dl_threshold - # 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) + toa256 = random.randint(toa256_min, toa256_max) - # Apply TA value + return toa256 + + # Calculates a random ToA value for Uplink bursts + def calc_ul_toa256(self): + # Calculate a range for randomization + toa256_min = self.toa256_ul_base - self.toa256_ul_threshold + toa256_max = self.toa256_ul_base + self.toa256_ul_threshold + + # Generate a random ToA value + toa256 = random.randint(toa256_min, toa256_max) + + # Apply TA value indicated by MS ta256 = self.ta * 256 toa256 -= ta256 return toa256 + # Calculates a random RSSI value for Downlink bursts + def calc_dl_rssi(self): + # Calculate a range for randomization + rssi_min = self.rssi_dl_base - self.rssi_dl_threshold + rssi_max = self.rssi_dl_base + self.rssi_dl_threshold + + # Generate a random RSSI value + return random.randint(rssi_min, rssi_max) + + # Calculates a random RSSI value for Uplink bursts + def calc_ul_rssi(self): + # Calculate a range for randomization + rssi_min = self.rssi_ul_base - self.rssi_ul_threshold + rssi_max = self.rssi_ul_base + self.rssi_ul_threshold + + # Generate a random RSSI value + return random.randint(rssi_min, rssi_max) + # Converts a L12TRX message to TRX2L1 message - def transform_msg(self, msg_raw): + def transform_msg(self, msg_raw, dl = True): # Attempt to parse a message try: msg_l12trx = DATAMSG_L12TRX() @@ -87,10 +120,12 @@ msg_trx2l1 = msg_l12trx.gen_trx2l1() # Randomize both RSSI and ToA values - msg_trx2l1.rssi = msg_trx2l1.rand_rssi( - min = self.rssi_min, max
osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/7000 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c Gerrit-PatchSet: 1 Gerrit-Project: osmocom-bb Gerrit-Branch: fixeria/trx Gerrit-Owner: Vadim YanitskiyGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately
Review at https://gerrit.osmocom.org/7000 fake_trx/burst_fwd.py: calculate both RSSI and ToA separately In order to be able to simulate and randomize both RSSI and ToA values for Uplink and Downlink separately, let's calculate them in separate methods of the BurstForwarder. Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c --- M src/target/fake_trx/burst_fwd.py 1 file changed, 62 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/00/7000/1 diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py index bcf2257..503d035 100644 --- a/src/target/fake_trx/burst_fwd.py +++ b/src/target/fake_trx/burst_fwd.py @@ -39,42 +39,75 @@ # one GSM symbol advance. ta = 0 - # Constants - # TODO: add options to change this - RSSI_RAND_TRESHOLD = 10 - RSSI_RAND_MIN = -90 - RSSI_RAND_MAX = -60 + # Timing of Arrival values indicated by transceiver + # in units of 1/256 of GSM symbol periods. A pair of + # base and threshold values defines a range of ToA value + # randomization: from (base - threshold) to (base + threshold). + toa256_dl_base = 0 + toa256_ul_base = 0 - # TODO: add options to change this - TOA256_RAND_TRESHOLD = 128 - TOA256_RAND_BASE = 0 + toa256_dl_threshold = 128 + toa256_ul_threshold = 128 + + # RSSI values indicated by transceiver in dBm. + # 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 + rssi_ul_threshold = 5 def __init__(self, bts_link, bb_link): self.bts_link = bts_link self.bb_link = bb_link - # Generate a random RSSI range - rssi = random.randint(self.RSSI_RAND_MIN, self.RSSI_RAND_MAX) - self.rssi_min = rssi - self.RSSI_RAND_TRESHOLD - self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD + # Calculates a random ToA value for Downlink bursts + def calc_dl_toa256(self): + # Calculate a range for randomization + toa256_min = self.toa256_dl_base - self.toa256_dl_threshold + toa256_max = self.toa256_dl_base + self.toa256_dl_threshold - # 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) + toa256 = random.randint(toa256_min, toa256_max) - # Apply TA value + return toa256 + + # Calculates a random ToA value for Uplink bursts + def calc_ul_toa256(self): + # Calculate a range for randomization + toa256_min = self.toa256_ul_base - self.toa256_ul_threshold + toa256_max = self.toa256_ul_base + self.toa256_ul_threshold + + # Generate a random ToA value + toa256 = random.randint(toa256_min, toa256_max) + + # Apply TA value indicated by MS ta256 = self.ta * 256 toa256 -= ta256 return toa256 + # Calculates a random RSSI value for Downlink bursts + def calc_dl_rssi(self): + # Calculate a range for randomization + rssi_min = self.rssi_dl_base - self.rssi_dl_threshold + rssi_max = self.rssi_dl_base + self.rssi_dl_threshold + + # Generate a random RSSI value + return random.randint(rssi_min, rssi_max) + + # Calculates a random RSSI value for Uplink bursts + def calc_ul_rssi(self): + # Calculate a range for randomization + rssi_min = self.rssi_ul_base - self.rssi_ul_threshold + rssi_max = self.rssi_ul_base + self.rssi_ul_threshold + + # Generate a random RSSI value + return random.randint(rssi_min, rssi_max) + # Converts a L12TRX message to TRX2L1 message - def transform_msg(self, msg_raw): + def transform_msg(self, msg_raw, dl = True): # Attempt to parse a message try: msg_l12trx = DATAMSG_L12TRX() @@ -87,10 +120,12 @@ msg_trx2l1 = msg_l12trx.gen_trx2l1() # Randomize both RSSI and ToA values - msg_trx2l1.rssi = msg_trx2l1.rand_rssi( - min = self.rssi_min, max = self.rssi_max) - msg_trx2l1.toa256 = msg_trx2l1.rand_toa256( - min = self.toa256_min, max = self.toa256_max) + if dl: +