Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MikroTik Chateau 5G experimental primary band lock script
#1
MikroTik's 4G based routers all have the ability to lock the primary band by specifying an EARFCN and PCI to lock to with an AT command.  This is the carrier/band the modem uses for uploading.  When the modem aggregates carriers across multiple bands, it generally uploads on the primary carrier band and receives only on the aggregated carriers.  For example, if the modem connects with band 20 as the primary band and bands 1 and 3 as the CA bands, it will receive data on all 3 bands simultaneously, but upload on band 20 only.   One exception is with upload carrier aggregation.

The band the modem chooses as the upload band can have a big impact on the upload speed.  For example, a 5MHz band only has 1/4 the upload capacity of a 20MHz band, assuming equal contention and signal strength/quality on both bands. 

When the user is a very long distance from the cell tower such as over 35km, the modem may not be able to synchronise with the upload carrier of high frequency bands over 1700MHz.  When this happens the modem gets stuck at the RACH stage trying to connect on band 1, 3, etc, but connects fine on the lower frequency bands such as 20 or 28.  While the modem can usually aggregate the higher frequency bands fine for additional download speed, the network may try handing the modem's primary band over to a high frequency band, causing the connection to cycle down/up.  In the case of 4G-only Qualcomm modems including the higher end 4G Snapdragon X24, they get stuck endlessly trying to connect on whichever high frequency band the network handed over to. 

With Quectel based MikroTik modems such as the LTE12 and LTE18 based models, the primary band can be locked by locking to a specified EARFCN and PCI using the following terminal command:

/interface lte at-chat lte1 input="at+qnwlock=\"common/4g\",1,EARFCN,PCI"

The list of bands and carriers (EARCN and PCI numbers) can be obtained by running the cell-monitor command:

/interface lte cell-monitor lte1

The cell lock lasts until the next power cycle, such as a reboot.  The cell lock can also be removed with the following command:

/interface lte at-chat lte1 input="at+qnwlock=\"common/4g\",0"

With the MikroTik Chateau 5G, the cell lock command not only locks the primary carrier, it also locks aggregated carriers.  If additional earfcn/carrier parameters are not specified, the modem will try locking the aggregated carriers on different EARFCNs to the same PCI number as the primary PCI number.  This can cause the modem to endlessly switch between aggregated carriers, severely degrading the download performance. 

Having experimented with varies ways of trying to lock the primary band on the MikroTik Chateau 5G, including a very buggy undocumented EARFCN lock AT command, the most effective method I found so far is by temporarily locking the modem to the single desired band whenever it switches primary band.  The AT command for locking bands does not cause the connection to drop, unlike changing the selection in the Winbox LTE configuration.  The following script automates this by monitoring the primary band twice a second and locking to the single desired band as soon as the primary band changes.  Once the modem is back on the desired primary band, it re-enables the rest of the bands to allow carrier aggregation again.

Code:
# Primary band to lock to
:local mainband 28
:local pinghost "8.8.8.8"

# Get current time stamp
:local ctime
if ([:len [timestamp]] = 23) do={:set ctime [:pick [timestamp] 5 13]} else={:set ctime [:pick [timestamp] 7 15]}

# Note the current selection of locked bands
set $ltebands [pick [/interface lte at-chat lte1 input="at+qnwprefcfg=\"lte_band\"" as-value] 0]
set $lockedbands [pick $ltebands ([find $ltebands ","] +1) [find $ltebands "\n"]]
set $wrongband 0

