TCP Send Timing Issue

R

Richard Charts

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.
 
G

Guest

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.
 
R

Richard Charts

Dave said:
Hi Richard,

Just a guess, but try setting NoDelay to true.

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.
 
P

Peter Duniho

Richard Charts said:
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
 
R

Richard Charts

Peter said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top