Huge thanks to Joshua Colp for mirroring services

A plan for span

Share on Twitter Digg this story Click to view a printable version Mon, 07 Jul 2008 21:59:02 -0300

Oron Peled has posted an RFC on the DAHDI (formerly Zaptel) span system.

Hi,

This is a renewed version of a paper distributed internally in Xorcom (and addressed to one of the Digium developers handling zaptel) some 6 months ago.

In this (long) mail I'd like to present:

* How Dahdi/Zaptel currently address spans and channels and why this is a big problem.

* How do I propose to solve it. What parts of the solution already exist. What is still missing. Backward compatibility.

* Final discussion.

Problem statement
-----------------

1. Span and channel registration today:

* Spans are identified by their numbers and channels by a numbering which is *global* across all spans.

* Span number are determined according to their registration order to Dahdi. Therefore, this determines the channel numbering.

* Most Dahdi low-level drivers registers their spans when they detect the relevant hardware devices.

RESULT: global channel numbering depends on hardware probing order.

2. Hardware probing:

* Some types of hardware have inherently non-deterministic probing order. An obvious example is hot-pluggable hardware like our USB Astribanks. Although we solved our specific case ages ago, other hardware types may gradually face the same problems.

* Even with relatively static devices like PCI cards, the addition of a single PCI device to an Asterisk server can change the probing order and thus affect the channel numbering of other cards. (Do you think an addition of single SCSI controller would affect the probing order of Zaptel/Dahdi cards? ... yes it may).

RESULT: Current span and channel numeric addressing is naive for big systems.

An addition of a single card to an existing PBX with several PCI cards may force a global change to the dialplan that already handle a couple hundred of lines.

This is totally unacceptable in a production environment.

Proposed Solution Components
----------------------------

1. Unique span naming: We must have unique names that identify spans and do not depend on their registration order:

* The names should be assigned by low-level drivers. They can identify the cards however they like, for example:

- One possibility is to read it from some property stored on the card itself (like a MAC address on a NIC).
E.g:
F00-1234-fee1-dead-5678

- Another option is to use the fully qualified PCI address:
bridge->bus->slot->function
as a unique identifier. E.g: PCI-bridge1-slot4-func2

* Although low-level drivers are assigning these "labels" they should be globally unique. It can be trivially achieved by prefixing them with the driver name (low-level drivers should have limited character set for these labels).
Examples:
wctdm:PCI-slot2
wctc4xxp:ID-4567-E3F4
xpp:USB-0000:00:1d.7/5-2

2. Exporting these names to user-space:

* These names should be available to high-level driver and to user space. The mechanism for this already exist, since Digium introduced the 'location' field in the SPANINFO ioctl() We should only mandate the limitations for the strings that may be stored in this field (or add another field?)

* However, we would like to create device files named according to these span identities. Therefore:

