Asterisk SIP Channels

Source: Internet
Author: User
SIP Channel Module

The SIP Channel module enables asterisk to communicate via VoIP with SIP telephones and exchanges. Asterisk is able to act

  • A sipClient: This means that asterisk registers as a client to another sip server and has es and places callto this server. Incoming callare routed to an asterisk extension.
  • A sipServer: Asterisk can be configured so that sip clients (phones, software clients) register to the asterisk server and set up sip sessions with the server, I. e. calland answers incoming call. this said, asterisk is not a full-feature SIP server like SIP Express Router or openser. if you are going to have thousands of SIP phones, you should use ser or openser and forward callto asterisk for voicemail or PSTN access.
  • A sipGateway: Asterisk acts as a media gateway between SIP, IAX, MGCP, H.323 and PSTN connections. as an example, an asterisk server can be connected to ISDN to give your sip clients connectivity to the Switched Telephony Network.
  • Why is asterisk not a sip proxy?

 

Notes
  • Asterisk supports Enum-see asterisk config enum. conf.
  • Asterisk support dns srv records, pointers to sip proxy servers for Internet domains. See Asterisk SIP srvlookup
  • When and why is asterisk a media gateway for sip cils? -See Asterisk SIP media path
  • With a bit of tweaking, asterisk supports sip URL dialing.
  • Asterisk supports sip over UDP, but not over TCP.
  • You can store your sip devices in a database for dynamic configuration, see Asterisk SIP MySQL peers

 

Processing sip Channels

Configuration of SIP channels is done by modifyingSip. confFile. See:

  • SIP Channel Configuration

 

Using the dial command with SIP Channels

Recall that the format of the dial command is like this:

Dial (Type/Identifier,Timeout,Options,URL)

For sip channels,TypeIs alwaysSIP.Timeout,OptionsAndURLParts are explained on the dial page.

TheIdentifierParameter can be made up of up to three parts:

[Exten@]Peer[:Portno]

  • Peer: The name of a peer to connect to. This can be one:

    • A peer or friend defined in SIP. conf
    • An IP address (e.g.192.168.1.8)
    • A domain name (e.g.Asterisk.org). For domain names, asterisk will first look for a dns srv record for that domain name (if the srvlookup option is turned on ). if present, this tells asterisk which computer it shoshould connect. if there is no SRV record defined for the domain, then asterisk will connect to the machine directly.
  • Portno: The UDP port to use. If omitted, asterisk will use the standard sip port, 5060.
  • Exten: If defined, then asterisk will request the Peer to connect us to extensionExten.

Note: Only if you use a peer or friend identifier (I. e. the title of a section in SIP. conf), the corresponding options for authentication etc. will be used.

Here are some examples of complete dial commands as they might appear in your dialplan:

Exten => S, 1, dial (Sip/ipphone); call our peer "ipphone" whose connection details are in SIP. conf
Exten => S, 1, dial (Sip/Joshua @ ipphone); call our peer "ipphone", requesting extension "Joshua"
Exten => S, 1, dial (Sip/john@foo.com); Connect to foo.com, requesting extension "John"
Exten => S, 1, dial (Sip/192.168.1.8: 9999,20); Connect to 192.168.1.8 on port 9999, with a 20 sec timeout.
Exten => S, 1, dial (Sip/8500@sip.com: 9876); Connect to sip.com port 9876, requesting extension 8500.

Distinctive Ring styles

There doesn't yet seem to be a standard for how to tell a sip phone that you want it to ring with a distinctive ring. on sip handsets that support distinctive ring at all, the exact method of specifying distinctive ring varies from one model to another. often (or always ?) It is by sending a sip "alert-Info" header, but what the value of this header shocould be is not consistent. if you can figure out what alert-Info header asterisk shocould send, then you can get asterisk 1.0 and 1.2 to send such a header by setting the alert_info channel variable before you dial:

Exten => S, 1, setvar (alert_info = something)
Exten => S, 2, dial (Sip/Myphone)

InAsterisk 1.0The alert_info is no longer a special variable that is inherited by the outgoing channel. instead, a generic method of handling inheritance of Variable Based on prefixing the variables with an underscore "_" (or two underscores "_" for permanent inheritence) has been introduced. the following construct wocould be used instead of the above:

Exten => S, 1, setvar (_ alert_info = something)
Exten => S, 2, dial (Sip/Myphone)

