||This article needs additional citations for verification. (August 2006)|
Traffic shaping (also known as "packet shaping") is a computer network traffic management technique which delays some or all datagrams to bring them into compliance with a desired traffic profile. Traffic shaping is a form of rate limiting.
If a link becomes saturated to the point where there is a significant level of contention (either upstream or downstream) latency can rise substantially. Traffic shaping can be used to prevent this from occurring and keep latency in check. Traffic shaping provides a means to control the volume of traffic being sent into a network in a specified period (bandwidth throttling), or the maximum rate at which the traffic is sent (rate limiting), or more complex criteria such as GCRA. This control can be accomplished in many ways and for many reasons; however traffic shaping is always achieved by delaying packets. Traffic shaping is commonly applied at the network edges to control traffic entering the network, but can also be applied by the traffic source (for example, computer or network card) or by an element in the network. Traffic policing is the distinct but related practice of packet dropping and packet marking. The technique of selecting or categorising traffic into different types or classes is traffic classification.
Traffic shaping is sometimes applied by traffic sources to ensure the traffic they send complies with a contract which may be enforced in the network by a policer.
Nodes in an IP network which buffer packets before sending on a link which is at capacity result in a traffic shaping effect. This can appear at for example a low bandwidth link (such as dial-up), a particularly expensive WAN link or satellite hop.
Traffic shaping is often used in combination with:
- Differentiated services, Integrated services — including traffic classification and prioritization.
- Weighted round robin (WRR)
- Random early detection (RED), Weighted RED (WRED) and RED In/Out (RIO) — Lessens the possibility of port queue buffer tail drops and this lowers the likelihood of TCP global synchronization.
- A number of port queue buffers.
- VLAN tagging IEEE 802.1q
A traffic shaper works by delaying metered traffic such that each packet complies with the relevant traffic contract. Metering may be implemented with for example the leaky bucket or token bucket algorithms (the former typically in ATM and the latter in IP networks). Metered packets or cells are then stored in a FIFO buffer for each separately shaped class, until they can be transmitted in compliance with the prevailing traffic contract. This may occur immediately (if the traffic arriving at the shaper is already compliant), after some delay (waiting in the buffer until its scheduled release time) or never (in case of buffer overflow).
Overflow condition 
All traffic shaper implementations have a finite buffer, and must cope with the case where the buffer is full. A simple and common approach is to drop traffic arriving while the buffer is full (tail drop), thus resulting in traffic policing as well as shaping. A more sophisticated implementation could apply a dropping algorithm such as Random Early Discard; a crude alternative would be to allow overflowing traffic through unshaped.
Traffic classification 
Simple traffic shaping schemes shape all traffic uniformly by rate. More sophisticated shapers first classify traffic. Traffic classification categorises traffic (for example, based on port number or protocol). Different classes can then be shaped separately to achieve a desired effect.
Self-limiting sources 
A self-limiting source produces traffic which never exceeds some upper bound, for example media sources which cannot transmit faster than their encoded rate allows. Self-limiting sources shape the traffic they generate to a greater or lesser degree. Congestion control mechanisms can also affect traffic shaping of sorts - for example TCP's window mechanism implements a variable rate constraint related to bandwidth-delay product.
TCP Nice, a modified version of TCP developed by researchers at the University of Texas at Austin, allows applications to request that certain TCP connections be managed by the operating system as near zero-cost background transfers, or "nice" flows. Such flows interfere only minimally with foreground (non-nice) flows, while reaping a large fraction of spare network bandwidth.
Relationship to traffic management 
Traffic shaping is a specific technique and one of several which combined constitute Bandwidth management. Current common usage, particularly in discussion of domestic Internet service provision, frequently confuses traffic shaping with traffic management and traffic policing, with classification policies and in general with any measure deliberately taken by an ISP which is detrimental to some user's IP traffic performance.
ISPs and traffic management 
- See bandwidth throttling, bandwidth management, and also Teletraffic engineering in broadband networks
Traffic shaping is of interest especially to Internet Service Providers (ISPs). Their high-cost, high-traffic networks are their major assets, and as such, are the focus of all their attentions. They sometimes use traffic shaping to optimize the use of their network, sometimes by intelligently shaping traffic according to importance, other times by discouraging uses of applications by harsh means. There are those who believe it is not the ISP's place to decide what is "important"; in such cases per-client traffic shaping is more effective without creating potential controversies about what traffic is being controlled.
||This section needs additional citations for verification. (August 2009)|
To ISPs, mere protocol identification (classification) gives the intangible yet significant benefit of seeing what internet traffic is flowing through the network. From this they can see which subscribers are doing what on their network and can target services to the subscriber base they have attracted. However as time progresses, more and more protocols are using tunneling and encryption to defeat these methods. Also, many protocols are very difficult or impossible to detect. In such cases, per-client shaping is more effective. By establishing policies based on the IP or IP grouping of a client, ISPs ensure that end users cannot defeat shaping by disguising protocols or encrypting their traffic.
In addition, intelligent shaping schemes can guarantee a particular Quality of Service (often measured in jitter, packet loss, and latency) for an application or a user while still allowing other traffic to use all remaining bandwidth. This allows ISPs to offer Differentiated services and to upsell existing services to subscribers (such as offering minimum-latency computer gaming for an additional fee on top of basic internet).
More importantly, shaping allows ISPs to tier their services using software, reducing their costs and increasing the menu of products they can offer.
For Wireless ISP's, particularly those who use Wifi-based protocols, Congestive collapse is a serious problem. Due to the unfortunate nature of Wifi when several stations are all trying to access a single access point at once, once the load is past roughly 95% channel load, the throughput starts to drop dramatically. Whilst the channel stays at the same usage (roughly 99%), the throughput just gets slower and slower due to the number of retries. TCP performance may be greatly impacted by the long delay over the wireless link caused by the congestion at the access point. A long delay can cause expiration of the TCP RTO timer at the sender's side and then force TCP into slow-start. On the other hand, if the long delay is experienced on the ACK path, it could cause the so-called "ACK compression", which will disturb the synchronization between the TCP sender and the TCP receiver. Multiple compressed ACKs if passing through the wireless access point all together can clock-out the same amount of large packets from the TCP sender and all of them may arrive at the wireless bottleneck in a short time and further worsen the congestion there. Therefore traffic shaping should be seriously considered on a WISP in order to avoid these possible performance impacts.
Traffic Shaping and also prioritization are becoming more and more common in the corporate market. Most companies with remote offices are now connected via a Wide area network (WAN). Applications tend to become centrally hosted at the head office and remote offices are expected to pull data from central databases and server farms. As applications become more hungry in terms of bandwidth and prices of dedicated circuits being relatively high in most areas of the world, instead of increasing the size of their WAN circuits, companies feel the need to properly manage their circuits to make sure business-oriented traffic gets priority over best-effort traffic. Traffic shaping is thus a good means for companies to avoid purchasing additional bandwidth while properly managing these resources.
Alternatives to traffic shaping in this regards are application acceleration and WAN optimization and compression, which are fundamentally different from traffic shaping. Traffic shaping defines bandwidth rules (or partitions as some vendors call them) whereas application acceleration using multiple techniques like a TCP Performance Enhancing Proxy. WAN optimization and compression (WOC) on the other hand would use compression and differential algorithms and techniques to compress data streams or send only differences in file updates. The latter is quite effective for chatty protocols like CIFS.
See also 
- Teletraffic engineering in broadband networks
- Network congestion avoidance
- Quality of service
- Bandwidth throttling
- Multilayer switch
- Rate limiting
- TCP pacing
- Token bucket
- Leaky bucket
- Broadband Networks
- Bandwidth management
- Network neutrality
- IETF RFC 2475 "An Architecture for Differentiated Services" section 18.104.22.168 - Internet standard definition of "Shaper"
- ITU-T Recommendation I.371: Traffic control and congestion control in B-ISDN Section 7.2.7 defines traffic shaping as a traffic control mechanism which "alters the traffic characteristics of a stream of cells on a VCC or a VPC to achieve a desired modification of those traffic characteristics, in order to achieve better network efficiency whilst meeting the QoS objectives or to ensure conformance at a subsequent interface. ... Shaping modifies traffic characteristics of a cell flow with the consequence of increasing the mean cell transfer delay."
- IEEE INFOCOM 2001. Arsenic: a user-accessible gigabit Ethernet interface Pratt, I., Fraser, K., Computer Laboratory, Cambridge University; Twentieth Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings 2001 Volume 1, pages: 67-76 vol.1. Describes a gigabit Ethernet NIC with transmit traffic shaping.
- Cisco Tech Notes: Comparing Traffic Policing and Traffic Shaping for Bandwidth Limiting. Document ID: 19645 Graphs illustrate differences in typical output
- *Review of the Internet traffic management practices of Internet service providers (Telecom. Reg. Policy CRTC 2009-657) Canadian telecomms regulator CRC ruling relating to traffic shaping usage by domestic ISPs.
- Helzer, Xu Congestion Control for Multimedia Streaming with Self-Limiting Sources Josh Helzer, Lisong Xu
- Venkataramani, Kokku, Dahlin TCP Nice: Self-tuning Network Support for Background Applications, Arun Venkataramani, Ravi Kokku and Mike Dahlin
- ATM Forum Traffic Management Specification, Version 4.0 Approved Specification 0056.00, Section 5.5, Traffic Shaping
- CNet: Is Comcast's BitTorrent filtering violating the law? Analysis of Comcast's impersonation techniques for limiting BitTorrent usage.
- "Deploying IP and MPLS QoS for Multiservice Networks: Theory and Practice" by John Evans, Clarence Filsfils (Morgan Kaufmann, 2007, ISBN 0-12-370549-5)
- "Peer-to-Peer File Sharing: The Impact of File Sharing on Service Provider Networks", Sandvine Incorporated, copyright 2002
- BBC News - Traffic Shaping and BitTorrent
- shaping on a map
- IT-world.com, Traffic Shaping article comparing traffic management techniques circa 2001
- Network World, 03/05/01: Where should traffic shaping occur?
- Network World, 03/07/01: WAN-side traffic shaping
- Linux Kernel: Traffic Control, Shaping and QoS
- A Practical Guide to Linux Traffic Control
- Web based traffic shaping bridge/router
- Dynamisches Bandbreitenmanagement im Chemnitzer StudentenNetz (German work about "DynShaper-Software" used at CSN (student network at Chemnitz University of Technology): Manuals)
- Tecniche di gestione avanzata del traffico internet (in Italian) article describing network traffic management techniques including classification (Classificazione), policing (Regolamentazione), scheduling (Programmazione) and shaping ("lo shaping"). Translations as given in the article.