Wednesday, May 09, 2007

SRTP design thoughts and some general implementation

Recently I did some design and implementation of the SRTP project's architecture. I'd like to share my thoughts with you. :-)

OK, here's my design:
1. The srtp support will be based on JMF's RTP support. We will translate each RTP packets into SRTP packets before they are sent out.
And translate received SRTP packets into normal RTP packets before they are forwarded to JMF.
This means we only perform the translation between RTP and SRTP. Normal RTP's work is still done by JMF, such as jitter buffer control.

2. JMF allow developer to specify the transport of RTP packets. The RTPConnector interface is design for this purpose.
JMF will write outgoing packets through RTPConnector and read incoming packets from RTPConnector.
So, by implementing the RTPConnector interface, we could intercept the outgoing/incoming RTP/RTCP packets and then do our encryption/decryption work.

3.The encryption/decryption is actually a transformation of RTP packets. So, we can first define a general class "TransformConnector".
And then specify the transforming logic through interface "PacketTransformer". Each implementation of "PacketTransformer" contains
the concrete logic of how the packets will be manipulated. In our case, we will encapsulate our encryption/decryption logic in "SRTPTransformer".

4. TransformConnector and related support class such as TransformInputStream / TransformOutputStream deals with abstract PacketTransformer interface.
When a packet is ready to be sent, it will be handed to PacketTransformer, after transformation, the returned packet (maybe complete new one) will then be sent out.
When a packet is received, it will fist handed to PacketTransformer for reverse transformation, and then the returned packet will be handed to JMF for later processing.

Here's the implementation status:

1. I finished a minimal implementation of the above design. And created a dummy transformer (does nothing, returns the packet to be transformed directly)
2. I modified JMF's example code and make a small test program, to test the dummy transformer (and the TransformConnector). In my environment, it works fine.
The core modification is instead of initialize RTPManager using local address and add remote address as target, we pass our TransformerConnector object to
the initialize() method of RTPManager.
3. I use eclipse 3.2.2 as my IDE. JMF's version is 2.1.1e.
Coding styles and project related regulations are not considered so much, will be refactored later.

No comments:

About Me

My photo
Beijing, China
Currently a graduate student at Peking University, Beijing, China. I am pursuing my master degree in Computer Network and Distributed System Laboratory of PKU.