Archive for the 'FreeSWITCH' Category

FreeSWITCH + OpenAIS = mod_openais

Example console output:

freeswitch@test01> ais help

ais cluster <show>
ais help

freeswitch@test01> ais cluster show

 Node ID:                0x100000a
 Node Address: 
 Node BootTimestamp:     Fri, 13 Aug 2010 15:14:11 GMT
 Node Is Member:         Yes
 Node ID:                0x200000a
 Node Address: 
 Node BootTimestamp:     Mon, 11 Oct 2010 19:21:50 GMT
 Node Is Member:         Yes
=======================================================[  2 node(s) ]==


Example output of node joining + leaving the cluster:

freeswitch@test01> 2011-01-30 01:31:53.606847 [DEBUG] mod_openais.c:371 CLM event(s) available
2011-01-30 01:31:53.606847 [DEBUG] mod_openais.c:186 clm_cluster_track_cb() called
2011-01-30 01:31:53.606847 [DEBUG] mod_openais.c:192 CLM: Node '' [ID: 0x200000a, Address:], Event: 'Left'

freeswitch@test01> 2011-01-30 01:31:56.803345 [DEBUG] mod_openais.c:371 CLM event(s) available
2011-01-30 01:31:56.804643 [DEBUG] mod_openais.c:186 clm_cluster_track_cb() called
2011-01-30 01:31:56.804643 [DEBUG] mod_openais.c:192 CLM: Node '' [ID: 0x200000a, Address:], Event: 'Joined'


fs_cli event output (node leaving, still going to rework this a bit):

Event-Subclass: OpenAIS-Node-Left
priority: HIGH
Event-Name: CUSTOM
Core-UUID: 86032536-bea5-4a44-87c4-547579b2e4c2
FreeSWITCH-Hostname: test01
FreeSWITCH-IPv6: ::1
Event-Date-Local: 2011-01-30 01:33:35
Event-Date-GMT: Sun, 30 Jan 2011 00:33:35 GMT
Event-Date-Timestamp: 1296347615442192
Event-Calling-File: mod_openais.c
Event-Calling-Function: clm_send_event
Event-Calling-Line-Number: 152
Node-ID: 0x200000a
Node-BootTimestamp: 1286824910000000000

Analysis of the FreeTDM/OpenZAP BRI PTMP “Problem”

Collecting everything here before posting to the relevant places…

The Problem:

People reporting audio distortion on the BRI PTMP (S0) bus after placing calls with FreeTDM (or other unexpected behaviour like devices crashing, acting odd etc.). Those distortions vanish after stopping or restarting FreeSWITCH. (NOTE: I/O module is Zaptel/DAHDI)

The Cause (short):

1. FreeTDM opens the B-Channel immediately, on outgoing and incoming calls, even if no media has been signalled by the NT (via PROGRESS IE or any other means) (this can cause other devices on the bus to crash).

2. FreeTDM (or the signalling module) does not completely close the B-Channel on hangup, leaving the B-Channel open and transmitting frames (this is what causes the distortions on the bus, after the first call).

The Cause (long):

For outgoing channels:

1. mod_freetdm:channel_outgoing_channel()  opens a channel using this piece of code (line 1283 ff.):

