SIP Stack implementation in OCaml

Hi,
Only been learning OCaml for 2 months and have a project where I need to make SIP calls out and ensure they are answered to test some telecommunications systems. Is anyone aware of a SIP library for OCaml? Could probably use Cohttp it generate SIP message, but a whole client may be a bit advanced al this stage.

Many Thanks,

Ian.

2 Likes

Do you need to establish RTP (audio) communication or just test for accepted vs rejected call attempts? If you just need SIP to essentially ping, you might get away with a very simple request generator and response parser and direct UDP I/O (one packet out, wait for one response packet back, determine success/failure).

If you need full SIP support you might want to look into FFI to https://github.com/pjsip/pjproject which is a battle-tested C library.

2 Likes

I will need to make a call, so will need interact with another SIP call processor (Cisco Call Manager in my case). Ideally I will want to test the audio path with a tone of some kind, but going to just make and terminate a call initially. Thanks for the response, I will investigate how difficult it will be to call the c code from OCaml.

1 Like

We’ve developed some code for SIP + RTP analysis but it includes both SIP request/response parser and a simple parser for RTP header (in the case of g.711, the headers can be variable length). Feel free to reach out if you’d like a copy. We haven’t published it yet.

2 Likes

Update: apparently @quernd has written a sip server prototype :slight_smile: again, were open to sharing the code if you need it. We’re just not open sourcing it (yet) because of the cost of open sourcing it while there is likely no one who would use it.

Is it available anywhere, @quernd’s prototype? I couldn’t easily find it. Personally, I was curious to play around with SIP a while ago. At the moment I don’t have the time.

To give a bit more context, what I wrote is far from a full-fledged SIP server. It’s a proxy that allows us to place SIP/RTP calls to a service that uses a different protocol for audio streaming. The functionality is pretty basic:

  • It listens for SIP INVITE requests from a client
  • It parses the SDP and sets up RTP communication with the client accordingly
  • It bridges RTP to that other service

Basically I wrote it last Saturday morning between @wokalski’s last two messages. It’s very much tailored to our needs and I cut a dozen corners by making assumptions that won’t work in other use cases.

That said, all the basic building blocks to implement SIP server logic are there: SIP, SDP and RTP. I’ll see what I can do to get this into a usable shape.

3 Likes