31/08/2021, 02:04 PM
MikroTik's 4G LTE routers have the ability to show neighbouring 4G cells, a feature many others lack such as the popular Huawei and TP-Link routers. This is very useful for checking the signal and quality readings of the aggregated cells, particularly when repositioning the router or adjusting an external antenna. The MikroTik Chateau router series can also report readings of the different MIMO layers (via AT chat), which is also useful when using individual antennas. See this post on how to get 4x4 MIMO with external antennas on the Chateau 5G.
After upgrading to the V7.1rc1 firmware, I ran into a problem with the built-in cell-monitor command. It now only lists a few neighbouring cells, even on V7.1rc2 at this time of posting. Another issue is that the main LTE status page does not show the signal readings of the aggregated cells, requiring the user to cross-check the aggregated cells with the (broken) cell-monitor list.
As a workaround, I wrote a few scripts to show aggregated cells, MIMO layers (primary carrier only) and neighbouring cells, all which refresh every second. Up until recently, I have never written MikroTik scripts, so these scripts will probably look messy to any seasoned MikroTik user.
Notice: These scripts have only been tested in 4G LTE mode with an active 4G connection. They will not produce any output in 3G WCDMA. In 5G NSA mode, they will only show LTE cells as I don't have any 5G coverage at this time to update for 5G read-outs. Please do not run in them in a production environment.
How to add a script
How to run a script
In the terminal, type:
/system script run [script name]
For example, if the script is called "camonitor", type:
/system script run camonitor
The script will run in a loop, refreshing the readings every second, much quicker than the Router OS built-in cell-monitor command. Type 'Q' to stop or 'P' to pause. Press 'D' to dump the readings above. Note: It does not save them to file.
Carrier Aggregation Cell Monitor
Display the RSRP, RSRQ and SINR readings of the primary (PCC) and aggregated (SCC) cells. At present, the A03 firmware (preinstalled on the Chateau 5G) has a bug that causes incorrect SINR read-outs for the aggregated cells. This is reportedly fixed in the A04 firmware.
Neighbour Cell Monitor
Works much like the Router OS cell monitor, but refreshes the readings every second. It lacks the age column. It will display the full list of neighbouring cells even on V7.1rc1 and V7.1rc2.
MIMO Layer Signal Readings
With an AT chat command, the modem can display the RSRP, RSRQ and SINR readings of each MIMO layer for the primary cell. This is particularly useful when checking or adjusting multiple antennas, such as with 4x4 MIMO when using the high frequency bands. In 2x2 MIMO, the 3rd and 4th layer will show -140 for the RSRP.
After upgrading to the V7.1rc1 firmware, I ran into a problem with the built-in cell-monitor command. It now only lists a few neighbouring cells, even on V7.1rc2 at this time of posting. Another issue is that the main LTE status page does not show the signal readings of the aggregated cells, requiring the user to cross-check the aggregated cells with the (broken) cell-monitor list.
As a workaround, I wrote a few scripts to show aggregated cells, MIMO layers (primary carrier only) and neighbouring cells, all which refresh every second. Up until recently, I have never written MikroTik scripts, so these scripts will probably look messy to any seasoned MikroTik user.
Notice: These scripts have only been tested in 4G LTE mode with an active 4G connection. They will not produce any output in 3G WCDMA. In 5G NSA mode, they will only show LTE cells as I don't have any 5G coverage at this time to update for 5G read-outs. Please do not run in them in a production environment.
How to add a script
- In Winbox, go into System -> Scripts.
- Click the '+' icon.
- In the "Name:" field, give it a name like "camonitor".
- Copy and paste the script in the white area below, then click 'OK'.
- Repeat the steps for each script, giving each a separate name for step 3.
How to run a script
In the terminal, type:
/system script run [script name]
For example, if the script is called "camonitor", type:
/system script run camonitor
The script will run in a loop, refreshing the readings every second, much quicker than the Router OS built-in cell-monitor command. Type 'Q' to stop or 'P' to pause. Press 'D' to dump the readings above. Note: It does not save them to file.
Carrier Aggregation Cell Monitor
Display the RSRP, RSRQ and SINR readings of the primary (PCC) and aggregated (SCC) cells. At present, the A03 firmware (preinstalled on the Chateau 5G) has a bug that causes incorrect SINR read-outs for the aggregated cells. This is reportedly fixed in the A04 firmware.
Code:
# Print headings
local headings do={
/terminal style syntax-noterm
put "CA PCI\tBAND BW\tEARFCN\tRSRP\tRSRQ\tRSSI\tSINR"
/terminal style none
}
$headings
# Bandwidth to MHz conversion
set $bandwidth {"6"="1.4";"15"="3";"25"="5";"50"="10";"75"="15";"100"="20"}
# Reset counters
set $count 0
set $pcount 0
# Loop until a keystroke
do {
# Reset cursor position and note previous line count
for n from=1 to=$count step=1 do={/terminal cuu}
set $pcount $count
set $count 0
# Get the list of carrier aggregation cells from using the modem at-chat command
set $cells [pick [/interface lte at-chat lte1 input="at+qcainfo" as-value ] 0]
# Loop through each LTE cell
set $i [find $cells "QCAINFO"]
while ($i>0) do={
set $cell [ toarray "" ]
set $output ""
set $i ($i+9)
# Retrieve the raw type, EARFCN, bandwidth, band, PCI, RSRP, RSRQ, RSSI and SINR
for n from=1 to=9 do={
set $j [find $cells "," $i]
# set $output ($output . [pick $cells ($i+1) $j] . "\t")
set ($cell->$n) [pick $cells ($i+1) $j]
set $i $j
}
set $sinr ([tostr ([tonum [pick $cells ($i+1) [find $cells "\r" $i]]] * 2 - 20)])
set $band ("B" . ([pick ($cell->4) 10 ([len ($cell->4)]-1)]) . " ")
# Prepare and display output
if ([find ($cell->1) "pcc"]=0) do={set $output "PCC"} else={set $output "SCC"}
set $output ($output . " " . ($cell->6) . "\tB" . ([pick $band 1 3]) . " " . \
($bandwidth->($cell->3)) . "M\t" . ($cell->2) . \
"\t" . ($cell->7) . "\t" . ($cell->8) . "\t" . ($cell->9) . "\t" . $sinr)
/terminal el; put $output
# Go to the next LTE cell
set $i [find $cells "QCAINFO" $i]
set $count ($count+1)
}
# Clear any extra lines from the previous run
/terminal el
for n from=($count+1) to=$pcount step=1 do={put ""; /terminal el}
for n from=($count+1) to=$pcount step=1 do={/terminal cuu}
# Check for any keystroke, then wait one second
/terminal el; put "-- [Q quit | D dump | P pause]"
set $key ([/terminal inkey timeout=1] & 223)
set $time [/system clock get time]
/terminal cuu;
# Keystroke D (68) = dump, P (80) = Pause, Q (81) = Quit
if ($key=68) do={/terminal el; set $count 0; put "-- $time\n"; $headings}
if ($key=80) do={/terminal el; put "-- Paused" ; /terminal inkey; /terminal cuu; }
} while (key!=81)
/terminal el
Neighbour Cell Monitor
Works much like the Router OS cell monitor, but refreshes the readings every second. It lacks the age column. It will display the full list of neighbouring cells even on V7.1rc1 and V7.1rc2.
Code:
# Print headings
local headings do={
/terminal style syntax-noterm
put "EARFCN\tPCI\tRSRQ\tRSRP\tRSSI"
/terminal style none
}
$headings
# Reset counters
set $count 0
set $pcount 0
# Loop until a keystroke
do {
# Reset cursor position and note previous line count
for n from=1 to=$count step=1 do={/terminal cuu}
set $pcount $count
set $count 0
# Get the list of neighbour cells from using the modem at-chat command
set $cells [pick [/interface lte at-chat lte1 input="at+qeng=\"NEIGHBOURCELL\"" as-value ] 0]
# Loop through each LTE cell
set $i [find $cells "LTE"]
while ($i>0) do={
set $output ""
set $i ($i+4)
# Retrieve the EARFCN, PCI, RSRQ, RSRP and RSSI, then print these
for n from=1 to=5 do={
set $j [find $cells "," $i]
set $output ($output . [pick $cells ($i+1) $j] . "\t")
set $i $j
}
/terminal el; put $output
# Go to the next LTE cell
set $i [find $cells "LTE" $i]
set $count ($count+1)
}
# Clear any extra lines from the previous run
/terminal el
for n from=($count+1) to=$pcount step=1 do={put ""; /terminal el}
for n from=($count+1) to=$pcount step=1 do={/terminal cuu}
# Check for any keystroke, then wait one second
/terminal el; put "-- [Q quit | D dump | P pause]"
set $key ([/terminal inkey timeout=1] & 223)
set $time [/system clock get time]
/terminal cuu;
# Keystroke D (68) = dump, P (80) = Pause, Q (81) = Quit
if ($key=68) do={/terminal el; set $count 0; put "-- $time\n"; $headings}
if ($key=80) do={/terminal el; put "-- Paused" ; /terminal inkey; /terminal cuu; }
} while (key!=81)
/terminal el;
MIMO Layer Signal Readings
With an AT chat command, the modem can display the RSRP, RSRQ and SINR readings of each MIMO layer for the primary cell. This is particularly useful when checking or adjusting multiple antennas, such as with 4x4 MIMO when using the high frequency bands. In 2x2 MIMO, the 3rd and 4th layer will show -140 for the RSRP.
Code:
# Print headings
local headings do={
/terminal style syntax-noterm
put "MIMO\tL1\tL2\tL3\tL4"
/terminal style none
}
$headings
# Reset counters
set $count 0
set $pcount 0
# Loop until a keystroke
do {
# Reset cursor position
for n from=1 to=$count step=1 do={/terminal cuu}
set $count 3
# Get the RSRP, RSRQ and SINR readings using the modem at-chat command
set $rsrp [pick [/interface lte at-chat lte1 input="at+qrsrp" as-value ] 0]
set $rsrq [pick [/interface lte at-chat lte1 input="at+qrsrq" as-value ] 0]
set $sinr [pick [/interface lte at-chat lte1 input="at+qsinr" as-value ] 0]
set $i 7
set $output "RSRP\t"
for n from=1 to=4 do={
set $j [find $rsrp "," $i]
set $output ($output . [pick $rsrp ($i+1) $j] . "\t")
set $i $j
}
/terminal el; put $output
set $i 6
set $output "RSRQ\t"
for n from=1 to=3 do={
set $j [find $rsrq "," $i]
set $output ($output . [pick $rsrq ($i+1) $j] . "\t")
set $i $j
}
set $output ($output . [pick $rsrq ($i+1) [find $rsrq "\r" $i]])
/terminal el; put $output
set $i 6
set $output "SINR\t"
for n from=1 to=3 do={
set $j [find $sinr "," $i]
set $output ($output . ([tonum [pick $sinr ($i+1) $j]] * 2 - 20) . "\t")
set $i $j
}
set $output ($output . [([tonum [pick $sinr ($i+1) [find $sinr "\r" $i]]] * 2 - 20)])
/terminal el; put $output
# Check for any keystroke, then wait one second
/terminal el; put "-- [Q quit | D dump | P pause]"
set $key ([/terminal inkey timeout=1] & 223)
set $time [/system clock get time]
/terminal cuu;
# Keystroke D (68) = dump, P (80) = Pause, Q (81) = Quit
if ($key=68) do={/terminal el; set $count 0; put "-- $time\n"; $headings}
if ($key=80) do={/terminal el; put "-- Paused" ; /terminal inkey; /terminal cuu; }
} while (key!=81)
/terminal el;