Intermediate iRules: Clarifying IP::tos command usage

The IP::tos command has been around since the v4 days, and there has been some confusion on IP tos versus DSCP. The command takes the supplied value (or returns  a value) and applies to the tos field overall, which is eight bits. So if you take express forwarding, which is DSCP 46 and use IP::tos 46, you'll notice on the wire that something is amiss:

What gives? Well, the DSCP markings are in the first 6 bits of the tos field, so you need to bit-shift to the left a couple places. That results in 46 * 22 = 184. So 184 is the value you would use with the IP::tos command.

00101110 = 46

10111000 = 184

By setting IP::tos 184, you can see on the wire that all is now well in the world:

The below table maps the DSCP values in decimal to the value you'll need to use with the IP::tos command to get expected results.

DSCP Mappings for IP::tos Command
Precedence Type of Service DSCP Class DSCP Value IP::tos Value
0 0 none 0 0
1 0 cs1 8 32
1 1 af11 10 40
1 10 af12 12 48
1 11 af13 14 56
10 0 cs2 16 64
10 1 af21 18 72
10 10 af22 20 80
10 11 af23 22 88
11 0 cs3 24 96
11 1 af31 26 104
11 10 af32 28 112
11 11 af33 30 120
100 0 cs4 32 128
100 1 af41 34 136
100 10 af42 36 144
100 11 af43 38 152
101 0 cs5 40 160
101 11 ef 46 184
110 0 cs6 48 192
111 0 cs7 56 224

I updated the TCP Profile QoS article I wrote a few years back with this updated table, as well as the IP::tos command page in the iRules documentation. Thanks to F5er Alex for tracking this down!

 
Updated Oct 02, 2023
Version 4.0

Was this article helpful?