David Whitney

 

XBox Live Connection Bug - Live won’t automatically connect until you perform a network test

November 19th, 2008

I’m not sure if the XBox live team have an official bug reporting mechanism, so I’ll put this post here in the interim and hopefully a search engine or two will pick up on it.

This has no bearing on the NXE that launched today, I’ve just coincidently solved the problem.

Symptoms

XBox 360 fails to automatically connect to xbox live after power on.  If you then go and perform a network test, it’ll succeed.  Following this, live will connect fine until you power off the xbox for a time greater than a minute or two.

Cause

There appears to be a bug in the code that deals with manual network configuration of the xbox 360.  If you manually assign the console an IP address and then manually assign a DNS server but leave the DNS server discovery setting to automatic, the xbox fails to do a DNS lookup, either automatically or manually, on system startup.

Solution

If you manually assign an IP address and DNS server, ensure that the DNS lookup mode is also set to manual.

I have no idea why the console lets you configure a DNS server and then gives you the choice to use it or not, I’d have thought it’d be one or the other, and it’s a very easy mistake to make and quite tricky to diagnose.

Peer to peer networking using Windows Communication Foundation (WCF) Peer Channels and the Peer Mesh (C# .Net)

November 17th, 2008

What Is P2P?

Peer to peer communication became somewhat notorious through its use in the sharing of materials of dubious origins online.  File sharing networks like Napster, eDonkey and Kazaa made use of decentralised peer to peer communication, but there’s far more to peer to peer networking than file sharing.  Essentially, Peer to peer is a method of exchanging data between two points, without the use of a central server.  Wikipedia description here (makes for good reading).

Uses For P2P

Peer to peer networking is a great way to build decoupled message-based distributed systems.  It’s a great way of sharing the available amount of bandwidth between a series of nodes effectively, and it’s a great way to produce push-based systems.

Some obvious simple uses of p2p communication would be file sharing networks, chat networks, or large file distribution networks (e.g. Valve Software’s’ Steam platform).

In business, I’ve implemented p2p in place of solutions that were traditionally patched together using email (small notification clients that monitor other applications that send peer messages being a specific example) and p2p is ideal for these kinds of usages.

Reliability

P2P differs from traditional sockets programming in the way that it isn’t deemed a reliable communication channel.  Without your own additional logic the messages you send cannot be guaranteed to arrive, nor should they be, as peer communication is built around a “fire and forget” model.  When designing applications that use p2p, it’s important that you deal with failure conditions and program defensively.  Presume messages will be lost, however unlikely that is to actually happen.

P2P in .NET 3.0/5 - The WCF Peer Channel

In .Net 3.0, Microsoft introduced the Windows Communication Foundation, a new unified communications model for .Net developers.  The WCF Peer Channel was provided with the first release of WCF for developers to use.  The WCF Peer channel is quite easy to understand as an abstraction.  It features two main components; the peer resolver and peer participants.

The Peer Resolver

The peer resolver is the registration server for the mesh.  Whilst in principle p2p is decentralised, there needs to be a known address which a new node uses to connect to other peers.  The resolver keeps track of all node registrations, when a node connects, the resolver supplies the new node with the peer addresses of its nearest neighbours.  The node maintains an internal database of nodes, and (implementation dependant) often requires nodes to phone home at a set interval in order to advertise their membership of the mesh.

Participants

Each and every node on the mesh is a participant.  In traditional sockets programming there’s a very strong concept of connected and disconnected; not so with p2p connections.  A participant is online if it can “see” other nodes.  A participant joins the network by registering with a resolver.  The resolver then supplies the participant with a number of peer addresses that the participant then attempts to establish connections to.  When peers are found, they exchange and relay messages across the mesh.

Working examples

The rest of this piece is concerned with implementing a peer to peer network in C#, along with providing some useful helper libraries, some tests and a production-ready peer resolver.

The Persistent Peer Mesh Resolver

The Microsoft SDK provides a basic peer mesh resolver example.  Unfortunately, this resolver is stateless and as such if the resolver is restarted or crashes for any reason it looses its registration database which leads to something akin to an IRC net split if peers register with the resolver before and after a restart.  I’ve extended the default Customer Peer Mesh Resolver so that it backs up its registration database to disk and reloads any active node registrations on restart.

The bulk of the work is done by the PersistentCustomResolver class.  It’s accessible only as a thread safe singleton and manages the instantiation of a StatefulResolverService (which is an extended instance of CustomPeerResolverService from System.ServiceModel.PeerResolvers) and deals with opening a WCF endpoint for listening for new peer registrations.  The StatefulResolverService manages a PersistingRegistrationCache which backs up new peer registrations when they occur or are refreshed.

The Persistent peer mesh resolver can ultimately be used very simply in either a Windows service or a stand alone application.

Usage example:

    class Program
    {
        public static void Main()
        {
            PersistentCustomResolver.Instance.Listen();

            Console.WriteLine(”Custom resolver service is started”);
            Console.WriteLine(”CleanupInterval: {0}”, PersistentCustomResolver.Instance.CleanupInterval);
            Console.WriteLine(”RefreshInterval: {0}”, PersistentCustomResolver.Instance.RefreshInterval);

            Console.WriteLine(”Press <ENTER> to terminate service”);
            Console.ReadLine();

            PersistentCustomResolver.Instance.StopListening();
        }
    }

The resolver has two public properties, one of them (CleanupInterval) defines the length of time between the purging of inactive nodes, and the other (RefreshInterval) defines time period in which the resolver expects that active nodes will refresh their registration information.

In addition to the simple usages example above, a not insignificant amount of WCF configuration has to take place in App.config in order to allow the framework to listen correctly.

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <configuration>
      <system.serviceModel>
        <services>
          <service name=”Resolver.StatefulResolverService”>
            <host>
              <baseAddresses>
                <add baseAddress=”net.tcp://localhost/peerResolverService” />
              </baseAddresses>
            </host>
            <endpoint address=”net.tcp://localhost/peerResolverService”
                      binding=”netTcpBinding”
                      bindingConfiguration=”PeerResolverBinding”
                      contract=”System.ServiceModel.PeerResolvers.IPeerResolverContract” />
          </service>
        </services>
        <bindings>
          <netTcpBinding>
            <binding name=”PeerResolverBinding”
                     transferMode=”Buffered”
                     transactionProtocol=”OleTransactions”
                     hostNameComparisonMode=”StrongWildcard”
                     closeTimeout=”00:01:00″
                     openTimeout=”00:01:00″
                     receiveTimeout=”00:10:00″
                     sendTimeout=”00:10:00″
                     transactionFlow=”false”
                     maxBufferPoolSize=”50000000″
                     maxBufferSize=”268435455″
                     maxReceivedMessageSize=”268435455″
                     maxConnections=”10000″
                     >
              <readerQuotas
                maxDepth=”50000000″
                maxStringContentLength=”50000000″
                maxArrayLength=”50000000″
                maxBytesPerRead=”50000000″
                maxNameTableCharCount=”50000000″
              />
              <security mode=”None”/>
            </binding>
          </netTcpBinding>
        </bindings>
      </system.serviceModel>
    </configuration>

The above configuration tells the resolver to listen using the endpoint net.tcp://localhost/peerResolverService using the standard peer resolver contract.  Participants will need to be aware of this endpoint to register on the mesh.  The net.tcp binding configuration has some very large configuration values set that would likely be revised for a production system.

Joining a Peer Mesh

Connecting to a peer mesh requires two things; an active peer mesh connection, and a peer message processor.  The peer connection acts as the communication channel and the message processor instance responds to any peer events received on that connection.  I’ve encapsulated this into the class PeerMeshManager.  The PeerMeshManager class simplifies joining a mesh, leaving a mesh, and sending a message to the mesh.  It’s left to the individual implementation to instantiate a Message processor and set the public property of the PeerMeshManager appropriately, allowing the application to respond to events on the mesh.  See the following example:

    Console.Write(”Connecting to Peer Mesh…”);

    PeerMessageProcessor messageProcessor = new PeerMessageProcessor();
    messageProcessor.PeerEventRaised += messageProcessor_PeerEventRaised;
    PeerMeshManager.Instance.MessageProcessor = messageProcessor;
    PeerMeshManager.Instance.ConnectedToPeers += Instance_ConnectedToPeers;
    PeerMeshManager.Instance.DisconnectedFromPeers += Instance_DisconnectedFromPeers;
    PeerMeshManager.Instance.JoinNetwork();

The PeerMessageProcessor makes a handful of events available to the application:

    public event PeerEventHandler PeerEventRaised;
    public event UnhandledPeerEventHandler UnhandledPeerEventRaised;

    public event ConnectedHandler ConnectedPeerEventRaised;
    public event DisconnectedHandler DisconnectedPeerEventRaised;
    public event RequestPeerAnnounceHandler RequestPeerAnnouncePeerEventRaised;

The first two events are the more interesting…

  • For each peer message that is sent, PeerEventRaised will be fired.
  • If an even of a specific type is fired (say ConnectedPeerEventRaised) and there is no listener wired up to ConnectedPeerEventRaised, then UnhandledPeerEventRaised will fire for that event.
  • The specific event handlers will fire if a peer event of that type occurs on the mesh.

If you were to expand the provided source code with your own peer events, I’d recommend adding custom events for each peer event, and maintaining the above pattern (always fire a PeerEventRaised event, for every event, regardless, always fire a specific event, and always fall back to firing an UnhandledPeerEventRaised event) for consistency.

I’ve provided a few helper classes that the PeerMeshConnection uses, however I’ll skip explaining them in full.  I’ve provided two working peer applications that talk to each other.  One is a listener that listens and outputs peer messages, the other sends them in bulk.  Feel free to experiment.  The sample listener looks like this:

    class Program
    {
        static void Main()
        {
            Console.Write(”Connecting to Peer Mesh…”);

            var messageProcessor = new PeerMessageProcessor();
            messageProcessor.PeerEventRaised += messageProcessor_PeerEventRaised;
            PeerMeshManager.Instance.MessageProcessor = messageProcessor;
            PeerMeshManager.Instance.ConnectedToPeers += Instance_ConnectedToPeers;
            PeerMeshManager.Instance.DisconnectedFromPeers += Instance_DisconnectedFromPeers;
            PeerMeshManager.Instance.JoinNetwork();

            Console.Write(”Done.”);

            Console.ReadLine();
        }

        private static int _recievedCount = 0;
        static void messageProcessor_PeerEventRaised(PeerEvent e)
        {
            Console.Clear();
            Console.WriteLine(”Rcvd {0} messages.”, _recievedCount);
            Console.WriteLine(”Recieved: {0}”, e.UniqueIdentifier);
            Console.WriteLine(”App: {0}”, e.Application);
            Console.WriteLine(”From: {0}”, e.UserId);
            Console.WriteLine(”At: {0})”, e.Timestamp);
            _recievedCount++;
        }

        private static void Instance_ConnectedToPeers(object sender, EventArgs e)
        {
            Console.WriteLine(”Connected to peers.”);
        }

        private static void Instance_DisconnectedFromPeers(object sender, EventArgs e)
        {
            Console.WriteLine(”Disconnected from peers.”);
        }       
    }

