Asterisk study notes: two-machine E1 Card Interoperability Experiment

Source: Internet
Author: User
Tags goto openssl
Required hardware and software environment and connection mode

Required hardware and software environment
This test used two E1 cards, respectively, te110p and te210p, according to the instructions on the card to jump into the E1 mode.
Two machines, operating system centos4.x, installed ZAPTEL,LIBPRI and asterisk.
The installation process is summarized as follows:
Rpm-q kernel-source zlib zlib-devel OpenSSL openssl-devel
Detection of the above packages are installed, if there is a missing can not continue the next step work
# CD Zaptel into the unpacked Zaptel source directory
# make clean; Make install
# CD ... /libpri into the unpacked Libpri source directory
# make clean; Make install
# CD ... /asterisk into the unpacked asterisk source directory
# make clean; Make install
# Make Samples
; Generate the default configuration file

(* note, if the CentOS4.3 system, due to system bugs, compile Zaptel will have errors to play kernel patches)
E1 Card Connecting Line
The E1 card can be connected by two connecting lines, the 75ω and 120ω lines respectively. This test because did not find the standard E1 cable, so can only use 100M cable instead, as long as the line does not do too long, should not be a problem.
The interface of the E1 card is the Rj-48 interface. RJ48 is the interface for serial lines such as T1/e1, and the RJ45 of Ethernet is the same. For different transmissions, the signal definition is not the same, and I do this test by T1/e1 Trunk and Digital Voice Port (RJ-48). The following are the signals of each stitch: Pin1 Signal 1 rx + (Input) 2 RX-(Input) 3-4 TX + (OUTPUT) 5 TX-(output) 6-7-8-
When you do the line should pay attention to the RJ48 mouth is "convex" this shape, the line order from left to right is 87654321. Cross the line when you are on both sides, 1<->4,2<->5 exchange.
After the line is well connected directly to two pieces of E1 card can be.
E1 Card driver Loading and configuration
Zapdata installed, you need to manually load the E1 card driver only line, you can add it to the/etc/rc.local when the boot automatically load. The Load method is:
Modprobe Zaptel
Modprobe Wct4xxp (te210p) or WCTE11XP (te110p)

Configuring related parameters requires editing/etc/zaptel.conf ("[]" content not required when using the te110p card)
Span=1,1,0,ccs,hdb3,crc4
[Span=2,2,0,ccs,hdb3,yellow]
BCHAN=1-15,17-31[,32-46,48-62]
DCHAN=16[,47]
Loadzone=cn
Defaultzone=cn

Configure/etc/asterisk/zapata.conf:
1 shielding the middle of the line configuration
; Signalling=fxo_ls
2 Uncomment the following lines at the end of the file;
Switchtype = Euroisdn
signalling = Pri_net (or PRI_CPE, two must be configured differently to enable two-machine direct interconnection)
Group = 1
Channel => 1-15,17-31[,32-46,47-62] (te110p card does not configure content in [])
The ZTCFG–VVV can be used to see if there is anything wrong with it.
Asterisk Brief configuration
Before the configuration needs to be regulated, two E1 cards need to set a number first, because the conditions are limited, there is no extension, so we can only use SIP terminal as an extension to do the test, so that each machine needs to be equipped with a SIP account. We have regulated the following:
Machine SIP account E1 card number
A (te210p) 00000000 02100000000
B (te110p) 11111111
11111112 051011111111
051011111112
The SIP and dial plans are configured separately below.
Configuring SIP modules and adding SIP accounts
Within the/etc/asterisk/sip.conf file on Server B, the bindport=5058 in [general] can change the listening port.

At the end of the file, add:
[11111111]
Type=friend
username=11111111
secret=11111111
Host=dynamic
Context=default
Nat=yes
Canreinvite=no
Disallow=all
Allow=ulaw
Allow=alaw

Also add 11111112 account number.

