Commit 28d77010 authored by Robert Schmidt's avatar Robert Schmidt

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.
parent f282402e
......@@ -213,6 +213,10 @@ ID = GNB_MAC_UL_PDU_WITH_DATA
DESC = NR MAC uplink PDU for an UE
GROUP = ALL:MAC:GNB:WIRESHARK
FORMAT = int,gNB_ID : int,CC_id : int,rnti : int,frame : int,slot : int,harq_pid : buffer,data
ID = GNB_MAC_PUSCH_POWER_CONTROL
DESC = NR MAC PUSCH power control-related data
GROUP = ALL:MAC:GNB:CSV
FORMAT = int,rnti : int,frame : int,slot : int,snrx10 : int,phr : int,tpc : int,tb_size : int,txpower_calc : int,rbSize : int,mcs : int,rssi
ID = GNB_MAC_DL_RAR_PDU_WITH_DATA
DESC = NR MAC downlink PDU for RAR
GROUP = ALL:MAC:GNB:WIRESHARK
......
......@@ -987,6 +987,17 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP,
if (timing_advance != 0xffff)
UE_scheduling_control->ta_update = timing_advance;
UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640 - (txpower_calc * 10);
const NR_sched_pusch_t *sched_pusch = &UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch;
(void) sched_pusch; // avoids warnings of unused sched_pusch when compiling without T
T(T_GNB_MAC_PUSCH_POWER_CONTROL, T_INT(rntiP), T_INT(frameP), T_INT(slotP),
T_INT(UE_scheduling_control->pusch_snrx10),
T_INT(UE_scheduling_control->ph),
T_INT(sched_pusch->tpc_pusch),
T_INT(sched_pusch->tb_size),
T_INT(txpower_calc),
T_INT(sched_pusch->rbSize),
T_INT(sched_pusch->mcs),
T_INT(rssi));
if (UE_scheduling_control->tpc0 > 1)
LOG_D(NR_MAC,
"[UE %04x] %d.%d. PUSCH TPC %d and TA %d pusch_snrx10 %d rssi %d phrx_tx_power %d PHR (1PRB) %d mcs %d, nb_rb %d\n",
......@@ -2607,7 +2618,8 @@ void post_process_ulsch(gNB_MAC_INST *nr_mac, post_process_pusch_t *pusch, NR_UE
ss->searchSpaceType->present);
// Reset TPC to 0 dB to not request new gain multiple times before computing new value for SNR
UE->UE_sched_ctrl.tpc0 = 1;
cur_harq->sched_pusch.tpc_pusch = sched_ctrl->tpc0;
sched_ctrl->tpc0 = 1;
fill_dci_pdu_rel15(&UE->sc_info,
&UE->current_DL_BWP,
......
......@@ -469,6 +469,9 @@ typedef struct NR_sched_pusch {
NR_pusch_dmrs_t dmrs_info;
bwp_info_t bwp_info;
int phr_txpower_calc;
/// TPC command for this PUSCH
int tpc_pusch;
} NR_sched_pusch_t;
typedef struct NR_pdsch_dmrs {
......
......@@ -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.
#!/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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment