Community discussions

MikroTik App
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Automatically Change Frequencies To Compensate for Weather

Tue May 05, 2009 12:14 pm

Somewhere in the Pacific Ocean, near the world's best shortcut, lies an island some 20 miles offshore.
This island now has a fast PtP 5 GHz wireless connection, thanks to some routerboards and other accessories.

While the connection works well most of the time, unfortunately there is a problem.
The tide in Pacific varies by 18 feet and this creates havoc with the link.
Regardless of the frequency used, the connection will go offline (because of reflections and destructive interference) for some period of time every day.
However, with each different frequency, the water height at which the link will go offline is different.

For example, at 3 PM I might have -90 dB on 5200 MHz and -75 dB on 5800 MHz. A few hours later, I have -92 dB on 5800 MHz and -73 dB on 5200 MHz.

If I could dynamically switch between the two frequencies, I could achieve nearly 100% uptime (except for the 1-2 seconds it takes for the station to reconnect).

I would like to have a script that takes a TX signal reading, from the AP side, every 30 seconds. If the average over 4 readings is -85 dB or worse, I want it to switch to the other channel. I just need it to move between the two channels.

If someone could post the code for this, it would be great.
I'll be happy to PayPal you $30 for your time.

Please, no comments suggesting I use bigger antennas. If that is your suggestion then you don't understand the problem.
Last edited by RK on Fri May 08, 2009 1:04 pm, edited 1 time in total.
 
User avatar
roc-noc.com
Forum Veteran
Forum Veteran
Posts: 869
Joined: Sun Dec 02, 2007 3:27 am
Location: Rockford, IL USA
Contact:

Re: Automatically Change Frequencies To Compensate for Weather

Tue May 05, 2009 5:13 pm

Strange that the tide level affects those frequencies differently.

Are you running horizontal polarity? What antennas are you using? How high are they above MSL?

Tom
-----------------------------------------------
http://www.roc-noc.com
Tom, CCNA, ISP, USA Mikrotik Distributor
888-762-5662
-----------------------------------------------
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Tue May 05, 2009 10:39 pm

Strange that the tide level affects those frequencies differently.

Are you running horizontal polarity? What antennas are you using? How high are they above MSL?

Tom
I don't think it's strange. It makes perfect sense.

It's VPOL (HPOL was worse), 24dBi on one side and 28dBi on the other, around 150m and 30m.
 
InoX
Forum Guru
Forum Guru
Posts: 1969
Joined: Tue Jan 09, 2007 6:44 pm

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 06, 2009 1:52 am

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 06, 2009 6:40 am

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
Getting a small script is much much simpler, and cheaper, than installing two huge dishes.
Your suggestion is illogical.
 
changeip
Forum Guru
Forum Guru
Posts: 3810
Joined: Fri May 28, 2004 5:22 pm

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 06, 2009 6:44 am

isnt DFS supposed to help with this? it will automatically pick the right frequency if the link goes down? Not sure, but worth looking into.
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 06, 2009 10:38 am

isnt DFS supposed to help with this? it will automatically pick the right frequency if the link goes down? Not sure, but worth looking into.
DFS picks the least busy frequency but it only does it once. It does not re-pick when the link goes down.
Also, some of the frequencies which are not busy on one end, are VERY busy on the other end so the frequency it picks often does not work at all.
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 06, 2009 11:24 am

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
Getting a small script is much much simpler, and cheaper, than installing two huge dishes.
Your suggestion is illogical.
Actually, his suggestion is appriopriate. When you establish a link you have to provide enough signal strength to cover such changes in propagation. Even if conditions are better, -72dBm is low signal. It should be stronger anyways.
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Thu May 07, 2009 11:58 pm

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
Getting a small script is much much simpler, and cheaper, than installing two huge dishes.
Your suggestion is illogical.
Actually, his suggestion is appriopriate. When you establish a link you have to provide enough signal strength to cover such changes in propagation. Even if conditions are better, -72dBm is low signal. It should be stronger anyways.
The R5H connects at 54 Mbps at -72dB. That is neither low nor slow.
Why should it be stronger? Just to waste time, effort, money, and spectrum?
 
