I have some old code which polices a variety TCP sources using a token bucket filter, if you want to take a look at it. It can be obtained from http://www.eecs.umich.edu/~wuchang/ered/