How to change the DSCP value in IP header

If you need to validate your QoS configuration, this article may be helpful to you. I will discuss here how to change the DSCP value in the simplest way, including Linux and Windows systems.

Linux – ICMP

The most easiest way is to use the -Q parameter when PING. The -Q parameter here should specify TOS(Decimal) instead of DSCP. You can refer to this website.

root@nginx:~# ping -Q 184 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=106 time=8.42 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=106 time=8.43 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=106 time=8.38 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=106 time=9.25 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 8.376/8.619/9.252/0.365 ms
root@nginx:~# ^C
root@nginx:~# 

Linux – TCP&UDP

The above method only applies to ICMP packets. If you need to test TCP&UDP, you need to use iperf3.

root@nginx:~# apt install iperf3

After installing iperf3, we can use the -S parameter to specify the TOS value. Note that the TOS value here should be Hexadecimal. You can also refer to this website.

root@nginx:~# iperf3 -c 10.106.41.202 -S 0xB8

Windows – TCP&UDP

For Windows systems, we can use -v parameter to specify the TOS value. But this method does not work on the Windows 10 system on my laptop. And editing the Registry/Group Policy also does not work. Now I find that the only way to let it work on my Windows 10 System is to use NetQos commands.

For NetQos, there are the following 4 commands, you can refer to my example.

  • New-NetQosPolicy: Creates a new network QoS policy.
  • Get-NetQosPolicy: Retrieves network Quality of Service (QoS) policies.
  • Remove-NetQosPolicy: Removes a network Quality of Service (QoS) policy.
  • Set-NetQosPolicy: Updates the QoS policy settings.

Note that we need to specify the DSCP(Decimal) value here.

PS C:\Users\test> New-NetQosPolicy -Name "Backup" -IPDstPrefixMatchCondition "192.168.10.0/24" -NetworkProfile ALL -DSCPAction 46


Name           : Backup
Owner          : Group Policy (Machine)
NetworkProfile : All
Precedence     : 127
JobObject      :
IPProtocol     : Both
IPDstPrefix    : 192.168.10.0/24
DSCPValue      : 46


PS C:\Users\test> Get-NetQosPolicy


Name           : Backup
Owner          : Group Policy (Machine)
NetworkProfile : All
Precedence     : 127
JobObject      :
IPProtocol     : Both
IPDstPrefix    : 192.168.10.0/24
DSCPValue      : 46


PS C:\Users\test> Remove-NetQosPolicy  -Name "Backup"

Confirm
Are you sure you want to perform this action?
Remove-NetQosPolicy -Name Backup -Store GPO:localhost
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
PS C:\Users\test>
PS C:\Users\test> Get-NetQosPolicy
PS C:\Users\test>
PS C:\Users\test>

For details, we can refer to Microsoft’s official website.

References

iPerf3
DSCP & TOS
Serverius speedtest
Howto to quick test a DSCP based QoS system?
How to change ToS or DSCP values in IP header while sending a Ping, in Microsoft Windows products?

Leave a Reply

Your email address will not be published.