Post feature RSS About Starcraft networking model

Starcaft is the most popular RTS of all time. Just recently I got into an discussion on how StarCraft implements networking. We where talking about two types of networking which are lock step networking model and server correcting model. Here i will describe now starcaft networking model works.

Posted by on


About Starcraft networking model

Starcaft is the most popular RTS of all time. It might not be the best but it is the most popular. Just recently I got into an discussion on how StarCraft implements networking. We where talking about two types of networking which are lock step networking model and server correcting model.
In lock step model every thing happens on all the clients at once and only the client commands player commands are exchanged between the players. This requires 100% deterministic simulaiton so that each client simulates the game exactly the same.
In the server correcting model the clients also try to simulate the game world. But they dont have to be exact. Some clients can use GPU for physics while other use CPU. Some clients might not even have access to the whole game state just what server gives them. Server periodically corrects the clients.
Starcarft definilty uses lock step model of networking.
Starcarft packets are devided into 2 main groups. The Command1 group and the Command2 group. Command1 groups packets consurned with joning or leaving the game while Command2 group conserns what happens during the game.

Command Group 1

Each command one packets stars with a Command1 packet header. This includes checksum to verify the packet is correct. Thats odd considering the network software/hardware allready should do that for you even when you are using UDP. Then it also contains flags to verify and resend lost packets. Does not appears that there is a notion of unimportant packets - probably no need to sence this is using lock step model. Then it has sent and recive counters - so that packets stay in order. The flags and ordering combined nicly make the packet lossless TCP type connection work over UDP.
The commands in this group includes Join Requests, Ping, Pick Player position, team, and race, Get Game state, Get Map and Map options, and some Leave Messages.
The random seed is also generate at game start. Even though random numbers are random they sequance they come in is not. And this sequance is picket at game start and is used for the duraction of the game.

Command Group 2

This command group is more interesting because its wher the real time messages happen. They are very simmilar to the command 1 group. The messages are sent about 4 a second. Avg time between messages is not quite 250ms but is 219ms probably because the speed constant is easy to tweek. The interesting thing is that every time step a command group 2 packet is sent. Each command group 2 packet contains N sub packets or a special NULL packet if there isn't any. This is how starcaft knows when to start a new simulation turn I guess when it has gotten all packets for that time step from all connected clients.
The type sub packets are alot like what 2aw has. There is player selected units packet and a player selected units to add. Kind of odd considering you can selecte up to 12 units any ways.
The is order packet which is used for all the orders. There is lots of different orders in starcaft even if you dont reaise it.
Then there is a lot of packets which just active deactivate abilities. I find this odd because there is ton of abilities in starcaft and i would have though that having just use ability and stop ability with and ability ID inside the order would have been enough. If they wanted to optimize and move the ability ID into the space of packets why didn't they do that for orders too?
There is no order queques in starcaft. Some thing that was one of the 1st features to make it in 2aw because i love it so much.
There is also some messages commands - interesting to note that both command1 and command2 has sending message packet, one in the game lobby and one in game. Its interesting that game lobby is handled by the local game server rather then the battle net lobby - which I would have though be more logical.
Note there is no unit positions, health, or stats updates ever. Even when they get build or die. Only what player clicks and orders - that is because using lock step networking model all of that can be derived.

RTS Networking

Talking about RTS networking always deserves a metnio of the "1,500 Archers" paper about networking in Age of Empires. It looks like starcaft does it nearly the same. I wonder what the modern RTS like SupCom, WC3, Wic, and SoSE doe for networking. Do they jump on flexibity of server correcting model or do they still stick with tried and true lock stepping model.
Comments
Draco1985
Draco1985

Now, that was a very interesting set of facts. I do admit, I was really surprised to read some of it, e.g. the lack of updates on unit health, etc. but it's true, you don't really need them if you think about it.

Though I know my way around rather basic programming, I'm more a gamer than a coder, so I take this more as "nice to know" than as a base for really productive work. So thanks for the insight.

Reply Good karma Bad karma+1 vote
Xanthor
Xanthor

as far as I know SupCom uses lock stepping, there is no server in a SupCom game it is peer to peer (as far as I know mind you)

Reply Good karma Bad karma+1 vote
treeform Author
treeform

Yes it is. Thats how most RTSes are structured.

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Feature
Tags
Feature
Browse
Features
Share
Related Games
Related Engines
Panda3d
Panda3d BSD