trafic shaping interupts samba

This is a discussion on trafic shaping interupts samba within the Linux Networking forums, part of the Linux Forums category; Hello there, I found one "script" on the internet about traffic shaping. It's lightly modified to my ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-05-2006
korgman
 
Posts: n/a
Default trafic shaping interupts samba

Hello there,

I found one "script" on the internet about traffic shaping. It's lightly
modified to my needs.

I have one problem that is solved, but I wish to know why this problem exists.
Problem is that I have to add four lines to mark "samba communication" as
"fast. See four lines before # Samba

If I remove those four lines, samba connection works half of the time and
does I can't mount any Windows XP resources.

I don't understand why I have to use those four lines since the internal
network is free above...

The script:

#!/bin/sh -x
# be verbose!

tc qdisc add dev eth0 root handle 1: htb default 20
# add new htb handler on eth0, default for traffic is 20

tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
# root class

tc class add dev eth0 parent 1:1 classid 1:10 htb rate 100mbit ceil 100mbit
# ethernet class 1:10

tc class add dev eth0 parent 1:1 classid 1:11 htb rate 12kbps ceil 12kbps
# internet

tc class add dev eth0 parent 1:11 classid 1:20 htb rate 12kbps ceil 12kbps
# we use this class for the bulk traffic

tc class add dev eth0 parent 1:11 classid 1:21 htb rate 6kbps ceil 12kbps
# SSH

tc class add dev eth0 parent 1:11 classid 1:22 htb rate 3kbps ceil 12kbps
# mldonkey's class

tc class add dev eth0 parent 1:11 classid 1:23 htb rate 6kbps ceil 12kbps
# HTTP

tc class add dev eth0 parent 1:11 classid 1:24 htb rate 5kbps ceil 12kbps
# high priority internet traffic

# The above commands set up the HTB queues where we will \"dump\" our packets in
# Now it's time to mark the packets:

iptables -A POSTROUTING -t mangle -o eth0 -p tcp -m length --length :64 -j MARK --set-mark 20
# high priority (small packets), used for ACKs (allows regular transfers with no slowdown)

iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 22 -j MARK --set-mark 21
iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 22 -j MARK --set-mark 21
# SSH traffic (port 22) - only use this if you have an ssh server running or ssh a lot

iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 80 -j MARK --set-mark 23
iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 80 -j MARK --set-mark 23
# HTTP

iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
# This marks all packages sent by user 1010, change this to the user mldonkey is running under
# (there should ONLY mldonkey be running with this UID)

# at the end, mark all traffic that is for the local LAN to be put into 10
iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 -j MARK --set-mark 10

# I added this to solve samba reliability problems with Windows XP
iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --dport 139 -j MARK --set-mark 10
iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --sport 139 -j MARK --set-mark 10
iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --dport 445 -j MARK --set-mark 10
iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --sport 445 -j MARK --set-mark 10
# Samba

# flow handling (after marking)
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:20
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
Reply With Quote
  #2 (permalink)  
Old 08-05-2006
korgman
 
Posts: n/a
Default Re: trafic shaping interupts samba

On 2006-08-05, korgman <korgie@gmail.com> wrote:
> I have one problem that is solved, but I wish to know why this problem exists.


Wrong :-( Problem is not solved. My modification is useless.
Only with tc qdisc del dev eth0 root I can mount Windows xp shares

> The script:
>
> #!/bin/sh -x
> # be verbose!
>
> tc qdisc add dev eth0 root handle 1: htb default 20
> # add new htb handler on eth0, default for traffic is 20
>
> tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
> # root class
>
> tc class add dev eth0 parent 1:1 classid 1:10 htb rate 100mbit ceil 100mbit
> # ethernet class 1:10
>
> tc class add dev eth0 parent 1:1 classid 1:11 htb rate 12kbps ceil 12kbps
> # internet
>
> tc class add dev eth0 parent 1:11 classid 1:20 htb rate 12kbps ceil 12kbps
> # we use this class for the bulk traffic
>
> tc class add dev eth0 parent 1:11 classid 1:21 htb rate 6kbps ceil 12kbps
> # SSH
>
> tc class add dev eth0 parent 1:11 classid 1:22 htb rate 3kbps ceil 12kbps
> # mldonkey's class
>
> tc class add dev eth0 parent 1:11 classid 1:23 htb rate 6kbps ceil 12kbps
> # HTTP
>
> tc class add dev eth0 parent 1:11 classid 1:24 htb rate 5kbps ceil 12kbps
> # high priority internet traffic
>
> # The above commands set up the HTB queues where we will \"dump\" our packets in
> # Now it's time to mark the packets:
>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -m length --length :64 -j MARK --set-mark 20
> # high priority (small packets), used for ACKs (allows regular transfers with no slowdown)
>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 22 -j MARK --set-mark 21
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 22 -j MARK --set-mark 21
> # SSH traffic (port 22) - only use this if you have an ssh server running or ssh a lot
>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 80 -j MARK --set-mark 23
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 80 -j MARK --set-mark 23
> # HTTP
>
> iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
> iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
> # This marks all packages sent by user 1010, change this to the user mldonkey is running under
> # (there should ONLY mldonkey be running with this UID)
>
> # at the end, mark all traffic that is for the local LAN to be put into 10
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 -j MARK --set-mark 10
>
> # flow handling (after marking)
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:20
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10

Reply With Quote
  #3 (permalink)  
Old 08-06-2006
davids@webmaster.com
 
Posts: n/a
Default Re: trafic shaping interupts samba


korgman wrote:

> # flow handling (after marking)
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:20
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10


That first line says "handle 21" and should say "handle 20".

DS

Reply With Quote
  #4 (permalink)  
Old 08-06-2006
korgman
 
Posts: n/a
Default Re: trafic shaping interupts samba

On 2006-08-05, davids@webmaster.com <davids@webmaster.com> wrote:
>
> korgman wrote:
>
>> # flow handling (after marking)
>> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:20
>> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21
>> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22
>> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23
>> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10

>
> That first line says "handle 21" and should say "handle 20".


Nice observation! Sorry for that :-). I also deleted my four lines of # Samba and
it seems ok. Thanks!

