Wednesday, August 11, 2010

Asterisk PRI Trunk Group customization - Top-Down/Bottom-Up Hunting

A glare condition is quite often issue, if the PRIs at PBX and CO is not configured properly for outbound/inbound calls to hunt the B channels.

You might be wondering, what the hell is 'a glare condition'?

A glare condition is the situation when the when a outbound call finds a clear channel and a new inbound call arrives at the very same instant, the inbound call wins, the outbound call gets "all circuts are busy"or vice versa.

So, how to fix it?

Let's say we have 23 channel PRI with D channel - 24. Telco is sending the inbound calls to hunt from channel 1 -> 23. So, I need to set outbound calls to hunt from channel 23 -> 1 to avoid the Channel Busy before ANY possibility of call collision.

How can I do that in Asterisk?

You specify which of four methods the Zap channel module is to use to select a non-busy channel from the channel group by prefixing the group number with one of the letters g, G, r, or R:
g: select the lowest-numbered non-busy Zap channel (aka. ascending sequential hunt group).
G: select the highest-numbered non-busy Zap channel (aka. descending sequential hunt group).
r: use a round-robin search, starting at the next highest channel than last time (aka. ascending rotary hunt group).
R: use a round-robin search, starting at the next lowest channel than last time (aka. descending rotary hunt group). [/color]

Create a new ZAP trunk and specify G0 as the trunk ID, go to your outbound routes. replace any routes calling for the trunk g0 and replace with new trunk G0. Go back and delete the g0 trunk so it will not be accidently selected as it is going to be the first trunk in the pull down list.

Wednesday, May 26, 2010

PRI/T1 having issues.... follow some of the checkpoints

[I am assuming that you know how to play with Asterisk]

A. Phyical Connection Issues

1. cabling

2. smart jack : It is the jack that can be used by Telco provider to do the loopback test remotely. With that said, it is not the mandatory device to put in the customer side, but Telco installs it on customer side so that they can do loopback test from their end remotely.

3. demarc : Telco line terminates to demarc of the customer primises.

Make a loop back plug. Simply take RJ-45 plug, loop a wire from pin1 to pin4 and another from pin2 to pin 5 and crip down the RJ-45.

If the circuit or the PRI/T1 card showing RED alarm, plug the loopback plug, if the circuit goes green then it says that hardware is good and configuration might also be good. But not 100% sure.
Plug the loopback plug on the smart jack to see if the Telco is having the issue. If the circuit goes green on the smart jack too, then jump to step B.

B. Protocol/signalling/configuration issues

1. Check if you are in sync on the physical layer - one of your T1 endpoints should provide clocking and another end should take clocking from the line

#/etc/zaptel.conf or /etc/dahdi/system.conf

span=<span num>,<clocking>,<LBO>,<framing>,<encoding>
e.g span=1,0,0,esf,b8zs

Here, clocking is set to 0 so it is using internal clock for clocking. So, it's configured like master clock source. The other end should be configured as slave for clocking ( i.e set second parameter to 1). If you are using T1 line from Telco provider, make sure that you set clocking to '0' as Telco is always configured as master for clocking.

esf,b8zs is widely accepted framing and encoding in North America.

2. Then, check if you have the same protocol running by both parties on the D-channel

#/etc/asterisk/zapata.conf or /etc/asterisk/chan_dahdi.conf

switchtype=<specify switchtype>
e.g switchtype=national

3. Finally, check if you have the right master/slave relationship on ISDN level. One side of the link should be set as network while another end should be set as user/slave.

#/etc/asterisk/zapata.conf or /etc/asterisk/chan_dahdi.conf

signalling=<specify signalling>


e.g signalling=pri_cpe #user-side configuration (Slave/User)
e.g signalling=pri_net #network-side configuration (Master)

If you are unsure how the other side is configured just try to set pri_net on Asterisk side. If it works with Telco provider, make sure that you contact them and tell them to change their configuration to NETWORK so that you can change your Asterisk as USER (pri_cpe).



Some bonus information:

Framing:
ESF
D4
CAS
CCS

Encoding:
B8ZS
AMI
HDB3
NCRC2

Signalling:
pri_cpe
pri_net
fxs_ks
fxs_ls
fxs_gs
fxo_ks
fxo_ls
fxo_gs
em (E&M)
em_w (E&M Wink)
em_e1

Switchtype:

Only used for PRI
national --> National ISDN 2 (default)
dms100 --> Nortel DMS100
4ess --> AT&T 4ESS
5ess --> Lucent 5ESS
euroisdn --> EuroISDN (common in Europe)
ni1 --> Old National ISDN 1
qsig --> Q.SIG




FAQs:


Why do we need encoding for T1 circuit? Why B8ZS?

