Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kalta committed Jul 8, 2013
0 parents commit 6db0820
Show file tree
Hide file tree
Showing 93 changed files with 23,509 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2013, Carlos González Florido <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
PROJECT = nksip
DIALYZER = dialyzer
REBAR = ./rebar

all: app

deps:
@$(REBAR) get-deps

app: deps
@$(REBAR) compile

clean: clean-docs clean-logs
@$(REBAR) clean
rm -f erl_crash.dump

clean-logs:
rm -rf nksip/log
rm -rf samples/nksip_loadtest/log
rm -rf samples/nksip_pbx/log
rm -rf samples/nksip_tutorial/log

docs: clean-docs
@$(REBAR) doc skip_deps=true

clean-docs:
rm -f nksip/doc/*.css nksip/doc/*.html \
nksip/doc/*.png nksip/doc/edoc-info
rm -f samples/nksip_loadtest/doc/*.css samples/nksip_loadtest/doc/*.html \
samples/nksip_loadtest/doc/*.png samples/nksip_loadtest/doc/edoc-info
rm -f samples/nksip_pbx/doc/*.css samples/nksip_pbx/doc/*.html \
samples/nksip_pbx/doc/*.png samples/nksip_pbx/doc/edoc-info
rm -f samples/nksip_tutorial/doc/*.css samples/nksip_tutorial/doc/*.html \
samples/nksip_tutorial/doc/*.png samples/nksip_tutorial/doc/edoc-info

tests: app eunit

eunit:
@$(REBAR) eunit skip_deps=true

build-plt:
@$(DIALYZER) --build_plt --output_plt .$(PROJECT).plt \
--apps kernel stdlib sasl tools inets crypto public_key ssl

dialyze: app
@$(DIALYZER) nksip/ebin/nksip*.beam --plt .$(PROJECT).plt \
-Werror_handling #-Wunmatched_returns -Wrace_conditions -Wunderspecs

shell:
erl -config samples/nksip_loadtest/priv/app.config \
-args_file samples/nksip_loadtest/priv/vm.args

tutorial:
erl -config samples/nksip_tutorial/priv/app.config \
-args_file samples/nksip_tutorial/priv/vm.args

loadtest: app
erl -config samples/nksip_loadtest/priv/app.config \
-args_file samples/nksip_loadtest/priv/vm.args -s nksip_loadtest

pbx: app
erl -config samples/nksip_pbx/priv/app.config \
-args_file samples/nksip_pbx/priv/vm.args -s nksip_pbx

build_tests:
erlc -pa nksip/ebin -pa deps/lager/ebin -o nksip/ebin -I include \
+export_all +debug_info nksip/test/*.erl


104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Introduction
============

NkSIP is an Erlang SIP framework or _application server_, which greatly facilitates the development of robust and scalable server-side SIP applications like proxy, registrar, redirect or outbound servers and [B2BUAs](http://en.wikipedia.org/wiki/Back-to-back_user_agent).

**This software is still alpha quality!! Do not use it in production!!**

SIP is the standard protocol related to IP voice, video and remote sessions, supported by thousands of devices, softphones and network operators. It is the basic building block for most current voice or video enabled networks and it is the core protocol of the IP Multimedia Subsytem [IMS](https://en.wikipedia.org/wiki/IP_Multimedia_Subsystem). SIP is powerful and flexible, but also very complex to work with. SIP basic concepts are easy to understand, but developing robust, scalable, highly available applications is usually quite hard and time consuming, because of the many details you have to take into account.

NkSIP takes care of much of the SIP complexity, while allowing full access to requests and responses.

NkSIP allows you to run any number of **SipApps**. To start a SipApp, you define a _name_, a set of _transports_ to start listening on and a **callback module**. Currently the only way to develop NkSIP applications is using [Erlang]("http://www.erlang.org") (a new, language-independent way of developing SipApps is in the works). You can now start sending SIP requests, and when your application starts receiving requests, specific functions in the callback module will be called. Each defined callback function has a _sane_ default functionality, so you only have to implement the functions you need to customize. You don't have to deal with transports, retransmissions, authentications or dialog management. All of those aspects are managed by NkSIP in a standard way. In case you need to, you can implement the related callback functions, or even process the request by yourself using the powerful NkSIP Erlang functions.

NkSIP has a clean, written from scratch, [OTP compliant](http://www.erlang.org/doc/design_principles/users_guide.html) and [fully typed](http://www.erlang.org/doc/reference_manual/typespec.html) pure Erlang code. New RFCs and features can be implemented securely and quickly. The codebase includes currently more than 50 unit tests. If you want to customize the way NkSIP behaves beyond what the callback mechanism offers, it should be easy to understand the code and use it as a powerful base for your specific application server.

NkSIP is currently alpha quality, it probably has important bugs and is not **not yet production-ready**, but it is already very robust, thanks to its OTP design. Also thanks to its Erlang roots it can perform many actions while running: starting and stopping SipApps, hot code upgrades, configuration changes and even changing your application behavior and function callbacks on the fly.

NkSIP scales automatically using all of the available cores on the machine. Without any serious optimization done yet, and using common hardware (4-core i7 MacMini), it is easy to get more than 1.000 call cycles (INVITE-ACK-BYE) or 8.000 stateless registrations per second. On the roadmap there is a **fully distributed version**, based on [Riak Core](https://github.com/basho/riak_core), that will allow you to add and remove nodes while running, scale as much as needed and offer a very high availability, all of it without changing your application.

NkSIP is a pure SIP framework, so it _does not support any real RTP media processing_ it can't record a call, host an audio conference or transcode. These type of tasks should be done with a SIP media server, like [Freeswitch](http://www.freeswitch.org) or [Asterisk](http://www.asterisk.org). However NkSIP can act as a standard endpoint (or a B2BUA, actually), which is very useful in many scenarios: registering with an external server, answering and redirecting a call or recovering in real time from a failed media server.


Current Features
----------------


* Full RFC3261 coverage, including SIP Registrar (RAM storage only).
* A written from scratch, fully typed Erlang code easy to understand and extend, with more than 50 unit tests.
* Hot core and application code upgrade.
* Very few external dependencies: [Lager](https://github.com/basho/lager) for error logging and [Cowboy](http://ninenines.eu") as TCP/SSL acceptor and Websocket server.
* UDP, TCP and TLS transports, capable of handling thousands of simultaneous sessions.
* Stateful proxy servers with serial and parallel forking.
* Stateless proxy servers, even using TCP/TLS.
* Automatic registrations and timed pings.
* Dialog and SDP media start and stop detection.
* SDP processing utilities.
* Simple STUN server (for future SIP Outbound support).
* Robust and highly scalable, using all available processor cores.

See [FEATURES.md](../nksip/FEATURES.md) for up to date RFC support.



Documentation
-------------
Full documentation is available [here](http://kalta.github.io/nksip/doc/0.1.0/core/doc/index.html).


**Sample Applications**

There are currently two samples applications included with NkSIP:
* NkPBX. Implements a SIP registrar and forking proxy, with endpoints monitoring. See [docs](http:kalta.github.io/nksip/doc/0.1.0/nksip_pbx/doc/index.html).
* NkLoadTest. Heavy-load NkSIP testing. See [docs](http:kalta.github.io/nksip/doc/0.1.0/nksip_loadtest/doc/index.html).


Quick Start
===========

```
> git clone https://github.com/kalta/nksip
> cd nksip
> make
> make tests
```

Now you can start a simple SipApp using default `nksip_sipapp.erl` callback module:

```erlang
> make shell
1> nksip:start(test1, nksip_sipapp, [], [])
2> nksip_uac:options(test1, "sip:sip2sip.info", [])
{ok, 200}
```

You could also start the sample application `NkPBX` to have a target SIP server to test:
```erlang
3> nksip_pbx:start()
4> nksip_uac:register(test1, "sip:127.0.0.1;transport=tls", [])
{ok, 407}
```

We need a password. We use now `make_contact` option to generate a valid _Contact_ header:
```erlang
5> nksip_uac:register(test1, "sip:127.0.0.1;transport=tls", [{pass, "1234"}, make_contact])
{ok, 200}
6> {reply, Reply1} = nksip_uac:register(test1, "sip:127.0.0.1;transport=tls", [{pass, "1234"}, full_response]).
7> nksip_response:headers(<<Contact>>, Reply1)
```

We have now registered. With the option `full_response` we get a full resonse object instead of simple the code. The server replies with the stored _Contact_.

Roadmap
-------
See [ROADMAP.md](../nksip/ROADMAP.md)










50 changes: 50 additions & 0 deletions cover.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
% Uncomment this line to append eunit tests coverage data to ct tests coverage data
% {import, [".eunit/eunit.coverdata"]}.
{incl_mods, [
nksip_app,
nksip_auth,
nksip_config,
nksip_counters,
nksip_dialog,
nksip_dialog_fsm,
nksip_dialog_lib,
nksip_dialog_proxy,
nksip_dialog_uac,
nksip_dialog_uas,
nksip_headers,
nksip_lib,
nksip_parse,
nksip_proc,
nksip_proxy,
nksip_queue,
nksip_registrar,
nksip_request,
nksip_response,
nksip_sdp,
nksip_sipapp,
nksip_sipapp_auto,
nksip_sipapp_srv,
nksip_sipapp_sup,
nksip_sipmsg,
nksip_stats,
nksip_store,
nksip_stun,
nksip_sup,
nksip_trace,
nksip_transaction_uac,
nksip_transaction_uas,
nksip_transport,
nksip_transport_conn,
nksip_transport_sup,
nksip_transport_tcp,
nksip_transport_uac,
nksip_transport_uas,
nksip_transport_udp,
nksip_uac,
nksip_uac_fsm,
nksip_uac_lib,
nksip_uas_fsm,
nksip_uas_lib,
nksip_uas_proxy,
nksip_unparse
]}.
27 changes: 27 additions & 0 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
In the current version the following RFCs are supported:

RFC|Description|Coverage
---|---|---
[RFC3261](http://tools.ietf.org/html/rfc3261)|SIP 2.0|Full
[RFC2617](http://tools.ietf.org/html/rfc2617)|Digest authentication|Full
[RFC3263](http://tools.ietf.org/html/rfc3263)|SRV Resolution|Full (no SRV/NAPTR weight support)
[RFC3264](http://tools.ietf.org/html/rfc3264)|Offer/Answer Model|Full
[RFC3581](http://tools.ietf.org/html/rfc3581)|RPort|Full
[RFC4566](http://tools.ietf.org/html/rfc4566)|SDP Parser and Generator|Full (limited processing utilities)
[RFC5389](http://tools.ietf.org/html/rfc5389)|STUN|Basic STUN client and server
[RFC6026]([http://tools.ietf.org/html/rfc6026)|2xx responses|Full


NkSIP features also:
* SIP Registrar (RAM storage only).
* A written from scratch, fully typed Erlang code easy to understand and extend. More than 50 unit tests.
* Hot code loading.
* Very few external dependencies: [Lager](https://github.com/basho/lager) for error logging and [Cowboy](http://ninenines.eu") as TCP/SSL acceptor and Websocket server.
* UDP, TCP and TLS transports, capable of handling thousands of simultaneous sessions.
* Stateful proxy servers with serial and parallel forking.
* Stateless proxy servers, even using TCP/TLS.
* Automatic registrations and timed pings.
* Dialog and SDP media start and stop detection.
* SDP processing utilities.
* Simple STUN server (for future SIP Outbound support).
* Robust and highly scalable, using all available processor cores.
40 changes: 40 additions & 0 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ROADMAP
=======

In no special order:

* More application examples
* _Bridge_ support for B2BUA.
* _IPv6_.
* _SIP Websockets_ support.
* External control, to be able to use NkSIP without having to use Erlang or outside of the NkSIP Erlang VM.
* Fully distributed, highly available version based on [Riak Core](https://github.com/basho/riak_core).
* IMS and RCS extensions.


Many common SIP featured are still missing and will be addressed in following versions, including:

* [RFC2976](http://tools.ietf.org/html/rfc2976): INFO
* [RFC3262](http://tools.ietf.org/html/rfc3262): PRACK
* [RFC3265](http://tools.ietf.org/html/rfc3265): SUBSCRIBE, NOTIFY
* [RFC3311](http://tools.ietf.org/html/rfc3311): UPDATE
* [RFC3327](http://tools.ietf.org/html/rfc3327): Path
* [RFC3428](http://tools.ietf.org/html/rfc3428): MESSAGE
* [RFC3515](http://tools.ietf.org/html/rfc3515): REFER
* [RFC3608](http://tools.ietf.org/html/rfc3608): Service-Route
* [RFC3891](http://tools.ietf.org/html/rfc3891): Replaces
* [RFC3892](http://tools.ietf.org/html/rfc3892): Referred-By
* [RFC3903](http://tools.ietf.org/html/rfc3903): PUBLISH
* [RFC4028](http://tools.ietf.org/html/rfc4028): Session Timers
* [RFC4320](http://tools.ietf.org/html/rfc4320): Invite transactions
* [RFC4321](http://tools.ietf.org/html/rfc4321): Non-invite transactions
* [RFC4475](http://tools.ietf.org/html/rfc4475): Torture tests
* [RFC5027](http://tools.ietf.org/html/rfc5057): Multiple dialog
* [RFC5626](http://tools.ietf.org/html/rfc5626): Outbound
* [RFC5627](http://tools.ietf.org/html/rfc5626): GRUU






Loading

0 comments on commit 6db0820

Please sign in to comment.