Categories

Category cover

Automation
35 posts

Category cover

Notes
19 posts

Category cover

Security
19 posts

Category cover

Personal Security
14 posts

Category cover

Infrastructure
11 posts

Category cover

CISO
9 posts

Category cover

OT/ICS
5 posts

Category cover

UNetLab
3 posts

Category cover

Write-up
3 posts

Category cover

Books
2 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Verifying end-to-end QoS marking

Andrea Dainese
September 04, 2014
Post cover

A not-so-easy process about QoS involves the verification of end-to-end QoS marking: are the marks maintained through the all network?

Before going deep, let’s recap how an IP packet can be marked:

  • The IP field reserved for QoS is 8 bits long and it’s called TOS (Type of Service).
  • RFC791 defines 3 bits for IPP (IP Precedence) and 3 bit for traffic characteristics (Delay, Throughput and Reliability). 2 MBZ bits (Must Be Zero).
  • RFC1349 updates RFC791 and define 3 bits for IPP, 4 bits for TOS (Delay, Throughput, Reliability and Cost) and 1 MBZ bit. In this RFC “Type of Service” is referred to as the 8 bits field in the IP header, and “TOS” is referred to as the 4 bits field inside the 8 bits “Type of Service” field.
  • RFC2474 defines another way to use the ToS field: 6 bits for DSCP and 2 MBZ bits. RFC4594 defines how DCP bits can be used: DF (Default Forwarding), AF (Assured Forwarding), EF (Expedited Forwarding), or CS (Class Selector).

More QoS-related RFC exists, but they are out of the scope of this very short document.

ToS (int)ToS (hex)ToS (bin)IPPTOSDSCP (PHB)DSCP (int)DSCP (bin)
00x0000 000 0 00 - Routine0000 - Normal ServiceDF (CS0)0000000
320x20001 000 0 01 - Priority0000 - Normal ServiceCS18001000
400x28001 010 0 01 - Priority0100 - Maximize ThroughputAF1110001010
480x30001 100 0 01 - Priority1000 - Minimize DelayAF1212001100
560x38001 110 0 01 - Priority1100 - Minimize Delay and Maximize ThroughputAF1314001110
640x40010 000 0 02 - Immediate0000 - Normal ServiceCS216010000
720x48010 010 0 02 - Immediate0100 - Maximize ThroughputAF2118010010
800x50010 100 0 02 - Immediate1000 - Minimize DelayAF2220010100
880x58010 110 0 02 - Immediate1100 - Minimize Delay and Maximize ThroughputAF2322010110
960x60011 000 0 03 - Flash0000 - Normal ServiceCS324011000
1040x68011 010 0 03 - Flash0000 - Normal ServiceAF3126011010
1120x70011 100 0 03 - Flash1000 - Minimize DelayAF3228011100
1200x78011 110 0 03 - Flash1100 - Minimize Delay and Maximize ThroughputAF3330011110
1280x80100 000 0 04 - Flash Override0000 - Normal ServiceCS432100000
1360x88100 010 0 04 - Flash Override0000 - Normal ServiceAF4134100010
1440x90100 100 0 04 - Flash Override1000 - Minimize DelayAF4236100100
1520x98100 110 0 04 - Flash Override1100 - Minimize Delay and Maximize ThroughputAF4338100110
1600xa0101 000 0 05 - CRITIC/ECP0000 - Normal ServiceCS540101000
1840xb8101 110 0 05 - CRITIC/ECP1100 - Minimize Delay and Maximize ThroughputEF46101110
1920xc0110 000 0 06 - Internetwork Control0000 - Normal ServiceCS648110000
2240xe0111 000 0 07 - Network Control0000 - Normal ServiceCS756111000

Within the same AF class, higher DSCPs have a higher drop probability (AFX1 = low, AFX2 = medium, AFX3 = high). Lower AF class should have a low drop probability (AF1X < AF2X < AF3X < AF4X).

IPP and TOS are no more used, but for completeness here is the TOS table:

TOSService
0 0 0 0Normal Service
X X X 1Minimize Monetary Cost
X X 1 XMaximize Reliability
X 1 X XMaximize Throughput
1 X X XMinimize Delay

Why so many values?

Currently DSCP is the most used QoS model, but each network tool can take input using a specific format.

Analyzing packets

Let’s assume we want to check if received packets are correctly marketed. We want to analyze EF and AF1 classes. On Linux, tcpdump takes decimal ToS values:

sudo tcpdump -n -v 'icmp and (ip[1] & 0xfc == 184 or ip[1] & 0xfc == 56 or ip[1] & 0xfc == 48 or ip[1] & 0xfc == 40)'

The Linux ping command also takes decimal ToS:

ping -Q 184

Cisco routers take the binary ToS:

#ping
Protocol [ip]:
Target IP address: 2.2.2.2
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: Loopback0
Type of service [0]: 0xb8
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]: