Davidc502- wrt1200ac wrt1900acx wrt3200acm wrt32x builds

Hello im using this script:

#!/bin/sh

## "atm" for old-school DSL or change to "DOCSIS" for cable modem, or
## "other" or anything else, for everything else

LINKTYPE="ethernet"

WAN=eth1.100 # change this to your WAN device name
UPRATE=85000 #change this to your kbps upload speed
LAN=eth0.1
DOWNRATE=185000 #change this to about 80% of your download speed (in kbps)
OH=37 # number of bytes of Overhead on your line (37 is reasonable
      # starting point, better to be too big than too small) probably
      # likely values are between 20 and 50

PFIFOMIN=5 ## minimum number of packets in pfifo, 4 to 10 is good guess
PACKETSIZE=350 # bytes per game packet avg (guess, 250 to 500 is likely) 
MAXDEL=25 # ms we try to keep max delay below for game packets after
	  # burst 10-25 is good 1 clock tick at 64Hz is ~16ms

BWMAXRATIO=20 ## prevent ack floods by limiting download to at most
	      ## upload times this amount... ratio somewhere between
	      ## 10 and 20 probably optimal. we down-prioritize
	      ## certain ACKs to reduce the chance of a flood as well.

if [ $((DOWNRATE > UPRATE*BWMAXRATIO)) -eq 1 ]; then
    echo "We limit the downrate to at most $BWMAXRATIO times the upstream rate to ensure no upstream ACK floods occur which can cause game packet drops"
    DOWNRATE=$((BWMAXRATIO*UPRATE))
fi

## how many kbps of UDP upload and download do you need for your games
## across all gaming machines? 

## you can tune these yourself, but a good starting point is this
## formula.  this script will not work for UPRATE less than about
## 600kbps or downrate less than about 1000kbps

GAMEUP=$((UPRATE*15/100+400))
GAMEDOWN=$((DOWNRATE*15/100+400))

## you can try setting GAMEUP and GAMEDOWN manually, some report this
## works well for CoD
#GAMEUP=400
#GAMEDOWN=800


DSCPSCRIPT="/etc/dscptag.sh"

if [ ! -f $DSCPSCRIPT ]; then
    workdir=$(pwd)
    echo "You do not have the DSCP tagging script, downloading from github"
    cd /etc/
    wget https://raw.githubusercontent.com/dlakelan/routerperf/master/dscptag.sh
    cd $workdir
fi



## Right now there are four possible leaf qdiscs: pfifo, red,
## fq_codel, or netem. If you use netem it's so you can intentionally
## add delay to your packets, set netemdelayms to the number of ms you
## want to add each direction. Our default is pfifo it is reported to
## be the best for use in the realtime queue

gameqdisc="fq_codel"

#gameqdisc="netem"

#netemdelayms="1"
#netemjitterms="7"
#netemdist="normal"


if [ $gameqdisc != "fq_codel" -a $gameqdisc != "red" -a $gameqdisc != "pfifo" -a $gameqdisc != "netem" ]; then
    echo "Other qdiscs are not tested and do not work on OpenWrt yet anyway, reverting to red"
    gameqdisc="red"
fi

## set up your ipsets here:

## get rid of any references to the ipsets
iptables -t mangle -F dscptag > /dev/null 2>&1


for set in realtimeset4 lowprioset4  ; do
    ipset destroy $set > /dev/null 2>&1
    ipset create $set hash:ip > /dev/null 2>&1
    ipset flush $set > /dev/null 2>&1
done

for set in realtimeset6 lowprioset6  ; do
    ipset destroy $set > /dev/null 2>&1
    ipset create $set hash:ip family inet6 > /dev/null 2>&1
    ipset flush $set > /dev/null 2>&1
done

## some examples to add your gaming devices to the realtime sets,
## allows you to have more than one console etc. Just add your ips
## into the list of ips in the for loop

for ip4 in 192.168.1.150 192.168.1.151; do
    ipset add realtimeset4 "$ip4"
done

for ip6 in 2001:818:db20:9500::150 2001:818:db20:9500::151 ; do
    ipset add realtimeset6 "$ip6"
done


### add ips of "low priority" machines, examples might include things
### that interfere with more important stuff, like gaming ;-). For
### example 4k TVs will typically buffer big chunks of data which can
### cause gaming stuttering but because they have buffers they don't
### really need super high priority