do {
  do {
    # Check the current primary band using the AT command "at+qcainfo".  Alternative AT command is "at+qnwinfo"
    set $qnwinfo [pick [/interface lte at-chat lte1 input="at+qcainfo" as-value] 0]
    set $i [find $qnwinfo "LTE BAND"]
    set $band [pick $qnwinfo ($i+9) ([find $qnwinfo "," $i] - 1)]

    # If the current primary band is correct after forcing a band change then enable the other locked bands for CA
    if ($mainband=$band) do={
      if (wrongband=1) do={
        if ([ping $pinghost count=1 as-value]->"time"!=nul) do={
          interface/lte/at-chat lte1 input="at+qnwprefcfg=\"lte_band\",$lockedbands"
          set $wrongband 0 
        }
      }
      if (wrongband>1) do={ set $wrongband 0 }     
    } else={
      if (wrongband!=1) do={
        if (band>0 && wrongband<3) do={
          # If the primary band has changed then log the wrong band
          :log info "Modem switched to band $band at $ctime"
          set $ltebands [pick [/interface lte at-chat lte1 input="at+qnwprefcfg=\"lte_band\"" as-value] 0]
          set $lockedbands [pick $ltebands ([find $ltebands ","] +1) [find $ltebands "\n"]]
          delay 0.1

          # Check if the current primary band is in the locked band selection
          if ([find $ltebands ",$mainband"] > 0 || [find $ltebands ":$mainband"] > 0) do={
            # Lock the modem to the specified single band to force it onto this band
            interface/lte/at-chat lte1 input="at+qnwprefcfg=\"lte_band\",$mainband"
            set $wrongband 1
          } else={
            :log info "Band $mainband not in locked band list $lockedbands"
            set $wrongband 3
          }
        } else={
          # If the primary band is not available then log the connection as dropped
          if (wrongband<2) do={
            :log info "Modem LTE drop at $ctime"
            set $wrongband 2
          }
        }
      }     
    }
  } on-error={
    :log info "LTE at-chat error at $ctime"
    set $wrongband 2
  }
  delay 0.5
  if ([:len [timestamp]] = 23) do={:set ctime [:pick [timestamp] 5 13]} else={:set ctime [:pick [timestamp] 7 15]}
} while=(wrongband<4);

Change the '28' at the top of the script to the desired primary band.

Note: Disable the 2G and 3G Network Modes (if available) before running the script. 

How to add a script
  1. In Winbox, go into System -> Scripts.
  2. Click the '+' icon.
  3. In the "Name:" field, give it a name like "bandlock".
  4. Copy and paste the script in the white area below, then click 'OK'.

To run the script: Go into Winbox -> System -> Scripts, select the band lock script and click the "Run Script" button. 

Top stop the script: Go into the Winbox -> System -> Scripts -> Jobs tab, select the band lock script and click the red '-' button in the toolbar.

When the script is running, check the Log section.  If there is a continuous list of "Modem switched to band xx...", then the network does not allow using this primary band with carrier aggregation.  Many networks also don't tolerate locking to a low frequency primary band when aggregating with high frequency bands.  This is particularly the case with the Eir network here in Ireland.
Reply
#2
Thanks for this. I have a Zyxcel 5103E and recently bought a used Chateau 5G. It has very advanced features of which some are over my head. They both were pretty much similar in terms of speed but WiFi is better with the Zyxel due to WiFi 6. Any way just yesterday I was able to lock bands, I selected B20 and N78 with the Zyxel that gave me just over 100Mbps in download speeds.

Can I select band N78 with the script?
Reply
#3
This script is just for locking the primary 4G upload band. When the router aggregates multiple bands, e.g. 1+3+20, it will generally use just one band for uploading, which could in this case could be 1, 3 or 20. This script tries to lock the primary upload band to the selected band. For example, if band 3 gives the fastest upload speeds, this script can try to keep the primary band on band 3, while still letting it aggregate bands 1 and 20 for downloading.

For general band 4G and 5G locking (like the band locking on your Zyxel router), you can do this in Winbox -> Interfaces -> lte1 (double-click the line) -> General tab. In here, click the down arrow to the right of the LTE bands and 5G bands one or more times to select the bands to lock to. To remove a band lock, click the up arrow to the right of the locked band number.
Reply
#4
(20/09/2024, 06:07 PM)Seán Wrote: This script is just for locking the primary 4G upload band.  When the router aggregates multiple bands, e.g. 1+3+20, it will generally use just one band for uploading, which could in this case could be 1, 3 or 20.  This script tries to lock the primary upload band to the selected band.  For example, if band 3 gives the fastest upload speeds, this script can try to keep the primary band on band 3, while still letting it aggregate bands 1 and 20 for downloading.

For general band 4G and 5G locking (like the band locking on your Zyxel router), you can do this in Winbox -> Interfaces -> lte1 (double-click the line) -> General tab.  In here, click the down arrow to the right of the LTE bands and 5G bands one or more times to select the bands to lock to.  To remove a band lock, click the up arrow to the right of the locked band number.

