Log PUSCH power control variables via T trace GNB_MAC_PUSCH_POWER_CONTROL

Include plotting tool and README on how to log and visualize graphics.
This commit is contained in:
Robert Schmidt
2025-11-03 16:32:19 +01:00
parent f282402ea2
commit 28d770108f
5 changed files with 109 additions and 1 deletions

View File

@@ -32,3 +32,43 @@ The plots are saved in three formats: `.png`, `.pdf` and `.svg`.
### Example graphs:
#### BER
![image](./ber_compare.svg)
## `plot_power_control.sh`
This plots the relevant graphs for power control at the gNB, exported through T
and recorded via the [`csv` tracer](../../common/utils/T/DOC/T/csv.md) and
plotted with `gnuplot`.
Run first the `csv` tracer in one terminal, selecting the desired quantities, and
write them out to a file:
./common/utils/T/tracer/csv -d ../common/utils/T/T_messages.txt -s $'\t' -t time GNB_MAC_PUSCH_POWER_CONTROL time snrx10 phr tpc tb_size txpower_calc rbSize mcs > /tmp/pusch.csv
in a second terminal, run the gNB with desired configuration, and pass the
`--T_stdout 2` option to connect to the `csv` tracer:
sudo ./nr-softmodem -O <config> --T_stdout 2
Note that you could also run both in one window, connecting both commands with
a `&`. In that case, it's important to run the `nr-softmodem` at second
position, which will receive signals and stop the `csv` tracer when stopping
the main process.
After recovering the `pusch.csv` file, you could plot it with a script.
./plot-power-control.gp.sh /tmp/pusch.csv
The script prints four graphs:
1. prints instantaneous SNR, and "deltaMCS" (the power used for the
transmission if in deltaMCS mode that accounts for MCS). It also prints an
average SNR, but this has to be manually post-processed from the instanteous
SNR values (`snrx10` above)
2. TPC commands and PHR of the UE
3. Resource blocks used for all transmissions, and the MCS
4. transport block size of the transmission, to estimate the amount of traffic.
The script should either auto-scale graphs or have sensible defaults. It prints
on screen. There is code to print to a file; uncomment the relevant lines to
achieve this.

View File

@@ -0,0 +1,49 @@
#!/bin/bash
function die() { echo "$@"; exit 1; }
[[ $# == 1 ]] || die "usage: $0 <filename>"
FILE=${1}
#OUTPUT=/tmp/results.png
#echo "dumping to $OUTPUT"
gnuplot << EOF
#set terminal pngcairo size 2000,2000 enhanced font 'Verdana,10'
#set output "$OUTPUT"
set format x '%H:%M:%S'
set timefmt '%H:%M:%S'
set datafile separator "\t"
set xdata time
#set xrange ['08:43:17':'08:43:18']
set grid
set multiplot layout 4,1
set yrange [0:300]
set ylabel "dB"
plot "$FILE" using 1:2 w l title "SNRx10 (inst)", "$FILE" using 1:9 w l title "SNRx10 (smooth)", "$FILE" using 1:6 w l title "txpower-calc"
set yrange [5:50]
set ylabel "PHR (dB)"
set y2range [0:3]
set y2label "TPC"
set boxwidth 0.1
plot "$FILE" using 1:4 w points pt 7 axes x1y2 title "TPC", "$FILE" using 1:3 w l title "PHR"
set yrange [0:60]
set ylabel "RB"
set y2range [0:27]
set y2label "MCS"
plot "$FILE" using 1:7 w l title "RB", "$FILE" using 1:8 w l axes x1y2 title "MCS"
set yrange [0:1000]
set ylabel "TB size (B)"
plot "$FILE" using 1:5 w l
unset multiplot
pause mouse close
EOF