What's new

[Script] 160mhz channel recovery for wifi 6 only routers

Update:

- Auto-Detects 5ghz Interface if not manually configured
- Added: Strict_Sticky variable, which will attempt to stay on the preferred channel (Normally it only attempts this if outside of the channel range)
- Reads 5ghz nvram setting from GUI to determine user configuration (Reducing any manual configuration)
- If GUI is configured for a specific channel (e.g. 100/160), then fallback will be disabled and "Strict_Sticky" mode will be enforced.
- If GUI is configured for auto, script operates normally how I originally intended with fallback usage
 

Attachments

This is for both dual-band & tri-band routers. Tri-band logic is UNTESTED (I don't have a tri-band router)

- Auto-detects tri-band or dual-band mode
---If both IFACES left empty, it will auto-detect mode
---If IFACE1 is configured only, dual-band is assumed
---if IFACE1 & IFACE2 is configured, tri-band is assumed
- Tri-band mode, it will configure first ETH to be 36/160 and second to be 100/160
---Tri-band mode, STRICK_STICKY can be configured, preferably it should be off
---Preferred Channel & Disable_fallback are ignored in Tri-band mode

I think that's everything. Works just like fix_160A. Originally I wasn't going to attempt a tri-band router version because of the various models and how their interfaces don't follow a standard scheme. But my method of auto detection doesn't care about that. It gets all interfaces with "nvram get sta_phy_ifnames". And assumes any interface with a channel between 36-165 is the 5ghz interface. Only thing that may be a problem is if AiMesh nodes will show up in "sta_phy_ifnames". I don't have a mesh setup so i wouldn't know. But this script wouldn't be good for an AiMesh setup anyways because of the channel overlap problem.

Hopefully it works. If it doesn't then I probably won't be able to make it work since I don't have a tri-band router to troubleshoot with.

Edit: Minor change with "sta_phy_ifnames" usage. Better suited for it would be "wl_ifnames". As this only shows the interfaces and not potentially any nodes from a mesh. I overlooked it because it looked quite similar to "wl1_ifname" which is a key for an individual interface and got them mixed up. Also made a change to determine filename automatically for the script to use.

Made the same changes to fix_160A in the post before this.
 

Attachments

Last edited:
Some changes I've made.

- Changed CAC status processing to polling rather than a fixed time to handle different regions automatically.
- Added a menu
- Added script arguments for "install, uninstall, menu, exec"

Some things I'm considering.

- Guard to check if connected clients are 160mhz capable. It would prevent unnecessary channel upgrades/movement minimizing CAC checks.
- Is it still advantageous for 80mhz clients if router is broadcasting at 160mhz?
- Naming it hindsight160 as my final release
- What's the ideal default state when GUI is set to "Auto", should fallback be enabled or disabled?

Overall goal is to have default config for "Auto" that minimizes unnecessary disconnects. Any channel movement increases chances of disconnects. Upgrading in place doesn't result in disconnects. And I think I figured out why some clients disconnect and some clients don't. I believe it's their range because the change to 160mhz reduces it's capable range as the energy is more spread out. So they're more inclined to reconnect to the 2.4ghz band.

I think I got the script to a point where there is no configuration is required.

I'm waiting for feedback from anyone testing out my tri-band version before making any further updates.
 
Last edited:
Look on the label for FCCID and/or EU-RED numbers - that means they were tested and certified...

Perhaps you're smarter than the regulatory testers and software dev engineers at both Asus and Broadcom.

If that's the case, you're in the wrong job...

Just accept that this has been an eternal oversight on asus's part, and that you DO NOT KNOW EVERYTHING.

@soul4kills good work, i hope this ends up on amtm

You may need to take into account that region spec might dictate only a single 160mhz bonding range of 36-64, due to cutting up the 100+ range, this will result in an 80mhz only configuration for certain regions.

Australia, Canada, only has 6 of the bonding frequencies, 100-116, while 100-124 is needed to get 160mhz.
China and Russia don't have this range period.
You can account for this by testing nvram get wl1_country_code
 
Last edited:
Where is this last release ? Thanks ;)
Lol. It will come soon. Still trying to figure some stuff out.

Just accept that this has been an eternal oversight on asus's part, and that you DO NOT KNOW EVERYTHING.

@soul4kills good work, i hope this ends up on amtm

You may need to take into account that region spec might dictate only a single 160mhz bonding range of 36-64, due to cutting up the 100+ range, this will result in an 80mhz only configuration for certain regions.