Ans: B8ZS (Bipolar/Binary Eight Zero Substitution), also known as "Clear Channel" or "clear 64" is used with ESF framing in T1 Carrier systems. It uses Out-of-band signalling frees up all 8 bits of each byte to carry data, allowing each channel 64kpbs.

Consecutive eight zero bits is encoded as 000+-0-+0


B8ZS satisfies T1 Carrier regenerator ones density requirement that fifteen consecutive zeros cannot be send and that an average of at least one out of eigth bits contains a one. With that said, sending and receiving end both should be using B8ZS.


Why do we require framing for T1 circuit? Why ESF?
Ans: Since T1 circuit used TDM (Time Division Multiplexing). Acceptable audio bandwith is 4 KHz, so as per Nyquist Criteria sampling frequency should be 2x4KHz i.e 8 KHz. 8KHz can also be considerd as 8000 frames /second. Each channel is framed at 8KHz, so each channel has occupies bandwith of 8 bytes/frame x 8000 frames /second = 64 kpbs.

Frame synchronization is necessary to identify the timeslots wthin each 24 channel frame in T1 circuit. Synchronization takes place by allocating a framing or 193rd bit.
(8 bits data/channel x 24 channels/frame + 1 framing bit/frame)=193
i.e 193rd bit is the framing bit

For T1 line (also known as DS1)
(8 bits data/channel x 24 channels/frame + 1 framing bit/frame) x 8000 frames/second=1.544kbps

Looking at the above expression, we can say that we have
framing data= (1 framing bit/frame x 8000 frames/second) = 8 kbps
Because this 8 kbps channel is used for framing, only 1.536 kpbs (i.e 1.544kpbs - 8 kbps) is actually passed on to the user.

ESF (Extended Super Frame) consists of twenty-four consecutive 193rd bit frames.


Tuesday, May 4, 2010

I have multiple T1 cards on the Asterisk Server. How do I know which T1 card will load first?

Ans: This is very important question as SPANs for Tie Trunks relates with the order in which T1 card loads. For example,
Card 0 has Span1-4 as it is loaded first
Card 1 has Span5-8 as it is loaded second

However, what will happen if Card1 loads first. You are in trouble as Card1 will host Span1-4, not the Card0.

To prevent this disaster to happen, Digium has Ident Dial that makes the driver load on the card in specific order. Ident Dial has range from '0-9' 'A-F'.

Now, I would do this

Card0 with Ident set to 0
Card1 with Ident set to 1

This will ensure that Card0 will have Span1-4
and Card1 will have Span5-8

Setting all cards to zero should cause the driver to automatically number the cards. The dial should only be used if a specific order is needed.

http://kb.digium.com/entry/106/

Wednesday, April 28, 2010

Benefits of using trunk group instead of multiple T1/E1 trunks

(Explaination is based on benefits of creating trunkgroup of two T1 lines)

  • Less programming of trunk groups in the CO to manipulate overflow whether it be in or out. That is, if 1 trk group is busy there will be no need for overflow to the other trunk group. If it is one trunk group all the channels will hunt to next channel if they are in use whether it is inbound or outbound. Traditionally, incoming starts from trk member 1, outbound starts from trk member 46.

  • You will also get a backup d-channel that wil be available if the primary has a problem. If for some reason another span is needed, depending if the Asterisk is capable of doing this, it can be set-up as a full T1 rather than a PRI. This will get you an additional b-channel for voice and the full T1 can be a rider AND use the the d-channel signaling form the other spans.

Q: How can we achieve that in asterisk?

Ans: NFAS (Non-Facilities Associated Signaling) is an ISDN feature for sharing one ISDN D channel accross multiple ISDN PRI lines.

http://www.voip-info.org/wiki/view/NFAS

http://www.asterisk.org/doxygen/asterisk1.2/Config_zap.html

Thursday, April 15, 2010

SIP trunk between two Asterisk Servers

Let say I have two asterisk servers R01 and S01

; ****************
; *** SIP.CONF ***
; ****************
;
; Summary:
; - Configuration for SIP protocol
; - All phone registration information resides here
;
; Server: R01
; File location: /etc/asterisk/sip.conf
; *****************
;

[general]
disallow=all
allow=ulaw
canreinvite=no

register => trunk-S01-R01:welcome@[IP-add-of-S01]/trunk-S01-R01

[trunk-R01-S01]
type=friend
secret=welcome
host=dynamic
context=from-S01
;username=trunk-S01-R01

[1000]
type=friend
context=phones
host=dynamic
username=1000
secret=abc123



; ****************
; *** SIP.CONF ***
; ****************
;
; Summary:
; - Configuration for SIP protocol
; - All phone registration information resides here
;
; Server: S01
; File location: /etc/asterisk/sip.conf
; ***************
;