for ip4 in 192.168.1.198 192.168.1.197 192.168.1.199; do
    ipset add lowprioset4 "$ip4"
done

for ip6 in 2001:db8::1 2001:db8::2 ; do
    ipset add lowprioset6 "$ip6"
done




## Help the system prioritize your gaming by telling it what is bulk
## traffic ... define a list of udp and tcp ports used for bulk
## traffic such as torrents. By default we include the transmission
## torrent client default port 51413 and the default TCP ports for
## bittorrent. Use comma separated values or ranges A:B as shown. Set
## your torrent client to use a known port and include it here

UDPBULKPT="51413"
TCPBULKPT="51413,6881:6889"


WASHDSCPUP="yes"
WASHDSCPDOWN="yes"


######################### CUSTOMIZATIONS GO ABOVE THIS LINE ###########

cat <<EOF

This script prioritizes the UDP packets from / to a set of gaming
machines into a real-time HFSC queue with guaranteed total bandwidth 

Based on your settings:

Game upload guarantee = $GAMEUP kbps
Game download guarantee = $GAMEDOWN kbps

Download direction only works if you install this on a *wired* router
and there is a separate AP wired into your network, because otherwise
there are multiple parallel queues for traffic to leave your router
heading to the LAN.

Based on your link total bandwidth, the **minimum** amount of jitter
you should expect in your network is about:

UP = $(((1500*8)*3/UPRATE)) ms

DOWN = $(((1500*8)*3/DOWNRATE)) ms

In order to get lower minimum jitter you must upgrade the speed of
your link, no queuing system can help.

Please note for your display rate that:

at 30Hz, one on screen frame lasts:   33.3 ms
at 60Hz, one on screen frame lasts:   16.6 ms
at 144Hz, one on screen frame lasts:   6.9 ms

This means the typical gamer is sensitive to as little as on the order
of 5ms of jitter. To get 5ms minimum jitter you should have bandwidth
in each direction of at least:

$((1500*8*3/5)) kbps

The queue system can ONLY control bandwidth and jitter in the link
between your router and the VERY FIRST device in the ISP
network. Typically you will have 5 to 10 devices between your router
and your gaming server, any of those can have variable delay and ruin
your gaming, and there is NOTHING that your router can do about it.

EOF

ipt64 (){
    iptables $*
    ip6tables $*
}


setqdisc () {
DEV=$1
RATE=$2
MTU=1500
highrate=$((RATE*90/100))
lowrate=$((RATE*10/100))
gamerate=$3
useqdisc=$4
DIR=$5


tc qdisc del dev "$DEV" root > /dev/null 2>&1

case $LINKTYPE in
    "atm")
	tc qdisc replace dev "$DEV" handle 1: root stab mtu 2047 tsize 512 mpu 68 overhead ${OH} linklayer atm hfsc default 13
	;;
    "DOCSIS")
	tc qdisc replace dev $DEV stab overhead 25 linklayer ethernet handle 1: root hfsc default 13
	;;
    *)
	tc qdisc replace dev $DEV stab overhead 37 linklayer ethernet handle 1: root hfsc default 13
	;;
esac
     

DUR=$((5*1500*8/RATE))
if [ $DUR -lt 25 ]; then
    DUR=25
fi

# if we're on the LAN side, create a queue just for traffic from the
# router, like LUCI and DNS lookups
if [ $DIR = "lan" ]; then
    tc class add dev "$DEV" parent 1: classid 1:2 hfsc ls m1 50000kbit d "${DUR}ms" m2 10000kbit
fi


#limit the link overall:
tc class add dev "$DEV" parent 1: classid 1:1 hfsc ls m2 "${RATE}kbit" ul m2 "${RATE}kbit"


# high prio realtime class
tc class add dev "$DEV" parent 1:1 classid 1:11 hfsc rt m1 "$((RATE*97/100))kbit" d "${DUR}ms" m2 "${gamerate}kbit"

# fast non-realtime
tc class add dev "$DEV" parent 1:1 classid 1:12 hfsc ls m1 "$((RATE*70/100))kbit" d "${DUR}ms" m2 "$((RATE*30/100))kbit"

# normal
tc class add dev "$DEV" parent 1:1 classid 1:13 hfsc ls m1 "$((RATE*20/100))kbit" d "${DUR}ms" m2 "$((RATE*45/100))kbit"

# low prio
tc class add dev "$DEV" parent 1:1 classid 1:14 hfsc ls m1 "$((RATE*7/100))kbit" d "${DUR}ms" m2 "$((RATE*15/100))kbit"

# bulk
tc class add dev "$DEV" parent 1:1 classid 1:15 hfsc ls m1 "$((RATE*3/100))kbit" d "${DUR}ms" m2 "$((RATE*10/100))kbit"



## set this to "drr" or "qfq" to differentiate between different game
## packets, or use "pfifo" to treat all game packets equally

## games often use a 1/64 s = 15.6ms tick rate +- if we're getting so
## many packets that it takes that long to drain at full RATE, we're
## in trouble, because then everything lags by a full tick... so we
## set our RED minimum to start dropping at 9ms of packets at full
## line rate, and then drop 100% by 3x that much, it's better to drop
## packets for a little while than play a whole game lagged by a full
## tick

REDMIN=$((RATE*MAXDEL/3/8)) 

REDMAX=$((RATE * MAXDEL/8)) 

# for fq_codel
INTVL=$((100+2*1500*8/RATE))
TARG=$((540*8/RATE+4))



case $useqdisc in
    "drr")
	tc qdisc add dev "$DEV" parent 1:11 handle 2:0 drr
	tc class add dev "$DEV" parent 2:0 classid 2:1 drr quantum 8000
	tc qdisc add dev "$DEV" parent 2:1 handle 10: red limit 150000 min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	tc class add dev "$DEV" parent 2:0 classid 2:2 drr quantum 4000
	tc qdisc add dev "$DEV" parent 2:2 handle 20: red limit 150000 min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	tc class add dev "$DEV" parent 2:0 classid 2:3 drr quantum 1000
	tc qdisc add dev "$DEV" parent 2:3 handle 30: red limit 150000  min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	## with this send high priority game packets to 10:, medium to 20:, normal to 30:
	## games will not starve but be given relative importance based on the quantum parameter
    ;;

    "qfq")
	tc qdisc add dev "$DEV" parent 1:11 handle 2:0 qfq
	tc class add dev "$DEV" parent 2:0 classid 2:1 qfq weight 8000
	tc qdisc add dev "$DEV" parent 2:1 handle 10: red limit 150000  min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	tc class add dev "$DEV" parent 2:0 classid 2:2 qfq weight 4000
	tc qdisc add dev "$DEV" parent 2:2 handle 20: red limit 150000 min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	tc class add dev "$DEV" parent 2:0 classid 2:3 qfq weight 1000
	tc qdisc add dev "$DEV" parent 2:3 handle 30: red limit 150000  min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit probability 1.0
	## with this send high priority game packets to 10:, medium to 20:, normal to 30:
	## games will not starve but be given relative importance based on the weight parameter

    ;;

    "pfifo")
	tc qdisc add dev "$DEV" parent 1:11 handle 10: pfifo limit $((PFIFOMIN+MAXDEL*RATE/8/PACKETSIZE))
	;;
    "red")
	tc qdisc add dev "$DEV" parent 1:11 handle 10: red limit 150000 min $REDMIN max $REDMAX avpkt 500 bandwidth ${RATE}kbit  probability 1.0
	## send game packets to 10:, they're all treated the same
	;;
    "fq_codel")
	tc qdisc add dev "$DEV" parent "1:11" fq_codel memory_limit $((RATE*200/8)) interval "${INTVL}ms" target "${TARG}ms" quantum $((MTU * 2))
	;;
    "netem")
	tc qdisc add dev "$DEV" parent 1:11 handle 10: netem limit $((4+9*RATE/8/500)) delay "${netemdelayms}ms" "${netemjitterms}ms" distribution "$netemdist"
	;;


esac


echo "adding fq_codel qdisc for non-game traffic"
for i in 12 13 14 15; do 
    tc qdisc add dev "$DEV" parent "1:$i" fq_codel memory_limit $((RATE*200/8)) interval "${INTVL}ms" target "${TARG}ms" quantum $((MTU * 2))
done


}


setqdisc $WAN $UPRATE $GAMEUP $gameqdisc wan

## uncomment this to do the download direction via output of LAN
setqdisc $LAN $DOWNRATE $GAMEDOWN $gameqdisc lan

## we want to classify packets, so use these rules

cat <<EOF

We are going to add classification rules via iptables to the
FORWARD chain. You should actually read and ensure that these
rules make sense in your firewall before running this script. 

Continue? (type y or n and then RETURN/ENTER)
EOF

read -r cont