Friend said that the account can be paged out, username represents the account number, secret represents the password, host represents the domain name or address of the account, Nat indicates whether the media agent, Disallow=all to prohibit the main call of all media types, allow= Ulaw represents the g711 of the U-Law encoding, disallow and allow is or relationship.
   
The 00000000 account number is built on server A, and the other configurations are the same.
Configuring Dial Plans
Edit the/etc/asterisk/extensions.conf file on Server B and add at the end:
Exten => _021.,1,setcallerid (051011111111)
Exten => _021.,n,dial (zap/g1/${exten:0})
Exten => _021.,n,hangup
The simulated environment assumes that the B server local number starts with 0510, the a server local number is 021, and when the local account on the B server dials the 021 opening number, because it is not a local number, the E1 is out and the call to a server is transferred. and send the main call number for the local No. 051011111111 code to facilitate callback (of course, the number does not actually exist, the following will be processed on the number)
Exten => _0510.,1,dial (SIP/${EXTEN:4},20,RT)
Exten => _0510.,n,hangup
When called 0510, for local number, remove 0510 prefix direct to local SIP account (condition limit, no direct physical extension, use soft phone simulation)

For example, when a server turns 0510 to an outgoing call to the B server, the caller calls to 051011111111 and automatically transfers to SIP account 11111111. Then the hang up action.
When a 021 opening number, such as 02100000000, is called from the B server, the transmission number is set to 051011111111 and the G1 is dialed through the Zap module (that is, from the E1 card). G1 (group 1, see zapata.conf Configuration), $ (exten) indicates the called number, calling No. 02100000000 on Server A.

A on the server, the configuration is:
Exten => _021.,1,dial (SIP/${EXTEN:3},20,RT)
Exten => _021.,n,hangup
That is, the B server above sent out 021 of the initial number of outgoing calls (also processing local calls, a server is the same), remove the 021 prefix to call the local SIP account.
Exten => _0510.,1,setcallerid (02100000000)
Exten => _0510.,n,dial (zap/g1/${exten:0})
Exten => _0510.,n,hangup
IBID., a server to call 0510 opening number, the need to be out to B server processing, set a 021 initial local account after E1 send out the call.