[general]
disallow=all
allow=ulaw
canreinvite=no

register => trunk-R01-S01:welcome@[IP-add-of-R01]/trunk-S01-R01

[trunk-S01-R01]
type=friend
secret=welcome
host=dynamic
context=from-R01
;username=trunk-R01-S01

[2000]
type=friend
context=phones
host=dynamic
username=2000
secret=abc123



DIALPLAN

;******************
;extensions.conf
;
;Server: R01
;******************

[globals]

[general]
autofallthrough=yes

[Internal]
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Dial(SIP/${EXTEN},30);
exten => _1XXX,n,Playback(the-party-you-are-calling)
exten => _1XXX,n,Hangup()

[External]
exten => _2XXX,1,NoOp()
exten => _2XXX,n,Dial(SIP/trunk-R01-S01/${EXTEN},30)
exten => _2XXX,n,Hangup()

[phones]
include => Internal
include => External

[from-S01]
include => Internal


;******************
;extensions.conf
;
;Server: S01
;******************
[globals]

[general]
autofallthrough=yes

[Internal]
exten => _2XXX,1,NoOp()
exten => _2XXX,n,Verbose(1,I am in Internal)
exten => _2XXX,n,Dial(SIP/${EXTEN},30)
exten => _2XXX,n,Hangup()

[External]
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Verbose(1,I am in External)
exten => _1XXX,n,Dial(SIP/trunk-S01-R01/${EXTEN},30);
exten => _1XXX,n,Playback(the-party-you-are-calling)
exten => _1XXX,n,Hangup()

[phones]
include => Internal
include => External

[from-R01]
include => Internal


>Start Asterisk #asterisk
>Go to Asterisk Console #asterisk -rv
CLI> sip show peers
CLI> sip show registry

Friday, April 9, 2010

SPAN in details (for Asterisk)

SPAN is the trunk parameter defined in /etc/dahdi/system.conf [ traditionally /etc/zaptel.conf ] for the PRI interface.

Trunk can be T1/E1.

span = [span num], [timing], [line build out], [framing], [coding]

e.g span = 1,0,0,esf,b8zs

This means, the specified trunk is mapped to SPAN 1 of the T1 card. It uses internal clock of card as time source as second parameter is 0. LBO is 0 and it doesn't require to be changed most of the time as cable is not going to be more than 133ft from smart jack. Framing is esf. Coding is b8zs.
[ Also remember, each PRI card should have their own independent clock source ]
In brief, you can say, this particular trunk is esf,b8zs with internal clock as time source.


I would like to write about some other parameters defined in /etc/dahdi/system.conf

span = 1,0,0,esf,b8zs
bchan=1-23 #B-Channel defination
dchan=24 #D-Channel defination

Since bchan+dchan=24, it is T1 trunk configuration.
For E1 trunk, bchan+dchan=31

Also note that FRAMING and CODING is main factor that can distinguish between T1 and E1 trunk.
--------------T1----------------------E1
Framing -- esf / d4------------ ccs / cas
Coding ---- b8zs / ami -------- hdb3 / ami
-----------------------------------------


When you talk about Trunk, you also need to specify the switch type. Switchtype parameter is defined in /etc/asterisk/chan_dahdi.conf . It can be National or dms100 or 5ess

Default Switch: National
Nortel Switch : dms100 [ but it's weird that in my case, i had to use 5ess switchtype to interface my Asterisk Server with Nortel Switch]
Dialogic Fax Server Switch : dms100

So, PRI with following configuration can be said as T1 trunk with esf,b8zs signalling and National switchtype.

#/etc/dahdi/system.conf
span = 1,0,0,esf,b8zs

#/etc/asterisk/dahdi.conf
switchtype = National



Wonderful explaination at :

http://www.asteriskguru.com/tutorials/pri_zaptel.html
http://www.asteriskguru.com/tutorials/pri.html


Telcom Terminologies

ISDN : Integrated Service Digital Network
=> 1.544Mbps line
=> Based on T1/E1
=> Carry DSO signal

BRI : Basic Rate Interface for SOHO
2B + 1D

PRI : Primary Rate Interface for large enterprise
T1: 23B + 1D
E1: 30B + 1D

PRI channels are typically used by medium to large enterprises with digital PBXs to provide them digital access to PSTN.

PRI is service and T1 is the hardware used for delivery. For eg. TE420 is one of the T1 hardware for PRI.

B - Channel : B stands for Bearer; It's an ISDN channel that carries data
D - Channel: D stands for Delta; It's an ISDN channel that carries control and signaling information


CSU/DSU : Channel Service Unit/Data Service Unit
=> It is a digital interface to connect DTE device, like router, to a digital circuit (eg. T1/E1 line)
=> It operates at physical layer of OSI model.