ToS, Precendence and DSCP Mapping
ToS/Precedence and DSCP are both using the 8-bit Type of Service field in the IP header.
P2 P1 P0 T2 T1 T0 U U
DSCP (DiffServ Code Point):
D5 D4 D3 D2 D1 D0 U U
where T2 is Delay, T1 is Throughput, T0 is Reliability, U is unused.
DiffServ utilizes the same IP precedence bits, plus offers finer priority granularity with the next three bits (D0 is always 0, so it's actually two bits).
D5, D4 and D3 defines the class - 101 is class EF and 001, 010, 011, 100 are class AF.
Class EF doesn't have subclass, but class AF support subclass using D2 and D1 bits.
For instance af21 is 010010, basically af2 is the main class, while 1 is the subclass (Note: the last bit is D0, which is always 0). Below is the complete mapping list.
<0-63> Differentiated services codepoint value
af11 Match packets with AF11 dscp (001010)
af12 Match packets with AF12 dscp (001100)
af13 Match packets with AF13 dscp (001110)
af21 Match packets with AF21 dscp (010010)
af22 Match packets with AF22 dscp (010100)
af23 Match packets with AF23 dscp (010110)
af31 Match packets with AF31 dscp (011010)
af32 Match packets with AF32 dscp (011100)
af33 Match packets with AF33 dscp (011110)
af41 Match packets with AF41 dscp (100010)
af42 Match packets with AF42 dscp (100100)
af43 Match packets with AF43 dscp (100110)
cs1 Match packets with CS1(precedence 1) dscp (001000)
cs2 Match packets with CS2(precedence 2) dscp (010000)
cs3 Match packets with CS3(precedence 3) dscp (011000)
cs4 Match packets with CS4(precedence 4) dscp (100000)
cs5 Match packets with CS5(precedence 5) dscp (101000)
cs6 Match packets with CS6(precedence 6) dscp (110000)
cs7 Match packets with CS7(precedence 7) dscp (111000)
default Match packets with default dscp (000000)
ef Match packets with EF dscp (101110)
FR Traffic Shaping:
Traffic shaping will initially allocate full tokens to the interface, after they are used up, tokens will have to be earned.
FR traffic shaping’s CIR is actually the target rate, not provider’s CIR, normally it’s greater than provider’s CIR.
minCIR (if not specified, by default minCIR = 1/2 CIR) is provider’s CIR. minCIR should only be used in conjunction with adaptive shaping.
Bc (bits) = CIR * Tc
Be (bits) is actually the size of a token bucket, which saves all the unused Bc bits from previous intervals (initially Be bucket is full). If Be bucket is full, no more unused Bc bits can be saved. The available bits in the Be bucket is the number of bits that can be sent out above Bc during any given interval. Be can only be used once per second - during the first Tc in the 1-second period.
Tc by default is 1/8 second on a link slower than 640Kbps, and 1/16 second on a link faster than 640Kbps. Maximum Tc valus is 125ms, and minimum Tc value is 10ms.
Note: when there is a time sensitive traffic, use the smallest Tc value to prevent high priority packets from waiting a long interval for the next Tc.
Traffic shaping has its own queue, which is separate from the outbound interface queue. The traffic shaping queue can hold 40 packet by default (the range is 1-1024).
When there is a congestion, the receiver will get packets with FECN bit marked, and the returning traffic back to the sender will have the BECN bit marked. The problem is if the receiver never sends any packet back, the sender won’t get any BECN.
frame-relay fecn-adapt command forces the receiver to send a packet back whenever it receives a FECN packet.
In the below example, CLASS_1 will be applied on PVC 504, CLASS_2 will be applied on PVC 503, and CLASS_3 will be applied on PVC502.
interface Serial 0/0
frame-relay class CLASS_1
interface Serial 0/0.1 point-to-point
ip address 10.0.1.1 255.255.255.0
frame-relay interface-dlci 504
interface Serial 0/0.2 multipoint
ip address 10.0.2.1 255.255.255.0
frame-relay class CLASS_2
frame-relay map 10.0.2.2 502 broadcast
frame-relay map 10.0.2.3 503 broadcast
frame-relay interface-dlci 502
More information can be found at:
Frame Relay Traffic Policing
ATM Traffic Shaping