System link networking in XNA Game Studio 2.0

Originally posted to Shawn Hargreaves Blog on MSDN, Wednesday, November 21, 2007

So, the 2.0 beta is out...

If you are wanting to try out our shiny new network API, you may be waiting to be emailed the code which unlocks access to Games for Windows - LIVE. But did you know:

Local profiles are easy and free to create. After you add the GamerServicesComponent to your game, just press the Home key to bring up the Guide, then create a new profile. When it asks if you want to join LIVE, cancel that screen. Tada! You now have a local profile, and you can make many of these on as many computers as you like.

Local profiles cannot create or join LIVE PlayerMatch sessions, but they work just fine for system link. I normally test my games using system link between my Xbox and PC, but if you have more than one computer you can use PC to PC system link as well.

If you have previously done LIVE programming using the native API, you are probably thinking "hmm, but system link and LIVE are pretty different. How is testing using one going to make sure my game works with the other?". The answer is that we did a lot of work in the XNA Framework to make sure system link and LIVE sessions will behave exactly the same. For instance we added some code in our system link session discovery layer which exactly emulates the behavior of the LIVE matchmaking servers.

In fact, you should only see three differences between system link and LIVE sessions:

  1. System link works with local profiles, while LIVE requires a Gold account and Creators Club subscription.
  2. System link only works over a local subnet, while LIVE works over the Internet.
  3. Because they are only exchanging packets over a local network, system link sessions will see very low latency and packet loss compared to playing over the Internet.

Difference #3 is the main thing that affects testing of your game, so we built in a solution for this, too:

    NetworkSession.SimulatedLatency = TimeSpan.FromMilliseconds(200); 
    NetworkSession.SimulatedPacketLoss = 0.1f;

This will simulate the worst network conditions you are likely to encounter out in the wilds of the Internet. Just make sure you remember to turn the simulation off when you finish testing!

Blog index   -   Back to my homepage