SCTP - association initialisation

Introduction

In my previous post we've explored how SCTP packets are encoded and what protocol elements they contain. Next we will look at three SCTP procedures - association creation, user data transfer and association tear down. Each procedure requires specific message flow, which will be reviewed in separate posts.

Section 4 from RFC 4960 has a state diagram for a SCTP association. There are two main states - CLOSED and ESTABLISHED. The transfer between them contains more intermediate states (COOKIE-WAIT, COOKIE-ECHOED, etc). Two endpoints can exchange user data only when the association is in ESTABLISHED state. This is accomplished with association initialisation procedure. Once it is completed successfully the peers can exchange data by following user data transfer procedure. Finally the connection is closed with termination of association procedure. Now we will review association creation procedure.

Read more…

SCTP: overview and message encoding

SCTP Introduction

SCTP is transport layer protocol with functions similar to TCP and some unique additions. Although it is not very popular in the Internet world, this protocol plays important role in telecommunication networks. It is used as a transport for various SIGTRAN protocols and it is the default transport protocol in EPC.

There is a Wikipedia article which provides a basic overview of SCTP's features. Another good document is SCTP: What is it, and how to use it? by Randal Stewart, Michael Tuxen and Peter Lei. In this article I want to provide SCTP overview from network developer point of view, which (in my opinion) means to dig into some specifications. What you will find here is a quick walkthrough the parts that I find most interesting, with references to the corresponding sections in RFC 4960, the SCTP specification.

Read more…

LDAP support in Asterisk 1.4

This is another post from my old blog. Again - the information here is old so it may not be useful for the recent versions of Asterisk. It is for Asterisk 1.4.

I had to use an LDAP server to retrieve SIP accounts for Asterisk. I had some difficulties to make it work, so I'll describe what I did here. Officially in Asterisk 1.4 there is no LDAP support, but there is a plugin in SVN, which works with the trunk version. You can get it from here. res_config_ldap.c should be added in res from Asterisk source code directory. Then compile this way:

./configure
make menuconfig
LIBS=-lldap
export LIBS
make
make install

Then edit res_ldap.conf. You can get a sample from here. In the section [sip] you should add this line, for clear text password (highly unrecommended!):

secret = AstAccountSecret

In extconfig.conf this lines should be added:

sippeers => ldap,"ou=accounts,dc=example,dc=com",sip
sipusers => ldap,"ou=accounts,dc=example,dc=com",sip

And finally the LDAP server should include this schema. Restart Asterisk and everything should be fine.

func_odbc in Asterisk

Sooner or later, when you develop a dialplan for asterisk you'll need to work with database. There are many approaches for this. Below there is an old post from my previous blog, describing how to accomplish this with func_odbc(). This information is a bit outdated - it was tested on Asterisk 1.4, so it may not be usable for the current versions.

Of course in order to use func_odbc() you should have installed and configured ODBC itself. If you don't know how to do this check this great article from Debian-Administration.org. I'll only add that if the database connections are described in /etc/odbc.ini they will be accessible from all users of the system, which might be unacceptable. Alternative approach is to save the configuration in ~/.odbc.ini so they will be accessible only for the given user.

In Asterisk, the configuration file res_odbc.conf should be modified. For example:

[asterisk]
enabled => yes
dsn => ASTERISK
username => user
password => pass
pre-connect => yes

The database name is specified in square brackets, dsn is the dsn from odbc.ini. After that in func_odbc.conf you should configure the desired requests. For example:

[TEST]
dsn=asterisk
read=SELECT name from test where extension='${ARG1}';
write=INSERT INTO test VALUES ('${ARG1}', '${VAL2}');

As with AstDB, each function can read or write from/to the database. Here is an example how to use the new functions in Asterisk dialplan:

Set(foo=${ODBC_TEST(${EXTEN})})
Set(ODBC_TEST(alpha)=200)

The first line gets a value from the database, the second - saves one. alpha and ${EXTEN} are arguments (ARG). 200 is value (VAL). There are more examples at voip-info.org