Search code examples
javasocketsnetwork-programmingprotocols

Tips about design/implementation of own protocol


Where I work we are in need of a protocol capable of:

  • User login/logout
  • Send/Receive instructions
  • Send/Receive files
  • Send/Receive audio stream(could use RTP)
  • Send/Receive small XML files Use
  • cryptography for all those.

It will be implemented in java. So I have some questions, since I've never implemented a network protocol yet.

  1. Is it possible to use existing protocols to build this one?
  2. What tool can I use to help me design the protocol? For "Modeling"
  3. Is it possible to accomplish all this, doing it alone? I have as much time as I need for this.

I have a pretty good background in Java and C++, but not yet with sockets/networking programming.

Thanks!


Solution

  • I've got a feeling you're trying to reinvent either SIP (if your packet processing is mostly stateless and XML is small enough to go into <3k packets), or XMPP.

    If you need a connection oriented login/logout, and stateful commands/instructions, then XMPP is probably closer to the requirements. Also, Jingle extension to XMPP already deals with RTP setup and teardown. XML messages are trivial to embed into custom XMPP packets (which themselves are XML) and there are known XMPP solutions for proxying a file transfer.

    I'm pretty sure it meets your requirements quite well (at least the way they're presented here). If you don't have to design a completely new protocol, it's probably easier if you don't. Also reusing an existing XMPP server will allow you to solve the pain of creating your own message broker. There's OpenFire server, which is written in Java.