Fedora Linux Support Community & Resources Center
  #1  
Old 22nd June 2012, 02:06 PM
mese79 Offline
Registered User
 
Join Date: Nov 2010
Posts: 31
linuxopera
Question tc and traffic shaping problem

Hi
I'm using fedora 17 x86_64 and i want to limit my bandwidth speed in my office network.
It seems the easiest way is to install and use 'trickle', but it doesn't really affect bandwidth speed.
After some searching i found some bash scripts to do it via 'tc' command. but none of them work for me. i'v got error at the start point. when i try these commands:
Code:
tc qdisc del dev eth1 root
or
tc qdisc add dev eth1 root handle 1: cbq avpkt 1000 bandwidth 10mbit
Quote:
Error:
RTNETLINK answers: No such file or directory
I googled for this error and i think it's related with kernel and loaded modules. see here:
missing-ingress-qdisc.html
Well, i stuck at this error and i don't know what to do?!
Should i need recompile kernel? which are the necessary modules for traffic shaping works and how could i load them?
Thanks.
Reply With Quote
  #2  
Old 22nd June 2012, 02:22 PM
Dutchy Offline
Registered User
 
Join Date: Aug 2011
Posts: 928
linuxfirefox
Re: tc and traffic shaping problem

In F16 it works for me.
You could try if my script works for you (since using the command manually is rather difficult):
PHP Code:
#!/bin/bash
#
# tc-bandwidth-limit    Limits the bandwidth of the configured interface
#
# chkconfig: 345 95 05
#
# description:  Limits the bandwidth of the configured interface

### BEGIN INIT INFO
# Provides: tc-bandwidth-limit
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Required-Start:
### END INIT INFO

##
# original source :http://atmail.com/kb/2009/throttling-bandwidth/
#  tc uses the following units when passed as a parameter.
#  kbps: Kilobytes per second
#  mbps: Megabytes per second
#  kbit: Kilobits per second
#  mbit: Megabits per second
#  bps: Bytes per second
#       Amounts of data can be specified in:
#       kb or k: Kilobytes
#       mb or m: Megabytes
#       mbit: Megabits
#       kbit: Kilobits
#  To get the byte figure from bits, divide the number by 8 bit
##
# Name of the traffic control command.
TC=/sbin/tc

# The network interface we're planning on limiting bandwidth.
IF=eth0             # Interface

# Download limit (in mega bits)
DNLD=3mbps          # DOWNLOAD Limit

# Upload limit (in mega bits)
UPLD=3mbps          # UPLOAD Limit

# IP address of the machine we are controlling
IP=216.3.128.12     # Host IP

# Filter options for limiting the intended interface.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"

start() {

# We'll use Hierarchical Token Bucket (HTB) to shape bandwidth.
# For detailed configuration options, please consult Linux man
# page.

$TC qdisc add dev $IF root handle 1htb default 30
$TC 
class add dev $IF parent 1classid 1:1 htb rate $DNLD
$TC 
class add dev $IF parent 1classid 1:2 htb rate $UPLD
$U32 match ip dst $IP
/32 flowid 1:1
$U32 match ip src $IP
/32 flowid 1:2

# The first line creates the root qdisc, and the next two lines
# create two child qdisc that are to be used to shape download
# and upload bandwidth.
#
# The 4th and 5th line creates the filter to match the interface.
# The 'dst' IP address is used to limit download speed, and the
# 'src' IP address is used to limit upload speed.

}

stop() {

# Stop the bandwidth shaping.
$TC qdisc del dev $IF root

}

restart() {

# Self-explanatory.
stop
sleep 1
start

}

show() {

# Display status of traffic control status.
$TC -s qdisc ls dev $IF

}

case 
"$1" in

start
)

echo -
"Starting bandwidth shaping: "
start
echo "done"
;;

stop)

echo -
"Stopping bandwidth shaping: "
stop
echo "done"
;;

restart)

echo -
"Restarting bandwidth shaping: "
restart
echo "done"
;;

show)

echo 
"Bandwidth shaping status for $IF:"
show
echo ""
;;

*)

pwd=$(pwd)
echo 
"Usage: tc.bash {start|stop|restart|show}"
;;

esac
exit 
Adjust the variables to your environment and likes, then put it in /etc/rc.d./init.d and ensure the permissions are 755.
Then use systemctl enable tc-bandwidth-limit.service && systemctl start tc-bandwidth-limit.service to test if it works.
Reply With Quote
  #3  
Old 22nd June 2012, 05:32 PM
mese79 Offline
Registered User
 
Join Date: Nov 2010
Posts: 31
linuxopera
Re: tc and traffic shaping problem

Thanks, but i tried this before with no success
Here is some output:
Code:
#tc -s qdisc ls dev eth0
 qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 143903 bytes 1165 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0
And result of above script :
Code:
Starting bandwidth shaping: RTNETLINK answers: No such file or directory
RTNETLINK answers: No such file or directory
RTNETLINK answers: No such file or directory
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
done
I think something changed in f17 kernel.
Is there anybody have this problem on f17 too?
Reply With Quote
  #4  
Old 4th July 2012, 12:31 AM
Dutchy Offline
Registered User
 
Join Date: Aug 2011
Posts: 928
linuxfirefox
Re: tc and traffic shaping problem

You are right, this command doesn't seem to work on Fedora 17 anymore.
I'm fairly sure that it was working before on a 3.4 kernel and Fedora 16 but after I upgraded it doesn't.
I suspect the move to /usr to be the one that's to blame for this.

One other way that you could limit your bandwidth with is to lower the TCP buffers.
e.g. the following commands will limit your speed to about 30 ~ 25 MByte:

PHP Code:
sysctl net.ipv4.tcp_rmem="4096 8192 16384"
sysctl net.ipv4.tcp_wmem="4096 8192 16384" 
Information:
http://www.psc.edu/index.php/network...tcp-tune#Linux
http://www.linuxdict.com/2011-02-net...cp-udp-tuning/
Reply With Quote
  #5  
Old 14th July 2012, 12:54 AM
mindlike Offline
Registered User
 
Join Date: Jul 2012
Location: Studio City
Posts: 1
windows_vistachrome
Re: tc and traffic shaping problem

Try 'yum install kernel-modules-extra' then reload tc rules. They moved some tc stuff out of kernel and into an kernel 'extra' rpm.
Reply With Quote
  #6  
Old 14th July 2012, 04:31 PM
george_toolan Offline
Registered User
 
Join Date: Dec 2006
Posts: 2,076
linuxfirefox
Re: tc and traffic shaping problem

Also the name of the eth0 interface has changed ;-)

Code:
ifconfig
Reply With Quote
  #7  
Old 17th July 2012, 10:07 AM
mese79 Offline
Registered User
 
Join Date: Nov 2010
Posts: 31
linuxopera
Re: tc and traffic shaping problem

Quote:
Originally Posted by mindlike View Post
Try 'yum install kernel-modules-extra' then reload tc rules. They moved some tc stuff out of kernel and into an kernel 'extra' rpm.
I almost have been gave up!
But this saves me.
Thanks

Last edited by mese79; 17th July 2012 at 10:09 AM.
Reply With Quote
Reply

Tags
network, problem, shaping, tc qdisc, traffic

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
traffic shaping dragon2611 Using Fedora 0 1st January 2008 05:13 PM
Traffic Shaping bibiandco Servers & Networking 0 8th February 2007 10:05 AM
Traffic shaping javauser Servers & Networking 1 12th October 2004 04:36 PM


Current GMT-time: 04:05 (Friday, 25-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat