hate to sound egghead, but this stuff has been the subject of non-trivial
academic (yet practical) research, and there is a fair literature base.
hard to drag out refs from here, but one interesting ongoing project is
NPD by Vern Paxson, <vern@ee.lbl.gov>, which might serve as a starting
point for a lit search. some evenings it is nice to take a cs break from
all the grotty hacking.