Limiting bandwith using iptables -UPLOAD- limit not working

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
Shalvaid
DD-WRT Novice


Joined: 29 Nov 2013
Posts: 1

PostPosted: Fri Nov 29, 2013 1:50    Post subject: Limiting bandwith using iptables -UPLOAD- limit not working Reply with quote
Hello. I'm using iptables to limit the bandwith of my WRT54G V8 router flashed with DD-WRT v24-sp2 (10/10/09) micro.

I've managed myself to do this with the well known tool called "WRT54G Generator" developed by Robert "Robson".

This is the script:
Code:
#--------------------------------------------
#WRT54 Script Generator v1.02
#(C) 2006-2007 Robert "Robson" Mytkowski
#--------------------------------------------
TCA="tc class add dev br0"
TFA="tc filter add dev br0"
TQA="tc qdisc add dev br0"
SFQ="sfq perturb 10"
tc qdisc del dev br0 root
tc qdisc add dev br0 root handle 1: htb
tc class add dev br0 parent 1: classid 1:1 htb rate 2941kbit
$TCA parent 1:1 classid 1:10 htb rate 1470kbit ceil 1470kbit prio 2
$TCA parent 1:1 classid 1:11 htb rate 1471kbit ceil 1471kbit prio 0
$TQA parent 1:10 handle 10: $SFQ
$TQA parent 1:11 handle 11: $SFQ
$TFA parent 1:0 protocol ip prio 2 u32 match u16 0x0800 0xFFFF at -2 match u32 0x4CAE7CD3 0xFFFFFFFF at -12 match u16 0x60A4 0xFFFF at -14 flowid 1:10
$TFA parent 1:0 protocol ip prio 0 u32 match u16 0x0800 0xFFFF at -2 match u32 0x5DB2D2A2 0xFFFFFFFF at -12 match u16 0x5046 0xFFFF at -14 flowid 1:11
TCAU="tc class add dev imq0"
TFAU="tc filter add dev imq0"
TQAU="tc qdisc add dev imq0"
insmod imq
insmod ipt_IMQ
insmod ipt_mac
ip link set imq0 up
tc qdisc del dev imq0 root
tc qdisc add dev imq0 root handle 1: htb
tc class add dev imq0 parent 1: classid 1:1 htb rate 243kbit
$TCAU parent 1:1 classid 1:10 htb rate 10kbit ceil 20kbit prio 2
$TCAU parent 1:1 classid 1:11 htb rate 10kbit ceil 20kbit prio 0
$TQAU parent 1:10 handle 10: $SFQ
$TQAU parent 1:11 handle 11: $SFQ
iptables -t mangle -A PREROUTING -m mac --mac-source 60:A4:4C:AE:7C:D3 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -m mac --mac-source 50:46:5D:B2:D2:A2 -j MARK --set-mark 11
iptables -t mangle -A PREROUTING -j IMQ --todev 0


The problem is that the UPLOAD limit is not working.... despite the DOWNLOAD limit works perfectly.

I've tried with many values in rate and ceil but nothing seems to work.

I can't figure out what the problem is... maybe the upload bandwith is that small that I can't even limit it?

Thank you guys.
Sponsor
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Fri Aug 15, 2014 6:59    Post subject: Reply with quote
Hi all. Novice here. I'm having the same issue. I would really appreciate if someone could lead me in the right direction. The script I'm using is allowing me to limit download, but not upload speeds.
For reference, I'm running DD-WRT v24-sp2 (08/07/10) mini (SVN revision 14896) on an Asus RT-N16 router.

In the DD-WRT control panel > Administration > Commands > Command Shell: I save the following code as "Firewall"