AsAsterisk 1.4, Setting the _ alert_info or _ alert_info variables no longer works. Instead, callSipaddheader (alert-Info: Something)Asterisk func sipaddheader in your extensions. conf dialplan. By the way, already asterisk 1.2 Has supports for this new method:

Exten => S, 1, sipaddheader (alert-Info: Something)
Exten => S, 2, dial (Sip/Myphone)

To find out how to make your specific model of SIP Phone do distinctive ring, try looking for reference information about this topic from:

  • Asterisk configuration notes for specific phones
  • {
    Pagetracker. _ trackpageview ('/outgoing/wikipages/www.google.com /');
    } "Href =" http://www.google.com/"> Google
  • Your phone user manual
  • Your phone manufacturer's Web site

See also: MySQL custom ringtones

Vxml_url

Phones running the SCCP (skinny) firmware have some support for pushing XML pages. If you want to test it, set the variable vxml_url to point to a Cisco XML file on a Web server.

This adds information to the SIP "to:" header, and it cocould be used for other purposes if there are other phones that can take extra information in this way. For example:

Exten => S, 1, setvar (vxml_url = foobar)
Exten => S, 2, dial (Sip/John)

Wocould result in a to: Header looking something like this:

To: <SIP: john@192.168.1.8: 5061>; foobar

Incoming sip connections

When asterisk between es an incoming SIP call, the SIP Channel Module

  • First tries to find a [user] section matching the caller name (from: username ),
  • Then tries to find a [Peer] section matching the caller's IP address.
  • If no matching user or peer is found, the call is sent to the context defined in the [general] section of SIP. conf.

Read more about this on: Asterisk SIP User vs peer

Crossed incoming sip lines

I was getting the SIP context of Line 1 being played over line 2 and vice-a-versa, both lines being from the same provider/from domain/host.
A quick hack is to use something similar to the following in the extensions. conf and point your incoming sip contexts to it:

[Route-CILS]
Exten => S, 1, answer
Exten => S, N, set (cnum =$ {sip_header (to): 5: 11 })
Exten => S, N, gotoif ($ [$ {cnum }= 12223334444]? Sipline1, S, 1)
Exten => S, N, gotoif ($ [$ {cnum }= 12223335555]? Sipline2, S, 1)

[Sipline1]
... Code
[Sipline2]
... Code

This uses the to parameter of the SIP header function to check the dialed information and returns something like <SIP: 12223334444@domain.com>. the substring 5:11 gives the called number to check against and jump contexts if necessary, so your line-contexts can remain distinct. FYI, the from parameter returns the Caller information.

Freepbx users may also wish to see http://www.aussievoip.com/wiki/How+to+get+the+DID+of+a+SIP+trunk+when+the+provider+doesn%27t+send+it+%28and+why+some+incoming+SIP+calls+fail%29, which has some additional suggestions for dealing with this problem, including what to do if the provider sends a user name rather than number in the to parameter.

Names of established sip connections

When you have an established sip connection, its channel name will be in this format:

Sip/Peer-ID

PeerIs the identified peer andIDIs a random identifier to be able to uniquely identify multiple cballs from a single peer.

Sip/ipphone-45ed721c-A sip call from peer "ipphone"
Sip/192.168.1.8-01fb34d6-A sip call from 192.168.1.8

Note that using the chanisavail command will return channel names in this format.

The cut command can be useful for extracting the channel type from a full channel name. Let's say that the variableFooHas the value "Sip/ipphone-45ed721c ":

Cut (channeltype = Foo,/, 1)

Now variableChanneltypeHas the value "sip". You can use the gotoif command to check that a channel is a SIP Channel:

Gotoif ($ [$ {channeltype} = sip]? 10)

If you wish to extract just the peer from a channel name, you might use two cuts. If variableFooHas the value "Sip/ipphone-45ed721c", then after these steps, variableBarWill have the value "ipphone ":

Cut (bar = Foo,/, 2)
Cut (bar = bar,-, 1)

Note that this assumes you have not defined any peers in your sip. conf that have a hyphen in their name. otherwise an attempt to cut the peer from something like "Sip/my-name-83ee2891" wocould give you only "my "!

The asterisk Console

The SIP Channel module adds extra commands to the asterisk CLI console. For example,

  • Check the status of your own server's sip registrations with "sip show Registry ";
  • Obtain a list of clients that have registered with your server with "sip show peers ";
  • After you make changes to your sip. conf file, get the SIP Channel module to reload it with "sip reload" (will not abort active CILS ).

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.