Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips about design/implementation of own protocol

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

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

It will be implemented in java. So I have some questions, since I´ve never implemeted 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 acomplish 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

like image 733
fredcrs Avatar asked Aug 05 '10 11:08

fredcrs


2 Answers

Take a look a Google Protocol Buffers, which will generate a compact wire protocol as well as autogenerating Java message classes. I wish I'd heard of it before rolling my own message codec using Java NIO ByteBuffers.

like image 112
Adamski Avatar answered Sep 28 '22 18:09

Adamski


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.

like image 28
viraptor Avatar answered Sep 28 '22 19:09

viraptor