Oh so I don't need to use the script for 5g band as it's already available? Can't check right now is the kids are using the internet.
Reply
#5
(20/09/2024, 07:17 PM)benparker Wrote: Oh so I don't need to use the script for 5g band as it's already available? Can't check right now is the kids are using the internet.


Lock the band via menu in interfaces / lte. For instance I have B1/B3/B28 locked for 4G. I don't have the problem that motivated Sean to create the script, i.e. my B3 signal strength is good enough to be the primary band for both U/D channels, but I've noticed the modem some times favour the congested B20 as primary, that's why I have the 1/3/28 bands only in 4G. 

If you want to lock the 5G to only N78 the select it in the 5G section. Make sure the signal strength is good enough otherwise you won't benefit from 5G.
In my case N78 is too weak and I can only use B1 (n1) 5G NSA. 

[Image: Screenshot-2024-09-21-at-10-26-02.png]
Reply
#6
So I just tried and it didn't improve the speed at all, can't even hit 300Mbps but the Zyxel is doing 400+. Guess I'll sell it and stick to the Zyxel.
Reply
#7
I'd suggest just out of curiosity to connect via ethernet cat6 and re-run the speed tests, just to determine if the difference in performance is due to the 5G modem or the wifi
Reply
#8
Photo 
(20/09/2024, 06:07 PM)Seán Wrote: This script is just for locking the primary 4G upload band.  When the router aggregates multiple bands, e.g. 1+3+20, it will generally use just one band for uploading, which could in this case could be 1, 3 or 20.  This script tries to lock the primary upload band to the selected band.  For example, if band 3 gives the fastest upload speeds, this script can try to keep the primary band on band 3, while still letting it aggregate bands 1 and 20 for downloading.

For general band 4G and 5G locking (like the band locking on your Zyxel router), you can do this in Winbox -> Interfaces -> lte1 (double-click the line) -> General tab.  In here, click the down arrow to the right of the LTE bands and 5G bands one or more times to select the bands to lock to.  To remove a band lock, click the up arrow to the right of the locked band number.

Hello!

Is it possible to lock UL CA Band (earfcn,pci) with a script to the same as Primary Band on a Mikrotik Chateau?

   
Reply
#9
You can try specifying the two earfcn / pci carriers with the modem's cell lock command:

/interface lte at-chat lte1 input="at+qnwlock=\"common/4g\",2,1300,32,1471,32"

If this works, check what CA bands it aggregates. With the Three network here in Ireland, it will not aggregate additional download carriers unless I specify them also in that AT command, in which case there is no way to control which two it uses for the primary and upload bands.

If you mainly want to avoid it using band 28 as either upload band, I suggest using the LTE band selection in the Winbox LTE configuration and select just bands 3 and 7. As band 28 is a low frequency band with wider indoor coverage, it usually has the highest congestion, so leaving it out should have little effect on your download speed and prevent it being used as an upload band.
Reply
#10
Hi!

I have a problem with 5G NSA dropping the connection every now and then but not 4G.
There are 2 different n28 cells on two different towers near me.
I imagine the disconnections are due to my modem moving between the 2 towers.
I wrote to the Mikrotik chatbot "Dude" and got following answer right away.


Hi there! ? How can I help you? I'm a new chatbot and I might not answer all questions perfectly. My knowledge is based on the MikroTik documentation, which you can read here to get more in-depth knowledge.

Hi! I own a 5G R16 modem and i need a script to lock n28 on a specific cell.

To lock your 5G R16 modem to a specific cell on band n28, you can use the following script. Make sure to replace <freq> and <pci> with the specific frequency and Physical Cell ID (PCI) of the cell you want to lock to.

Copy code
/interface lte set lte1 modem-init="AT+QNWLOCK=\"common/5g\",1,[[<freq>,<pci>]]"
For example, if the frequency is 123456 and the PCI is 789, the command would look like this:

Copy code
/interface lte set lte1 modem-init="AT+QNWLOCK=\"common/5g\",1,[[123456,789]]"
Make sure the modem is in a non-operating state before applying this command. You can do this by disabling the LTE interface, applying the command, and then re-enabling the LTE interface.

If you need further assistance, please refer to our documentation or open a support ticket at our support portal.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)