views:

108

answers:

4

Hello. 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

A: 

You could use http or https. The java media framework contains an implementation of rtp.

Maurice Perry
http(s) is awful at sending large files/audio etc etc. It's also stateless so it would be harder to build login stuff.
Tom Gullen
+3  A: 

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.

Adamski
+1, that was a really interesting project I've never heard about before. I also rolled an entire own message codec with bytebuffers a couple of years ago (and it was quite annoying at times), if I had had something like this I could have cut development times significantly (but hey, it worked!). I'll definitively have a look at this when I get some spare time. Just too bad that I won't have much use for it in my current job (C# and WCF...).
wasatz
Just keep in mind that even though it's got "protocol" in the name, it's really just a way of (de)serialising messages into a binary format. This is only one small step in designing a your own message exchange. You'll need to think about the states, the error recovery, dealing with potential conflicts / message races, etc. etc.
viraptor
+1  A: 

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.

viraptor
thanks very much... I will check Jingle and XMPP
fredcrs
I read about and looks like Smack could be used to make my client...And I should use openfire as a server.But I dont know if Smack support streaming, I googled for it with no success. Should this be the best way?
fredcrs
I mean't audio streaming sorry.
fredcrs
A: 

Writing the protocol from scratch may require a lot of work. Take a look at XMPP.

If you want to write your own protocol, start with learning a form of RPC like JSON or similar, which will make your life a lot easier.

Jes