User avatar
bellis
newbie
Posts: 49
Joined: Wed Nov 05, 2008 1:15 am
Location: Woodland, WA
Contact:

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 12:38 am

unfortunately off the top of my head i cant think of a way to script frequency changes off signal strength, but if it truely based off of the tides, a little research of tide tables and you could simply set scripts to change frequency at given times. also you could create a script that if signal is worse than -xx dBi then change to 5xxx GHz, which would create a "search" for a frequency that gave it a signal that was acceptable.
"If it ain't broke, you're not tryin"
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 6:35 am

unfortunately off the top of my head i cant think of a way to script frequency changes off signal strength
Why not?
Surely scripts can check the signal strengths and change frequencies, right?
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 10:14 am

The R5H connects at 54 Mbps at -72dB. That is neither low nor slow.
Why should it be stronger? Just to waste time, effort, money, and spectrum?
Because you have to provide at least 22dB SNR and usually about 10 dB more to cover for propagation changes.

Less signal means problems, like what you have.
 
InoX
Forum Guru
Forum Guru
Posts: 1969
Joined: Tue Jan 09, 2007 6:44 pm

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 11:53 am

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
Getting a small script is much much simpler, and cheaper, than installing two huge dishes.
Your suggestion is illogical.
then I wish you a happy long struggle with your logic.
-72 is just too low to be reliable on that distance.
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 12:58 pm

use biger antennas. For a reliable link you need at least -65. Use XR5 also.
Getting a small script is much much simpler, and cheaper, than installing two huge dishes.
Your suggestion is illogical.
then I wish you a happy long struggle with your logic.
-72 is just too low to be reliable on that distance.
Are you just trolling? Or are you really clueless?
We have 20+ links, of more than 15 miles, with 100% uptime and signal in the -70s.
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 1:02 pm

The R5H connects at 54 Mbps at -72dB. That is neither low nor slow.
Why should it be stronger? Just to waste time, effort, money, and spectrum?
Because you have to provide at least 22dB SNR and usually about 10 dB more to cover for propagation changes.

Less signal means problems, like what you have.
-72 does provide for better than 22dB SNR. Where are you getting the 22dB SNR from anyway? We have links which work excellent with much lower SNR.
 
User avatar
bellis
newbie
Posts: 49
Joined: Wed Nov 05, 2008 1:15 am
Location: Woodland, WA
Contact:

Re: Automatically Change Frequencies To Compensate for Weather

Fri May 08, 2009 8:42 pm

unfortunately off the top of my head i cant think of a way to script frequency changes off signal strength
Why not?
Surely scripts can check the signal strengths and change frequencies, right?

it is certainly doable, many people have used similar scripts for alignment scripts and whatnot... just search for one and modify the signal levels and the "do" portion of the command.

p.s. - "can't think of a way off the top of my head" = i don't have it memorized and it is late and i need to go to bed

i agree with those that say you should have a better signal, however signal quality is more dependent upon snr that straight levels... i.e. a -50dBi signal is great, but if noise floor is at -55 dBi then it's crap. transversely if signal is at -70dBi, and noise floor is at -95dBi, you are in much better shape. As you are well aware it is all about the "bigger picture". there are way too many components to have a good connection to be able to say it wont work based on 1 "bad" aspect. there is almost always a way to compensate, many times without having to buy expensive and huge equipment.

keep on track with what you are doing, it certainly isn't a simple fix, but it *can* be done
"If it ain't broke, you're not tryin"
 
InoX
Forum Guru
Forum Guru
Posts: 1969
Joined: Tue Jan 09, 2007 6:44 pm

Re: Automatically Change Frequencies To Compensate for Weather

Sat May 09, 2009 12:31 am

let us know when you make a script that will make your link work all the time...for me is easier to install a bigger antenna.
 
changeip
Forum Guru
Forum Guru
Posts: 3810
Joined: Fri May 28, 2004 5:22 pm

Re: Automatically Change Frequencies To Compensate for Weather

Sat May 09, 2009 1:37 am

RK - a bunch of people chiming in and not giving you what you need : ) I will try to help.

You mention the TX value from the AP... Which value exactly do you want to monitor and decide upon?