and requires the configuration…

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <configuration>

        <system.serviceModel>

          <client>
             <!– chat instance participating in the mesh –>
             <endpoint name=”eclipseEndpoint”
                       address=”net.p2p://eclipseMeshTest/messages”
                       binding=”netPeerTcpBinding”
                       bindingConfiguration=”BindingCustomResolver”
                       contract=”PeerMesh2008.IPeerMessageProcessor”>
             </endpoint>
             <!– client used to communicate with the custom resolver service –>
             <endpoint name=”CustomPeerResolverEndpoint”
                       address=”net.tcp://localhost/peerResolverService”
                       binding=”netTcpBinding”
                       bindingConfiguration=”Binding3″
                       contract=”Microsoft.ServiceModel.Samples.ICustomPeerResolver”>
             </endpoint>
          </client>

          <bindings>
             <netPeerTcpBinding>
                <!– Refer to Peer channel security samples on how to configure netPeerTcpBinding for security –>
                <binding name=”BindingCustomResolver” port=”0″>
                  <security mode=”None” />
                  <resolver mode=”Custom”>
                    <custom address = “net.tcp://localhost/peerResolverService”
                                    binding=”netTcpBinding”
                                    bindingConfiguration=”Binding3″ />
                  </resolver>
              </binding>
               <binding name=”BindingDefault” port=”0″>
                 <security mode=”None”/>
                 <resolver mode=”Auto”/>            
               </binding>
             </netPeerTcpBinding>

             <netTcpBinding>
                <!– You can change security mode to enable security –>
                <binding name=”Binding3″>
                    <security mode=”None”/>
                </binding>
             </netTcpBinding>
          </bindings>

       </system.serviceModel>

    </configuration>

