ran-3gpp-calc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ran_3gpp_calc-0.1.0/LICENSE +21 -0
- ran_3gpp_calc-0.1.0/PKG-INFO +90 -0
- ran_3gpp_calc-0.1.0/README.md +65 -0
- ran_3gpp_calc-0.1.0/pyproject.toml +45 -0
- ran_3gpp_calc-0.1.0/setup.cfg +4 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc/__init__.py +27 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc/calculators.py +308 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc/cli.py +72 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc/py.typed +0 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc.egg-info/PKG-INFO +90 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc.egg-info/SOURCES.txt +13 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc.egg-info/dependency_links.txt +1 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc.egg-info/entry_points.txt +2 -0
- ran_3gpp_calc-0.1.0/src/ran_3gpp_calc.egg-info/top_level.txt +1 -0
- ran_3gpp_calc-0.1.0/tests/test_calculators.py +59 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Takwa Sebai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ran-3gpp-calc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic 3GPP RAN & RF engineering calculators: LTE TS 36.213 PA/PB CRS EPRE, LTE/5G NR PCI Mod 3/4/30 auditor, 5G NSA TR 38.913 latency budget, and RRC/NAS timers.
|
|
5
|
+
Author: Takwa Sebai
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://takwasebai.com/en/calculators/
|
|
8
|
+
Project-URL: Documentation, https://takwasebai.com/en/calculators/
|
|
9
|
+
Project-URL: Repository, https://github.com/tsebai/3gpp-ran-calculators
|
|
10
|
+
Keywords: 3gpp,5g-nr,lte,rf-engineering,pci,ran,telecom,latency
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Telecommunications Industry
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# 3GPP RAN & RF Calculators (`ran-3gpp-calc`)
|
|
27
|
+
|
|
28
|
+
[](https://doi.org/10.5281/zenodo.24796699)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Zero-dependency, strictly typed (`PEP 561`) Python library and CLI implementing deterministic 3GPP radio engineering calculations used in live 4G LTE and 5G NR optimization reviews:
|
|
32
|
+
|
|
33
|
+
1. **LTE Downlink Power Split (`3GPP TS 36.213` Section 5.2)**: Exact `rho_B / rho_A` ratio across 1, 2, and 4 CRS antenna ports, CRS EPRE (`dBm`), Type-A / Type-B PDSCH EPRE, and cell-edge footprint delta before changing `PA` / `PB`.
|
|
34
|
+
2. **LTE & 5G NR PCI Modulo Auditor (`TS 36.211` / `TS 38.211`)**: Simultaneous detection of exact PCI collision, two-hop neighbor PCI confusion, LTE CRS `Mod 3`, 5G NR SSB PBCH DMRS `Mod 4`, and Uplink DMRS `Mod 30` sequence-group overlaps.
|
|
35
|
+
3. **5G NSA (EN-DC) End-to-End Latency Budget (`TR 38.913` / `TS 38.211` / `TS 37.340`)**: Separates one-way radio SDU transit from TDD UL frame alignment, HARQ BLER retransmission tail, `X2-U` split-bearer delay, and EPC `P-GW` routing RTT.
|
|
36
|
+
4. **3GPP RRC & NAS Timers Reference (`TS 38.331` / `TS 36.331` / `TS 24.501`)**: Instant lookup for `T300`, `T301`, `T304`, `T310`, `T311`, `T312`, `T313`, `T319`, `T3510`, and `T3517`.
|
|
37
|
+
|
|
38
|
+
## Interactive Web Calculators (Zero Upload, EN / FR / ES / AR)
|
|
39
|
+
|
|
40
|
+
All 8 full interactive browser calculators with shareable scenario links (`#s=...`) are freely available online:
|
|
41
|
+
|
|
42
|
+
- **8 Free 3GPP Calculators Hub**: https://takwasebai.com/en/calculators/
|
|
43
|
+
- **LTE PRB Congestion & PA/PB Simulator**: https://takwasebai.com/en/calculators/lte-prb-congestion-pa-pb-simulator/
|
|
44
|
+
- **5G NSA End-to-End Latency Budget Simulator**: https://takwasebai.com/en/calculators/5g-nsa-end-to-end-latency-budget/
|
|
45
|
+
- **LTE & 5G NR PCI Mod 3 / Mod 4 / Mod 30 Auditor**: https://takwasebai.com/en/calculators/lte-5g-pci-mod3-mod4-mod30-auditor/
|
|
46
|
+
- **5G NR & 4G LTE RRC/NAS Timers Lookup**: https://takwasebai.com/en/calculators/5g-lte-rrc-timers-lookup/
|
|
47
|
+
|
|
48
|
+
## Installation & Quick Start
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### CLI Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Compare TS 36.213 CRS EPRE shift when moving from (PA=-3 dB, PB=1) to (PA=0 dB, PB=0)
|
|
58
|
+
ran-3gpp-calc pa-pb --power-dbm 46 --prb 100 --ports 2 --pa 0 --pb 0
|
|
59
|
+
|
|
60
|
+
# Audit serving PCI 27 against candidate neighbors across LTE Mod 3, NR Mod 4, and UL Mod 30
|
|
61
|
+
ran-3gpp-calc pci --serving 27 --neighbors 147 31 57 --rat BOTH
|
|
62
|
+
|
|
63
|
+
# Decompose a 26 ms commercial 5G NSA ping RTT across radio, X2-U, and EPC
|
|
64
|
+
ran-3gpp-calc nsa-latency --scs-khz 30 --tdd-wait-ms 1.8 --bler-pct 6 --x2u-ms 2.5 --epc-rtt-ms 14
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Python API
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from ran_3gpp_calc import compute_pa_pb_power_split, audit_pci_neighbors, compute_nsa_latency_budget
|
|
71
|
+
|
|
72
|
+
papb = compute_pa_pb_power_split(total_power_dbm=46.0, n_prb=100, crs_ports=2, pa_db=0.0, pb=0)
|
|
73
|
+
print(papb.crs_epre_dbm, papb.crs_delta_vs_baseline_db, papb.cell_edge_risk)
|
|
74
|
+
|
|
75
|
+
pci = audit_pci_neighbors(serving_pci=27, neighbor_pcis=[147, 31, 57], rat="BOTH")
|
|
76
|
+
for issue in pci.issues:
|
|
77
|
+
print(issue.neighbor_pci, issue.rule, issue.severity)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Field Workbooks & Printable Desk Packs
|
|
81
|
+
|
|
82
|
+
For engineering teams needing printable A4 protocol cheat-sheets, worked field root-cause cases, and Excel rollback registers:
|
|
83
|
+
|
|
84
|
+
- **5G NR & 4G LTE Protocol Cheat-Sheets Pack (12 A4 Field Sheets)**: https://takwasebai.com/en/5g-4g-protocol-cheat-sheets-pack/
|
|
85
|
+
- **LTE PRB Congestion & PA/PB Decision Workbook (PDF + Excel Rollback Audit)**: https://takwasebai.com/en/lte-prb-congestion-decision-workbook/
|
|
86
|
+
- **LTE & 5G NR PCI Planning & Audit Workbook (8 Worked Cases + Excel Auditor)**: https://takwasebai.com/en/lte-5g-pci-planning-audit-workbook/
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT License. Authored by **Takwa Sebai** (https://takwasebai.com/en/).
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 3GPP RAN & RF Calculators (`ran-3gpp-calc`)
|
|
2
|
+
|
|
3
|
+
[](https://doi.org/10.5281/zenodo.24796699)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Zero-dependency, strictly typed (`PEP 561`) Python library and CLI implementing deterministic 3GPP radio engineering calculations used in live 4G LTE and 5G NR optimization reviews:
|
|
7
|
+
|
|
8
|
+
1. **LTE Downlink Power Split (`3GPP TS 36.213` Section 5.2)**: Exact `rho_B / rho_A` ratio across 1, 2, and 4 CRS antenna ports, CRS EPRE (`dBm`), Type-A / Type-B PDSCH EPRE, and cell-edge footprint delta before changing `PA` / `PB`.
|
|
9
|
+
2. **LTE & 5G NR PCI Modulo Auditor (`TS 36.211` / `TS 38.211`)**: Simultaneous detection of exact PCI collision, two-hop neighbor PCI confusion, LTE CRS `Mod 3`, 5G NR SSB PBCH DMRS `Mod 4`, and Uplink DMRS `Mod 30` sequence-group overlaps.
|
|
10
|
+
3. **5G NSA (EN-DC) End-to-End Latency Budget (`TR 38.913` / `TS 38.211` / `TS 37.340`)**: Separates one-way radio SDU transit from TDD UL frame alignment, HARQ BLER retransmission tail, `X2-U` split-bearer delay, and EPC `P-GW` routing RTT.
|
|
11
|
+
4. **3GPP RRC & NAS Timers Reference (`TS 38.331` / `TS 36.331` / `TS 24.501`)**: Instant lookup for `T300`, `T301`, `T304`, `T310`, `T311`, `T312`, `T313`, `T319`, `T3510`, and `T3517`.
|
|
12
|
+
|
|
13
|
+
## Interactive Web Calculators (Zero Upload, EN / FR / ES / AR)
|
|
14
|
+
|
|
15
|
+
All 8 full interactive browser calculators with shareable scenario links (`#s=...`) are freely available online:
|
|
16
|
+
|
|
17
|
+
- **8 Free 3GPP Calculators Hub**: https://takwasebai.com/en/calculators/
|
|
18
|
+
- **LTE PRB Congestion & PA/PB Simulator**: https://takwasebai.com/en/calculators/lte-prb-congestion-pa-pb-simulator/
|
|
19
|
+
- **5G NSA End-to-End Latency Budget Simulator**: https://takwasebai.com/en/calculators/5g-nsa-end-to-end-latency-budget/
|
|
20
|
+
- **LTE & 5G NR PCI Mod 3 / Mod 4 / Mod 30 Auditor**: https://takwasebai.com/en/calculators/lte-5g-pci-mod3-mod4-mod30-auditor/
|
|
21
|
+
- **5G NR & 4G LTE RRC/NAS Timers Lookup**: https://takwasebai.com/en/calculators/5g-lte-rrc-timers-lookup/
|
|
22
|
+
|
|
23
|
+
## Installation & Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install -e .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### CLI Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Compare TS 36.213 CRS EPRE shift when moving from (PA=-3 dB, PB=1) to (PA=0 dB, PB=0)
|
|
33
|
+
ran-3gpp-calc pa-pb --power-dbm 46 --prb 100 --ports 2 --pa 0 --pb 0
|
|
34
|
+
|
|
35
|
+
# Audit serving PCI 27 against candidate neighbors across LTE Mod 3, NR Mod 4, and UL Mod 30
|
|
36
|
+
ran-3gpp-calc pci --serving 27 --neighbors 147 31 57 --rat BOTH
|
|
37
|
+
|
|
38
|
+
# Decompose a 26 ms commercial 5G NSA ping RTT across radio, X2-U, and EPC
|
|
39
|
+
ran-3gpp-calc nsa-latency --scs-khz 30 --tdd-wait-ms 1.8 --bler-pct 6 --x2u-ms 2.5 --epc-rtt-ms 14
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Python API
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from ran_3gpp_calc import compute_pa_pb_power_split, audit_pci_neighbors, compute_nsa_latency_budget
|
|
46
|
+
|
|
47
|
+
papb = compute_pa_pb_power_split(total_power_dbm=46.0, n_prb=100, crs_ports=2, pa_db=0.0, pb=0)
|
|
48
|
+
print(papb.crs_epre_dbm, papb.crs_delta_vs_baseline_db, papb.cell_edge_risk)
|
|
49
|
+
|
|
50
|
+
pci = audit_pci_neighbors(serving_pci=27, neighbor_pcis=[147, 31, 57], rat="BOTH")
|
|
51
|
+
for issue in pci.issues:
|
|
52
|
+
print(issue.neighbor_pci, issue.rule, issue.severity)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Field Workbooks & Printable Desk Packs
|
|
56
|
+
|
|
57
|
+
For engineering teams needing printable A4 protocol cheat-sheets, worked field root-cause cases, and Excel rollback registers:
|
|
58
|
+
|
|
59
|
+
- **5G NR & 4G LTE Protocol Cheat-Sheets Pack (12 A4 Field Sheets)**: https://takwasebai.com/en/5g-4g-protocol-cheat-sheets-pack/
|
|
60
|
+
- **LTE PRB Congestion & PA/PB Decision Workbook (PDF + Excel Rollback Audit)**: https://takwasebai.com/en/lte-prb-congestion-decision-workbook/
|
|
61
|
+
- **LTE & 5G NR PCI Planning & Audit Workbook (8 Worked Cases + Excel Auditor)**: https://takwasebai.com/en/lte-5g-pci-planning-audit-workbook/
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT License. Authored by **Takwa Sebai** (https://takwasebai.com/en/).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ran-3gpp-calc"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Deterministic 3GPP RAN & RF engineering calculators: LTE TS 36.213 PA/PB CRS EPRE, LTE/5G NR PCI Mod 3/4/30 auditor, 5G NSA TR 38.913 latency budget, and RRC/NAS timers."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Takwa Sebai" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["3gpp", "5g-nr", "lte", "rf-engineering", "pci", "ran", "telecom", "latency"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Telecommunications Industry",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
ran-3gpp-calc = "ran_3gpp_calc.cli:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://takwasebai.com/en/calculators/"
|
|
34
|
+
Documentation = "https://takwasebai.com/en/calculators/"
|
|
35
|
+
Repository = "https://github.com/tsebai/3gpp-ran-calculators"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["src"]
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
ran_3gpp_calc = ["py.typed"]
|
|
42
|
+
|
|
43
|
+
[tool.mypy]
|
|
44
|
+
strict = true
|
|
45
|
+
python_version = "3.11"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Deterministic 3GPP 4G LTE & 5G NR RAN engineering calculators."""
|
|
2
|
+
|
|
3
|
+
from .calculators import (
|
|
4
|
+
LatencyBudgetResult,
|
|
5
|
+
PaPbResult,
|
|
6
|
+
PciAuditIssue,
|
|
7
|
+
PciAuditResult,
|
|
8
|
+
TimerSpec,
|
|
9
|
+
audit_pci_neighbors,
|
|
10
|
+
compute_nsa_latency_budget,
|
|
11
|
+
compute_pa_pb_power_split,
|
|
12
|
+
lookup_3gpp_timers,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"LatencyBudgetResult",
|
|
17
|
+
"PaPbResult",
|
|
18
|
+
"PciAuditIssue",
|
|
19
|
+
"PciAuditResult",
|
|
20
|
+
"TimerSpec",
|
|
21
|
+
"audit_pci_neighbors",
|
|
22
|
+
"compute_nsa_latency_budget",
|
|
23
|
+
"compute_pa_pb_power_split",
|
|
24
|
+
"lookup_3gpp_timers",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"""Core 3GPP formulas for LTE PA/PB power allocation, PCI Mod 3/4/30 auditing, 5G NSA latency, and RRC/NAS timers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Sequence
|
|
8
|
+
|
|
9
|
+
# 3GPP TS 36.213 Table 5.2-1: ratio rho_B / rho_A indexed by PB in {0, 1, 2, 3}
|
|
10
|
+
_TS36213_RHO_B_OVER_RHO_A_1PORT: dict[int, float] = {
|
|
11
|
+
0: 5.0 / 4.0,
|
|
12
|
+
1: 1.0,
|
|
13
|
+
2: 3.0 / 4.0,
|
|
14
|
+
3: 1.0 / 2.0,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_TS36213_RHO_B_OVER_RHO_A_MULTI: dict[int, float] = {
|
|
18
|
+
0: 1.0,
|
|
19
|
+
1: 4.0 / 5.0,
|
|
20
|
+
2: 3.0 / 5.0,
|
|
21
|
+
3: 2.0 / 5.0,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
VALID_LTE_PRBS: frozenset[int] = frozenset({6, 15, 25, 50, 75, 100})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class PaPbResult:
|
|
29
|
+
"""Result of 3GPP TS 36.213 Section 5.2 downlink CRS and PDSCH EPRE computation."""
|
|
30
|
+
|
|
31
|
+
total_power_dbm: float
|
|
32
|
+
n_prb: int
|
|
33
|
+
crs_ports: int
|
|
34
|
+
pa_db: float
|
|
35
|
+
pb: int
|
|
36
|
+
rho_a_linear: float
|
|
37
|
+
rho_b_over_rho_a: float
|
|
38
|
+
rho_b_linear: float
|
|
39
|
+
crs_epre_dbm: float
|
|
40
|
+
pdsch_epre_type_a_dbm: float
|
|
41
|
+
pdsch_epre_type_b_dbm: float
|
|
42
|
+
crs_delta_vs_baseline_db: float
|
|
43
|
+
cell_edge_risk: str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _max_crs_epre_mw(total_power_mw: float, n_prb: int, crs_ports: int, pa_db: float, pb: int) -> tuple[float, float, float, float]:
|
|
47
|
+
rho_a = 10.0 ** (pa_db / 10.0)
|
|
48
|
+
ratio = _TS36213_RHO_B_OVER_RHO_A_1PORT[pb] if crs_ports == 1 else _TS36213_RHO_B_OVER_RHO_A_MULTI[pb]
|
|
49
|
+
rho_b = ratio * rho_a
|
|
50
|
+
|
|
51
|
+
# Type-A OFDM symbol (no CRS): 12 PDSCH REs per PRB per port
|
|
52
|
+
denom_type_a = 12.0 * n_prb * rho_a
|
|
53
|
+
# Type-B OFDM symbol (with CRS, TS 36.211 6.10.1.2):
|
|
54
|
+
# 1 port: 2 active CRS REs + 10 PDSCH REs; 2/4 ports: 2 active CRS REs + 2 muted DTX REs + 8 PDSCH REs per port
|
|
55
|
+
if crs_ports == 1:
|
|
56
|
+
denom_type_b = n_prb * (2.0 + 10.0 * rho_b)
|
|
57
|
+
else:
|
|
58
|
+
denom_type_b = n_prb * (2.0 + 8.0 * rho_b)
|
|
59
|
+
|
|
60
|
+
crs_epre_mw = total_power_mw / max(denom_type_a, denom_type_b)
|
|
61
|
+
return crs_epre_mw, rho_a, ratio, rho_b
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def compute_pa_pb_power_split(
|
|
65
|
+
total_power_dbm: float = 46.0,
|
|
66
|
+
n_prb: int = 100,
|
|
67
|
+
crs_ports: int = 2,
|
|
68
|
+
pa_db: float = -3.0,
|
|
69
|
+
pb: int = 1,
|
|
70
|
+
) -> PaPbResult:
|
|
71
|
+
"""Compute exact CRS EPRE and Type-A / Type-B PDSCH EPRE per 3GPP TS 36.213 Section 5.2."""
|
|
72
|
+
if n_prb not in VALID_LTE_PRBS:
|
|
73
|
+
raise ValueError(f"n_prb must be one of {sorted(VALID_LTE_PRBS)}, got {n_prb}")
|
|
74
|
+
if crs_ports not in (1, 2, 4):
|
|
75
|
+
raise ValueError(f"crs_ports must be 1, 2, or 4, got {crs_ports}")
|
|
76
|
+
if pb not in (0, 1, 2, 3):
|
|
77
|
+
raise ValueError(f"pb must be in 0..3, got {pb}")
|
|
78
|
+
if not (-12.0 <= pa_db <= 6.0):
|
|
79
|
+
raise ValueError(f"pa_db out of realistic TS 36.331 range [-12, +6] dB: {pa_db}")
|
|
80
|
+
|
|
81
|
+
total_mw = 10.0 ** (total_power_dbm / 10.0)
|
|
82
|
+
crs_mw, rho_a, ratio, rho_b = _max_crs_epre_mw(total_mw, n_prb, crs_ports, pa_db, pb)
|
|
83
|
+
base_crs_mw, _, _, _ = _max_crs_epre_mw(total_mw, n_prb, crs_ports, -3.0, 1)
|
|
84
|
+
|
|
85
|
+
crs_dbm = 10.0 * math.log10(crs_mw)
|
|
86
|
+
pdsch_a_dbm = 10.0 * math.log10(crs_mw * rho_a)
|
|
87
|
+
pdsch_b_dbm = 10.0 * math.log10(crs_mw * rho_b)
|
|
88
|
+
delta_db = crs_dbm - 10.0 * math.log10(base_crs_mw)
|
|
89
|
+
|
|
90
|
+
if delta_db <= -1.5:
|
|
91
|
+
risk = "HIGH_FOOTPRINT_SHRINK: CRS EPRE drops >= 1.5 dB vs (-3 dB, PB=1); verify A2/B2 and VoLTE QCI=1 borders."
|
|
92
|
+
elif pa_db <= -4.5:
|
|
93
|
+
risk = "HIGH_PDSCH_STARVATION: Strong CRS RSRP boost but reduced PDSCH EPRE risks cell-edge throughput stall."
|
|
94
|
+
else:
|
|
95
|
+
risk = "BALANCED: Standard symbol power balance across Type-A and Type-B OFDM symbols."
|
|
96
|
+
|
|
97
|
+
return PaPbResult(
|
|
98
|
+
total_power_dbm=round(total_power_dbm, 2),
|
|
99
|
+
n_prb=n_prb,
|
|
100
|
+
crs_ports=crs_ports,
|
|
101
|
+
pa_db=round(pa_db, 2),
|
|
102
|
+
pb=pb,
|
|
103
|
+
rho_a_linear=round(rho_a, 4),
|
|
104
|
+
rho_b_over_rho_a=round(ratio, 4),
|
|
105
|
+
rho_b_linear=round(rho_b, 4),
|
|
106
|
+
crs_epre_dbm=round(crs_dbm, 2),
|
|
107
|
+
pdsch_epre_type_a_dbm=round(pdsch_a_dbm, 2),
|
|
108
|
+
pdsch_epre_type_b_dbm=round(pdsch_b_dbm, 2),
|
|
109
|
+
crs_delta_vs_baseline_db=round(delta_db, 2),
|
|
110
|
+
cell_edge_risk=risk,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass(frozen=True)
|
|
115
|
+
class PciAuditIssue:
|
|
116
|
+
"""Single PCI conflict or modulo overlap between serving PCI and a neighbor PCI."""
|
|
117
|
+
|
|
118
|
+
neighbor_pci: int
|
|
119
|
+
rule: str
|
|
120
|
+
severity: str
|
|
121
|
+
explanation: str
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass(frozen=True)
|
|
125
|
+
class PciAuditResult:
|
|
126
|
+
"""Summary of PCI collision, confusion, Mod 3, Mod 4, and Mod 30 checks."""
|
|
127
|
+
|
|
128
|
+
serving_pci: int
|
|
129
|
+
rat: str
|
|
130
|
+
serving_mod3: int
|
|
131
|
+
serving_mod4: int
|
|
132
|
+
serving_mod30: int
|
|
133
|
+
issues: tuple[PciAuditIssue, ...]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def audit_pci_neighbors(serving_pci: int, neighbor_pcis: Sequence[int], rat: str = "BOTH") -> PciAuditResult:
|
|
137
|
+
"""Audit serving PCI against neighbor PCIs for TS 36.211 / TS 38.211 collisions and modulo overlaps."""
|
|
138
|
+
rat_norm = rat.upper()
|
|
139
|
+
if rat_norm not in ("LTE", "NR", "BOTH"):
|
|
140
|
+
raise ValueError("rat must be 'LTE', 'NR', or 'BOTH'")
|
|
141
|
+
max_pci = 503 if rat_norm == "LTE" else 1007
|
|
142
|
+
if not (0 <= serving_pci <= max_pci):
|
|
143
|
+
raise ValueError(f"serving_pci must be in 0..{max_pci}, got {serving_pci}")
|
|
144
|
+
|
|
145
|
+
issues: list[PciAuditIssue] = []
|
|
146
|
+
seen: set[int] = set()
|
|
147
|
+
for n_pci in neighbor_pcis:
|
|
148
|
+
if not (0 <= n_pci <= max_pci):
|
|
149
|
+
raise ValueError(f"neighbor_pci must be in 0..{max_pci}, got {n_pci}")
|
|
150
|
+
if n_pci in seen:
|
|
151
|
+
issues.append(
|
|
152
|
+
PciAuditIssue(
|
|
153
|
+
neighbor_pci=n_pci,
|
|
154
|
+
rule="PCI_CONFUSION",
|
|
155
|
+
severity="CRITICAL",
|
|
156
|
+
explanation=f"Duplicate neighbor PCI {n_pci} in neighbor list causes two-hop handover confusion.",
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
seen.add(n_pci)
|
|
160
|
+
|
|
161
|
+
if n_pci == serving_pci:
|
|
162
|
+
issues.append(
|
|
163
|
+
PciAuditIssue(
|
|
164
|
+
neighbor_pci=n_pci,
|
|
165
|
+
rule="PCI_COLLISION",
|
|
166
|
+
severity="CRITICAL",
|
|
167
|
+
explanation="Exact co-channel PCI collision with serving cell.",
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
continue
|
|
171
|
+
|
|
172
|
+
if rat_norm in ("LTE", "BOTH") and (n_pci % 3 == serving_pci % 3):
|
|
173
|
+
issues.append(
|
|
174
|
+
PciAuditIssue(
|
|
175
|
+
neighbor_pci=n_pci,
|
|
176
|
+
rule="LTE_CRS_MOD3",
|
|
177
|
+
severity="HIGH",
|
|
178
|
+
explanation=f"Both PCIs have mod 3 == {serving_pci % 3} (TS 36.211 2/4-port CRS RE subcarrier overlap).",
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
if rat_norm in ("NR", "BOTH") and (n_pci % 4 == serving_pci % 4):
|
|
183
|
+
issues.append(
|
|
184
|
+
PciAuditIssue(
|
|
185
|
+
neighbor_pci=n_pci,
|
|
186
|
+
rule="NR_PBCH_DMRS_MOD4",
|
|
187
|
+
severity="HIGH",
|
|
188
|
+
explanation=f"Both PCIs have mod 4 == {serving_pci % 4} (TS 38.211 SSB PBCH DMRS v-shift overlap).",
|
|
189
|
+
)
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
if n_pci % 30 == serving_pci % 30:
|
|
193
|
+
issues.append(
|
|
194
|
+
PciAuditIssue(
|
|
195
|
+
neighbor_pci=n_pci,
|
|
196
|
+
rule="UL_DMRS_MOD30",
|
|
197
|
+
severity="MEDIUM",
|
|
198
|
+
explanation=f"Both PCIs have mod 30 == {serving_pci % 30} (shared PUSCH/PUCCH DMRS base sequence group).",
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
return PciAuditResult(
|
|
203
|
+
serving_pci=serving_pci,
|
|
204
|
+
rat=rat_norm,
|
|
205
|
+
serving_mod3=serving_pci % 3,
|
|
206
|
+
serving_mod4=serving_pci % 4,
|
|
207
|
+
serving_mod30=serving_pci % 30,
|
|
208
|
+
issues=tuple(issues),
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass(frozen=True)
|
|
213
|
+
class LatencyBudgetResult:
|
|
214
|
+
"""7-segment 5G NSA (EN-DC) RTT decomposition vs 3GPP TR 38.913 target."""
|
|
215
|
+
|
|
216
|
+
slot_duration_ms: float
|
|
217
|
+
radio_uplane_rtt_ms: float
|
|
218
|
+
x2u_rtt_ms: float
|
|
219
|
+
backhaul_epc_rtt_ms: float
|
|
220
|
+
gi_server_rtt_ms: float
|
|
221
|
+
estimated_median_rtt_ms: float
|
|
222
|
+
estimated_p95_rtt_ms: float
|
|
223
|
+
dominant_segment: str
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def compute_nsa_latency_budget(
|
|
227
|
+
scs_khz: int = 30,
|
|
228
|
+
tdd_ul_wait_ms: float = 1.8,
|
|
229
|
+
initial_bler_pct: float = 5.0,
|
|
230
|
+
x2u_one_way_ms: float = 0.6,
|
|
231
|
+
backhaul_epc_rtt_ms: float = 8.0,
|
|
232
|
+
gi_server_rtt_ms: float = 2.0,
|
|
233
|
+
) -> LatencyBudgetResult:
|
|
234
|
+
"""Decompose commercial 5G NSA EN-DC ping RTT across TS 38.211, TS 37.340, and core transport."""
|
|
235
|
+
if scs_khz not in (15, 30, 60, 120):
|
|
236
|
+
raise ValueError(f"scs_khz must be 15, 30, 60, or 120, got {scs_khz}")
|
|
237
|
+
if not (0.0 <= initial_bler_pct <= 50.0):
|
|
238
|
+
raise ValueError("initial_bler_pct must be between 0 and 50")
|
|
239
|
+
if min(tdd_ul_wait_ms, x2u_one_way_ms, backhaul_epc_rtt_ms, gi_server_rtt_ms) < 0.0:
|
|
240
|
+
raise ValueError("Delay inputs must be non-negative")
|
|
241
|
+
|
|
242
|
+
slot_ms = 1.0 / (scs_khz / 15.0)
|
|
243
|
+
harq_rtt_ms = 8.0 * slot_ms
|
|
244
|
+
harq_adder_ms = 2.0 * (initial_bler_pct / 100.0) * harq_rtt_ms
|
|
245
|
+
ul_radio_ms = 2.5 * slot_ms + tdd_ul_wait_ms + 0.5 * harq_adder_ms
|
|
246
|
+
dl_radio_ms = 2.0 * slot_ms + 0.5 * harq_adder_ms
|
|
247
|
+
radio_total_ms = ul_radio_ms + dl_radio_ms
|
|
248
|
+
x2u_rtt_ms = 2.0 * x2u_one_way_ms
|
|
249
|
+
|
|
250
|
+
median_rtt = radio_total_ms + x2u_rtt_ms + backhaul_epc_rtt_ms + gi_server_rtt_ms
|
|
251
|
+
p95_rtt = median_rtt + harq_rtt_ms * (1.0 + initial_bler_pct / 15.0) + 0.8 * tdd_ul_wait_ms
|
|
252
|
+
|
|
253
|
+
segments = {
|
|
254
|
+
"NR Air Interface (TDD Wait + Slot + HARQ)": radio_total_ms,
|
|
255
|
+
"EN-DC X2-U Split Hop (TS 37.340)": x2u_rtt_ms,
|
|
256
|
+
"Backhaul, IPsec & EPC P-GW": backhaul_epc_rtt_ms,
|
|
257
|
+
"Gi / Peering / Test Server": gi_server_rtt_ms,
|
|
258
|
+
}
|
|
259
|
+
dominant = max(segments.items(), key=lambda kv: kv[1])[0]
|
|
260
|
+
|
|
261
|
+
return LatencyBudgetResult(
|
|
262
|
+
slot_duration_ms=round(slot_ms, 3),
|
|
263
|
+
radio_uplane_rtt_ms=round(radio_total_ms, 2),
|
|
264
|
+
x2u_rtt_ms=round(x2u_rtt_ms, 2),
|
|
265
|
+
backhaul_epc_rtt_ms=round(backhaul_epc_rtt_ms, 2),
|
|
266
|
+
gi_server_rtt_ms=round(gi_server_rtt_ms, 2),
|
|
267
|
+
estimated_median_rtt_ms=round(median_rtt, 2),
|
|
268
|
+
estimated_p95_rtt_ms=round(p95_rtt, 2),
|
|
269
|
+
dominant_segment=dominant,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@dataclass(frozen=True)
|
|
274
|
+
class TimerSpec:
|
|
275
|
+
"""3GPP RRC / NAS timer specification entry."""
|
|
276
|
+
|
|
277
|
+
name: str
|
|
278
|
+
rat: str
|
|
279
|
+
layer: str
|
|
280
|
+
spec: str
|
|
281
|
+
start_trigger: str
|
|
282
|
+
expiry_action: str
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
_TIMERS: tuple[TimerSpec, ...] = (
|
|
286
|
+
TimerSpec("T300", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "Transmission of RRCSetupRequest / RRCConnectionRequest", "Reset MAC and inform upper layers of RRC setup failure"),
|
|
287
|
+
TimerSpec("T301", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "Transmission of RRCReestablishmentRequest", "Enter RRC_IDLE (session drop)"),
|
|
288
|
+
TimerSpec("T304", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "Reception of reconfigurationWithSync (handover / PSCell addition)", "Trigger RRC re-establishment (MCG) or SCGFailureInformation (EN-DC)"),
|
|
289
|
+
TimerSpec("T310", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "N310 consecutive out-of-sync indications from L1 on SpCell", "Declare Radio Link Failure (RLF) and initiate re-establishment"),
|
|
290
|
+
TimerSpec("T311", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "Initiation of RRC connection re-establishment procedure", "Enter RRC_IDLE if no suitable cell is selected"),
|
|
291
|
+
TimerSpec("T312", "5G NR / LTE", "RRC", "TS 38.331 / TS 36.331", "MeasurementReport triggered with useT312 while T310 is running", "Declare fast RLF without waiting for full T310 expiry"),
|
|
292
|
+
TimerSpec("T313", "5G NR", "RRC", "TS 38.331", "N313 consecutive out-of-sync indications on PSCell", "Send SCGFailureInformation (t313-Expiry) over MCG"),
|
|
293
|
+
TimerSpec("T319", "5G NR", "RRC", "TS 38.331", "Transmission of RRCResumeRequest from RRC_INACTIVE", "Enter RRC_IDLE and report resume failure"),
|
|
294
|
+
TimerSpec("T3510", "5G NR", "NAS 5GMM", "TS 24.501", "Transmission of 5GS REGISTRATION REQUEST", "Abort registration attempt and start T3511 retry timer"),
|
|
295
|
+
TimerSpec("T3517", "5G NR", "NAS 5GMM", "TS 24.501", "Transmission of 5GS SERVICE REQUEST", "Abort service request procedure"),
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def lookup_3gpp_timers(query: str = "") -> tuple[TimerSpec, ...]:
|
|
300
|
+
"""Filter standard 3GPP RRC and NAS timers by ID, layer, or keyword."""
|
|
301
|
+
q = query.strip().lower()
|
|
302
|
+
if not q:
|
|
303
|
+
return _TIMERS
|
|
304
|
+
return tuple(
|
|
305
|
+
t
|
|
306
|
+
for t in _TIMERS
|
|
307
|
+
if q in f"{t.name} {t.rat} {t.layer} {t.spec} {t.start_trigger} {t.expiry_action}".lower()
|
|
308
|
+
)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Command-line interface for deterministic 3GPP RAN engineering checks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
from dataclasses import asdict
|
|
8
|
+
from typing import Sequence
|
|
9
|
+
|
|
10
|
+
from .calculators import (
|
|
11
|
+
audit_pci_neighbors,
|
|
12
|
+
compute_nsa_latency_budget,
|
|
13
|
+
compute_pa_pb_power_split,
|
|
14
|
+
lookup_3gpp_timers,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
prog="ran-3gpp-calc",
|
|
21
|
+
description="Deterministic 3GPP 4G/5G RAN calculators (companion to https://takwasebai.com/en/calculators/).",
|
|
22
|
+
)
|
|
23
|
+
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
24
|
+
|
|
25
|
+
p_papb = sub.add_parser("pa-pb", help="Compute LTE TS 36.213 CRS & PDSCH EPRE power split")
|
|
26
|
+
p_papb.add_argument("--power-dbm", type=float, default=46.0)
|
|
27
|
+
p_papb.add_argument("--prb", type=int, default=100)
|
|
28
|
+
p_papb.add_argument("--ports", type=int, default=2, choices=[1, 2, 4])
|
|
29
|
+
p_papb.add_argument("--pa", type=float, default=-3.0)
|
|
30
|
+
p_papb.add_argument("--pb", type=int, default=1, choices=[0, 1, 2, 3])
|
|
31
|
+
|
|
32
|
+
p_pci = sub.add_parser("pci", help="Audit serving PCI vs neighbor PCIs (Mod 3 / Mod 4 / Mod 30)")
|
|
33
|
+
p_pci.add_argument("--serving", type=int, required=True)
|
|
34
|
+
p_pci.add_argument("--neighbors", type=int, nargs="+", required=True)
|
|
35
|
+
p_pci.add_argument("--rat", choices=["LTE", "NR", "BOTH"], default="BOTH")
|
|
36
|
+
|
|
37
|
+
p_lat = sub.add_parser("nsa-latency", help="Decompose 5G NSA EN-DC end-to-end RTT")
|
|
38
|
+
p_lat.add_argument("--scs-khz", type=int, default=30, choices=[15, 30, 60, 120])
|
|
39
|
+
p_lat.add_argument("--tdd-wait-ms", type=float, default=1.8)
|
|
40
|
+
p_lat.add_argument("--bler-pct", type=float, default=5.0)
|
|
41
|
+
p_lat.add_argument("--x2u-ms", type=float, default=0.6)
|
|
42
|
+
p_lat.add_argument("--epc-rtt-ms", type=float, default=8.0)
|
|
43
|
+
p_lat.add_argument("--server-rtt-ms", type=float, default=2.0)
|
|
44
|
+
|
|
45
|
+
p_tmr = sub.add_parser("timers", help="Search 3GPP RRC / NAS timers")
|
|
46
|
+
p_tmr.add_argument("query", nargs="?", default="")
|
|
47
|
+
|
|
48
|
+
args = parser.parse_args(argv)
|
|
49
|
+
if args.cmd == "pa-pb":
|
|
50
|
+
res = asdict(compute_pa_pb_power_split(args.power_dbm, args.prb, args.ports, args.pa, args.pb))
|
|
51
|
+
elif args.cmd == "pci":
|
|
52
|
+
res = asdict(audit_pci_neighbors(args.serving, args.neighbors, args.rat))
|
|
53
|
+
elif args.cmd == "nsa-latency":
|
|
54
|
+
res = asdict(
|
|
55
|
+
compute_nsa_latency_budget(
|
|
56
|
+
args.scs_khz,
|
|
57
|
+
args.tdd_wait_ms,
|
|
58
|
+
args.bler_pct,
|
|
59
|
+
args.x2u_ms,
|
|
60
|
+
args.epc_rtt_ms,
|
|
61
|
+
args.server_rtt_ms,
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
else:
|
|
65
|
+
res = {"timers": [asdict(t) for t in lookup_3gpp_timers(args.query)]}
|
|
66
|
+
|
|
67
|
+
print(json.dumps(res, indent=2))
|
|
68
|
+
return 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
raise SystemExit(main())
|
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ran-3gpp-calc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic 3GPP RAN & RF engineering calculators: LTE TS 36.213 PA/PB CRS EPRE, LTE/5G NR PCI Mod 3/4/30 auditor, 5G NSA TR 38.913 latency budget, and RRC/NAS timers.
|
|
5
|
+
Author: Takwa Sebai
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://takwasebai.com/en/calculators/
|
|
8
|
+
Project-URL: Documentation, https://takwasebai.com/en/calculators/
|
|
9
|
+
Project-URL: Repository, https://github.com/tsebai/3gpp-ran-calculators
|
|
10
|
+
Keywords: 3gpp,5g-nr,lte,rf-engineering,pci,ran,telecom,latency
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Telecommunications Industry
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# 3GPP RAN & RF Calculators (`ran-3gpp-calc`)
|
|
27
|
+
|
|
28
|
+
[](https://doi.org/10.5281/zenodo.24796699)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Zero-dependency, strictly typed (`PEP 561`) Python library and CLI implementing deterministic 3GPP radio engineering calculations used in live 4G LTE and 5G NR optimization reviews:
|
|
32
|
+
|
|
33
|
+
1. **LTE Downlink Power Split (`3GPP TS 36.213` Section 5.2)**: Exact `rho_B / rho_A` ratio across 1, 2, and 4 CRS antenna ports, CRS EPRE (`dBm`), Type-A / Type-B PDSCH EPRE, and cell-edge footprint delta before changing `PA` / `PB`.
|
|
34
|
+
2. **LTE & 5G NR PCI Modulo Auditor (`TS 36.211` / `TS 38.211`)**: Simultaneous detection of exact PCI collision, two-hop neighbor PCI confusion, LTE CRS `Mod 3`, 5G NR SSB PBCH DMRS `Mod 4`, and Uplink DMRS `Mod 30` sequence-group overlaps.
|
|
35
|
+
3. **5G NSA (EN-DC) End-to-End Latency Budget (`TR 38.913` / `TS 38.211` / `TS 37.340`)**: Separates one-way radio SDU transit from TDD UL frame alignment, HARQ BLER retransmission tail, `X2-U` split-bearer delay, and EPC `P-GW` routing RTT.
|
|
36
|
+
4. **3GPP RRC & NAS Timers Reference (`TS 38.331` / `TS 36.331` / `TS 24.501`)**: Instant lookup for `T300`, `T301`, `T304`, `T310`, `T311`, `T312`, `T313`, `T319`, `T3510`, and `T3517`.
|
|
37
|
+
|
|
38
|
+
## Interactive Web Calculators (Zero Upload, EN / FR / ES / AR)
|
|
39
|
+
|
|
40
|
+
All 8 full interactive browser calculators with shareable scenario links (`#s=...`) are freely available online:
|
|
41
|
+
|
|
42
|
+
- **8 Free 3GPP Calculators Hub**: https://takwasebai.com/en/calculators/
|
|
43
|
+
- **LTE PRB Congestion & PA/PB Simulator**: https://takwasebai.com/en/calculators/lte-prb-congestion-pa-pb-simulator/
|
|
44
|
+
- **5G NSA End-to-End Latency Budget Simulator**: https://takwasebai.com/en/calculators/5g-nsa-end-to-end-latency-budget/
|
|
45
|
+
- **LTE & 5G NR PCI Mod 3 / Mod 4 / Mod 30 Auditor**: https://takwasebai.com/en/calculators/lte-5g-pci-mod3-mod4-mod30-auditor/
|
|
46
|
+
- **5G NR & 4G LTE RRC/NAS Timers Lookup**: https://takwasebai.com/en/calculators/5g-lte-rrc-timers-lookup/
|
|
47
|
+
|
|
48
|
+
## Installation & Quick Start
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### CLI Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Compare TS 36.213 CRS EPRE shift when moving from (PA=-3 dB, PB=1) to (PA=0 dB, PB=0)
|
|
58
|
+
ran-3gpp-calc pa-pb --power-dbm 46 --prb 100 --ports 2 --pa 0 --pb 0
|
|
59
|
+
|
|
60
|
+
# Audit serving PCI 27 against candidate neighbors across LTE Mod 3, NR Mod 4, and UL Mod 30
|
|
61
|
+
ran-3gpp-calc pci --serving 27 --neighbors 147 31 57 --rat BOTH
|
|
62
|
+
|
|
63
|
+
# Decompose a 26 ms commercial 5G NSA ping RTT across radio, X2-U, and EPC
|
|
64
|
+
ran-3gpp-calc nsa-latency --scs-khz 30 --tdd-wait-ms 1.8 --bler-pct 6 --x2u-ms 2.5 --epc-rtt-ms 14
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Python API
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from ran_3gpp_calc import compute_pa_pb_power_split, audit_pci_neighbors, compute_nsa_latency_budget
|
|
71
|
+
|
|
72
|
+
papb = compute_pa_pb_power_split(total_power_dbm=46.0, n_prb=100, crs_ports=2, pa_db=0.0, pb=0)
|
|
73
|
+
print(papb.crs_epre_dbm, papb.crs_delta_vs_baseline_db, papb.cell_edge_risk)
|
|
74
|
+
|
|
75
|
+
pci = audit_pci_neighbors(serving_pci=27, neighbor_pcis=[147, 31, 57], rat="BOTH")
|
|
76
|
+
for issue in pci.issues:
|
|
77
|
+
print(issue.neighbor_pci, issue.rule, issue.severity)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Field Workbooks & Printable Desk Packs
|
|
81
|
+
|
|
82
|
+
For engineering teams needing printable A4 protocol cheat-sheets, worked field root-cause cases, and Excel rollback registers:
|
|
83
|
+
|
|
84
|
+
- **5G NR & 4G LTE Protocol Cheat-Sheets Pack (12 A4 Field Sheets)**: https://takwasebai.com/en/5g-4g-protocol-cheat-sheets-pack/
|
|
85
|
+
- **LTE PRB Congestion & PA/PB Decision Workbook (PDF + Excel Rollback Audit)**: https://takwasebai.com/en/lte-prb-congestion-decision-workbook/
|
|
86
|
+
- **LTE & 5G NR PCI Planning & Audit Workbook (8 Worked Cases + Excel Auditor)**: https://takwasebai.com/en/lte-5g-pci-planning-audit-workbook/
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT License. Authored by **Takwa Sebai** (https://takwasebai.com/en/).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/ran_3gpp_calc/__init__.py
|
|
5
|
+
src/ran_3gpp_calc/calculators.py
|
|
6
|
+
src/ran_3gpp_calc/cli.py
|
|
7
|
+
src/ran_3gpp_calc/py.typed
|
|
8
|
+
src/ran_3gpp_calc.egg-info/PKG-INFO
|
|
9
|
+
src/ran_3gpp_calc.egg-info/SOURCES.txt
|
|
10
|
+
src/ran_3gpp_calc.egg-info/dependency_links.txt
|
|
11
|
+
src/ran_3gpp_calc.egg-info/entry_points.txt
|
|
12
|
+
src/ran_3gpp_calc.egg-info/top_level.txt
|
|
13
|
+
tests/test_calculators.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ran_3gpp_calc
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Unit tests for ran_3gpp_calc."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import io
|
|
7
|
+
import unittest
|
|
8
|
+
from contextlib import redirect_stdout
|
|
9
|
+
|
|
10
|
+
from ran_3gpp_calc import (
|
|
11
|
+
audit_pci_neighbors,
|
|
12
|
+
compute_nsa_latency_budget,
|
|
13
|
+
compute_pa_pb_power_split,
|
|
14
|
+
lookup_3gpp_timers,
|
|
15
|
+
)
|
|
16
|
+
from ran_3gpp_calc.cli import main
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TestRan3gppCalculators(unittest.TestCase):
|
|
20
|
+
def test_ts36213_pa_pb_baseline_vs_uniform(self) -> None:
|
|
21
|
+
base = compute_pa_pb_power_split(total_power_dbm=43.0, n_prb=100, crs_ports=2, pa_db=-3.0, pb=1)
|
|
22
|
+
flat = compute_pa_pb_power_split(total_power_dbm=43.0, n_prb=100, crs_ports=2, pa_db=0.0, pb=0)
|
|
23
|
+
self.assertAlmostEqual(base.crs_delta_vs_baseline_db, 0.0, places=2)
|
|
24
|
+
self.assertAlmostEqual(flat.crs_delta_vs_baseline_db, -3.00, delta=0.02)
|
|
25
|
+
self.assertIn("HIGH_FOOTPRINT_SHRINK", flat.cell_edge_risk)
|
|
26
|
+
|
|
27
|
+
def test_pci_collision_confusion_and_modulos(self) -> None:
|
|
28
|
+
# Serving 27: mod3=0, mod4=3, mod30=27
|
|
29
|
+
res = audit_pci_neighbors(27, [27, 147, 31, 57, 147], rat="BOTH")
|
|
30
|
+
rules = [i.rule for i in res.issues]
|
|
31
|
+
self.assertIn("PCI_COLLISION", rules)
|
|
32
|
+
self.assertIn("PCI_CONFUSION", rules)
|
|
33
|
+
self.assertIn("LTE_CRS_MOD3", rules)
|
|
34
|
+
self.assertIn("NR_PBCH_DMRS_MOD4", rules)
|
|
35
|
+
self.assertIn("UL_DMRS_MOD30", rules)
|
|
36
|
+
|
|
37
|
+
def test_nsa_latency_dominant_owner_switch(self) -> None:
|
|
38
|
+
clean = compute_nsa_latency_budget(scs_khz=30, tdd_ul_wait_ms=1.8, initial_bler_pct=5.0, x2u_one_way_ms=0.5, backhaul_epc_rtt_ms=8.0, gi_server_rtt_ms=2.0)
|
|
39
|
+
self.assertLess(clean.radio_uplane_rtt_ms, 6.0)
|
|
40
|
+
self.assertEqual(clean.dominant_segment, "Backhaul, IPsec & EPC P-GW")
|
|
41
|
+
|
|
42
|
+
x2_bad = compute_nsa_latency_budget(scs_khz=30, tdd_ul_wait_ms=1.5, initial_bler_pct=4.0, x2u_one_way_ms=8.0, backhaul_epc_rtt_ms=6.0, gi_server_rtt_ms=2.0)
|
|
43
|
+
self.assertEqual(x2_bad.dominant_segment, "EN-DC X2-U Split Hop (TS 37.340)")
|
|
44
|
+
|
|
45
|
+
def test_timers_lookup_and_cli_json(self) -> None:
|
|
46
|
+
t310 = lookup_3gpp_timers("T310")
|
|
47
|
+
self.assertGreaterEqual(len(t310), 1)
|
|
48
|
+
self.assertEqual(t310[0].name, "T310")
|
|
49
|
+
|
|
50
|
+
buf = io.StringIO()
|
|
51
|
+
with redirect_stdout(buf):
|
|
52
|
+
rc = main(["pci", "--serving", "12", "--neighbors", "15", "16"])
|
|
53
|
+
self.assertEqual(rc, 0)
|
|
54
|
+
payload = json.loads(buf.getvalue())
|
|
55
|
+
self.assertEqual(payload["serving_pci"], 12)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
unittest.main()
|