|
Since I see a lot of misinformation flying around, here's some brief information about SC2 and how its networking works.
UPDATE: Note that when I refer to latency in this post, I'm meaning network latency over the wire. Starcraft 2 includes a built-in command buffer that also adds input latency to smooth out and jittering or higher ping players - no amount of tweaking will reduce or alter that.
UPDATE 2: After some more research it appears SC2 is routed peer to peer rather than server based. Very disappointing . Irrelevant portions of this thread have been struck through.
UPDATE 3: Most of this thread is no longer relevant as this was written during the beta. The actual release uses UDP for game data so it has no issues with TCP latency.
Architecture Stacraft 2 games run using a server, similar to HoN - not peer to peer as the original BW does. This means that Blizzard is the one hosting the games, not you (note: custom games were not tested). The protocol is TCP, not UDP. I'm unsure why Blizzard decided to go with TCP/IP, since latency is generally worse over TCP especially with regard to lost packets. Perhaps they didn't want to deal with fragmentation or NAT issues?
"Drop hacks" / Lag Since other players also connect to Blizzard's server, not you, there is no way to be "drop hacked" in SC2. Drop hacking involves terminating the connection to the other player via some means - trivial in BW since both players are connected to each other - desynchronize the connection and you get a drop. However in SC2, since you are only connected to Blizzard's server, not the other player, the most you can do is disconnect yourself from the server, causing you to drop. Since the server knows who disconnected, it can award the win to the remaining player.
Note that this does not preclude any bugs in SC2 that might allow someone to purposefully cause a drop condition by sending malformed packets that crash the server (thus dropping everyone), but given the server architecture, drop hacking should not be an issue in SC2 provided the servers are reliable and well-coded.
You may notice there is still the "Waiting for players" screen. Rather than allow the server to continue if one player is lagging, it pauses the game for everyone. This was done out of fairness I imagine, since if someone is lagging it would not be fair for them to have to engage the other players army. Technically there is no reason why the game can't keep going similar to how HoN handles latency where only the player lagging experiences any lag. In theory this should allow a large number of spectators to be in a game without impacting the latency for the players - if a spectator lags, who cares?
Port Forwarding Since Starcraft 2 does not use peer to peer connections, you do not need to open any ports to play nor will doing so "improve" your connection. You connect to Blizzard's server, much like you connect to teamliquid.net every time you click a link - you do not need to open ports for outgoing connections.
Map Hacking Please keep in mind this is not a thread to discuss map hacking in, just some technical commentary. As some people have argued, since SC2 uses a server, it should be possible for the server to eliminate map hacking by only sending unit data for what a player can currently see. Theoretically, this could work - however as many have pointed out, SC2 is a lot more complex than other games such as HoN that do this - in HoN, there is a very small amount of units you have to consider, with only a few of those (heroes) having any particular state. With SC2, there can be hundreds of units, each in many states. If someone moves into your fog of war with hundreds of units that your game doesn't know about, that will result in a large amount of data required to be sent to your client. TCP doesn't burst particularly well, and if one of those packets in the burst is lost, you have a significant delay. There is also spells such as Scan that reveal part of the map immediately on clicking, which the server has no way to predict you using.
While it is technically possible to reduce map hacking with some clever coding and possibly imperceptible latency compromises, this was not done. The technical requirements for such impose a great deal on the latency of the game, and for an RTS latency is extremely important. Which brings me on to...
Improving Latency As I've mentioned, SC2 uses TCP. TCP is designed for data transfer with latency as a secondary consideration to bandwidth, so isn't really ideal for real-time games. Almost every FPS game in existence uses UDP for this reason. TCP requires reliable delivery - if a packet is lost, it has to be retransmitted, stalling the rest of the data while this happens. There is a small tweak you can make to improve TCP responsiveness for gaming.
Change TcpAckFrequency to 1:
How Run registry editor (Start, Run, regedit) and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces. You will see a list of random looking keys, find the one that has the "IPAddress" value that matches your current IP. Right click on the right side and go New -> DWORD. Call it TcpAckFrequency with a value of 1.
Why this works Usually TCP delays sending acknowledgments of received data until either more data has been received OR a timeout period elapses. This timeout period may be because the sending side is waiting for the ack before sending more data. By setting TcpAckFrequency to 1, you send an acknowledgment immediately rather than waiting, preventing miniature "stalls" in the data stream. Note that this WILL reduce your bandwidth, as you will be sending more ack packets, thus using more network resources.
Things that MIGHT help If you use ADSL, your connection may use interleaving which is a method of error resistance that adds latency to your connection. Look in your ADSL modem settings for an option to turn it off. Note that this may increase the chances of line noise affecting your connection, so it might be required to be on. You may need to contact your ISP as it may be something controlled on their side, but don't expect them to be too accommodating.
Wired vs wireless: A properly configured wireless network should have minimal latency, however if you are in a crowded area with obstructions and other 2.4 GHz noise, the latency caused by retransmissions might add up and cause issues. Try pinging your router - your latency should be 1-2ms at most. If not, try a wired connection while gaming.
If you have a low quality wireless card (common in cheap desktop / laptops), you may experience random periods of lag while it switches frequencies for background scanning (used for roaming between access points). You can turn off background scans with a tool such as WlanOptimizer (Vista / 7 only).
Tweaking your RWIN (Windows XP only) may help - see any number of guides online regarding this.
Things that will NOT help There is a huge amount of useless information on the Internet that offers supposedly improved performance. The following will NOT improve your network quality at all: Opening your ports. Changing "TCPNoDelay" registry setting. Changing "NetworkThrottlingIndex" registry setting. Changing "TcpDelAckTicks" registry setting. Disabling "QoS Packet Scheduler". In fact, very few registry tweaks will help - there's usually a good reason defaults are the defaults.
|
|
On March 25 2010 05:00 R1CH wrote: Improving Latency Change TcpAckFrequency to 1: <div style="margin-left: 32px"> How Run registry editor (Start, Run, regedit) and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces. You will see a list of random looking keys, find the one that has the "IPAddress" value that matches your current IP. Right click on the right side and go New -> DWORD. Call it TcpAckFrequency with a value of 1.
Those of us that played wow noticed this a few years ago as well, I went from ~200ms ingame to around 50ms. I do it manually in regedit but for those that are less used to tinker around in the regedit here's a simple program that fixes this for you regardless of win os: http://www.wowinterface.com/downloads/info13581-LeatrixLatencyFix.html
(it has nothing to do with wow, just happens to be hosted on a wow related site)
|
So what exactly does the TCPAckFrequency setting do? Does it have something to do with window size?
Edit: Nvm, you explained it.
|
United States12224 Posts
Great analysis R1CH. Although SC2 uses the "routed peer-to-peer" system, apparently similar to the one that Blizzard touted for War3, it doesn't appear that TcpAckFrequency would have any effect unless every player participating in the game had set it to the same value. Essentially, you're always playing at the speed of the slowest player, because any desyncs or delays call the Waiting for Players screen, right? The more people that know about the regkey, the better, though.
I suppose it's probably too late to expect Blizzard to restructure their netcode around UDP and simply adopt the measures for software port forwarding that War3 included.
|
Wow, thanks R1CH
Edit: TcpAckFrequency should be a hexadecimal value?
|
On March 25 2010 05:17 Excalibur_Z wrote: SC2 uses the "routed peer-to-peer" system. How do you know this? It would seem pretty flawed if this were the case, and make a lot of my points invalid .
|
I'm surprised sc2 uses tcp. That's pretty strange, but I guess the blizzard guys know what they are doing.
|
United States12224 Posts
On March 25 2010 05:19 R1CH wrote:Show nested quote +On March 25 2010 05:17 Excalibur_Z wrote: SC2 uses the "routed peer-to-peer" system. How do you know this? It would seem pretty flawed if this were the case, and make a lot of my points invalid .
Isn't that basically what you described though? Player A sends data to the server which is then sent to Players B and C, Player B sends data to the server which is then sent to Players A and C, and so forth. That is the War3 routed peer-to-peer system that Blizzard championed. I use that in quotes for SC2 because on the surface it appears quite similar, but of course it may not be.
EDIT: Although I suppose from that vague description I described what could be either routed peer-to-peer or client/server =/ Regardless, my initial question stands: wouldn't this only have an impact if every player enabled it?
|
Nice write-up. I tested the custom games and they are also routed through the server. I may also add one thing on how you can improve your latency: By getting a good add-in NIC. Best ones are the Intels: Intel PRO/1000 MT or GT(old versions) or the newer Intel PRO/1000 CT, they are very good and cheap NICs, under $30. Here are same reviews comparing it with integrated NICs:
http://forum.ncix.com/forums/topic.php?id=1304406 http://www.donutey.com/intelpro.php
Note that the Integrated NICs are evolving and difference is getting narrower but its still good to get one especially if you want to game and torrent at the same time.
|
On March 25 2010 05:26 Excalibur_Z wrote: EDIT: Although I suppose from that vague description I described what could be either routed peer-to-peer or client/server =/ Regardless, my initial question stands: wouldn't this only have an impact if every player enabled it? If it was indeed a routed P2P rather than client/server, it would indeed minimize the benefit, but it wouldn't be completely worthless since assuming both sides are data starved the same amount of time, you reduce it 50% by "fixing" it on your end.
|
On March 25 2010 05:28 Manaldski wrote:Nice write-up. I tested the custom games and they are also routed through the server. I may also add one thing on how you can improve your latency: By getting a good add-in NIC. Best ones are the Intels: Intel PRO/1000 MT or GT(old versions) or the newer Intel PRO/1000 CT, they are very good and cheap NICs, under $30. Here are same reviews comparing it with integrated NICs: http://forum.ncix.com/forums/topic.php?id=1304406http://www.donutey.com/intelpro.phpNote that the Integrated NICs are evolving and difference is getting narrower but its still good to get one especially if you want to game and torrent at the same time.
That's an interesting review, I've always thought that any NIC was enough for gaming, but there are some interesting results in that review.
|
On March 25 2010 05:28 Manaldski wrote: I may also add one thing on how you can improve your latency: By getting a good add-in NIC. Best ones are the Intels: Intel PRO/1000 MT or GT(old versions) or the newer Intel PRO/1000 CT, they are very good and cheap NICs, under $30. Here are same reviews comparing it with integrated NICs: Gonna have to disagree there, at the data rates most games use there is very little benefit to offloading. Even in the article you linked the only benefit was when maxing the connection with a torrent, and torrents are wildly erratic in speeds to begin with so I don't consider that a valid test. In any case it isn't a realistic scenario where you'd be gaming with large downloads going on in the background.
The only issue where a NIC really comes into play regarding latency is when running a server, where the amount of outgoing data begins to affect latency based on the link speed - eg 100mbps vs 1gbps. At 100mbps, you have 13107bytes/ms throughput vs 131070bytes/ms. Depending on the number of games, players, etc all hosted on the same server, this can begin to add up.
|
awesome post, i think you nailed it. BW used to have servers though back in the day, i remember all those server splits and stuff and i could always join anybody's games. It was probably more cost effective after a certain number of years to get rid of them and make it the way it is now.
|
Awsum, I wish I knew jack shit about networking =)
|
Canada1218 Posts
Really informative. Thanks for taking the time to explain all this!
|
Awesome post R1CH, thanks!
Improving Latency + Show Spoiler +As I've mentioned, SC2 uses TCP. TCP is designed for data transfer with latency as a secondary consideration to bandwidth, so isn't really ideal for real-time games. Almost every FPS game in existence uses UDP for this reason. TCP requires reliable delivery - if a packet is lost, it has to be retransmitted, stalling the rest of the data while this happens. There is a small tweak you can make to improve TCP responsiveness for gaming.
Change TcpAckFrequency to 1:
How Run registry editor (Start, Run, regedit) and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces. You will see a list of random looking keys, find the one that has the "IPAddress" value that matches your current IP. Right click on the right side and go New -> DWORD. Call it TcpAckFrequency with a value of 1.
Why this works Usually TCP delays sending acknowledgments of received data until either more data has been received OR a timeout period elapses. This timeout period may be because the sending side is waiting for the ack before sending more data. By setting TcpAckFrequency to 1, you send an acknowledgment immediately rather than waiting, preventing miniature "stalls" in the data stream. Note that this WILL reduce your bandwidth, as you will be sending more ack packets, thus using more network resources. I just want to attach a link for the curious: http://en.wikipedia.org/wiki/Nagle's_algorithm
I've always thought that any NIC was enough for gaming, but there are some interesting results in that review. Yeah i've seen some pretty amazing results from gaming NIC's before. But honestly? I dont believe it for a second. Your ISP's peering and infrastructure is so much more important than the last router->PC connection. But hey, stranger things have happend. Someone sponsor me a gaming NIC so i can check for myself =P
Things that MIGHT help If you use ADSL, your connection may use interleaving which is a method of error resistance that adds latency to your connection. I dont know about other countries, but where i live this option is not available directly for the end-user. However, a lot of ISP's will enable/disable fast interleave if you specificly request it.
Edit: Should read posts better. You pretty much already covered what i said about interleaving.
|
Good post R1CH, I had changed TcpAckFrequency on my previous install but had forgotten about it after reinstalling recently.
|
wowowow thanks for the info!!
|
Thanks R1CH, I just did this and I am testing to see if I did it right. My IP address wasn't listed (just the one from my home router, not the one at college) so I used the old one. It was the only IPAddress file that had a number as well.
|
|
|
|