if [ "$cont" = "y" ]; then

    ipt64 -t mangle -F FORWARD

    ipt64 -t mangle -N dscptag
    ipt64 -t mangle -F dscptag
    
    
    if [ "$WASHDSCPUP" = "yes" ]; then
	ipt64 -t mangle -A FORWARD -i $LAN -j DSCP --set-dscp-class CS0
    fi
    if [ "$WASHDSCPDOWN" = "yes" ]; then
	ipt64 -t mangle -A FORWARD -i $WAN -j DSCP --set-dscp-class CS0
    fi

    ipt64 -t mangle -A FORWARD -j dscptag
    source $DSCPSCRIPT
    
    ipt64 -t mangle -A FORWARD -j CLASSIFY --set-class 1:13 # default everything to 1:13,  the "normal" qdisc

    # traffic from the router to the LAN bypasses the download queue
    ipt64 -t mangle -A OUTPUT -o $LAN -j CLASSIFY --set-class 1:2
    
    ## these dscp values go to realtime: EF, CS5, CS6, CS7
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class EF -j CLASSIFY --set-class 1:11
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS5 -j CLASSIFY --set-class 1:11
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS6 -j CLASSIFY --set-class 1:11
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS7 -j CLASSIFY --set-class 1:11
    
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS4 -j CLASSIFY --set-class 1:12
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class AF41 -j CLASSIFY --set-class 1:12
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class AF42 -j CLASSIFY --set-class 1:12
    
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS2 -j CLASSIFY --set-class 1:14
    ipt64 -t mangle -A FORWARD -m dscp --dscp-class CS1 -j CLASSIFY --set-class 1:15

    ## wash DSCP out to the ISP now that we used it for classifying

    if [ "$WASHDSCPUP" = "yes" ]; then
	ipt64 -t mangle -A FORWARD -o $WAN -j DSCP --set-dscp-class CS0
    fi

    
    case $gameqdisc in
	"red")
	;;
	"pfifo")
	;;
	*)
	    echo "YOU MUST PLACE CLASSIFIERS FOR YOUR GAME TRAFFIC HERE"
	    echo "SEND GAME TRAFFIC TO 2:1 (high) or 2:2 (medium) or 2:3 (normal)"
	    echo "Requires use of tc filters! -j CLASSIFY won't work!"
	    ;;
    esac
    
    
    if [ $UPRATE -lt 3000 ]; then
	ipt64 -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -o $LAN -j TCPMSS --set-mss 540
    fi
    if [ $DOWNRATE -lt 3000 ]; then
	## need to clamp MSS to 540 bytes in both directions to reduce
	## the latency increase caused by 1 packet ahead of us in the
	## queue since rates are too low to send 1500 byte packets at acceptable delay
	ipt64 -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -o $WAN -j TCPMSS --set-mss 540
    fi


else
    cat <<EOF
Check the rules and come back when you're ready.
EOF
fi

echo "DONE!"


if [ "$gameqdisc" = "red" ]; then
   echo "Can not output tc -s qdisc because it crashes on OpenWrt when using RED qdisc, but things are working!"
else
   tc -s qdisc
fi

but this build have pre-config firewall rules that dont work with the script

David, could you release new builds with all the updates? Specially wireguard and dnsmasq?
Based upon the current one from May?
Thanks a lot in advance!

1 Like

Hi @davidc502. Thanks for your hard work in the past. I owned a Linksys WRT1900AC and your build is the only distribution where I get good wireless speeds on my router. On the generic OpenWRT build I can only obtain about 1/3 of the speed on your builds, even with @eduperez drivers. Since you have ceased distributing new builds can you please share your "magic"? Do you use a special WiFi driver? Or some special OpenWRT configuration? Thanks in advance.

In the david build on my router i only have one TCPMSS on the output and no one in the input its normal ..
Im not an IT expert, because a have a friend that have o the output and input

Hi guys, I'm giving up on this router! (WRT3200ACM), Mostly because of the WiFi issues. My ISP ultra cheap fiber modem reaches all my house, but this Linksys beast losses signal. I have tried everything. DD-WRT, OpenWRT stock and Davidc Build but no luck. I have read that there's a Netgear pricey model that I cant remember which is, that I may try, can someone remember me which one is it? I'm looking to a router that has the same features that my WRT3200ACM but works fine with open source firmwares like this or DD-WRT. Thanks a lot in advise!