This configuration should allow the application to register with the persistent resolver provided and join a mesh.

The second application requires exactly the same configuration and looks like this:

    class Program
    {
        static void Main()
        {
            Console.Write(”Connecting to Peer Mesh…”);

            PeerMessageProcessor messageProcessor = new PeerMessageProcessor();
            messageProcessor.PeerEventRaised += messageProcessor_PeerEventRaised;
            PeerMeshManager.Instance.MessageProcessor = messageProcessor;
            PeerMeshManager.Instance.ConnectedToPeers += Instance_ConnectedToPeers;
            PeerMeshManager.Instance.DisconnectedFromPeers += Instance_DisconnectedFromPeers;
            PeerMeshManager.Instance.JoinNetwork();
            string input = “y”;
            while(input.ToLower()!=”n”)
            {
                DoMessages();
                Console.WriteLine(”Send messages? (Y/N)”);
                input = Console.ReadLine();

                if(string.IsNullOrEmpty(input))
                {
                    input = “y”;
                }
            }

            Console.ReadLine();
        }
        private static void Instance_ConnectedToPeers(object sender, EventArgs e)
        {
            Console.WriteLine(”Connected to peers.”);
        }

        private static void Instance_DisconnectedFromPeers(object sender, EventArgs e)
        {
            Console.WriteLine(”Disconnected from peers.”);
        }

        private static int _recievedCount = 0;
        static void messageProcessor_PeerEventRaised(PeerEvent e)
        {
            //Console.WriteLine(”Recieved: {0} from: {1}”, e.UniqueIdentifier, e.UserId);
            _recievedCount++;
        }

        private static void DoMessages()
        {
            const int defaultNumberOfMessages = 1000;

            Console.Write(”Done.”);
            Console.WriteLine();
            Console.Write(”Number of messages to send (defaults to {0})? “, defaultNumberOfMessages);
            string upperString = Console.ReadLine();

            if (string.IsNullOrEmpty(upperString))
            {
                upperString = defaultNumberOfMessages.ToString();
            }

            int upper = Int32.Parse(upperString);

            Console.WriteLine(”Sending {0} messages…”, upper);

            for (int i = 1; i <= upper; i++)
            {
                var peerEvent = new PeerEvent();
                PeerMeshManager.Instance.SendMessage(peerEvent);
                //Console.WriteLine(”Sent: {0}, GUID: {1}”, i, peerEvent.UniqueIdentifier);
            }

            Console.WriteLine(”Sent {0} messages.”, upper);
            Console.WriteLine(”Rcvd {0} messages.”, _recievedCount);
        }

In order to run the provided code, you need .Net 3.0+ (I’d recommend 3.5 SP1).  First, compile and run the resolver and leave it running.  Then run the listener application, followed by the PeerMesh sample application.  You should (firewall permitting) be able to send messages in bulk between the two applications over the peer channel.  For further tests, you could run the peer clients on different machines (remembering to change the localhost address in the app.config for the resolver) or multiple instances of the client on one/many machines.

I’ve also provided an additional project containing MbUnit tests for the persistent resolver.  They’re not required to use the samples, so feel free to remove the project if you’re having build issues.

I’ll hopefully follow up this post with a larger explanation of the classes that underpin the PeerMeshConnection in the participant, but a working example now is likely more valuable the further exposition!

I apologise for any slightly ambiguous explanations given above, this post is here to serve as a little bit of a brain dump on WCF P2P, especially as the available resources online are alarmingly slim and without useful examples.

DOWNLOAD EXAMPLE SOLUTION HERE

Do Good Things (Fable II)

October 30th, 2008

This (well last) weeks chosen game purchase was Fable II (apologies to Dead Space and Far Cry 2, I’ll probably skip on the former for the time being and get to the latter over Christmas).  I’ve been quietly hopeful about how good Fable was going to be since the first pieces of concept art of the castle in Barrowstone made their way on to the internet (how shallow of me), and unlike the unfaltering critics of the world, I’ve been pleasantly surprised by the game.

I didn’t really take to the first Fable.  It felt far too empty, framed in the context of having recently played through Planescape: Torment (late at the time) Fable managed to get far too much arcade in my RPG.  I didn’t take to it and I gave up pretty early on.  The world wasn’t big enough, it felt too linear, it felt very simple and really it wasn’t much of a roll playing game.  You didn’t play a role, you played an archetype and there really wasn’t too much of you in the character.

I then played World of Warcraft for almost three years.

Funny how that taints the way you look at games before and after, because this time when I came to play Fable II, I adored the lengths they went to to put the arcade back in to my tedious RPGs.  Mass Effect did it last year by putting a story that I was interested in back in there and Fable II apparently did it with mini-games.  I think that this time I’m enjoying Fable for what its meant to be.  It’s brought out the Warcraft inspired power gamer in me, but alarmingly, the grinds in the game somehow remain fun (I’m looking at you, tedious manual labour jobs), the world, while lighthearted enough, feels like it has some depth and the whole package looks beautiful.

My only problem with Fable II is that the morality system feels broken.  See, when I do action/adventure/RPG-with–choice type games, I always like to play the equivalent of a paladin first time around.  Not the literal paladin class, but the “for the greater good” brooding hero type.  You know the one, most games force you to play the roll, and it always feels like the ones that don’t hope you’re going to anyway.  I guess I feel like it’s my way of pandering to the game designers.  I have no desire to be a software tester, and if the game is geared towards that character type, I tend to feel quite fulfilled playing it.  The story (where applicable) tends to feel like it works well, and you get to travel through the hero’s journey and a good time is had by all.

So I started playing Fable II with the motivation of “being as good as naturally possible”.  I was nice to everyone, spent about 3 hours emoting around town pleasing the comedicly fickle folk and spent about an hour working for the blacksmith.  I started my (currently expanding) property empire and was having a great time.  Everybody loved me.  And I really mean everybody, the villagers started following me like zombies who seemingly had nothing better to do than follow me around begging for marriage / sex / my babies / a roll in the hey and my suspension of believe was totally broken.

It appears I’d been too good.  I couldn’t really do any wrong at all.  I took a (lesbian) wife, I bought us a modest house, yet the villagers still came.  I had extramarital sex with a village in my marital house with my wife in the room.  Still adores me?  Yep.  I went into the middle of town and was very nasty to lots and lots of people.  Everyone still wanted to make out?  Sure.

I backtracked to the starting village, married a man and had a kid.  Everyone was still very happy.  Bought the entire town up and they loved me even more.  I’ve stopped short of driving the town into financial ruin for the amusement value but I feel like I’ve almost ruined the game for myself by being too good.  It seems that while the game design actively encourages you to go one way or another (despite offering a sliding scale of corruption you’re allowed whilst still being good or evil) it really doesn’t know what to do with you when you get there, and really it made me realise that Fable II failed with me in exactly the same way Fable did.  I felt disconnected from the game and the character I was supposed to inhabit and no stupid (if well programmed) virtual dog (I’m a cat person) was going to keep me there.

I love Mass Effect for the sense of morality actually having impact, and I hope Biowares recent mumbling’s about trying to maintain that sense of moral responsibility in the upcoming Old Republic game comes to fruition.  I think Lionhead need to realise that good and evil isn’t just a smile/dance or fart/angry emote before they’ll get the solid emotional connection they seem to have been aiming for since Black and White.

That said, I’m really enjoying Fable II, I’ve hardly touched on the plot and spent four full evenings engrossed in its world, being a good and righteous happy capitalist.  My property empire will be the envy of all the land and I really think they’ve got the action / RPG balance spot on this time.

Now Playing: Ulver - Lyckantropen Themes - NOFVJ0224090

Toteninsel

October 20th, 2008

One of a couple of projects I have on the go at the moment is a large digital painting.  I work exceptionally slowly when producing anything vaguely creative, but I’m quite pleased with how far it’s come currently.  A little bit of this is placeholder, and this is only a preview of the top half of the illustration.  The lower half is currently mostly white, and will likely be mirrored from the top (i.e. the lower half is upside down).

It’s a little bit cooperative, being based around a piece of music currently being demo’d by King Venus (plug).  A companion piece really, illustration influenced by audio influenced by a series of well known paintings of the Isle of the Dead.

Anyhow, I work very slowly, and slowly working on this is currently my idea of relaxation, so I should be done with it by about 2020.  I jest, hopefully in the next few weeks I’ll be comfortable enough with the lower half of the image (this is the second take on the whole thing as it is).

toten-top-preview

Click it for an ever so slightly larger version (the full size thing should be somewhere in the region of 1920×1080, which is a joy to work on on those monitors I picked up not so long ago).

Losing Direction, Or Why I Don’t Understand Little Big Planet

October 20th, 2008

I’m a pretty big fan of sandbox games.  Always have been.

I was the kid that enjoyed flying around in Magic Carpet but couldn’t stand the combat (1994 me just wasn’t that interested in the quirks of early FPS aiming I guess), the kid that loved pretending that the over-world of Zelda games was infinite and I just hadn’t quite got round to checking out its extremities and I still remember my infatuation with the demo of Grand Theft Auto in 1997 (it was time limited and felt vastly different to the finished game, the change of pace changed the gameplay mechanic).  I love the sandbox, I adore Morrowind (and to a lesser degree, Oblivion), I loved killing time running about the levels of Mario 64, I loved the original Tomb Raider, Nights, anything that gives me impression that the world is infinite and worth exploring, it’s what draws me to MMOs.

With all that said, I’m not really sure about the upcoming PlayStation3 game Little Big Planet.  It’s an interesting predicament, because if anything it appear that the game is the epitome of sandbox gameplay.  A physics based platformer that…. Now here’s the thing.  I’m not really sure what Little Big Planet is really about.  I’ve read the hype (and oh god has there been hype), I’ve watched tons of videos from the (almost public) beta, but I really don’t understand what they’re trying to do with the game.  I understand that there’s a single player “story mode” that’s about 50 levels long (so we’re talking Super Mario World-esq), and I understand that the rest of the game is based around level creation and sharing, but honestly?  I just don’t get it.  I don’t think it’ll work.

As a long time PC gamer, the replayability of many of my favourite games (notably early online FPS games like Quake and Tribes, and RTS titles like the original Total Annihilation) was made by the community of hardcore devotees spending seemingly all of their free time developing mod’s and add-on’s, but I get the feeling that that kind of attitude to interactive game design has slipped by the wayside as the barrier to entry has risen.  We’ve moved from a point where the tools and the inclination for homebrew modding was there, to a world where the tools vanished, and as a result, the inclination to produce a polished add-on for a game seems to have died with them.  The PC homebrew crowd had and still has a little bit of that us-against-the-world mentality that made homebrew development so fun.

So what’re they doing with Little Big Planet?  They’re placing the tools and the caring sharing attitude right into the hands of the players.  Excellent!  I love that.  But do people really care anymore?  The 2008 console market is a vastly different place from the homebrew lands of mid-90s bedroom coding, so I’d imagine it’ll be more difficult to get gamers enthusiastic, however, creation is addictive so they’ll capture an audience that way.  Once we’re at this point however, I’m just not really sure that people will really want to play a bunch of largely mediocre 2d platform traversing levels.  I’m sure someone will do something amazing, I’ve seen some really interesting proof of concept stuff (the shadow of the colossus level that was doing the rounds a week or two ago springs to mind) however I’ve not really seen anything I’d describe as breathtaking.  Sure it’s a bit quirky and cool, but is it actually a great, compelling game?  Recent experiences with games that are based largely around user created content haven’t exactly been positive (I’m looking at you Second Life, barely a game…).

Maybe I’m missing the point.  I love 2d platform games for what they are, I’m just not sure that a game focused around disjointed downloadable experiences without any kind of special mechanic or cohesive body is really as compelling as it used to be.  I can’t see how LBP can stand up to games like Braid (as an obvious example), which actually offered something compelling and new to the genre.  Braid succeeded not because it was a platformer, but because it was clever and featured compelling narrative.  The big success stories of the last few generations of gaming (in my mind at least) have been the ones that introduce interesting narrative, the Mass Effects, the Fahrenheits / Indigo Prophecies (the first half of at least), The Longest Journeys.

I can see the joy in LBP revolving around its simplicity.  It’s a great looking game for sure, and maybe the distilled Micro Machines style fun of a console level creator are something that’s been missing from the casual market for long enough for it to be massive, but I just don’t really see the justification for the hype at the end of the day.

I hope people care enough to create something brilliant inside the sandbox Little Big Planet gives them, but I think I’ll sit on the fence until I see something really great happen before being drawn in by the hype of this one.

————–

As a side note, I’m working on a full sample implementation of Peer to peer networking in C# .NET 3.0+ that should be done in the next few days.

Information on how to correctly use the WCF PeerChannel in an Enterprise environment seems really lacklustre and we’ve been fighting our way to a really practical implementation at work.  I should have some sample code ready in a week or so with any luck.  We’re currently using similar code as the core of a distributed, push-based system in production, and whilst it’s had it’s quirks, they’re being ironed out in the sample.

Suffering so you don’t have to!

Protecting Your Software - Authorisation and You

September 30th, 2008

Piracy is always a big issue in the software industry.  It’s a global epidemic and everyone is guilty of it.  You are too, and you know it.  That doesn’t make you evil, it just means you are as morally flexible as everyone.  So taken this as a given, as a SME developing custom software, how do you protect your investment and ensure the success of your product?

First, we need to address some universal truths.

  1. All software of any value will be pirated.
  2. All copy protection mechanisms will be worked around by someone of sufficient intelligence.
  3. If you have produced a good product for sale on the open market, it will be pirated.

Stealing software is VERY easy.  Once we, as professionals, are comfortable with the fact that our products WILL be stolen, we can start attempting to maximise the sales.  In order to sell just about anything, you need to know who your target audience is.  Who exactly are you selling to?  There are four types of user…

  1. The Legitimate Customer

    If you have the pleasure of having a legitimate customer, make sure nothing stands between them and using your software.  Help them out at every turn and never obstruct their usage.  They pay your bills, remember that.  These people will pay for your software and upgrade and maintenance.  They may well all be corporate entities who under threat of inspection need to remain 100% above board (tip: Develop software for the legal industry, they’re pretty much not allowed to steal).  Home users may fall into this category simply because they don’t know they can steal software easily.

  2. The Moral Pirate

    You probably fit into this category.  You pay for software, you like to think you’re a good software citizen.  You may occasionally go to the pirate bay to grab a cracked version of an application because the demo or cripple-ware version really gets in the way of you trying the software.  You probably wouldn’t think twice about installing one copy of Windows on two separate machines however.  People can end up accidentally becoming moral pirates simply due to a lack of understanding of (often confusing) software licenses.

  3. The Immoral Pirate

    Immoral pirates use file sharing networks, Usenet, peer to peer or private FTP as their default method of software delivery.  They don’t want to pay for software.  They may believe they’re stealing, they may believe they’re in the moral clear as your product endorses evil / closed source mentalities / kills kittens.  You’ll only ever get a sale from the camp if your software is so incredibly hard to steal or find that it’s much more convenient to pay for it.  And even if that’s the case, they’re more likely to investigate an alternative first.

  4. The Career Pirate

    You will never sell a copy to this person, except if they’re actively trying to produce a crack themselves.  Career pirates will produce cracks, publish 0-Day copies of your application, and they’ll do it for the challenge.  Intricate copy protection mechanisms act as encouragement to career pirates.  The harder the better.  It’s an arms race that they will *always* win.

Coming to Terms With Piracy

The first thing you have to realise is that software piracy isn’t actually a bad thing.  Software piracy often introduces people who will later become legitimate users of your software to your product.  If you find that a vast majority of your users are stealing your software, the first thing you need to do is find out why they’re stealing instead of paying…

  • Is your software too expensive?
  • Are you pricing for business but aiming at the individual user?
  • Is the cracked version of your application actually better than the paid for edition?
  • Is your “home” offering too basic and people prefer to steal an overpriced “Professional” edition?
  • Worst of all, is your software crippled by draconian DRM?

If the answer to any of the above questions is yes, then you’re not dealing with a technical problem, you’re dealing with a social engineering and marketing issue.  It’s YOUR FAULT that your software is being stolen because you’re not selling it properly.  You have to be prepared to take responsibility for a misjudged business decision.  It’s not about blaming anyone, it’s about fixing the problem.

Targeting Your Audience

Out of the four groups of users listed above, ignore the fact that the third and fourth group exist.  You will never sell software to those people, they will steal it.  Get over it and move on.  You’re not going to stop them, don’t waste valuable time and money trying to.  Yes?  Good.

You need to protect your software in a way that it actively encourages the first and second groups of users to pay you for your hard work.  The legitimate customer is easy.  They’re going to pay.  Don’t make it hard for them.

The second group is slightly harder.  They’re probably going to pay you, but if they can steal your software really easily, they probably won’t bother.

What you need is some kind of authentication system that is reasonably simple, doesn’t hinder the users and offers some kind of advantage to the paying customer.  Now the funny thing is, this is a solved problem.  For the past decade companies have been experimenting in trying to squeeze the odd payment out of the immoral and career pirates who were not going to pay a penny to start with.  The answer is the serial number.

Serial numbers work.

If you take anything from reading this essay, please take this.

What Not To Do

The following authentication mechanisms are horrible ideas…

  • Online authentication

    Do not presume your clients have always on internet access.  If they don’t and you implement this, they WILL pirate your software or go to a competitor.

  • Products that Phone Home

    If you’ve been naive enough to saddle your software with online authentication and start thinking that products that phone home are a good idea, start thinking about what happens when that product no longer has internet access…

  • Commercial Root-kits 

    There is nothing more immoral than saddling your users machine with software they don’t know about and can’t remove, especially when it is recording their usage and using up CPU cycles.

But!  What if these authentication mechanisms can actually net me a few more sales!  Forget it.  They won’t.

The pirates will still steal, and most importantly…?

You’ll have just spent a small fortune in R&D, infrastructure and development creating a bypass-able authentication system that you then have to keep operational forever.  Unless you manage to con your users into what is essentially a software rental model, those servers of yours have to be available until the end of time, with databases of all your registered users, the level of access they’re allowed to your application and all manner of other data.

Running these oppressive registration mechanisms is expensive, and can potentially introduce defects into your pristine code.  What’s more, they can get in the way of legitimate users and paying customers, driving them to become moral pirates.  As was stated at the start of this piece, you must never put obstacles between legitimate users and paying for your software.  That is commercial suicide.

This is not to say that you should give your product away.

Protecting Your Software

Now that we’ve looked at what not to do, how on earth can we protect our software?  I really do believe in the serial number.  But a few sane coding practices can help you protect your software fairly easily.

At the simplest level, a serial key can be achieved using common Public-Private key encryption techniques.  Take some key data regarding your application (commonly something like registered user / organisation name, number of licenses granted, perhaps an email address) and encrypt it with a private key.  Your application has the public key embedded within it.  If that information decodes correctly, then the application is registered.  Simple.

But not fool proof.  I’d rather not mislead you by implying that that solution would just work perfectly.  If a cracker could isolate the portion of your code where you load the public key into memory, he could produce a cracked executable with a different public key encoded inside, and thus sign his own keys that would unlock the modified application.

The good news is that depending on your target audience, it’s almost certainly more work than your average user would bother with to steal your program (just don’t load a file from “approot\publicKey.key” and think you’re being diligent!)

The benefits of a simple solution?  Easy.

  1. It’s really really easy for users to register your software.  They pay you, they get a serial key.
  2. You need not store lots of user information for registered users, the key can be regenerated given the same inputs.  Therefore, low overhead on authentication servers as the user technically only need perform this operation once.
  3. Relatively secure, uses known cryptographic techniques.  Certainly beats some traditional “just multiply the username as bytes by some random number”.
  4. Low impact on the application as a whole.
  5. Authentication data can be changed between minor versions, breaking any key generators in the wild and making the software more inconvenient to crack a second time.

There are a few other tricks you can use.

  1. If your software is lucky enough to print out user data in some output, then you’re home free, people won’t share a serial number if their name is stamped on all the documents that the counterfeit copies produce.
  2. Don’t externalise your serial number checks in to an easily replaceable DLL / assembly.  It’s just too easy to isolate and replace.
  3. Don’t call the authentication method just once returning a boolean representing “is registered” or not, this is also easy to isolate and replace.
  4. If you use an interpreted language, user code obfuscating tools to stop simple decompilation.

Conclusion

Hopefully the above outlines have made the issue of small software piracy a little easier to understand along with explaining why obstructive software registration techniques won’t win you sales and instead often cost you both sales and development money.

Don’t fear software piracy, just attempt to give your legitimate users an experience that’ll make them want to act as your agents to their friends and associates.

You can’t pay for any marketing as effective as genuine goodwill.

Dear Google (Chrome)

September 3rd, 2008

What happened to “don’t be evil”? 

Why do you insist that people “posting or displaying the content you give Google a perpetual, irrevocable, worldwide, royalty-free, and non-exclusive license to reproduce, adapt, modify, translate, publish, publicly perform, publicly display and distribute any content which you submit, post or display on or through, the services”?

What made you think that the world needed another browser?

When you decided you wanted a browser, was the design brief “Opera, but use WebKit, and a new JavaScript implementation”?  That’s really all you produced.

JavaScript needs fixing, you’re right about that.  But if for a second you think the “correct” way to fix JavaScript is to ignore significant inroads made by other corporations and organisations in a massive “not invented here” haemorrhage then you’re very, very mistaken.

But most of all, what made you think that people won’t see this as the transparent attempt to force the hand of web standards that it is?  Seriously, let me get this straight;  When Microsoft do ActiveX and invent things like the XML RPC object, that’s evil and against standards and trying to lock everyone to Windows.  But when you create a browser and re-implement JavaScript in an attempt to force the other browsers to follow your lead in an further attempt to give Google Apps a stranglehold on the majority of “online applications” that’s just fine?

JavaScript really really needs fixing, and yes, a lot of people use GMail, but to try and suppose that the entire web is so dominated by Google Apps that a browser need be created to drive market share towards them is pure egotism, especially for a company with at most (and I’m being generous) four successful projects under it’s belt (Search, the killer app.  AdWords, the money.  Google Maps for a slick implementation and debatable GMail due to market share).  It’s lunacy to think that you’re fixing anything, rather just adding an extra layer of development and complexity on to the already arduous battle for web compatibility.

Your browser isn’t bad, it’s quite clean, it’s likely another eternal beta, but in the end, it’s just a stripped back version of Opera.  I’m sure you’ll do a good job of it, but in the end, will yet another minority browser really be worth it?  You need another hit, I really appreciate that, but try remember not to be evil on the way.

I just wish you’d put all this effort into existing technology.  One of Mozilla’s millions of prototypes (you are the sugardaddy after all) or even Opera (seeing as you like it so much) would be ideal, lets not repeat history again and again.

Geeking Out

September 3rd, 2008

There’s nothing more rewarding than programming on huge displays.  Say all you like about notebooks and pocket sized this and that, but if you really want to bed in and do some hardcore development, or graphics editing, or just a bit of browsing, whilst gaming, whilst listening to music, whilst watching videos, there’s nothing like masses of screen real estate.

For the past year and a half or so I’ve been enjoying two 19″ monitors (single monitor configurations feel very claustrophobic to me these days) and the experience has been “ok”.  However, finally the price points on reasonable 24″ monitors are right and I’ve invested in a little bit of an upgrade…

2008_3_desktop

That’s 19″ (1280×1024) - 24″ (1920×1200) - 19″ (1280×1024).  I’ve not added the numbers together to get an accurate calculation of desktop real estate, nor have I attempted to work out how much more productive the lack of task switching and windowing has made me.  But I’ll tell you what… it’s incredibly cool.  And yes, it does take up the entire length of a dining room sized table.  And no I don’t have a problem with that.

The graphics card powering the configuration is pretty simple.  People rave about the Quadro FX cards but I went with a wholly more LO-FI setup of my current-ish generation 3d card 7900GT in PCI-E x16 mode powering the 24″ in “Single display” 3d rendering mode (for gaming), along with an old (as in, in a box somewhere) 7300GT in PCI-E 2x mode (same family, easy compatibility, same driver…) powering the two 19″ displays.  Works a treat.  Finally I found a use for the fact I needlessly bought an SLI motherboard.

I can’t begin to explain how much benefit you get from dual displays (and other people have explained it far better than I could), but the third is pure luxury.  The ability to have documentation, masses of source code and a running app a glance away is priceless.

The new display is a Benq 2400.  It’s a TN panel, so graphics “enthusiasts” will probably deride its colour reproduction (TN panels can’t quite produce the same depth of colour as other panel types), however it’s well reviewed, has decent contrast ratio and response times and no dead pixels.  Looks and feels fantastic to my heathen eyes and I’d definitely recommend it (£257 inc vat.).

StackOverflow, Bloodstock and The Clone Wars (Catching Up)

August 18th, 2008

I’ve got two or three things lined up and half written on technical subjects to finish up before they appear here (mostly surrounding good API design and how to achieve it, and myths about Exceptions in the .NET framework) but I’ve been exceptionally busy lately.

I’ve been enjoying the semi-private beta of Stackoverflow, Jeff Atwood and Joel Spolsky’s project to provide a “developer self help” community akin to Experts Exchange (just “without the suck”).  It’s pretty solid and appears to be playing out like a kind of Xbox live for programmers, at least in the beta, while people try to quickly answer things to get reputation and badges (think achievements).  I don’t know if the enthusiasm will hold out post release, but people do like shiny virtual awards, and people always have questions.

Attended the Bloodstock Open Air music festival at Catton Hall in Derby over this weekend.  Horrible horrible drive (whoever figured that not lighting roads where you’re expected to drive at 70mph was a good idea probably should be taken out the back and shot) but we stayed in a Hotel in the nearby Burton Upon Trent rather than camped.  The music was very much above par (if you like metal / extreme metal) across the three days.  In all honesty, I went to see Opeth headline the Friday and Soilwork play third slot on the Saturday but there was generally a lot of good material to fill the time.

Over the three days we managed to watch (earliest to latest):

Friday Saturday Sunday
Tyr Swallow The Sun Crowning Glory
Akercocke The Defiled Alestorm
Destruction Moonsorrow Grand Magus
Primal Fear Soilwork Mob Rules
Soulfly Iced Earth Kataklysm
Helloween Dimmu Borgir As I Lay Dying
Opeth Overkill
At The Gates

A few of those are partial (as much Dimmu Borgir as I could handle until I got bored, only about half of Destruction, Mob Rules and Overkill).  We caught the first track Napalm Death played before I remembered that they’re a little special (and not in the good way), and I made a point of leaving before Nightwish on Sunday night (it was raining, and Nightwish make me feel ill!).

Highlights were Opeth headlining (shortened set, Fredrik Ã…kesson seems to fit in better on lead guitar than he did on the pre-Watershed tour), Soulfly playing a lot of Sepultura, Tyr and Alestorm for utter hilarity (battle metal and pirate metal respectively), Soilwork being as tight as ever, Swallow the Sun being very atmospheric and At The Gates being metal as hell.

Overall at the end of the weekend I was feeling somewhat burnt out watching live music.  Which means going to Leeds next weekend will be a bit of effort…  I suspect we’ll just go to watch the big headliners (Metallica, Slipknot, rage against the machine and Queens of the Stoneage) perhaps skipping the Sunday entirely as it’ll be a case of driving to and from Manchester each evening.

image

I also went to check out the Star Wars: The Clone Wars animated feature length this evening.  As a huge extended universe Star Wars fan I pretty much feel indifferent about it.

It looked nice, was fluid, the voice acting was decent enough, the battle sequences were pretty cool, the light saber fights were decent looking if soullessly put together. 

Unfortunately they wrote an average main story (instead of one of a million better clone wars related tales they could have filmed) added a very annoying seemingly cross dressing English talking Hutt, and then went through the dialogue of the script adding pet names for minor characters to make the dialogue feel a little awkward and kiddie.

It wasn’t bad, I did enjoy it.  I’ve always left Star Wars cinema experiences (usually on opening night, they somehow slipped this under the radar) feeling elated, and this time I came out feeling pretty indifferent.  It was reasonable, a great kids film I guess, but whereas they previously made Star Wars kid suitable, this time it feels like they didn’t quite make the directly kid orientated release adult friendly enough and somehow made a few Star Wars characters say things they shouldn’t ever have had to say (Jedi calling a Hutt lave “Stinky” is just plain wrong).  I guess I just hope they make the animated series a little more adult friendly.

Hopefully I’ll get a few technical posts finished up in the next few days.  In the meantime, checkout Stackoverflow.com, see the Clone Wars if you can silence your inner adult and go listen to some Swallow The Sun.

Vintage Game Club: Grim Fandango

July 14th, 2008

image

I’ve just picked up on the fact that The Brainy Gamer blog is doing a gaming club (a-la ye old book clubs / reading circles) and the focus for the next session is Grim Fandango.

http://www.brainygamer.com/the_brainy_gamer/2008/07/vintage-game–1.html?cid=122321778#comment-122321778

If you have time to participate, I’d really recommend it.  Not because I have any idea how it’ll go (I obviously hope it goes well), but more because Grim Fandango is possibly the greatest adventure game ever written.  Easily in my top 10 games of all time (if I were fearless enough to make a list) and a game that holds storytelling and good game play in the utmost regard.

If you’ve played it, play again, if you haven’t, play it for the first time.  It’s a classic, and scarily it’s probably turning ten this year.  If I recall, the original tag-line was “An epic tale of crime and corruption in the land of the dead” and that holds.  An art-deco masterpiece of good storytelling, humour, and your first (and probably only chance) to play a travel agent for the department of the dead.

Buy it here:

http://www.play.com/Games/PC/4-/2555356/Grim-Fandango/Product.html?source=5003&kwmid=4481214&kmcid=1664184991&match_type=

http://www.amazon.com/gp/offer-listing/B00004WGW1/ref=dp_olp_2

Demo here:

http://www.fileplanet.com/32113/30000/fileinfo/Grim-Fandango

Read the Escapist feature on it here:

http://www.escapistmagazine.com/articles/view/issues/issue_139/2994-Walk-Don-t-Run



All contents ©David Whitney 1998-2008 unless otherwise stated.