How to create Policy-based QoS on Windows 7 through CLI?

3

0

I am trying to add ToS (QoS) support to a SIP client (taken from open-source Linphone) as so:

retval = setsockopt(session->rtp.socket, proto, value_type, (SOCKET_OPTION_VALUE)&tos, sizeof(tos));

But in Windows 7, all my attempts to add ToS failed; it continues to set zeros (as seen in Wireshark). Someone said it’s a “feature” (read bug) in Windows.

I read in this page how to create a QoS policy, so I created one manually by using the GUI:

Screenshot of Policy Editor showing QoS configuration

I tried the following steps:

  1. Go to HKLM\System\CurrentControlSet\Services\Tcpip\QoS
  2. Create the QoS key if it doesn’t exist
  3. Add a REG-SZ parameter named Do not use NLA and give it the value 1
  4. Reboot

It works as desired, but now my question is how can I automate the creation of such a policy (e.g., so that it can be done during a program installation)?

[EDIT]

My code is pure C and to use C# source code will be problematic a bit since I use the minGW environment and tools with ./configure && make && make install.

Maxim Shoustin

Posted 2013-11-28T21:48:50.427

Reputation: 83

Is the question about setting the registry via a .reg file or the reg add command?

– harrymc – 2013-12-01T17:13:31.310

@harrymc not at all, its not registry but group policy. IDK if its stored into registry. By adding Do not use NLA to QoS in registry I only activate created policy. otherwise it doesnt work – Maxim Shoustin – 2013-12-01T18:06:52.633

Answers

1

The article Programmatically updating local policy in Windows describes a .NET library that can assist with this problem.

If you do not wish to write a .net program, the simplest solution would be to create a AutoHotkey macro, possibly compiled to an .exe, that will do the GUI manipulations that create that group policy.

If you are using Windows 8 or Server 2012, the configuration of QoS is possible via PowerShell:
Network Quality of Service (QoS) Cmdlets in Windows PowerShell.

harrymc

Posted 2013-11-28T21:48:50.427

Reputation: 306 093

Thank you for info, I found this post :http://pete.akeo.ie/2011/03/porgramatically-setting-and-applying.html helpful. However, I didn't find Gpedit.h on my Windows 7. Sounds like it doesnt run on windows 7. I have SIP video application that sends video with ToS 0 and code dosn't work. I continue to investigate. Thanks

– Maxim Shoustin – 2013-12-01T20:16:29.047

I saw that post too and decided not to recommend it. If you are into programming, the source-code of the .NET library I found is also available. – harrymc – 2013-12-01T20:47:07.460

Im into programming but my code is pure C lang compiled with make under minGL – Maxim Shoustin – 2013-12-01T21:28:39.257

I never used minGL, but I doubt that its integration into Windows is as good as Visual Studio. The program you need is simple enough that you might consider trying .NET. Microsoft Visual Studio Express for Windows Desktop is free. – harrymc – 2013-12-01T23:03:23.033

i have VS8 and VS10, its ok, the issues here that plugin by Martin Eden written in C# and i compile code with gcc , so i looking for the way to use it. Thanks – Maxim Shoustin – 2013-12-02T02:43:43.833

There are many resources about calling C# from C and vice verso. For example Calling C# from C. gcc is more difficult, but one isolation method is to create a dll (maybe statically-linked).

– harrymc – 2013-12-02T06:45:53.387