Asterisk learning Manual: Dual-machine E1 card interconnection Experiment

Source: Internet
Author: User
Required hardware and software environments and Connection Methods

Required hardware and software environments
Two E1 cards are used in this test, te110p and te210p, respectively. They are switched to the E1 mode according to the instructions on the card.
Two machines, centos 4.x, and zaptel, libpri, and asterisk are installed.
The installation process is described as follows:
Rpm-Q kernel-source zlib-devel OpenSSL-devel
Check that the software package has been installed. If any software package is missing, you cannot continue the next step.
# Cd zaptel enter the decompressed zaptel source code directory
# Make clean; make install
# CD ../libpri enter the decompressed libpri source code directory
# Make clean; make install
# CD ../asterisk enter the extracted asterisk source code directory
# Make clean; make install
# Make Samples
Generate the default configuration file
 
(* Note: if it is a centos4.3 system, due to system bugs, there will be errors during zaptel compilation and Kernel Patching is required)
E1 card connection line
The E1 card can be connected using two connection lines: 75 Ω and 120 Ω. In this test, the standard E1 connection line is not found, so it can only be replaced by a m network cable. As long as the line is not too long, it should not be a problem.
The interface of the E1 card is the Rj-48 interface. Listen 48 is an interface used for T1/E1 and other serial lines. It is the same as RJ45 over Ethernet. For different transmission, the signal definition is different, this test I made in T1/E1 trunk and digital voice port (RJ-48) mode. Signal of each pin: pin1 signal 1 RX + (input) 2 RX-(input) 3-4 Tx + (output) 5 TX-(output) 6-7-8-
Note that the 48-port serial number is convex, and the linear sequence is 87654321 from left to right. The two sides need to be crossed when the line is made, 1 <-> 4, 2 <-> 5 Exchange.
Connect the two E1 cards directly after the cables are completed.
Drive loading and configuration of E1 card
After zapdata is installed, you must manually load the drive of the E1 card. You can add it to/etc/rc. Local to automatically load it when it is started. The loading method is as follows:
Modprobe zaptel
Modprobe wct4xxp (te210p) or wcte11xp (te110p)
 
To configure relevant parameters, edit/etc/zaptel. conf ("[]" is not required when the te110p card is used)
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) shield the configuration of the following line in the middle
; Signalling = fxo_ls
2) cancel the following line of comments at the end of the file;
Switchtype = euroisdn
Signalling = pri_net (or pri_cpe, the two must be configured differently to achieve direct interconnection between two servers)
Group = 1
Channel => 1-15, 17-31 [, 32-46,47-62] (Content in "[]" is not required for the te110p card)
After configuration, use ztcfg-vvv to check whether there are any errors.
Brief asterisk Configuration
Before configuration, you need to set up a number for each of the two E1 cards. Due to limited conditions and no extension, we can only use the SIP terminal as the extension for testing, in this way, a sip account is required for each machine. The rules are as follows:
Machine sip account E1 card number
A (te210p) 00000000 02100000000
B (te110p) 11111111
11111112 051011111111
051011111112
Configure the SIP and dial-up plans respectively.
Configure the SIP module and add a sip account
In the/etc/asterisk/sip. conf file on server B, 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

Add the 11111112 account.

Friend indicates that the account can call in and out, username indicates the account, secret indicates the password, host indicates the domain name or address of the account, and Nat indicates whether the account is used as a Media Proxy, disallow = All indicates that all media types of the caller are prohibited. Allow = ulaw indicates that u law encoding of g711 is allowed, and disallow and allow are or.
   
Create an account of 00000000 on server A. All other configurations are the same.
Configure a dial-up plan
Edit the/etc/asterisk/extensions. conf file on server B and add:
Exten => _ 021., 1, setcallerid (051011111111)
Exten => _ 021., N, dial (Zap/G1/$ {exten: 0 })
Exten => _ 021., N, hangup
In the simulated environment, assume that the local number of server B starts with 0510 and the local number of server a starts with 021. When the local account on server B calls the Starting number of 021, because it is not a local number, go to server a through outbound E1 and send the caller number to the local 051011111111 number for convenient callback (of course the number does not actually exist, the following will handle the number)
Exten => _ 0510., 1, dial (Sip/$ {exten: 4}, 20, RT)
Exten => _ 0510., N, hangup
When the callednumber starts with 0510, it is a local number. After the 0510 prefix is removed, it is directly transferred to the local sip account (with restrictions, no physical extension is available, and it is simulated by a soft phone)

For example, when server a switches an outbound call starting with 0510 to server B, the call is automatically forwarded to the SIP account 051011111111 when the call reaches 11111111. Then, it is the hanging action.
When a user calls the start Number of 021 on server B, for example, 02100000000, The passthrough number is set to 051011111111, and is allocated through G1 of the zap module (that is, outbound from the E1 card ). G1 (group 1, see Zapata. conf configuration), $ (exten) indicates the called Number and calls the 02100000000 number on server.

Server A is configured as follows:
Exten => _ 021., 1, dial (Sip/$ {exten: 3}, 20, RT)
Exten => _ 021., N, hangup
That is, when server B sends out calls starting with 021 (local calls are also processed, server a is the same), and calls the local sip account with the 021 prefix is removed.
Exten => _ 0510., 1, setcallerid (02100000000)
Exten => _ 0510., N, dial (Zap/G1/$ {exten: 0 })
Exten => _ 0510., N, hangup
Same as above, when a server calls a number starting with 0510, it needs to be forwarded to server B for processing. After a local account starting with 021 is set up, it sends a call through E1.

