none
How t set TCP_INITIAL_RTO_PARAMETERS with Socket.IOControl provided by .NET 4.5? RRS feed

  • Question

  • I initially started with "netsh interface tcp set global maxsynretransmissions", thus my goal is either

      to set this parameter programmatically at OS level during application installation

      or to set it programmatically at actual application level.

    It appears Max SYN Retransmissions is controlled by TCP_INITIAL_RTO_PARAMETERS structure. This structure can be set by WSAIoctl function in C++.  API is exposed in .NET through Socket.IOControl method.

    So, I am having a hard time figuring how to call Socket.IOControl to control values in

    typedef struct _TCP_INITIAL_RTO_PARAMETERS {
      USHORT Rtt;
      UCHAR  MaxSynRetransmissions;
    } TCP_INITIAL_RTO_PARAMETERS

    It appears Socket.IOControl applies to a current socket, but I am using TcpClient object and I am not sure if socket can be controlled to this degree in this case.

    Any comments will be greatly appreciated.

    Wednesday, June 24, 2015 6:35 PM

Answers

  • Hello,

    >>It appears Socket.IOControl applies to a current socket, but I am using TcpClient object and I am not sure if socket can be controlled to this degree in this case.

    It could be however may not be easy, since in .NET, the IOControlCode Enumeration does not provide the SIO_TCP_INITIAL_RTO value:

    https://msdn.microsoft.com/en-us/library/system.net.sockets.iocontrolcode%28v=vs.100%29.aspx?f=255&MSPPError=-2147217396

    So you could try to call the Socket.IOControl Method (Int32, Byte[], Byte[]) method which accepts an an Int32 value that specifies the control code of the operation to perform for the dwIoControlCode, this parameter value should be a integer represents “SIO_TCP_INITIAL_RTO”,  for the Byte array parameter which maps to lpvInBuffer, since this parameter accepts a byte array, you need to define a custom struct or using P/Invoke to import the original struct to your project and convert to a byte array object.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 25, 2015 6:29 AM
    Moderator