Summary:ASTERISK-01994: ztd-local driver
Reporter:nbougues (nbougues)Labels:
Date Opened:2004-07-12 05:47:53Date Closed:2008-06-07 10:46:35
Versions:Frequency of
Environment:Attachments:( 0) ztd-loc.c
( 1) ztd-loc.c.diff
Description:This really small ztdynamic driver enable a local TDM loop. It may be useful for at least two purposes :
- to interface Asterisk with another local app that understands the "one dev per timeslot" paradigm, to provide a virtual TDM link between them
- to connect two local Asterisk instances via TDM
- to monitor a TDM link : create 3 local links connected together. Make a DACS connection with a real TDM device, connect one of them to Asterisk, and have fun monitoring (read-only !!) the third one
These links are "no frame loss" guaranteed.
Comments:By: Mark Spencer (markster) 2004-07-12 11:01:18

This looks very interesting!  Can you include a patch for zaptel.conf.sample to show how you use it and also change // style comments to /* */ style comments?  Thanks!

By: nbougues (nbougues) 2004-07-15 10:37:42

Well, my first try wasn't so good after all.

So here is a new version (ztd-loc.c), which enables all the
described features.

The examples/explanations hereafter are biased toward E1 PRI. It should be
fairly straightforward to adapt to other situations.

* you want to test two Asterisk servers (or other software supprting
 Zaptel-alike interfaces) using TDM on one machine

Lines to add to zaptel.conf :


This will create two "loc" spans, with key "1", and id 0 and 1, connected
together since they ahve the same key.

Then add something like :



Then configure the first Asterisk to use 1-31 and the second one to use 32-62.

Channel 1 will be talking to 32, 2 to 33, etc.

* you want to monitor what's going on a TDM connection, for instance between
 your Asterisk server and an external TDM board, either on voice channels
 or on the sig channel, without interfering with Asterisk

Your zaptel.conf should look like :

# Normal setup for your TE410 or similar

# Create 4 local spans. Two of them connected together, and
# two others to monitor each direction of the link
# Key is 0
# Connect 0 <-> 1
# Connect 0 -> 2
# Connect 1 -> 3

# Now make a cross connect between the board and our local span group

# Here are the normal channels for the ports 2-4 ot the board



# The channels 125-155 (local span 0:0) are DACS-ed with channels 1-31,
# so there is no need to set them up

# These channels are for loc:0:1, that's where you will connect
# your Asterisk

# Those are the monitoring spans. They are read-only. You can monitor either
# voice channels or HDLC channel. You may set the timeslot 16 (channel 202) as
# clear if you want to validate HDLC decoding for instance.
# These spans should of course be used with your own testing/monitoring application.


- you can't get a frame lost. This is nice.
- you need to have a real zaptel device (either a board
 driver, or ztdummy) loaded first.
- alarms are not supported. The links are always on.
- there is a bug related to the DACS feature : you will
 get a panic if you try to rmmod ztd-loc when there are DACS-ed
 channels. Not sure why, but I believe it's not related to

By: twisted (twisted) 2004-07-23 20:51:09

Houskeeping reminder - Thanks!

By: nbougues (nbougues) 2004-07-26 08:29:29

FYI, I've been running several servers with such ztd-loc links for some weeks now.

My environnement is :
- 2 or 3 ztd-loc E1 links per server
- pure 1:1 connect, no monitoring

Not a single hickup.

But other areas (T1-alike, monitoring) probably need more testing.

By: Olle Johansson (oej) 2004-08-14 12:49:57

Moving this to experimental features for further testing. Suggest you mail the mailing list and inform about this patch and ask readers to help you test and give feedback.

By: Paul Cadach (pcadach) 2004-08-25 10:14:53

Check ticket ASTERISK-2269 about crashes when DACS is configured. Before unloading just do ztcfg -s to unconfigure all spans (required for clean unloading of ztd-* modules).

By: Paul Cadach (pcadach) 2004-08-25 10:21:20

ztd-loc.c.diff - proper module locking to prevent automatic unloading when in use.

By: Mark Spencer (markster) 2004-09-30 09:33:05

Is this now ready?  All bugs gone as far as you know?

By: Paul Cadach (pcadach) 2004-09-30 12:49:10

Last time I checked it had problems with SMP (single-CPU kernel works more-or-less well). I'll try to check again within next few days.

By: Brian West (bkw918) 2004-10-17 12:28:09

ready for CVS?

By: Mark Spencer (markster) 2004-10-25 23:09:24

Any activity here?  this looks like it would be pretty cool.

By: Paul Cadach (pcadach) 2004-10-25 23:17:47

Seems to ready for CVS. All bugs appears when ztd-local is in use related to core zaptel, not for this module.

By: Mark Spencer (markster) 2004-11-07 19:46:40.000-0600

Is there a disclaimer on file?

By: Russell Bryant (russell) 2004-11-14 22:02:06.000-0600

If there is no disclaimer on file, this can not be included in CVS.  Please feel free to re-open this bug when you can verify that you have a disclaimer on file.


By: Brian West (bkw918) 2004-12-01 16:36:27.000-0600

Lets get this disclaimed and IN CVS please.


By: Russell Bryant (russell) 2004-12-01 16:47:33.000-0600

Reminder sent to nbougues

There is interest in included your patch in CVS.  To do so, you must verify that you have a disclaimer on file.


By: Brian West (bkw918) 2004-12-01 17:09:24.000-0600

Any idea about the SMP on this?

By: Brian West (bkw918) 2004-12-01 18:27:57.000-0600

Ok lets see if we can solve htis SMP issue.. this thing is sooo handy ...


By: nbougues (nbougues) 2004-12-02 05:13:20.000-0600

OK, sorry for not replying earlier.

- As far as I know, my disclaimer is already on file (I had another patch integrated in CVS)
- About the SMP issues, I believe they are zaptel related. TDMoE has such problems as well.
- this software has been in use on several fairly active servers for a few months now.

By: Brian West (bkw918) 2004-12-02 07:47:22.000-0600

Yes we are now too it seems stable on no-SMP.


By: Brian West (bkw918) 2004-12-02 21:37:16.000-0600

You did disclaim this right?


By: Mark Spencer (markster) 2004-12-03 23:21:14.000-0600

Yah he mentioned the disclaimer earlier.  Added to CVS, thank you for your contribution!

By: Russell Bryant (russell) 2004-12-04 10:23:47.000-0600

This is cool.  Sorry for closing it out earlier!  I must have been on a housekeeping binge.

By: Digium Subversion (svnbot) 2008-06-07 10:46:35

Repository: dahdi
Revision: 505

U   trunk/Makefile
U   trunk/wctdm.c
A   trunk/ztd-loc.c

r505 | markster | 2008-06-07 10:46:35 -0500 (Sat, 07 Jun 2008) | 2 lines

Add ztd-loc, restruct wctdm for GCC 3.4 (bug ASTERISK-1994)