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.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
serverSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 1000);
Thanks.
ignacio machin - 10 Nov 2006 22:12 GMT
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.
> 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
[quoted text clipped - 9 lines]
>
> Thanks.
Dave Sexton - 10 Nov 2006 23:34 GMT
Hi Richard,
Just a guess, but try setting NoDelay to true.

Signature
Dave Sexton
>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
[quoted text clipped - 9 lines]
>
> Thanks.
Richard Charts - 13 Nov 2006 13:48 GMT
> Hi Richard,
>
[quoted text clipped - 16 lines]
> >
> > 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.SetSocketOption(SocketOptionLevel.Tcp,SocketOptionName.NoDelay,
true);
It is working now.
Thank you both for your help.
Peter Duniho - 13 Nov 2006 18:04 GMT
> 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.SetSocketOption(SocketOptionLevel.Tcp,SocketOptionName.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
Richard Charts - 13 Nov 2006 18:17 GMT
> > I had tried NoDelay originally and it didn't work.
> > This morning I looked some more and noticed the damn things needs
[quoted text clipped - 10 lines]
>
> 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.