>
> DS
>



--
--
Please excuse my english writing!
Slackware 10.1
Knowledge report: Newbie with custom kernel
Reply With Quote
  #5 (permalink)  
Old 08-07-2006
Andy Furniss
 
Posts: n/a
Default Re: trafic shaping interupts samba

korgman wrote:
> Hello there,
>
> I found one "script" on the internet about traffic shaping. It's lightly
> modified to my needs.
>
> I have one problem that is solved, but I wish to know why this problem exists.
> Problem is that I have to add four lines to mark "samba communication" as
> "fast. See four lines before # Samba
>
> If I remove those four lines, samba connection works half of the time and
> does I can't mount any Windows XP resources.
>
> I don't understand why I have to use those four lines since the internal
> network is free above...
>
> The script:
>
> #!/bin/sh -x
> # be verbose!
>
> tc qdisc add dev eth0 root handle 1: htb default 20
> # add new htb handler on eth0, default for traffic is 20


Unless you make a tc filter for it, arp will end up here - delaying arp
messes things up. HTB will pass unclassified traffic unshaped if you
don't use default, so you could try that and catch "the rest" of ip
traffic with an iptables rule or a tc filter.

>
> tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
> # root class
>
> tc class add dev eth0 parent 1:1 classid 1:10 htb rate 100mbit ceil 100mbit
> # ethernet class 1:10
>
> tc class add dev eth0 parent 1:1 classid 1:11 htb rate 12kbps ceil 12kbps
> # internet
>
> tc class add dev eth0 parent 1:11 classid 1:20 htb rate 12kbps ceil 12kbps
> # we use this class for the bulk traffic
>
> tc class add dev eth0 parent 1:11 classid 1:21 htb rate 6kbps ceil 12kbps
> # SSH
>
> tc class add dev eth0 parent 1:11 classid 1:22 htb rate 3kbps ceil 12kbps
> # mldonkey's class
>
> tc class add dev eth0 parent 1:11 classid 1:23 htb rate 6kbps ceil 12kbps
> # HTTP
>
> tc class add dev eth0 parent 1:11 classid 1:24 htb rate 5kbps ceil 12kbps
> # high priority internet traffic


Your rates need to add up to the parent rate (I know wondershaper on
lartc does it - it's wrong).

kbps to tc means k bytes/sec.

If you have a 100mbit nic then it's not 100mbit at ip level (well on eth
htb will see packets as ip+14) either way there are more overheads than
that so you can't expect 100mbit to work - though you are really shaping
for internet anyway.

You should use prio for htb classes if you want interactive to be served
before bulk - high prio (0 = highest) will get to borrow spare bandwidth
first aswell.

>
> # The above commands set up the HTB queues where we will \"dump\" our packets in
> # Now it's time to mark the packets:
>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -m length --length :64 -j MARK --set-mark 20
> # high priority (small packets), used for ACKs (allows regular transfers with no slowdown)


May be better to move this down so small don't get remarked by type

>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 22 -j MARK --set-mark 21
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 22 -j MARK --set-mark 21
> # SSH traffic (port 22) - only use this if you have an ssh server running or ssh a lot
>
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --dport 80 -j MARK --set-mark 23
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp --sport 80 -j MARK --set-mark 23
> # HTTP
>
> iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
> iptables -A OUTPUT -t mangle -o eth0 -m owner --uid-owner 1010 -j MARK --set-mark 22
> # This marks all packages sent by user 1010, change this to the user mldonkey is running under
> # (there should ONLY mldonkey be running with this UID)
>
> # at the end, mark all traffic that is for the local LAN to be put into 10
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 -j MARK --set-mark 10
>
> # I added this to solve samba reliability problems with Windows XP
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --dport 139 -j MARK --set-mark 10
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --sport 139 -j MARK --set-mark 10
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --dport 445 -j MARK --set-mark 10
> iptables -A POSTROUTING -t mangle -o eth0 -p tcp -d 192.168.178.0/24 --sport 445 -j MARK --set-mark 10
> # Samba
>
> # flow handling (after marking)
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:20
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23
> tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10


On a tc filter prio 1 is highest - doesn't make any difference here, though.
Reply With Quote
  #6 (permalink)  
Old 08-08-2006
korgman
 
Posts: n/a
Default Re: trafic shaping interupts samba

On 2006-08-07, Andy Furniss <spam@andyfurniss.entadsl.com> wrote:
> If you have a 100mbit nic then it's not 100mbit at ip level (well on eth
> htb will see packets as ip+14) either way there are more overheads than
> that so you can't expect 100mbit to work - though you are really shaping
> for internet anyway.


Thank you for all of your remarks! They are fabulous but I admit that
I din't fully understand everything beucase I don't know exactly how
the tcp/ip (networking) works..

I think I solved my problem that puzzles me (though you discovered
several others to my dissapointment!)

To work Samba I added the udp protocol and I think everything is fine.
Or I made again some newbie stupidity? :-)

I realised that "something is wrong" with my bandwidth rates, because
I run via SSH some X program on Windows and they are not so responsive
as in the past. But it was not important. I tried with 80mbit but it
was wayyy to slow to my needs.

I know than kb is kbytes/sec, I prefer to think like that.

Thanks again..
Reply With Quote
Reply
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0