SpiderMonkey – jME3 networking system (36 posts)

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:


    SpiderMonkey is a high performance Java networking engine. It is efficient, yet simple to use. Setting up a client/server mechanism requires no more than basic Java knowledge. The same goes for sending and receiving objects – in other words: Every monkey can use it!

    I’ve done a lot of research on how to make SpiderMonkey better than already existing libraries, and with the following feature set I think I’ve succeeded:

    UDP Done
    TCP Done
    SSL over TCP 70% done
    Synchronization
    Serialization Done
    Voice chat Done
    Chat (including channels, profanity filter (maybe), and completely extendable)
    JDBC layer (maybe, more to come)
    jME3 support layer
    Android support
    RMI 90% done
    Compression Done
    Connection filters Done
    Streaming (files, data) Done

    Easy to use, easy to learn
    Generic enough to be used for just about anything
    Thread safe

    The code is going to be available under the BSD License, and can be viewed here. Repository url is jME3′s :)
    Let me know what you think! :)

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:

    sbook said:
    Cool!  I might suggest further adding a level of generic-ness and abstracting the jME3 layer to an 'asset' layer or something of the sorts.  Similar for voice support; make the output an interface that you could just register a sound system with.

    The rationale here is that you widen your user base if folks outside of jME3 are using it.. More bugs, patches, suggestions, etc

    Thanks for the feedback!

    Yes I'll definitely do that, thanks for the tip. It'll be generic enough to be usable for everyone :)

  • Profile picture of ractoc ractoc24p said 1 year, 9 months ago:

    hey there,

    I'm currently working on a server / client system that will allow players to find eachother for multiplayer games. This library would need a lot of the features you are already planning to add to your library, so yours would be a good choice for me.

    My system would be set up in such a way that is is useable as stand-alone, this could be used mainly for the chat functionality, or integrated in any game. I you'r willing, I would propose I use your network layer. That way, you can use my project as sort of a testing ground for your network layer. This in turn helps you figure out features that work, features that don't work and featuers that are still missing.

    Just send me a PM if interested.

  • Profile picture of normen normen1291p said 1 year, 9 months ago:

    Yay, this sounds great! Networking is definitely very important to make jme a complete packge. Love the @syntax for syncing!

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:

    Today I've written the serialization system, and it turns out it's quite efficient. It uses 2 bytes for a class ID (compared to 4 bytes for some other serialization engines I've never heard about), and of course the serialization system is extendable. Class registration is forced, so no class names that are being serialized and sent across the network.

    I've updated the first post with status updates next to the features. I'll keep you updated!

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:

    Another update; almost done with the TCP and UDP connectivity, just need to try some things out and add some extra utility methods. Serialization has changed a bit, but it should remain like it is now for a while.

    SSL over TCP has been dropped, to replace it I will be implementing an encryption system, which'll allow encrypted messages over the already existing TCP/UDP connection. This means that you do not need a separate SSL connection any longer.

    File streaming has been added to the feature list – it does exactly what you think it does. Also works over the already existing TCP/UDP connection (though you'll probably want to use TCP for this).

    Stay tuned!

  • Profile picture of sbook sbook263p said 1 year, 9 months ago:

    I'm curious as to the decision to drop the SSL connection..

    Once the initial handshake is done there's minimal overhead required..  It might be something that you want to maintain for certain requests while others go over standard TCP.  What it sounds like to me is that you'd have to encrypt every message (and then decrypt it eventually)… wouldn't that be a potential choke point?

    Edit: Forgot to mention the other stuff:

    Sounds great!

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:

    sbook said:
    I'm curious as to the decision to drop the SSL connection..

    Once the initial handshake is done there's minimal overhead required..  It might be something that you want to maintain for certain requests while others go over standard TCP.  What it sounds like to me is that you'd have to encrypt every message (and then decrypt it eventually)… wouldn't that be a potential choke point?

    Edit: Forgot to mention the other stuff:

    Sounds great!

    I'm uncertain what you mean, to successfully create and run an SSL server, you would have to run it on a separate connection. So this means that you have a separate connection while you may not even have this extra connection, this extra port, this extra processing power required. It could replace the TCP server as a whole though, but that means that all objects, if they need to be encrypted or not, are going to be sent across TCP with SSL. For objects that don't need to be encrypted, that is lost processing power right there. SSL decrypts messages internally, just like SpiderMonkey will do by itself (as the planned 'custom encryption' feature).

    Thanks for the feedback, let me know if that's what you meant :)

  • Profile picture of sbook sbook263p said 1 year, 9 months ago:

    True, having to open an extra port could be annoying.  My point was basically that some things could be sent encrypted (and others not) concurrently.  Its true you're still a slave to bandwidth and latency however :)

    Definitely intriguing, doing everything over the same connection..  I'm still having some trouble understanding how it will work (one handshake at the beginning?) but you haven't told us that part yet!  Looking forward to the surprise!

    Just saw that a JDBC layer is a maybe.  Let me know if I can be of any help, I've gotten to know the sweet and the sours of JDBC over the past few years.

  • Profile picture of Momoko_Fan Momoko_Fan371p said 1 year, 9 months ago:

    Consider that SSL probably won't work under UDP, which is used by most games.
    By the way Levia, how are you going to establish the certificate authority? It won't work without a central server.
    You can probably use "fake" encryption using RC4, but you still need to send the session key initially.

  • Profile picture of Levia Levia4p said 1 year, 9 months ago:

    sbook said:
    True, having to open an extra port could be annoying.  My point was basically that some things could be sent encrypted (and others not) concurrently.  Its true you're still a slave to bandwidth and latency however :)

    Definitely intriguing, doing everything over the same connection..  I'm still having some trouble understanding how it will work (one handshake at the beginning?) but you haven't told us that part yet!  Looking forward to the surprise!

    Just saw that a JDBC layer is a maybe.  Let me know if I can be of any help, I've gotten to know the sweet and the sours of JDBC over the past few years.

    Nothing set in stone yet, haven't really given this a thorough thought yet, but I thought just handshaking whenever one peer wants to enable encryption. The keys would probably be cached there for any later encryption that needs to be done.

    [quote author=Momoko_Fan]
    Consider that SSL probably won't work under UDP, which is used by most games.
    [/quote]
    Yeah, SSL over UDP is quite..useless.

    [quote author=Momoko_Fan]
    By the way Levia, how are you going to establish the certificate authority? It won't work without a central server.
    You can probably use "fake" encryption using RC4, but you still need to send the session key initially.
    [/quote]
    I don't really understand this – since SSL isn't going to be used (for now, atleast) why do we need a CA?

  • Profile picture of Momoko_Fan Momoko_Fan371p said 1 year, 9 months ago:

    Levia said:
    [quote author=Momoko_Fan]
    By the way Levia, how are you going to establish the certificate authority? It won't work without a central server.
    You can probably use "fake" encryption using RC4, but you still need to send the session key initially.

    I don't really understand this – since SSL isn't going to be used (for now, atleast) why do we need a CA?
    [/quote]
    You can't have public key security without a certificate authority, since you would have to send the public keys between clients. A MitM attacker could listen and modify packets, if he arrived when the channel was being established.
    In other words, you can't have two clients communicate securely if they don't know anything about each over.

  • Profile picture of sbook sbook263p said 1 year, 9 months ago:

    Momoko_Fan said:
    You can't have public key security without a certificate authority, since you would have to send the public keys between clients. A MitM attacker could listen and modify packets, if he arrived when the channel was being established.
    In other words, you can't have two clients communicate securely if they don't know anything about each over.

    This was one of my initial questions of how it would be implemented..

    Levia said:
    Nothing set in stone yet, haven't really given this a thorough thought yet, but I thought just handshaking whenever one peer wants to enable encryption. The keys would probably be cached there for any later encryption that needs to be done.

    Handshaking every time you want to send something encrypted means 5 legs for every secure transmission.  Not only is it a waste of time in terms of the sensitive data being sent, but its also blocking any unencrypted communications since you're planning to go over the same link..

  • Profile picture of ractoc ractoc24p said 1 year, 9 months ago:

    Main drawbacks I see for using SSL are:
    1 – the cost. If you want to do it right you'd have to go and buy an expensive certificate.
    2 – you need a static IP address. Well you could do it with a dynamic one but then the costs would go up even higher.

    Either you have to deal with those two issues, or setup your own trust server, which makes things way more complicated then you really want as well. I had somethings like this a while back with one of my applications. We took an entirely different approach: compiling on demand.

    the process worked something like this:
    1 – you go to the website and create an account.
    2 – the system creates your account and with that account it creates an encryption key specific for your account.
    3 – you login to your account on the website
    4 – you press the download button.
    5 – at this point, the system generates an encription.jar which contains all the encription stuff. This is done on the fly because your unique encription key is compiled into this jar.
    6 – your download starts.

    What this does is it creates an encription key that is linked to your login. Granted this has some problems as well, but for us it worked gret because for one the application was always installed on just one system at a time. So we could figure out which key to use that way. For your situation you could use something similar I guess but then this generated key would be the public key and you would use it to verify the client is who they say they are.

    Oh and I put in one more thing to make things a little harder to hackers. Each time I sent an encripted packet from the server to the client, part of that packet was a new encription key. So the encription key  is only ever valid for one exchange.

  • Profile picture of normen normen1291p said 1 year, 9 months ago:

    About the cost thing: just keep in mind that jme3 is also meant for proffessional corporations that surely do have the money for certificates etc. :)