tags:

views:

56

answers:

1

Hello.

I'd like to control download volume/speed on my side -- and on the server's side as well (to be polite). ... It is not about "my own download manager".

Let's imagine: I allow my son to download max 500Mb / day from utube, and still, he initiates a session to download a 10Gb HD movie. (Not necessarily ab. parental control, but technically this is a good example).

The question I have is: how to limit. I want to write a driver that'd control this on the TCP (IP?) level. Is it possible to on TCP level?

I know I can handle it locally (by e.g. narrowing the TCP window I advertise to the server, or by simply closing the connection after XXX bytes).

But waht I really want is to tell the (say) utube politely: (after the connection had been established and the downloading is in progress) : don't try try hard to still squeeze this movie into small segments, and create a lot of congestion on the n/w - we're done.

I'd like to avoid the unnecessary n/w on any side; basically I'd like to be able (on the TCP level) to tell the other end: This is it, we're done for today. Please don't retry to deliver the whole movie, I am not interested in watching the rest of it (today). (So that utube would just stop polluting the bandwidth instantaneously).

Maybe to confuse you more -- but hopefully to clarify, -- here's an excerpt from the "Definitive guide to Linux network programming", p.31: (Talking about the 6 bits part of the TCP header: URG, ACK, PSH, RST, SYS, FIN): ""... situations arise when data must be transmitted out of band. ... This is whether the URG bit comes into play. Consider a connection a user wishes to abort, such as ..." (etc.).

That's probably what I am looking for: send the utube the "URG" with "ABORT". The only thing that is unclear to me from this text is this "ABORT". Is this "RST"? or what?

Please push me a bit in a right direction.

Thanks Gurus in advance.

A: 

You can use the existing QoS infrastructure to do traffic shaping in your Linux box.

The best way to do it is to use iproute's tc (or tcng) command to create different queues and set limits to each AND to use iptables to classify the packets into one of the existing queues. This will give you the most flexibility and the less code to write :-) (Which may or may not be what you want). I've found a tool that supposedly makes all this process easier.

Examples here and here.

You might also want to have a look at Shaperd to see example code (if a bit old) that uses libipq, which allows for packet queuing in userspace (which has since been superseded by libnetfilter_queue).

If you are not using Linux, but Windows, you might want to look at the QoS API or at existing software that'll do it for you, like Traffic Shaper

Vinko Vrsalovic
Vinko,this is very informative, I am digging into it.THANKS!!!
bzdjamboo