www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/12/06/13:55:14

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_FRT_STOCK2
X-Spam-Check-By: sourceware.org
Message-ID: <1323197685.81976.YahooMailClassic@web162002.mail.bf1.yahoo.com>
Date: Tue, 6 Dec 2011 10:54:45 -0800 (PST)
From: Matt Briggs <mattbriggs AT yahoo DOT com>
Subject: Setting TOS / DSCP on tx'd UDP in cygwin (sendto) using setsockopt
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019