This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Setting TOS / DSCP on tx'd UDP in cygwin (sendto) using setsockopt


Not a question - just a reporting of a solution to a problem that's cost me several days.

Have 'c' code (the test tool sipp) that sends UDP packets, and I needed to set the DSCP / TOS value to allow me to test equipment's QOS functionality.

The normal way to do this is to call setsockopt on the socket and set the TOS to the required value.  E.g.:


   if ( setsockopt(sock, IPPROTO_IP, IP_TOS, (char *) &tos, toslen) < 0 )
    ERROR("Setsockopt");

However, this returns success but does not change the TOS of the rtx'd packets under windows XP.  Various (untrue) reports online state that winsock does not support this method.  

I then tried rewriting the code to use raw sockets including my own IP header in my packet - this transmits my custom IP header OK - but overwrites the specified TOS with the windows default (0).

Grr.

I finally stumbled across the solution here:

http://support.microsoft.com/kb/248611

You need to add a windows registry key to enable manual setting of TOS.  Then the setsockopt method will work ok (but sending raw packets with custom IP headers you will still see the specified tos in your header overwritten).

--------

Quote from microsoft:

Follow these steps to enable the IP_TOS option for the Winsock setsockopt function and the -v option for the ping utility on Windows 2000, Windows XP, or Windows Server 2003:
- Start Registry Editor (Regedt32.exe).
- Go to the following key:
   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters

If you are running Windows 2000, follow these steps:
- On the Edit menu, click Add Value.
- In the Value name box, type DisableUserTOSSetting.
- In the Data Type list, click REG_DWORD, and then click OK.
- In the Data box, type a value of 0 (zero), and then click OK.

If you are running Windows XP or Windows Server 2003, follow these steps:
- On the Edit menu, point to New, and then click DWORD Value.
- Type DisableUserTOSSetting as the entry name, and then press ENTER. 

When you add this entry, the value is set to 0 (zero). Do not change the value.

Quit Registry Editor, and then restart the computer.





--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]