- We need sysfs representation for spans.
- Tzafrir already started some work in a branch long time ago.
- Doing it right will also clean up the deprecated class_device usage for channels (Kevin already #defined around this in Dahdi)

* The basic sysfs model maps nicely to Dahdi:

- Spans are devices on the (virtual) dahdi bus.

- Each span is a (virtual) bus on its own containing the channels as devices. Channels would have local (relative) numbers.

- Obviously the span unique label would be one of the attributes of every span object in sysfs. Another attribute should be the span number.

* Now using UDEV rules, we can create a naming scheme for both the spans and the channels. Since UDEV rules can access SYSFS attributes, the names should be based on the identity string of the span. One possible scheme may be:

/dev/dahdi/span/<span_identity>/<channum_in_the_span>

E.g:
/dev/dahdi/spans/PCI-slot5/1
/dev/dahdi/spans/PCI-slot5/2
...
/dev/dahdi/spans/PCI-slot5/24
/dev/dahdi/spans/PCI-bridge1-slot8/1
/dev/dahdi/spans/PCI-bridge1-slot8/2
...
/dev/dahdi/spans/PCI-bridge1-slot8/4

[Note that channel numbering is *local* to each span]

* We can even run a trivial script from UDEV that provides an *optional* mapping of physical span labels into logical user defined names.
E.g: the script can read something like /etc/dahdi/span_map:
# Name by driver Human usable name
PCI-slot5 fat_trunk
PCI-bridge1-slot8 main_office

And either map the names (if present) of leave them unmapped otherwise. This way the user will have:
/dev/dahdi/spans/fat_trunk/1
/dev/dahdi/spans/fat_trunk/2
...
/dev/dahdi/spans/fat_trunk/24
/dev/dahdi/spans/main_office/1
/dev/dahdi/spans/main_office/2
...
/dev/dahdi/spans/main_office/4

* Backward compatibility device files:
- Proper udev rules can create symlinks from /dev/dahdi/[1-] to the new names.

3. Changes to chan_dahdi:

* We need to decide on some unused separator character that would separate span name from relative channel number in modernized dialplans (let's assume ':')
Example:
Zap/main_office:5

* Channel parsing should be done as two steps:

- Try to parse as the following regex: Zap/[^:]+:d+
In that case, we save the span name and the (relative) channel number.

- Otherwise, try to parse the traditional way: Zap/d+

* When chan_dahdi opens the channel, it should be respectively done as:

- Map span name + local channel number to
/dev/dahdi/span/<name>/<number>

- Otherwise, open /dev/dahdi/channel + ioctl(...SPECIFY...)

* The result should be that existing dialplans are not changed (but don't have the benefits of the new scheme). On the other hand new dialplans (especially if they use the span name mapping) are very protected against hardware changes.

4. Changes to dahdi_cfg
* We need to optionally enable the alternative naming in /etc/dahdi/system.conf as well. dahdi_cfg should be able to translate the names in system.conf into device file names in /dev so it can open them and issue the required ioctl's.

* The new syntax must preserve the ability to use old style syntax. This means we need to differentiate absolute channel numbers (legacy) from span-relative channel numbers. I suggest to use different keywords for new syntax.
An example may be:

# Analog channels (legacy numbering)
fxsks=1-4

# Analog channels (new style)
spanname=PCI-slot2
channels=fxsks,1-4 # Look Ma, relative numbers
# dahdi_cfg should now config /dev/zap/spans/PCI-slot2/1 etc.

# PRI (new style)
spanname=PCI-slot5,1,0,esf,b8zs
bchannels=1-23 # Local numbers independent from other cards
dchannel=24

# More old syle definitions
span=1,1,0,esf,b8zs
# Hmmm. that may be duplicate of a previous named span
# if it incidentally got span number 1. The revised dahdi_cfg
# should issue a warning/error in this case.
bchan=1-23
dchan=24
# Again, if we already configured these channels, issue
# a warning/error. That's easy to detect since we can check:
# stat("/dev/dahdi/1") and stat("/dev/dahdi/PCI-slot5/1")
# for st_dev, st_ino equality.

* Most of the work here is implementing improved parsing in dahdi_cfg which seems pretty easy, taking into account the limited syntax of system.conf.

Hmmm.... maybe it's time to rewrite dahdi_cfg in perl... that would probably result in a 5-liner with three horrendous regular-expressions and one ioctl() in the end...
[OK, that one was a joke]


Final Thoughts
--------------

1. Implementing span names and exporting them is fairly trivial. The missing part is proper sysfs representation which isn't too bad. Even that alone would bring a lot of benefits. Span and channel properties can be represented properly and be used by user-space (e.g: for (semi)automatic configuration generation).

2. chan_dahdi and dahdi_cfg looks like more work, but since we only want to touch the parsing and opening of devices, it does not look like a very big code change.

The big prize for implementing it:
You add a new T1 span to a PBX with some 300 phones and have to configure only the new 24 lines. Other phones keep running as usual.

We can make it even simpler. If dahdi_cfg would implement an "includedir" directive and in /etc/dahdi/system.conf we have:
includedir /etc/dahdi/spans/*.conf

Then configuring the new span amounts to dropping a small file into this directory and rerunning dahdi_cfg.

Thoughts, comments, ideas, flames?

[Almost forgot: the Subject of this mail was cheerfully adapted from the infamous Paul Graham: http://www.paulgraham.com/spam.html ]

--
Oron Peled


You haven't voted yet! Vote:
Current Rating: 0/10 (0 votes)

Comments (Click to post)

Comments
Name:
Subject:
Website:
Message: 

Similar Articles (Based on Title)

FCC seeks public comment on plan to move PSTN to VoIP - December 8, 2009
The CompareBusinessProducts website has an article on the FCC requesting comment about moving the PSTN to VoIP.

Asterisk-Users: How to restart a GS 101/102 phone remotely - September 28, 2004
Tony Mountifield posted an answer to the asterisk-users list on how to remotely restart a GrandStream phone.

Voxilla: VoIP Market Leaders Declare a Price War - October 1, 2004
It seems a price war has broken out between AT and T and Vonage over VOIP Services.

Xorcom: How to install a SIP phone, Connecting to the Asterisk Manager - October 12, 2004
The guys over at Xorcom have a tips section with a couple of tips.

Sipura Technology Announces Two New VoIP Endpoint Products (one a phone) - October 16, 2004
Their press release was in PDF so I've converted it to text so that you can read it easier.

Ravings of a strange mind: Back from Fall VON - November 4, 2004
Craig Southeren has posted details of his trip to VON.

Astertest.com: Asterisk Makes a Great Media Server - November 20, 2004
The guys over at Astertest have managed ti get 790 simultaneous audio playbacks on a $350 PC.

Asterisk-Users: A new alternative to see who is online - November 21, 2004
Nicolas has posted details of a program to display the status of lines in Windows

TechWeb: VoIP Pioneer Predicts A Roiling 2005 for IP Telephony - December 21, 2004
Jeff Pulver has predicted that the effects of open source VOIP software "will be felt in the next 12 to 18 months".

*-CVS: A few changes of note - January 6, 2005
RAWplayer, wctdm and fxotune commits have occured.

pbs.org: Betting a Billion - January 11, 2005
Robert X. Cringely has put Asterisk success in his predictions for 2005.

First Asterisk CVS commit from a plane! - January 13, 2005
Kram (Mark Spencer) has committed the first CVS change to Asterisk from a plane. History has been made!

About DeStar, a web frontend for Asterisk - January 22, 2005
Alejandro Rios Pena has posted details of an article about DeStar.

Meet Asterisk: A one-day introduction to the Asterisk PBX! - February 11, 2005
Digium has put out a press release about an upcomming Asterisk training session.


Original Content (C) 2004-2010 Matt Riddell
Back 5  Feed Add
to
Google Subscribe with Bloglines
Go to today

Icons by: FastIcon.com


Back to life
July 21, 2010 Average Vote: 10
Hey all - I am back online after some pretty big projects which have taken all my time. Will be updating the Asterisk news over the next few days.

Nerd Vittles: Building a Bluetooth Proximity Detection System with Asterisk
December 12, 2005 Average Vote: 10
The Nerd Vittles site has an article on proximity detection using Asterisk and a TomTom GPS

Automated Testing Update
July 30, 2010 Average Vote: 10
Russell Bryant has posted details of a new mailing list for automated testing of Asterisk and some information on the progress that has been made. There is no way to say how important I think this work is. It really makes a huge difference to Asterisk and the ability to use it in an enterprise environment. Really great work.

VoIP-Info: FFasterisk Video file converter
August 25, 2006 Average Vote: 10
The wiki has a link to a new piece of software for converting video to the format required for Asterisk.

Code Review: SRTP support for Asterisk
March 12, 2009 Average Vote: 10
Terry Wilson has moved his SRTP branch onto the Digium review board.

HumBug - Pre BETA Launch Registration
July 27, 2010 Average Vote: 10
Nir Simionovich has posted details of the beta of the new call analytics service.

Interview with BKW_
December 7, 2004 Average Vote: 10
We've finally completed our interview with BKW. Hope you like! :-)

SlashDot: GSM and Asterisk Integration
August 21, 2005 Average Vote: 10
There is a post up on SlashDot which talks about using cellphones with Asterisk.

Interview with Mark Spencer
November 26, 2004 Average Vote: 9.9
We have managed to get an interview with Mark Spencer AKA Markster. Mark Spencer is the creator of Asterisk and by far the most active developer.

Asterisk and Kamailio realtime integration tutorial
May 24, 2010 Average Vote: 9.9
Daniel-Constantin Mierla has posted a link to a tutorial on integrating Asterisk and Kamailio using realtime.

Asterisk IPv6 update
February 1, 2010 Average Vote: 9.8
Olle has posted an update on IPV6 in Asterisk and a link to a blog post of his.

Proposal for T.38 transparent gateway design in Asterisk
April 29, 2010 Average Vote: 9.8
Kevin Fleming has posted a proposed design for a transparent T.38 gateway for Asterisk:

Asterisk Monitoring with iPhone and iPod touch
February 12, 2010 Average Vote: 9.7
For the past couple of weeks I have been working on an app that allows you to monitor and restart Asterisk servers.

Monitoring Asterisk with Munin
January 7, 2010 Average Vote: 9.7
I had a few requests for these munin plugins after some discussion on one of the Asterisk lists and thought people might like them.

New Zealand Asterisk Voices
March 2, 2006 Average Vote: 9.7
Chris Hodgetts has posted details of recordings of Asterisk Sounds with a New Zealand accent.


Automated Testing Update
July 30, 2010
Russell Bryant has posted details of a new mailing list for automated testing of Asterisk and some information on the progress that has been made. There is no way to say how important I think this work is. It really makes a huge difference to Asterisk and the ability to use it in an enterprise environment. Really great work.

Asterisk 1.8.0-beta2 Now Available
July 28, 2010
The Asterisk Development Team has announced the release of Asterisk 1.8.0-beta2.

HumBug - Pre BETA Launch Registration
July 27, 2010
Nir Simionovich has posted details of the beta of the new call analytics service.

Branch Merging Changes
July 26, 2010
Russell Bryant has posted details of some changes to the way developers need to commit code to Asterisk because of the newly released 1.8 branch.

Asterisk 1.8.0-beta1 is Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.8.0-beta1. This release marks the beginning of the testing process for the eventual release of Asterisk 1.8.0.

Asterisk 1.6.2.10 Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.6.2.10.

Asterisk 1.4.34 Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.4.34.

AppleRaisin - AstDB over realtime
July 23, 2010
Olle has posted a note about his awesome AppleRaisin branch which provides the ability to store AstDB in realtime. This would make for a much simpler failover and clustering situation.

QueueMetrics 1.6.1 released
July 22, 2010
Lenz has posted a note to inform us that QueueMetrics version 1.6.1 has been released. This release offers a large number of bug fixes, misc improvements and new developements including hotdesking.

Asterisk 1.8 Branch Creation
July 22, 2010
Russell Bryant has posted a note to inform us of the creation of the 1.8 branch of Asterisk.