Code:
#--------------------------------------------
#WRT54 Script Generator v1.02
#(C) 2006-2007 Robert "Robson" Mytkowski
#--------------------------------------------
# Limit Download to rateMb/s guaranteed, ceilMb/s max
TCA="tc class add dev br0"
TFA="tc filter add dev br0"
TQA="tc qdisc add dev br0"
SFQ="sfq perturb 10"
tc qdisc del dev br0 root
tc qdisc add dev br0 root handle 1: htb
tc class add dev br0 parent 1: classid 1:1 htb rate 35000kbit
$TCA parent 1:1 classid 1:10 htb rate 448kbit ceil 448kbit prio 2
$TQA parent 1:10 handle 10: $SFQ
$TFA parent 1:0 prio 4 protocol ip handle 10 fw flowid 1:10
iptables -t mangle -A POSTROUTING -d 192.168.1.143 -j MARK --set-mark 10

# Limit Upload to rateMb/s guaranteed, ceilMb/s max
TCAU="tc class add dev imq0"
TFAU="tc filter add dev imq0"
TQAU="tc qdisc add dev imq0"
insmod ipt_IMQ
insmod imq
insmod ipt_mac
ip link set imq0 up
tc qdisc del dev imq0 root
tc qdisc add dev imq0 root handle 1: htb
tc class add dev imq0 parent 1: classid 1:1 htb rate 10000kbit
$TCAU parent 1:1 classid 1:10 htb rate 224kbit ceil 224kbit prio 2
$TQAU parent 1:10 handle 10: $SFQ
$TFAU parent 1:0 prio 4 protocol ip handle 10 fw flowid 1:10
iptables -t mangle -A PREROUTING -s 192.168.1.143 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -j IMQ --todev 0

Then go to Management, apply settings, save, reboot router. (QoS is disabled)
When I test the connection, download is limited, but upload is still the full amount. Same problem many people are having.

I've updated "modprobe" to "insmod" in the code like people recommend in this thread:
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=76364
I've also tried enabling and disabling the QoS like some have suggested.

I've also tried using the startup scripts suggested in these threads:
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=47314
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=90315

I've also tried searching other threads for clues:
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=43730

I've tried tweaking different parameters. I've tried using a MAC address rather than an IP. I've tried saving the script as startup rather than firewall as it apparently worked for someone else. I've tried several enable/disable/rebooting methods with QoS. Nothing seems to work. Can anyone help? Much thanks.


Last edited by thermal on Sat Aug 23, 2014 2:00; edited 1 time in total
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Fri Aug 15, 2014 10:16    Post subject: Reply with quote
@thermal
Is there any particular reason for using 4 years old build?
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Sat Aug 16, 2014 4:49    Post subject: Reply with quote
Mile-Lile wrote:
@thermal
Is there any particular reason for using 4 years old build?

Unless, there is something I don't know about, that is the latest version available for my router. Right? Or am I reading that wrong?
Snapshot of my router on the DD-WRT.com router database page:
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Sun Aug 17, 2014 11:00    Post subject: Reply with quote
ftp://ftp.dd-wrt.com/betas/2014/06-23-2014-r24461/broadcom_K3X/
you are wellcome:)
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Sun Aug 17, 2014 11:24    Post subject: Reply with quote
or if you are using mini for rt n16 than this:
ftp://ftp.dd-wrt.com/betas/2014/06-23-2014-r24461/broadcom_K26/
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Tue Aug 19, 2014 8:49    Post subject: Reply with quote
Mile-Lile wrote:
ftp://ftp.dd-wrt.com/betas/2014/06-23-2014-r24461/broadcom_K3X/
you are wellcome:)

Mile-Lile wrote:
or if you are using mini for rt n16 than this:
ftp://ftp.dd-wrt.com/betas/2014/06-23-2014-r24461/broadcom_K26/

@Mile-Lile Thank you for showing me that there are newer versions of the firmware. Silly me for assuming the database would be up to date. Confused I've been since reading through a bunch of threads to familiarize myself with how to update the firmware, including the Peacock thread and Asus RT-N16 threads.

According to User madman999, "In order to get a 3.x kernel build onto the Asus RT-N16, you need to go from a 2.6 kernel build to 3.x 21530 then to the latest." 3.x also seems to have some other issues with users, so I think I'll hold off on this version for now.