if (group_id >= 0) {
  status = ftdm_channel_open_by_group(group_id, direction, &caller_data, &ftdmchan);
} else if (chan_id) {
  status = ftdm_channel_open(span_id, chan_id, &ftdmchan);
} else {
  status = ftdm_channel_open_by_span(span_id, direction, &caller_data, &ftdmchan);

each of these functions opens a selected channel using the “channel->fio->open()” callback of the channel’s I/O module, causing the channel to be “physically” openened. In the case of Zaptel/DAHDI (B-)channels this means (the) AUDIO_MODE is enabled, causing audio frames to be transmitted and received from the ISDN bus.

For TE-mode, this behaviour is wrong, the selected channel has not been acknowledged by the NT and may still change after the SETUP message. For NT-mode, opening the B-Channel at this stage is wrong too, even if the channel does not change later. The earliest possible state to open the channel here is, for inbound calls, after the SETUP ACK message for overlap-dial (inband dialtone).

NOTE: This is something the signalling module has to control ({oz,ft}mod_isdn does that already)!

2. The signalling module (e.g. current ftmod_libpri) does not call ftmod_close_channel() on hangup to completely close the channel.

On hangup, the signalling module _MUST_ call ftmod_channel_close() to “physically” close the B-Channel, for Zaptel/DAHDI channels this means disabling AUDIO_MODE to stop transmitting frames on B-Channels and to avoid distortions on the S0 bus and confusing other devices.

This requires the I/O module implements the neccessary code to close a channel in its close() callback.

NOTE: ftmod_zt does that since commit c1517e99d1

[RFD] The solution:

Don’t open channels in mod_freetdm:channel_outgoing_channel() (or any other place that does it too early), reserve and assign the channel instead. Let the signalling module handle opening/closing of channels (or, as a fallback, let the FreeTDM core open the channel upon entering states that really need to have the channel open, e.g. PROGRESS_MEDIA).

mod_ssh: libssh-0.4.0 update

mod_ssh’s bundled version of libssh has been updated to version 0.4.0. Parts of mod_ssh had to be fixed to compile with the new libssh version and a couple of things have been improved in the process (e.g. error handling in the load function and the “ssh” api command).

No new features otherwise.

NOTE: There still seems to be an issue with buffer handling / ANSI control sequences and reloading mod_ssh kills FreeSWITCH with a SIGBUS.

UPDATE: ANSI control sequence corruption has been fixed (commit 33c6ee7…).

FreeSWITCH ebuilds updated

Ebuilds for FreeSWITCH-1.0.5_pre3 and FreeSWITCH-sounds-1.0.12 are now in the axsentis-overlay.


Project: LibISDN ASN.1 En-/Decoder

Motivation: Handle Q.932 ROSE RPC calls.

Status: Early code, decoding mostly works, parts have to be rewritten for encoding to work (in a usable way).

Target Milestone: Being able to handle incoming MWI request from my ISDN phone and sent an answer that will make the icon on its LC-Display light up.

Project: libRTCP

Motivation: En-/Decoding of RTCP messages.

Status: Early version, can already decode some RTCP messages, needs more work.

Target Milestone: Working en-/decoding of XR and most other RTCP messages.

Project: mod_netlink

Motivation: Receive netlink events from linux kernel about IP-Address and HW-Configuration changes and inject them into the FreeSWITCH core.

Status: Some proof-of-concept code written (Binding to netlink multicast groups and receiving events + dumping them in hex+ascii / text)

Notes: Will need linux-2.6.30+ (unless you really want to run FreeSWITCH as root).

Target Milestone: Turn PoC code into mod_netlink.c, handle incoming network interface + ip address change events, handle incoming CPU up/down events, turn them into FreeSWITCH events.

Project: mod_http_rpc

Motivation: Current mod_xml_rpc sucks.

Status: Basic HTTP access works, using embedded mongoose.

Target Milestone: HTTP/XML-RPC API calls working, authentication via user directory.

Project: RTP Acceleration

Motivation: 10k+ calls on a single box, without ending up in context-switch hell caused by RTP recv/send syscalls.

Status: Working on early proof-of-concept code (userspace UDP/IP stack).

Notes: New test hardware: Managed 8-port 1GigE (HP 1800-8G, ~11.6Mpps), Dual-Port PCIe Intel 1000/PT, two Broadcom NetXtreme BCM5721 PCIe cards. Full setup will be completed after dead PSU has been replaced in test01.

Next milestone: Get UDP recv+send and ARP working in PoC, adapt code to lastest TX-Ring changes in 2.6.31+, start benchmarking.

Project: Improve FreeSWITCH startup time by starting modules in parallel

Motivation: Spend less time loading and initializing modules, some of which may block for some time in their startup function. Track inter-module dependencies and parallelize loading using a set/pool of threads executing the startup routines.

Status: Planning

Project: Improve configuration option handling of OpenZAP modules

Motivation: The current situation sucks completely

Status: Some option handling code written, needs to be integrated into OpenZAP (+ modified to fit)

Next milestone: Try to integrate this into OpenZAP, using mod_isdn

Project: Complete clean rewrite of the FreeSWITCH buildsystem using GNU Make, current Autools, system libs and support for the FHS.

Motivation: Meh… (we already depend on GNU Make anyway and some of us are able to roll their own controlled environment)

Status: Already started this some time ago, need to find a way to create a GIT repo that only contains and syncs the source code parts.

Target Milestone: Build core and most important modules using system libs, maybe add some of that fancy “make mod_foo” stuff via a makefile include that adds the neccessary rules. Add proper pkg-config support for the core (and remove fsxs).

Project: New work desk.

Motivation: Totally sucks to have no space to put stuff on (one of the reasons there’s not much progress in LibISDN development right now)

Status: Need to get vacation first (*sigh*)

FreeSWITCH-1.0.4 released!

Ebuilds have been updated. The freeswitch-sounds-1.0.11 ebuild includes support for the russian ‘elena’ set, use LINGUAS=”ru_RU” to install it.

Ebuilds are here: axsentis overlay Git repository

See for the announcement.

Random development ideas: mod_upnp

A module based on the (MIT-licensed) MiniUPnP client library that uses UPnP (of course) to auto-discover your router and (with the help of FS’s events) magically forwards RTP traffic on-demand to your FreeSWITCH server.

UPDATE: FreeSWITCH got PMP / UPnP support in the core now, so this item is obsolete now.

mod_ssh: yet another status update

test02 freeswitch-trunk # ssh -p2222 test@localhost
test@localhost's password:
Welcome to FreeSWITCH on test02


That’s the new (not finished) terminal emulation, together with a customized (well, current ssh.conf.xml default) prompt.

mod_ssh status

Supported features:

  • Useraccounts in ssh.conf.xml, passwords in cleartext, SHA1 or MD5 hashed
  • Connection timeout, listen ip and port configuration via ssh.conf.xml (default: port 2222)
  • Password-based ssh authentication only, the server part of libssh doesn’t support public-key auth at the moment
  • Connecting via ssh client and entering api commands works, the commands will be executed and the result sent to the client. Mod_ssh is still lacking a (simple) terminal emulator so line editing etc. won’t work.
  • Logout via “…” or “logout” (use the “shutdown” api command to shut the switch down)
  • “ssh” api commands to list/kick active sessions and list/lock/unlock accounts

Even more progress…

Output has been cleaned up:

freeswitch@test02> ssh account
API CALL [ssh(account)] output:
===================== Accounts =====================
Username        | Auth-types
foobar          | password
test            | password
=================================[  2 account(s) ]==

freeswitch@test02> ssh session
API CALL [ssh(session)] output:
===================== Sessions =====================
Username        | Online since        | Misc.
               - No active sessions -

freeswitch@test02> 2008-11-28 17:43:49 [NOTICE] mod_ssh.c:512 ssh_handle_message() User "test" logged in
2008-11-28 17:43:49 [NOTICE] mod_ssh.c:583 ssh_handle_message() User "test" opened a shell session

freeswitch@test02> ssh session
API CALL [ssh(session)] output:
===================== Sessions =====================
Username        | Online since        | Misc.
test            | 2008-11-28 17:43:49 |
=================================[  1 session(s) ]==

And another command works now:

freeswitch@test02> ssh session kick test
API CALL [ssh(session kick test)] output:
+OK: 1 session(s) kicked

freeswitch@test02> ssh session
API CALL [ssh(session)] output:
===================== Sessions =====================
Username        | Online since        | Misc.
               - No active sessions -


Next Page »