My best shot for now at giving an example would be to direct you to the wiki of the project I have done this for - there is the script I wrote as well as another one initially based upon it.
http://wiki.leipzig.freifunk.net/Tra...ochens_Version
As you will notice the site is in german but maybe you can grasp what the script does.
Basically it marks traffic of different kinds with the help of iptables - and puts the marked packets into qdiscs with a priority defined by me.
These qdiscs are served according to their priority (set by me) and are served strictly by that priority.
Lower priority qdiscs will have to wait until the higher is satisfied.
True trafficshaping (such as a guaranteed bandwidth per user/ip/kind of traffic) could be done easily with minor changes - it was just not suitable for me to implement that (my ISP has hugely varying bandwidths...and shaping would need a specific and stable bandwidth available.
Thus, prioritizing was my only option.
If you are interested I can provide that script with comments in english - or help create a custom solution.
For this we would need to know what exactly you want to achieve and how your network is set up.