I'm a bit confused if these are the same version or not:
ftp://ftp.dd-wrt.com/betas/2014/06-23-2014-r24461/broadcom_K26/dd-wrt.v24-24461_NEWD-2_K2.6_mini_RT-N16.trx
ftp://ftp.dd-wrt.com/others/eko/BrainSlayer-V24-preSP2/2014/06-23-2014-r24461/broadcom_K26/dd-wrt.v24-24461_NEWD-2_K2.6_mini_RT-N16.trx
And, I assume I can go from my old current version, v24-sp2 (08/07/10) mini (SVN revision 14896), straight to this new K2.6 version.

Also, I'm not sure if this is a more stable version to go with than the above...
http://desipro.de/ddwrt/K26/r22000++/kingkong-nv32k-broadcom.bin

Any chance you know? Otherwise I think I need to follow up in another thread since this is getting a bit off topic from the OP.
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Tue Aug 19, 2014 10:46    Post subject: Reply with quote
I cant help you because I never had broadcom router. I just know that QoS and limiting works great on atheros...
Ask on ddwrt/broadcom chipset... I think you can easily upgrade to k2.6 mini... just see firmware size cause your rtn16 has 4MB flash...
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Thu Aug 21, 2014 6:53    Post subject: Reply with quote
I've upgraded the firmware of my Asus RT-N16 to the latest DD-WRT v24-sp2 (06/07/14) kingkong - build 22000M. And I'm still having the same issue as before with the old firmware.

The download bandwidth limit works, but upload bandwidth limit does not. I'm using the same firewall script code that's in the second post in this thread. Anyone have any ideas what I can try next?
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Thu Aug 21, 2014 8:20    Post subject: Reply with quote
you don't need script generator when you can do it from GUI read this: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=264574&highlight=
that script is for older kernels...
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Thu Aug 21, 2014 8:23    Post subject: Reply with quote
sorry:) wrong topic... see this http://www.dd-wrt.com/phpBB2/viewtopic.php?t=266494&highlight=
I dont have time to post new pictures...
just use manual if you want to limit in kbits...
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Fri Aug 22, 2014 2:34    Post subject: Reply with quote
@Mile-Lile
Thanks for the info. New features that were not in the previous build. However, it's still not working.
I'm trying to limit the bandwidth of my xbox one to 224kbits up and 448kbits down. I've got it on a wired connection to my router. I've set it to a static IP. I've set the xbox MAC address in QoS like so...
*pic deleted*

Could you please double check my settings? Any advice would be helpful. I'm not sure if I should be using LAN and/or WAN. I don't know if I should be checking any of the TCP options. I don't know why the MAC priority lists both WAN up/down but only LAN max; what's the difference?

My internet provider says that my download/upload speeds should be 100/10 MBps. However, the download varies from 30-120 MBps when I test it on my xbox one. Upload is pretty consistent at 10-11 MBps.

I've power cycled my xbox, router and modem after any changes.
BTW, is pressing the "reboot router" button in the DD-WRT gui the same as unplugging the power cord out and back in?


Last edited by thermal on Sat Aug 23, 2014 1:52; edited 1 time in total
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Fri Aug 22, 2014 5:43    Post subject: Reply with quote
If internet is hosted on you router(i.e pppoe) you should use WAN shaping, or if you use your router as WDS Station or Client Bridge (Routed) you should use LAN&WLAN shaping. In that case traffic is going just trough router switch not CPU so ddwrt must use ebtables to shape traffic on L2 level (MAC level)...
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Fri Aug 22, 2014 5:45    Post subject: Reply with quote
it is important to read wiki too
http://www.dd-wrt.com/wiki/index.php/Quality_of_Service
thermal
DD-WRT Novice


Joined: 15 Aug 2014
Posts: 11

PostPosted: Sat Aug 23, 2014 1:58    Post subject: Reply with quote
@Mile-Lile Thanks for the info.

I found my error. I accidentally switched priority of the MAC address from manual to exempt. Everything else was correct.
Upload and download bandwidth limiting works now!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum