I know that I can shape output traffic with tc or a similar tool. However, I want to shape the input traffic now—actually, I want to prioritize downloading of files of certain type through a slow lossy connection.

I know the reason tc can only shape output traffic: the host itself has no direct control over the amount of input traffic. On the other hand, TCP has some measures built in it which prevent the TCP traffic from overflowing a slow connection. So, can I mangle something in TCP header so that the remote host will think my connection is slower than it thinks?

Suppose that I am able to set the corresponding mark on both types of connections with iptables. Is there any way to reduce the input bandwidth of connections of first type, but only if connections of second type are present?


What you are referring to is TCP Explicit Congestion Notification (http://en.wikipedia.org/wiki/Explicit_Congestion_Notification.) I don't think what you're looking for is technically possible, since by the time the packet has been received by the Linux server itself, you've already received the packets and are trying to adjust them after-the-fact.

Realistically, if you want QOS or traffic shaping, it should be done at your upstream provider, not at the receiving end. In other words, all traffic shaping is done at the source side, not the destination side.

  • I don't really see why it wouldn't be possible to sort of implement it. If the router just drops X packets , then the sender should slow down the rate at which they send packets. This would require TCP and a trust of proper TCP flow control on the sender side though. – Kyle Brandt Nov 22 '11 at 17:16

There are very good solutions to this available, unfortunately none of them are available for free on Linux. Delaying or dropping the packets works very, very poorly. You can do it if you have to, but the results are adequate at best. By the time you've received a packet, it has already consumed the inbound bandwidth you are trying to protect.

The right way to do it is to mangle the outbound TCP window advertisements, advertising a smaller window to the other side. There are hardware and software implementations that do this, but to my knowledge none are available for free on Linux.

This script explains one way to do it and has some very detailed comments explaining the theory and limitations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.