[@cip-home] /interface wireless registration-table> :put [get 0 signal-strength ]
-74dBm@1Mbps

that one above?

So if the reading above averages > -85db then change the AP frequency ?

Sam
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 138
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 13, 2009 5:15 am

RK,

I have created a script to meet your exact specifications (well I had to add a few specs that were critical, but not considered). Please contact me via AIM (see profile) if you would like to proceed.

The script features the following:
Global variables to set desired minimum dBm (default=-85) as well as minimum SNR (default=12), interface name (in case you have more than 1 wireless interface in the AP, default=wlan1), the two frequencies (default=5200,5800), a check delay in seconds (checking 4 times as fast as possible rarely produces different numbers, so I put a short delay between each of the 4 values to be averaged, default=5), the number of checks to average together (default=4) and the ability to choose whether you are swapping based on dBm (default), SNR, or either. Finally, it logs all frequency swaps as script info, showing the frequency it changed to as well as why (no clients or it lists the average dBm and SNR values).

It will swap frequencies if NO clients are registered (in other words, signal so poor they dropped) as well as if they are registered but do not meet the qualifications you specified in the variables.

You will be able to get it to execute as often as you like using the System Scheduler, and while you can choose 30 seconds if you like, I would recommend something more like 1 minute as a minimum and 5 minutes preferred. Bringing the link back up within 5 minutes is still a might better than having to keep an eye on it. Plus, with a longer time between execution, you may wish to increase the number of samples in the average or extend the delay between samples.

Besides the variable definitions and easy to read formatting, it's just a lean 12 lines of code for fast execution and low cpu overhead.

-John
Last edited by jgellis on Wed May 13, 2009 6:04 am, edited 1 time in total.
- If I helped you solve your problem... I am now able to accept tax-deductible Karma donations!
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 138
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 13, 2009 5:59 am

RK,

It was great chatting with you and I hope you enjoy the script. It was thoughtful of you to pay for the work and then let the community benefit from it freely.

If you or anyone else should have a need for advanced MT scripting and design, please do not hesitate to call on me!

-John

INSTALLATION INSTRUCTIONS:
While I love the cmd line for everything else, scripting is not in that category.
Within Winbox...
  • Add a New Schedule under System>Scheduler (alternately, you could add this as a System>Script and just call it from the scheduler with '/sys scr run scriptname' as your scheduler event)
  • Name it as you wish, set your Start Time as startup from the dropdown
  • Set you interval as you wish (I recommend no less than 1 minute, but prefer 5 minutes to allow clients to register successfully and signals to settle)
  • Paste the code below into the "On Event" box
  • Edit only the last word of the first 8 lines, leave everything else as is.
    • wlanname is the name of the wireless interface to affect
    • dbm0snr1either2 means: monitor dbm only=0, snr only=1, either=2
    • mindbm and minsnr are the minimum numbers you will accept
    • freq1 and freq2 are the frequencies to toggle between (make sure they are in the correct band for your interface and country)
    • checkdelay is the number of seconds between samples
    • samplescount is the number of samples to average together during each run
:local wlanname wlan1
:local dbm0snr1either2 0
:local mindbm -85
:local minsnr 12
:local freq1 5200
:local freq2 5800
:local checkdelay 5
:local samplescount 4

:global newfreq 0
:global avgdbm 0
:global avgsnr 0
:if ([/int wir get [find name=$wlanname] frequency]=$freq1) do={
  :global newfreq $freq2
  } else={
  :global newfreq $freq1
  }
:if (![/int wir get [find name=$wlanname] running]) do={
    /int wir set [find name=$wlanname] frequency=$newfreq; :log info "Switching to $newfreq MHz due to no clients registered."
    } else={
    :for i from=1 to=$samplescount do={
      :set avgdbm ($avgdbm+[:pick [/int wir reg get [find interface=$wlanname] signal-strength] 0 ([:find [/int wir reg get [find interface=$wlanname] signal-strength] @]-3)])
      :set avgsnr ($avgsnr+[/int wir reg get [find interface=$wlanname] signal-to-noise])
      :delay $checkdelay
      }
    :set avgdbm ($avgdbm/$samplescount)
    :set avgsnr ($avgsnr/$samplescount)
    :if ((avgdbm<=mindbm && (dbm0snr1either2=0 || dbm0snr1either2=2)) || (avgsnr<=minsnr && (dbm0snr1either2=1 || dbm0snr1either2=2))) do={
      /int wir set [find name=$wlanname] frequency=$newfreq; :log info "Switching to $newfreq MHz due to dBm average of $avgdbm and SNR average of $avgsnr over the last $samplescount samples."
      }
    }
