User Tools

Site Tools


topics:networking:trafficshaping

Traffic shaping

I always had an interrest in network traffic shaping, but since Apple released IOS5 my interrest intensified. Althought I didn't understand it at first, the 'issue' is fotostream.

Whenever me or my wife came home from an event where we took pictures with our iPhones, our home internet became really slow. At first we didn't see this pattern, but after a while it became clear. tcpdump showed that our phones were very active pushing data to the internet for quite a while. Fotostream.

Ingress traffic shaping using veth devices

Having a router that routes traffic between the internet and all my PC's, phones, etc allows to do great traffic shaping by using the HTB qdisc in both directions. However if your router is a PC itself, it's impossible to use HTB to do traffic shaping on it's own inbound network traffic. I came up with a funny solution: use Virtual Ethernet devices to introduce an additional bridge. Assume your PC's current network config consists of a singe NIC, like this:

eth0(192.168.1.1)---LAN

Being eth0 your physical NIC with IP 192.168.1.1 and LAN your Ethernet network. Now consider changing this to:

veth0(192.168.1.1)---veth1---br0---eth0---LAN

Being veth0 and veth1 a pair of Virtual Ethernet devices, and br0 a bridge with veth1 and eth0 it's ports. Now we have the same logical Ethernet structure in terms of functionality, but with a veth0 and an veth1 device with which we can do HTB based traffic shaping:

  • All veth0 outbound traffic can be shaped using HTB
  • All veth1 outbound traffic can als be shaped using HTB, but this is actually your servers inbound traffic!!!

The commands to make this alle happen:

ip link add name veth0 type veth peer name veth1
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 veth1
ifconfig br0 up
ifconfig eth0 up
ifconfig veth1 up
ifconfig veth0 192.168.1.1
topics/networking/trafficshaping.txt · Last modified: 2013/01/05 21:20 by rolf