The rango is a competent router up to a 1G pipe, may want to consider turning off the radios and adding an AP with a wired backhaul, such as an EAP245.

2 Likes

Maybe you should try to install USB-WiFi on WRT3200acm, here it was already discussed somewhere. You will also save on this.

1 Like

Netgear r7800 is really stable.

2 Likes

Dear razor7,
Hello and I hope that you are both safe and well. I second ninjanoir78's suggestion and recommendation that the :

Netgear r7800 is really stable.

I bought two of these recently after near three years with Davidc502's Builds - I own 32x / wrt3200acm / 1900acs v2 / and 1200ac -- as you know Dave has taken a sabbatical / hiatus ( if we are all lucky ).
There is a good chance that Dave may never come back to this project. So, I moved onto the Netgear r7800. Two great OpenWRT Builds for the Netgear r7800 are listed below :

Hannu Nyman aka hnyman
He produces three builds / two based on Master / 
and one based on stable 19.07.6 with up to date commits
hnyman releases builds every two to three days for Master
see here for downloads and thread :

https://forum.openwrt.org/t/build-for-netgear-r7800/316

There is another promising firmware for Netgear r7800 by ACwifidude

ACwifidude's Build is based off master + hardware 
offloading with the two NSS cores
Build Goals: Maximum ipq806x performance for Gigabit WAN connections
ACwifidude releases a new Build every weekend normally
see here for downloads and thread :

https://forum.openwrt.org/t/ipq806x-nss-build-netgear-r7800-tp-link-c2600-linksys-ea8500/82525

I realize that this post is off topic but I like razor7 and others are looking for
viable alternatives for OpenWRT in the aftermath of Dave's work and efforts
being halted since June 2020.

Also Hannu Nyman aka hnyman 's CPU frequency scaling driver for mvebu (WRT3200ACM etc.) Build - updated about once a month

https://forum.openwrt.org/t/cpu-frequency-scaling-driver-for-mvebu-wrt3200acm-etc/2808/2

Hope this helps for all those looking to move forward.

2 Likes

I have just taken the leap of faith from using Davids builds and tried the latest No-nonsense linksys WRT build on my 1900ACS.
These builds could be an option.
I admit I have a simple network config lan1-4 bridged and vlan taging on the WAN port. Configuring DSA could be an issue for some moving forward.
So far no noticeable issues after 2.5hrs uptime.

Dear larrynz,
Hello and I hope that you are both safe and well. When you say :

tried the latest No-nonsense linksys WRT build

May I inquire to which build are you referring ? Maybe you can point me in the right direction and I and others can give that option a try as well. Thanks in advance for your input and assistance.

Edit : I was able to find No-nonsense linksys WRT build
Thread and downloads here for all interested :

https://forum.openwrt.org/t/no-nonsense-linksys-wrt-builds/80522

Thanks for the information and update 
about this development for WRT routers
1 Like

Yes that's the one, in the community build section.
I believe there is also a Superwrt build in there,but haven't tried it.

Hi,

is there an easy way to update the packages that came baked into david's last build?..I tried looking in the software section of the luci menu but the updates part doesn't seem to populate after I request a list update.

if there's a script or something which will handle it, I'd love to get it as I feel there may be packages now which could do with updating.

2 Likes

hi @batkung it seems not so easy... Differences between Stock OpenWrt and Comunnity Build

Hi, i have wrt3200acm, testing many fw and it always show only 1 radio.
radio0 Marvell 88W8964 802.11bgn and i can only use 2.4GHz. Any suggestion?
My kernel log
https://throwaway.link/.a7a23da1bb2df8cecca68d50b9a9dd09#df85470b88d46434788618360c7aa375

Check kernel log for setup / errors...

I've picked up a r7800 to replace my wrt3200acm and am much happier so far. It has been discontinued, so finding a new might be hard. Good luck.

First, please edit the post and replace your log dump with a throwaway link i.e.

dmesg | nc termbin.com 9999

dmesg dump from a rango. Ignore the differences as I am booting 5.10.x, but I see no phy1 getting setup on your device, not even a failed attempt. You say you have tried many FW versions, presumption would be HW failure.

On oem fw i can configure wifi but it not working at all. On openwrt it works but only 1 radio is available. I will check hw, thx for advice.

Quick stupid question, is anyone running plain openwrt on their linksys routers?
What do I lose by running that vs david's build?
I read the comparison, so there is a few packages, drivers are specific for a device, but does that mean these custom builds are better than the standard from openwrt?