Asterisk dual machine E1 simple interoperability test
With ASTERISK–CVVVVVVV on a, b two servers to start asterisk, if there is no problem will appear in the &CLI> form of the prompt, you can debug and send instructions (you can adjust the number of VVV letters to indicate how much debugging information displayed, You can use the TAB key to automatically complete the prompt line command.
Use a soft phone to log on to both the B and a servers with 11111111,11111112 and 00000000 accounts, and test below.
1111111[1|2] Call 05101111111[2|1],1111111[2|1] Soft phone ringing, you can call, simulate local calls.
1111111[1|2] Call 02100000000,00000000 soft phone ringing, you can call, Analog E1 dial out (for 11111111 account, B Server) and inbound (For 00000000 account, a server).
Asterisk Dial Plan Advanced Configuration
As a simple simulation environment, the dial plan configuration for numbers is relatively simple and may not meet the requirements in a real-world environment, and it is necessary to have a deep understanding of the asterisk of the numbering and dialing processes in the Dial plan configuration in order to configure a flexible dial plan that meets the actual requirements.
Here is an example, that is, from B through the E1 out of the call, not fixed to send a main call number, such as in this case can make the call to the end of the SIP account is odd to set a master station sent out, such as even, then send out another main station.
The configuration file for Server B can be changed to:
Exten => _0510.,1,dial (SIP/${EXTEN:4},20,RT)
Exten => _0510.,n,hangup

Exten => _021.,1,set (Lastnum=${callerid (num):-1})
Exten => _021.,2,gotoif ($[${lastnum}% 2]?5)
Exten => _021.,3,setcallerid (051011111112)
Exten => _021.,4,goto (6)
Exten => _021.,5,setcallerid (051011111111)
Exten => _021.,6,dial (zap/g1/${exten:0})
Exten => _021.,n,hangup

Can add a few more accounts in B's sip.conf, test know, when the SIP account is the last odd, call 02100000000, at 02100000000 can see the main call number is 051011111111, and the end is even, Is 051011111112, the configuration in the example above will be analyzed to briefly describe the asterisk commands, functions, variables, and expression syntax.
In the configuration file, _0510. is used to match the called number, it can be a direct number, or it can be matched with a wildcard character, and its official document can be viewed in the wildcard format.
The number after the match number indicates the processing steps after the success of the number matching, according to a number of serial number of the execution, but also through Goto and other jump commands for jump execution, numbers can not repeat and numbering errors, otherwise it will cause the Dial plan logic error, If you do not use the goto jump command (The jump command requires a real number value), you can use n instead of (or after the actual number Goto used), the system automatically increments the serial number to exempt from manual management trouble.
The last item is the processing command field for the asterisk dial plan, in which commands, functions, variables, and expressions can be used, with simply one command, such as Hangup (a command without parameters), hang up the phone, or be dial (zap/g1/${exten:0}) (Command with parameters), call Zap Channel through the E1 call, the parameters are variable ${exten}, there can be expressions, such as GotoIf ($[${lastnum}% 2]?5) in the $[${lastnum}%2], with "$[...]" The enclosed field is an expression.

All of the function description data can be viewed:
Http://www.voip-info.org/wiki/index.php?page=Functions
The common functions are:
CallerID set or read the master call information (call number, description, Ani,dnis,rdnis, etc.)
CHANNEL set or read the parameters of a call channel (such as the state of a ZAP channel)
Cut similar to substr function, commonly used for the interception of numbers (number connection does not need to use the function)
ENV Sets or reads system environment variable values
IF to judge the true and false of an expression
LEN calculates the length of the string (generally used to determine whether there is a master number for 0 detection)
Math to calculate mathematical expressions
MD5 Calculation MD5
REGEX matching, Format ("<reg ex>" <data>)
Set the most commonly used, custom variable settings

The command instructions for all modules can be viewed:
Http://www.voip-info.org/wiki/index.php?page=Asterisk+-+documentation+of+application+commands
Common modules commonly used commands are:
Normal call handling
Wait for a certain time
Waitexten waits for the user to press the key until the timeout time
Answer in the main party, the phone is connected.
Busy in the main party performance for, busy
Chanisavail detects if a channel is available
Dial pull a Channel
Hangup in the main party performance, the phone has been hung up
Ringing in the main party performance, heard ringing

Process Control
Goto jumps directly to a number number of a dial plan (default is the current dial plan)
GotoIf configuration criteria to determine if true to jump to the specified number
Gotoiftime jumps to the specified number number when the specified time condition is met
Gotosub jumps to the specified sub (Child plan), which adds a plan name after the number, unlike a normal numeric number jump, which can be returned to the trunk with return in a sub
GOTOSUBIF, make conditional judgment and jump to Sub
Return sub in Trunk

Voice control
Background Play background music
Playback play sound, unlike background music, users need to listen to play before they can continue the execution of the Dial plan
Sayunixtime Broadcast Time
Sayalpha Read characters
Saydigits reads a number, a number reads a number
Saynumber read the value, unlike the previous one, this command recognizes the value unit
Record recording

Other
MeetMe attend the meeting
Voicemail voice mail

System predefined variables can refer to:
Http://www.voip-info.org/wiki/index.php?page=Asterisk+variables
${callerid} Master Call information, take number ${callerid (num)}
${datetime} Current Time information
${exten} is called number

The expression syntax logic can refer to:
Http://www.voip-info.org/wiki/view/Asterisk+Expressions
Basic format: $[EXPR1 operator EXPR2]
Logical operations:
"|", "&", "!"

Compare operations:
"=", "!=", "<", ">", "<=", ">="

Arithmetic operations
"+", "-", "*", "/", "%"

Regular action:
"Expr1:regex", "Expr1 =~ expr2"

Other:
"Expr1?" EXPR2:: Expr3 "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.