Thread Rating:
  • 0 Vote(s) - 0 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


Forum Jump:


Users browsing this thread: 1 Guest(s)