Australia, Canada, only has 6 of the bonding frequencies, 100-116, while 100-124 is needed to get 160mhz.
China and Russia don't have this range period.
You can account for this by testing nvram get wl1_country_code

Thanks for the suggestion/feedback.

So I considered the scenario you're talking about but I don't think it's necessary. Mostly because i'm lazy and because it'll just add more complexity to the script for no gains. The reason why I say no gains is because in it's current form, it can already solve this issue if the user sets their 5ghz to a fixed channel. My assumption is that if a user is aware enough to use this script, they're aware enough to know there's not point in using auto in your scenario and it's more advantageous to them to use a fixed channel if 160mhz connection is what they want. But i'll include it in the scripts about/help dialog to direct users accordingly. Unless there is more to the scenario that i'm not seeing.
 
Update:

This is the dual-band + tri-band version. Since there are no complaints, I assume tri-band logic has been working fine.

- Changed CAC status processing to polling rather than a fixed time to handle different regions automatically.
- Accounted for another status from DFS.
-When a CAC is attempted on a channel that is in a NOP state, it gets out right "rejected".
-When a CAC is attempted on channel that uses a blocked channel for bonding, it will spin up the CAC but, then "aborts" as soon as it sees the adjacent channel in a NOP state.
- Added a menu to configure settings with an about/help page
- Added script arguments for "install, uninstall, menu, exec"
- Added guard to check clients for 160mhz capability before attempting a cac check
- Auto mode will utilize fallback and only jumps to preferred channel when necessary, unlike strick_sticky mode.

Edit: No configuration is required. It will read your 5ghz channel settings you set in the GUI. As pointed out in post #41 & #42

Hopefully this is my final update. Enjoy.

Edit: Updated the file. There was a bug with the log file, fixed it.

Edit 2: Updated the file again. Thanks @ColDen for helping me with the bugs. This time it's fixed I hope.
- Fixed an a function that didn't capture errors properly.
- Added an echo to show feedback when the script runs successfully.
 

Attachments

Last edited:
Update:

This is the dual-band + tri-band version. Since there are no complaints, I assume tri-band logic has been working fine.

- Changed CAC status processing to polling rather than a fixed time to handle different regions automatically.
- Accounted for another status from DFS.
-When a CAC is attempted on a channel that is in a NOP state, it gets out right "rejected".
-When a CAC is attempted on channel that uses a blocked channel for bonding, it will spin up the CAC but, then "aborts" as soon as it sees the adjacent channel in a NOP state.
- Added a menu to configure settings with an about/help page
- Added script arguments for "install, uninstall, menu, exec"
- Added guard to check clients for 160mhz capability before attempting a cac check
- Auto mode will utilize fallback and only jumps to preferred channel when necessary, unlike strick_sticky mode.

Hopefully this is my final update. Enjoy.
Hi,

I have previously successfully run your fix_160A script:
1776009929405.png

1776010416669.png

But I am unable to successfully run your hindsight160 script (once run it stop at the last line of code and as-soon-as I click anything PuTTY crash):
1776010512804.png

Is there something I am doing wrong or shoud run your code differently?
 
Hi,

I have previously successfully run your fix_160A script:
View attachment 71184
View attachment 71185
But I am unable to successfully run your hindsight160 script (once run it stop at the last line of code and as-soon-as I click anything PuTTY crash):
View attachment 71186
Is there something I am doing wrong or shoud run your code differently?

I replaced the file in the most recent update post, it should work now. I forgot to add 2 guards when a log file didn't exist. Hopefully that's the only issue.
 
I replaced the file in the most recent update post, it should work now. I forgot to add 2 guards when a log file didn't exist. Hopefully that's the only issue.
Thanks for the quick reply but unfortunately still crashing at the end of the script once I hit any key.
 
I replaced the file in the most recent update post, it should work now. I forgot to add 2 guards when a log file didn't exist. Hopefully that's the only issue.
I just compared the file in post #47 with the one in post #1 and they are exactly the same (unfortunately I overwrited my previously downloaded copy with the one in post #47 and therefore cannot make a similar verification)... Are you sure that you did correctly uploaded the updated file in post #47?
 
Thanks for the quick reply but unfortunately still crashing at the end of the script once I hit any key.

How are
I just compared the file in post #47 with the one in post #1 and they are exactly the same (unfortunately I overwrited my previously downloaded copy with the one in post #47 and therefore cannot make a similar verification)... Are you sure that you did correctly uploaded the updated file in post #47?

