trxcon/l1sched: clarify TDMA Fn (mod 26) maps
[osmocom-bb.git] / src / target / trx_toolkit / burst_fwd.py
blob69245317124822b85f3264d7f02d4ebb267baddc
1 # -*- coding: utf-8 -*-
3 # TRX Toolkit
4 # Burst forwarding between transceivers
6 # (C) 2017-2020 by Vadim Yanitskiy <axilirator@gmail.com>
7 # Contributions by sysmocom - s.f.m.c. GmbH
9 # All Rights Reserved
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 import logging as log
23 from trx_list import TRXList
25 class BurstForwarder(TRXList):
26 """ Performs burst forwarding between transceivers.
28 BurstForwarder distributes bursts between the list of given
29 FakeTRX (Transceiver) instances depending on the following
30 parameters of each transceiver:
32 - execution state (running or idle),
33 - actual RX / TX frequencies,
34 - list of active timeslots.
36 Each to be distributed 'TxMsg' message is being transformed
37 into a 'RxMsg' message, and then forwarded to transceivers
38 with partially initialized header. All uninitialized header
39 fields (such as rssi and toa256) shall be set by each
40 transceiver individually before sending towards the L1.
42 """
44 def forward_msg(self, src_trx, rx_msg):
45 # Originating Transceiver may use frequency hopping,
46 # so let's precalculate its Tx frequency in advance
47 tx_freq = src_trx.get_tx_freq(rx_msg.fn)
49 if src_trx.rf_muted:
50 del rx_msg.burst # burst bits are omited
51 rx_msg.burst = None
53 # Iterate over all known transceivers
54 for trx in self.trx_list:
55 if trx == src_trx:
56 continue
58 # Check transceiver state
59 if not trx.running:
60 continue
62 # Match Tx/Rx frequencies of the both transceivers
63 if trx.get_rx_freq(rx_msg.fn) != tx_freq:
64 continue
66 # Transform from TxMsg to RxMsg and forward
67 tx_msg = rx_msg.trans(ver = trx.data_if._hdr_ver)
68 trx.handle_data_msg(src_trx, rx_msg, tx_msg)