Asterisk dual-host E1 simple interoperability test
Use asterisk-cvvvvvvv to start Asterisk on servers A and B. If there is no problem, a prompt in the form of & CLI> appears, debugging and command sending are supported (you can adjust the number of vvv letters to indicate the number of debugging information displayed, and use the tab key to automatically complete the prompt line command ).
Log on to server B and server a with accounts 1111111112, 11111112, and 00000000 respectively. perform the following test.
1111111 [1 | 2]: Call 05101111111 [2 | 1]. Call 1111111 [2 | 1] to simulate a local call.
1111111 [1 | 2] When you call 02100000000, you can call by ringing the 11111111 soft phone. In this case, E1 dial out (for 00000000 accounts, server B) and incoming call (for accounts, server a) are simulated ).
Advanced Configuration of Asterisk Dial-Up Plan
As a simple simulated environment, the number dial-up plan configuration is relatively simple and may not meet the requirements in the actual application environment, we need to have a deep understanding of the logic processing methods of the number and dialing process in the dial-up plan configuration of Asterisk to configure a flexible dial-up plan that meets actual needs.
The following is an example. When B is called out through E1, a caller number is not sent, for example, in this example, if the last digit of the SIP account that initiates a call is an odd number, a caller ID is set to be sent. If the last digit is an even number, another caller ID is sent.
The configuration file of server B can be changed:
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
 
It can be in the SIP. several more accounts are added to the conf file. The test shows that when the last digit of the SIP account is an odd number, when the last digit of the SIP account is 02100000000, when the last digit is 02100000000 and the last digit is an even number, the value is 051011111112. Next, we will analyze the configuration in the previous example and briefly introduce the asterisk commands, functions, variables and expression syntax.
In the configuration file, such as _ 0510. is used to match the called number. It can be a direct number or a wildcard to match the number. Its wildcard format can be viewed in its official documentation.
The number after the number is matched indicates the processing step after the number is matched successfully. The number is executed one by one. However, you can use a jump command such as goto to perform the jump, numbers cannot be repeated or numbers are incorrect. Otherwise, the dialing plan logic may be incorrect. For example, if a jump command such as goto is not used (the jump command requires a real number value ), the serial number can be replaced by N from 2 (or used after the actual number used by Goto). The system automatically increments the serial number to save the trouble of manual management.
The last one is the processing command field of the asterisk Dial-Up Plan. In the command field, you can use commands, functions, variables, and table expressions. You can simply use only one command, for example, hangup (a command without parameters), hanging up the phone, or dial (Zap/G1/$ {exten: 0}) (a command with parameters ), when calling zap through E1, another variable $ {exten} in the parameter can also have expressions, such as gotoif ($ [$ {lastnum} % 2]? 5) in $ [$ {lastnum} % 2], the field included in "$ [...]" is the expression.

For more information about all functions, see:
Http://www.voip-info.org/wiki/index.php? Page = Functions
Common functions include:
Callerid sets or reads the Caller information (such as the caller number, description, Ani, dnis, and rdnis)
Set or read call channel parameters (for example, the status of a zap channel)
Cut is similar to the substr function, which is generally used for number truncation (no function is required for number connection)
Env sets or reads system environment variable values
If is used to determine whether the expression is true or false
Len calculates the length of a string (generally used to determine whether the value is 0 and check whether there is a caller number)
Math computes Mathematical Expressions
MD5 calculation MD5
RegEx Regular Expression matching, format ("<Reg ex>" <DATA>)
Set is the most common and custom variable setting.

You can view the command instructions for all modules:
Http://www.voip-info.org/wiki/index.php? Page = asterisk +-+ documentation + of + application + commands
Common commands for common modules include:
Common call handling
Wait wait for a certain period of time
Waitexten waits for the user to press the button until the timeout time
Answer shows in the caller that the phone is connected
Busy is busy at the caller
Chanisavail checks whether a channel is available
Dial pulls a channel
Hangup is displayed on the caller, and the phone has been hung up.
Ringing is displayed in the caller.

Process Control
Go to the number of a dial-up plan (the default is the current dial-up plan)
Gotoif configuration condition judgment. If it is true, it will jump to the specified number
Gotoiftime jump to the specified number when the specified time condition is met
Gotosub redirects to the specified sub (sub-plan). You can add the plan name after the number. Different from the normal number jump, you can use return to return the trunk in sub.
Gotosubif is the same as above. Jump to sub after condition judgment
Return the trunk in return sub

Sound Control
Playing background music
The playback sound. Unlike the background music, you must finish playing the video before proceeding to the dial-up plan.
Sayunixtime broadcast time
Sayalpha read characters
Saydigits: Read a number.
Saynumber reads the value. different from the previous one, this command can recognize the value unit.
Record recording

Others
Meetme participation
Voicemail voice mailbox

For predefined system variables, refer:
Http://www.voip-info.org/wiki/index.php? Page = asterisk + Variables
$ {Callerid} Caller information, get the number $ {callerid (Num )}
$ {Datetime} current time information
$ {Exten} called Number

For more information about expression syntax logic, see:
Http://www.voip-info.org/wiki/view/Asterisk+Expressions
Basic Format: $[expr1 operator expr2]
Logical operation:
"|", "&", "!"

Comparison operation:
"=", "! = "," <","> "," <= ","> ="

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

Regular Operation:
"Expr1: RegEx", "expr1 = ~ Expr2"

Others:
"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.