TCP Send Timing Issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Charts

    #1

    TCP Send Timing Issue

    I am building a simulator that needs to send out 2 messages on a tcp
    connection each at a rate of 1 packet / 50ms. Right now it kind of
    works in that it is sending 8 (4 of each) at 200ms. Is there a way to
    force the packets to at the least go out every 50 ms?
    If 1 of each is combined is fine, but 4 of each at a time is a problem.
    Are there any more options I can set to improve this?
    Right now my socket is setup as :
    serverSocket = new Socket( AddressFamily.I nterNetwork,
    SocketType.Stre am, ProtocolType.Tc p);
    serverSocket.Se tSocketOption(S ocketOptionLeve l.Socket,
    SocketOptionNam e.SendTimeout, 1000);

    Thanks.

  • ignacio machin

    #2
    RE: TCP Send Timing Issue

    Hi,

    There is no way to be 100% sure that you will send them at the required rate.
    Windows is not a real time OS and your app depends of others events
    happening in the OS at the same time.

    The best you can do is using a Timer (I bet you are doing it anyway )

    Beside that, what u consider a "packet"? It's a TCP datagram? (think this is
    the correct term) if so it will depend of the network and I'm not sure if you
    can go that low using the framework as to force the packet size.



    "Richard Charts" wrote:
    I am building a simulator that needs to send out 2 messages on a tcp
    connection each at a rate of 1 packet / 50ms. Right now it kind of
    works in that it is sending 8 (4 of each) at 200ms. Is there a way to
    force the packets to at the least go out every 50 ms?
    If 1 of each is combined is fine, but 4 of each at a time is a problem.
    Are there any more options I can set to improve this?
    Right now my socket is setup as :
    serverSocket = new Socket( AddressFamily.I nterNetwork,
    SocketType.Stre am, ProtocolType.Tc p);
    serverSocket.Se tSocketOption(S ocketOptionLeve l.Socket,
    SocketOptionNam e.SendTimeout, 1000);
    >
    Thanks.
    >
    >

    Comment

    • Dave Sexton

      #3
      Re: TCP Send Timing Issue

      Hi Richard,

      Just a guess, but try setting NoDelay to true.

      --
      Dave Sexton

      "Richard Charts" <richard.charts @gmail.comwrote in message
      news:1163193452 .510970.176060@ h54g2000cwb.goo glegroups.com.. .
      >I am building a simulator that needs to send out 2 messages on a tcp
      connection each at a rate of 1 packet / 50ms. Right now it kind of
      works in that it is sending 8 (4 of each) at 200ms. Is there a way to
      force the packets to at the least go out every 50 ms?
      If 1 of each is combined is fine, but 4 of each at a time is a problem.
      Are there any more options I can set to improve this?
      Right now my socket is setup as :
      serverSocket = new Socket( AddressFamily.I nterNetwork,
      SocketType.Stre am, ProtocolType.Tc p);
      serverSocket.Se tSocketOption(S ocketOptionLeve l.Socket,
      SocketOptionNam e.SendTimeout, 1000);
      >
      Thanks.
      >

      Comment

      • Richard Charts

        #4
        Re: TCP Send Timing Issue


        Dave Sexton wrote:
        Hi Richard,
        >
        Just a guess, but try setting NoDelay to true.
        >
        --
        Dave Sexton
        >
        "Richard Charts" <richard.charts @gmail.comwrote in message
        news:1163193452 .510970.176060@ h54g2000cwb.goo glegroups.com.. .
        I am building a simulator that needs to send out 2 messages on a tcp
        connection each at a rate of 1 packet / 50ms. Right now it kind of
        works in that it is sending 8 (4 of each) at 200ms. Is there a way to
        force the packets to at the least go out every 50 ms?
        If 1 of each is combined is fine, but 4 of each at a time is a problem.
        Are there any more options I can set to improve this?
        Right now my socket is setup as :
        serverSocket = new Socket( AddressFamily.I nterNetwork,
        SocketType.Stre am, ProtocolType.Tc p);
        serverSocket.Se tSocketOption(S ocketOptionLeve l.Socket,
        SocketOptionNam e.SendTimeout, 1000);

        Thanks.
        I had tried NoDelay originally and it didn't work.
        This morning I looked some more and noticed the damn things needs
        boolean value not an int.
        serverSocket.Se tSocketOption(S ocketOptionLeve l.Tcp,SocketOpt ionName.NoDelay ,
        true);
        It is working now.
        Thank you both for your help.

        Comment

        • Peter Duniho

          #5
          Re: TCP Send Timing Issue

          "Richard Charts" <richard.charts @gmail.comwrote in message
          news:1163425736 .416166.215750@ h48g2000cwc.goo glegroups.com.. .
          I had tried NoDelay originally and it didn't work.
          This morning I looked some more and noticed the damn things needs
          boolean value not an int.
          serverSocket.Se tSocketOption(S ocketOptionLeve l.Tcp,SocketOpt ionName.NoDelay ,
          true);
          It is working now.
          Note that turning off the Nagle algorithm simply disables the performance
          optimization of consolidating outbound TCP/IP packets. There are still
          other ways that your data can be held up. If you have a specific need for
          100% reliable constant rate data transmission, TCP/IP isn't the appropriate
          transport.

          Pete


          Comment

          • Richard Charts

            #6
            Re: TCP Send Timing Issue


            Peter Duniho wrote:
            "Richard Charts" <richard.charts @gmail.comwrote in message
            news:1163425736 .416166.215750@ h48g2000cwc.goo glegroups.com.. .
            I had tried NoDelay originally and it didn't work.
            This morning I looked some more and noticed the damn things needs
            boolean value not an int.
            serverSocket.Se tSocketOption(S ocketOptionLeve l.Tcp,SocketOpt ionName.NoDelay ,
            true);
            It is working now.
            >
            Note that turning off the Nagle algorithm simply disables the performance
            optimization of consolidating outbound TCP/IP packets. There are still
            other ways that your data can be held up. If you have a specific need for
            100% reliable constant rate data transmission, TCP/IP isn't the appropriate
            transport.
            >
            Pete
            It's a simulator of actual hardware that will exist in a closed LAN, so
            disabling Nagle does exactly what I need. Exact timing any where
            between Xms - Yms (and even that wasn't that important) was less my
            concern rather than that it was important that the traffic was crossing
            the network in the correct form. It was important to match the way
            that the hardware being simulated was outputting packets.
            Right option for the right job and all that.

            Comment

            Working...