- If I helped you solve your problem... I am now able to accept tax-deductible Karma donations!
 
complete2006
Member Candidate
Member Candidate
Posts: 235
Joined: Tue Feb 07, 2006 7:18 pm

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 13, 2009 7:28 pm

Nice.
Extending the script for setting tx-power and watching the remote-rx with an option to set the power without reconnect we will have a simple atpc.
Is there a way to set tx-power without loosing the connection?
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 138
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: Automatically Change Frequencies To Compensate for Weather

Wed May 13, 2009 7:41 pm

Is there a way to set tx-power without loosing the connection?
Unfortunately, no. Any changes to tx-power (from either end) cause the wireless interface to stop and restart, resulting in a reconnect by the clients. Luckily, the reconnect only takes a split second.
- If I helped you solve your problem... I am now able to accept tax-deductible Karma donations!
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Thu Jul 30, 2009 12:36 pm

For those considering trying the same thing, I have been using wanned's script since early May and my system has been running great.
Uptime is better than 99% on any given day.

Here are the settings I use:

:local dbm0snr1either2 0
:local mindbm -87
:local minsnr 12
:local freq1 5620
:local freq2 5660
:local checkdelay 4
:local samplescount 5

As I expected, it turned out to be much easier and cheaper than installing bigger antennas as some suggested.
 
cdiggity
newbie
Posts: 31
Joined: Fri Oct 31, 2008 12:40 pm

Re: Automatically Change Frequencies To Compensate for Weather

Fri Dec 04, 2009 5:49 am

You only change the frequency from 5620 to 5660 and that makes enough difference to solve your ducting/over water wierdness issues?
 
RK
Long time Member
Long time Member
Topic Author
Posts: 560
Joined: Tue Nov 21, 2006 11:22 am
Location: Winnipeg, Canada and Central America

Re: Automatically Change Frequencies To Compensate for Weather

Sat Dec 05, 2009 10:19 pm

You only change the frequency from 5620 to 5660 and that makes enough difference to solve your ducting/over water wierdness issues?
I don't think it's a ducting issue. I think it's a tide/reflection issue in my case, and, yes, it works.
 
ManUtd
newbie
Posts: 30
Joined: Sun Sep 16, 2007 10:24 pm

Re: Automatically Change Frequencies To Compensate for Weath

Thu May 19, 2011 10:30 pm

RK,

It was great chatting with you and I hope you enjoy the script. It was thoughtful of you to pay for the work and then let the community benefit from it freely.

If you or anyone else should have a need for advanced MT scripting and design, please do not hesitate to call on me!

-John

INSTALLATION INSTRUCTIONS:
While I love the cmd line for everything else, scripting is not in that category.
Within Winbox...
  • Add a New Schedule under System>Scheduler (alternately, you could add this as a System>Script and just call it from the scheduler with '/sys scr run scriptname' as your scheduler event)
  • Name it as you wish, set your Start Time as startup from the dropdown
  • Set you interval as you wish (I recommend no less than 1 minute, but prefer 5 minutes to allow clients to register successfully and signals to settle)
  • Paste the code below into the "On Event" box
  • Edit only the last word of the first 8 lines, leave everything else as is.
    • wlanname is the name of the wireless interface to affect
    • dbm0snr1either2 means: monitor dbm only=0, snr only=1, either=2
    • mindbm and minsnr are the minimum numbers you will accept
    • freq1 and freq2 are the frequencies to toggle between (make sure they are in the correct band for your interface and country)
    • checkdelay is the number of seconds between samples
    • samplescount is the number of samples to average together during each run
