Introduction and Setup

If you came here via a search engine, chances are that you looking for a quick and dirty way of testing DSCP on your network. Differentiated Services, described in RFC 2474 and RFC 2475 provide a way to mark, prioritize, police, etc IP flows based on various attributes. This allows network operators to maintain different levels of QoS on their networks.

This post captures details on how to generate traffic from a client with different DSCP fields set and verify that they are received on the server side.

Note: RFC-compliant implementation of IPsec will copy the DSCP field from the payload and copy it into the IPsec header.

Steps
    1. Start a wireshark sniffer on the server side. Filter on the client IP to make your life easier.
tcpdump -ieth0 -n 'host 192.168.2.1' -wdscp-test.pcap

where,
eth0 – interface to capture packets.
192.168.2.1 – the IP address of your client
dscp-test.pcap – the name of the file that will capture the sniffer trace.

    1. Copy and paste the snippet below to generate the packets.
for i in 00 04 08 0C 10  20 28 30 38 40 48 50 58 60 68 70 78 80 88 90 98 A0 B0 B8 C0 E0; 
do 
    ping -c1 -Q 0x$i 192.168.3.1; 
done
  1. You will need tshark, which is part of wireshark to read the pcap and print out the key fields.
tshark -r dscp-test.pcap -Tfields -e ip.src -e ip.dst -e ip.dsfield

This will print an output similar to one below, which will have the source IP address, destination IP address, and the DSCP field value.

192.168.2.1     192.168.3.1     0
192.168.3.1     192.168.2.1     0
192.168.2.1     192.168.3.1     4
192.168.3.1     192.168.2.1     4
192.168.2.1     192.168.3.1     8
192.168.3.1     192.168.2.1     8
192.168.2.1     192.168.3.1     12
192.168.3.1     192.168.2.1     12
192.168.2.1     192.168.3.1     16
192.168.3.1     192.168.2.1     16
192.168.2.1     192.168.3.1     32
192.168.3.1     192.168.2.1     32
192.168.2.1     192.168.3.1     40
192.168.3.1     192.168.2.1     40
192.168.2.1     192.168.3.1     48
192.168.3.1     192.168.2.1     48
192.168.2.1     192.168.3.1     56
192.168.3.1     192.168.2.1     56
192.168.2.1     192.168.3.1     64
192.168.3.1     192.168.2.1     64
192.168.2.1     192.168.3.1     72
192.168.3.1     192.168.2.1     72
192.168.2.1     192.168.3.1     80
192.168.3.1     192.168.2.1     80
192.168.2.1     192.168.3.1     88
192.168.3.1     192.168.2.1     88
192.168.2.1     192.168.3.1     96
192.168.3.1     192.168.2.1     96
192.168.2.1     192.168.3.1     104
192.168.3.1     192.168.2.1     104
192.168.2.1     192.168.3.1     112
192.168.3.1     192.168.2.1     112
192.168.2.1     192.168.3.1     120
192.168.3.1     192.168.2.1     120
192.168.2.1     192.168.3.1     128
192.168.3.1     192.168.2.1     128
192.168.2.1     192.168.3.1     136
192.168.3.1     192.168.2.1     136
192.168.2.1     192.168.3.1     144
192.168.3.1     192.168.2.1     144
192.168.2.1     192.168.3.1     152
192.168.3.1     192.168.2.1     152
192.168.2.1     192.168.3.1     160
192.168.3.1     192.168.2.1     160
192.168.2.1     192.168.3.1     176
192.168.3.1     192.168.2.1     176
192.168.2.1     192.168.3.1     184
192.168.3.1     192.168.2.1     184
192.168.2.1     192.168.3.1     192
192.168.3.1     192.168.2.1     192
192.168.2.1     192.168.3.1     224
192.168.3.1     192.168.2.1     224
print