Jump to content
  • Advertisement
Sign in to follow this  
Shakkan

Lowest latency and highest priority packets?

This topic is 2562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I am trying to implement a network communication module where each packet (UDP datagram) is sent in real-time (or fastest possible) since timing really matters in this scenario. Using Winsock, tests indicated that latency is very low in optimal conditions but, for example, if a network file transfer is initiated, my ping times begin to increase dramatically (150-600ms). The UDP datagrams I want to send are very small (50 bytes every 10ms) so I would like those packets to have priority over the non-urgent ones like file transfer over LAN.

I tried a game of L4D2 and while playing, I initiated a big file transfer saturating the infrastructure (100mbps) and ping remained unchanged.
Are there special tricks that game developers use to prioritize packet sending? With Winsock, choices seem rather limited.

What would you suggest to achieve lowest latency possible for sending small packets at predefined intervals and have priority over other transfers?

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement

I tried a game of L4D2 and while playing, I initiated a big file transfer saturating the infrastructure (100mbps) and ping remained unchanged.
Are there special tricks that game developers use to prioritize packet sending? With Winsock, choices seem rather limited.

What would you suggest to achieve lowest latency possible for sending small packets at predefined intervals and have priority over other transfers?


"Lowest latency possible" is whatever you get -- better performance than what you get is "not possible" :-)


Given that you cannot control the internet, you have to accept some amount of latency. The "ping" from L4D2 includes some buffering that can smooth out the jitter that you get when conditions change. To get low jitter (change in latency), you have to buffer, and accept a higher average latency.

Share this post


Link to post
Share on other sites

[quote name='Shakkan' timestamp='1323122040' post='4890847']
I tried a game of L4D2 and while playing, I initiated a big file transfer saturating the infrastructure (100mbps) and ping remained unchanged.
Are there special tricks that game developers use to prioritize packet sending? With Winsock, choices seem rather limited.

What would you suggest to achieve lowest latency possible for sending small packets at predefined intervals and have priority over other transfers?


"Lowest latency possible" is whatever you get -- better performance than what you get is "not possible" :-)


Given that you cannot control the internet, you have to accept some amount of latency. The "ping" from L4D2 includes some buffering that can smooth out the jitter that you get when conditions change. To get low jitter (change in latency), you have to buffer, and accept a higher average latency.
[/quote]

So basically, what you're saying is that games do buffer and the ping time displayed is not the real thing? Let's say I want to achieve lowest latency and highest priority on a local LAN. Is the only way by writing something like an NDIS miniport driver or is there a level below Winsock that can be used to achieve higher priority over other traffic?

Thanks!

Share this post


Link to post
Share on other sites
How exactly would you propose to reduce latency?


After you have established the connection, the first major source of latency is the distance traveled. Your program cannot redirect the wires that jump from ISP to ISP and replace it with a physical connection directly to your target.

The second major source of latency is the speed of physical medium (which gets multiplied by distance traveled). Your software cannot replace physical wires with physical beams of light, which are going to be the fastest physical medium you can use.

Another major source of latency is hardware. Your software cannot rewire the cheap high-latency NIC installed on someone's PC that adds 5ms of latency by itself. Your software cannot rewire the ISP's NOC to improve the hardware which is usually very low latency.

Yet another is saturation on the line. Your software cannot control what other people on the Internet are doing.

Another is router prioritization rules. I suppose you could contract with your ISP to get an IP SLA that requires a certain latency to major hubs, but those can be very expensive.


When showing the ping time, they often will take the average of several. The initial message takes a little time to figure out the route, so you always need to disregard the first result used for connection. Next there is natural jitter caused by other traffic and saturation of equipment, so a rolling average is always a good idea.

Was there something else you were planning on doing to reduce latency?

Share this post


Link to post
Share on other sites

How exactly would you propose to reduce latency?


After you have established the connection, the first major source of latency is the distance traveled. Your program cannot redirect the wires that jump from ISP to ISP and replace it with a physical connection directly to your target.

The second major source of latency is the speed of physical medium (which gets multiplied by distance traveled). Your software cannot replace physical wires with physical beams of light, which are going to be the fastest physical medium you can use.

Another major source of latency is hardware. Your software cannot rewire the cheap high-latency NIC installed on someone's PC that adds 5ms of latency by itself. Your software cannot rewire the ISP's NOC to improve the hardware which is usually very low latency.

Yet another is saturation on the line. Your software cannot control what other people on the Internet are doing.

Another is router prioritization rules. I suppose you could contract with your ISP to get an IP SLA that requires a certain latency to major hubs, but those can be very expensive.


When showing the ping time, they often will take the average of several. The initial message takes a little time to figure out the route, so you always need to disregard the first result used for connection. Next there is natural jitter caused by other traffic and saturation of equipment, so a rolling average is always a good idea.

Was there something else you were planning on doing to reduce latency?


Hi,

I'm well aware of the things I cannot change such as latency induced by hardware but with the tests I ran using Winsock, a roundtrip between 2 PCs on local LAN takes ~1ms. This is perfect but the main problem is that this result is highly susceptible to other traffic going on. Isn't there a way to tell Windows: "Hey, this packet is small and it must be sent right now. Put it in front of the FIFO!" so that it leaves the NIC ASAP. With Winsock, I don't think this is possible since this is high level, right?

What I'm wondering is whether it is possible to achieve that at all. I believe it is but it might be more complicated than I would've imagined. This might be off-topic but if anyone knows, would that be possible with a custom NDIS miniport driver? The main objective here is to have my latency unaffected by other traffic (i.e. file transfer over LAN).

Thanks in advance.

Share this post


Link to post
Share on other sites
What if everyone did this? Everyone considers their data to be priority. When everything is prioritised, nothing is prioritised.

Remember, most of the time the user will not be stupid enough to expect to run a time sensitive internet application while also initiating massive file transfers. The more likely situation is that one network user is trying to run a latency sensitive application, and another is doing a bulk transfer.

You cannot solve such social problems with software. You might be able to mess around with the QOS settings on your router, but that would be a specific setup for your specific network, and is not a general solution.


I tried a game of L4D2 and while playing, I initiated a big file transfer saturating the infrastructure (100mbps) and ping remained unchanged.
Are there special tricks that game developers use to prioritize packet sending? With Winsock, choices seem rather limited.
[/quote]
Why not read how Valve does it? It might be sending less data than you think. It is possible that they are using some of the Windows QoS APIs, but I have never used them so I don't know what options they give you.

Share this post


Link to post
Share on other sites

"Hey, this packet is small and it must be sent right now. Put it in front of the FIFO!" so that it leaves the NIC ASAP. With Winsock, I don't think this is possible since this is high level, right?


You may want to look into the "QOS scheduler" for Windows. Some versions of Windows turn this on by default.

However, that still doesn't matter. Most switches put in way too much buffering for your priority to be meaningful. Let's assume there's 50 ms worth of gigabit switching buffering in your network switch. Perhaps your first packet goes out ahead of the big TCP packets, but then the TCP packets go out and fill up the buffer anyway until you send your next packet 10 ms later. At that point, your packet is either blocked, or dropped, because the switch is full, and has to wait 50 ms to drain into the other end.

In fact, too much buffering, and too many parallel download streams, are the two main culprits in Internet performance today, causing both throughput and latency problems. Google "buffer bloat" to see why this is so.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!