:local wlanname wlan1
:local dbm0snr1either2 0
:local mindbm -85
:local minsnr 12
:local freq1 5200
:local freq2 5800
:local checkdelay 5
:local samplescount 4

:global newfreq 0
:global avgdbm 0
:global avgsnr 0
:if ([/int wir get [find name=$wlanname] frequency]=$freq1) do={
  :global newfreq $freq2
  } else={
  :global newfreq $freq1
  }
:if (![/int wir get [find name=$wlanname] running]) do={
    /int wir set [find name=$wlanname] frequency=$newfreq; :log info "Switching to $newfreq MHz due to no clients registered."
    } else={
    :for i from=1 to=$samplescount do={
      :set avgdbm ($avgdbm+[:pick [/int wir reg get [find interface=$wlanname] signal-strength] 0 ([:find [/int wir reg get [find interface=$wlanname] signal-strength] @]-3)])
      :set avgsnr ($avgsnr+[/int wir reg get [find interface=$wlanname] signal-to-noise])
      :delay $checkdelay
      }
    :set avgdbm ($avgdbm/$samplescount)
    :set avgsnr ($avgsnr/$samplescount)
    :if ((avgdbm<=mindbm && (dbm0snr1either2=0 || dbm0snr1either2=2)) || (avgsnr<=minsnr && (dbm0snr1either2=1 || dbm0snr1either2=2))) do={
      /int wir set [find name=$wlanname] frequency=$newfreq; :log info "Switching to $newfreq MHz due to dBm average of $avgdbm and SNR average of $avgsnr over the last $samplescount samples."
      }
    }

This script don't working on ROS 5.x, any modifications to get it work ?
 
pilotnz
just joined
Posts: 5
Joined: Thu Jul 15, 2010 6:07 am

Re: Automatically Change Frequencies To Compensate for Weath

Wed Nov 28, 2012 3:00 am

ManUtd,

Likewise, I could not make this script work (using ROS 5.22).
I spent a long time with this script, trying to get it to work.
Finally I found line 22 contained an error, OR old code / syntax that now no longer works.
      :set avgdbm ($avgdbm+[:pick [/int wir reg get [find interface=$wlanname] signal-strength] 0 ([:find [/int wir reg get [find interface=$wlanname] signal-strength] @]-3)]) 
The "@" symbol does not seem to belong (there's no reference to it in the scripting manual) - what is it's purpose?
Also, the "-3" at the end of the line does not make sense.

With the following changes to this line, it works really well:
      :set avgdbm ($avgdbm+[:pick [/int wir reg get [find interface=$wlanname] signal-strength] 0 ([:find [/int wir reg get [find interface=$wlanname] signal-strength]]3)]) 
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 138
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: Automatically Change Frequencies To Compensate for Weath

Wed Nov 28, 2012 3:40 am

There is absolutely nothing wrong with that line, at least up through version 5.14. If you understood the scripting :pick and :find commands, you would realize that should not be removed.

The :pick command is taking a sub string from the signal strength result which looks like "-61dBm@54Mbps"
0 is the beginning of the string
The pick command will take the number of characters from that string equal to the numerical location of the "@" symbol minus 3 characters, resulting in a value of just -61 in our example.

I just copied and pasted the following into a cmdlin on version 5.14 and saw the expected result:
:put [:pick [/int wir reg get [find interface=wlan1] signal-strength] 0 ([:find [/int wir reg get [find interface=wlan1] signal-strength] @] -3)]
What "works really well" now is not what was intended and will have very undesirable results.

Your modifications actually break the :find command and result in a static :pick from 0 to 3. That appears to work correctly, unless you get a signal-strength below -99, in which case your modification will falsely report only the first two digits (i.e. -10 instead of -101). In cases of weak signal sensing, this is critical not to misread those values. If you have forced clients into a signal strength range that absolutely rules out the possibility of -100 or worse signals, then feel free to shorten that line further as follows:
:set avgdbm ($avgdbm+[:pick [/int wir reg get [find interface=$wlanname] signal-strength] 0 3)])
- If I helped you solve your problem... I am now able to accept tax-deductible Karma donations!

Who is online

Users browsing this forum: No registered users and 30 guests