I checked and it's the updated file. I usually access ssh through windows terminal. I downloaded putty and to test since you said that's what you're using. I downloaded the file from here as well. Deleted all the ones i have on my router. Added an echo to the "exec" which runs when you start the file directly. And it executed fine without problems.
Screenshot 2026-04-12 111713.png

Code:
finish() {
    if [ "$VERBOSE" -eq 0 ]; then
        exit 0
    fi

    if [ "$LOG_ROTATE_RAM" = "1" ]; then
        if [ -f "$LOG_FILE" ]; then
            local content
            content=$(tail -n $LOG_LINES "$LOG_FILE")
            echo "$content" > "$LOG_FILE"
        else
            : > "$LOG_FILE"
        fi
    else
        if [ -f "$LOG_FILE" ]; then
            tail -n $LOG_LINES "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
        else
            : > "$LOG_FILE"
        fi
    fi
    exit 0
}

This is the part that I changed. Does this function exist as shown here?

Are there any error messages?
 
How are


I checked and it's the updated file. I usually access ssh through windows terminal. I downloaded putty and to test since you said that's what you're using. I downloaded the file from here as well. Deleted all the ones i have on my router. Added an echo to the "exec" which runs when you start the file directly. And it executed fine without problems.
View attachment 71192
Code:
finish() {
    if [ "$VERBOSE" -eq 0 ]; then
        exit 0
    fi

    if [ "$LOG_ROTATE_RAM" = "1" ]; then
        if [ -f "$LOG_FILE" ]; then
            local content
            content=$(tail -n $LOG_LINES "$LOG_FILE")
            echo "$content" > "$LOG_FILE"
        else
            : > "$LOG_FILE"
        fi
    else
        if [ -f "$LOG_FILE" ]; then
            tail -n $LOG_LINES "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
        else
            : > "$LOG_FILE"
        fi
    fi
    exit 0
}

This is the part that I changed. Does this function exist as shown here?

Are there any error messages?
I don't have any error message, PuTTY simply crash as-soon-as I press a key when on-hold at the last line of the script. Please note that I simply copy then paste your script file once in PuTTY (like I did with your fix_160A script file).
 
I just compared the file in post #47 with the one in post #1 and they are exactly the same (unfortunately I overwrited my previously downloaded copy with the one in post #47 and therefore cannot make a similar verification)... Are you sure that you did correctly uploaded the updated file in post #47?
I think I figured it out.

Code:
is_160_active_or_capable() {
    local iface="$1" info

    info=$(wl -i "$iface" assoclist 2>/dev/null | grep -oE '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}' 2>/dev/null | xargs -r -I {} wl -i "$iface" sta_info {} 2>/dev/null) || return 1

    if echo "$info" | grep -qE "SGI160"; then
        log 3 "[$iface] 160MHz-capable client found"
        return 0
    fi

    log 1 "[$iface][SKIP] No 160MHz-capable clients associated."
    return 1
}

Can you replace this function in the script? In the old one, I didn't redirect the possible error messages. So that might be the issue. I think the problem is you don't have any clients connected when you're starting it, and it's crashing at this part?
 
I think I figured it out.

Code:
is_160_active_or_capable() {
    local iface="$1" info

    info=$(wl -i "$iface" assoclist 2>/dev/null | grep -oE '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}' 2>/dev/null | xargs -r -I {} wl -i "$iface" sta_info {} 2>/dev/null) || return 1

    if echo "$info" | grep -qE "SGI160"; then
        log 3 "[$iface] 160MHz-capable client found"
        return 0
    fi

    log 1 "[$iface][SKIP] No 160MHz-capable clients associated."
    return 1
}

Can you replace this function in the script? In the old one, I didn't redirect the possible error messages. So that might be the issue. I think the problem is you don't have any clients connected when you're starting it, and it's crashing at this part?
I placed the new instructions then copy the file (using WinSPC) this time:
1776020333327.png

Then proceed similarly like you this time:
1776020386180.png

But did not get any messages (after having change the permission). Please note that I am not an expert but think of my self as good (for a 72 years guy).
 
Lol, sorry, you have to change it in the file. Then run it.

Edit: I forgot I added a menu you can do "./hindsight160.sh menu" and you can change it in there.
Will have to do this tomorrow, my wife just told me that our guests have just arrive. Thanks
 
Will have to do this tomorrow, my wife just told me that our guests have just arrive. Thanks
No worries, thank you for helping me iron out the bugs. I'm certain it should be working now since you didn't get the same pause at the end of the file like the first time. Fingers crossed.

I updated the file in the update post of #47.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top