Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

viernes, 23 de noviembre de 2018

SIP INVITE header fields

Understanding common header fields in a SIP INVITE

The SIP INVITE is the foundation for every SIP phone call. It is simple and flexible, but often poorly understood by users. The purpose of this article is to provide a quick and easy reference to the critical headers in a SIP INVITE.
The SIP INVITE request is the message sent by the calling party, inviting the recipient for a session. The SIP headers included in this SIP INVITE request provide information about the message.
Consider the following SIP message, with the common SIP headers highlighted:
INVITE sip:bob@biloxi.example.com SIP/2.0
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bf9
Max-Forwards: 70
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 2 INVITE
Contact: <sip:alice@client.atlanta.example.com;transport=tcp>
Diversion: Carol <sip:carol@atlanta.example.com>;privacy=off;reason=no-answer;counter=1;screen=no
Remote-Party-ID: Alice <sip:alice@atlanta.example.com>
P-Asserted-Identity: Alice <sip:alice@atlanta.example.com>
P-Charge-Info: <sip:eve@atlanta.example.com>
P-Source-Device: 216.3.128.12
Content-Type: application/sdp
Content-Length: 151
X-BroadWorks-DNC: network-address=sip:+9876543210@127.0.0.101;user=phone
User-Agent: X-Lite release 1104o stamp 56125 v=0 o=alice 2890844526 2890844526 IN IP4 client.atlanta.example.com s=- c=IN IP4 192.0.2.101 t=0 0 m=audio 49172 RTP/AVP 0 a=rtpmap:0 PCMU/8000
The following sections explain these header fields.

Request URI

INVITE sip:bob@biloxi.example.com SIP/2.0
The Request URI is the contact information of the next hop in the call route. In the above example, the username of the next hop is bob, who is hosted by biloxi.example.com.

Via

Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bf9
Max-Forwards: 70
The Via header field indicates the path taken by the request so far and helps in routing the responses back along the same path. If the SIP INVITE passed through multiple SIP proxies, there will be multiple VIA headers. In the given example, the responses will be sent back to client.atlanta.example.com at the port 5060.

From

From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
The From header field indicates contact information of the initiator of the SIP INVITE request, Alice in this case.

To

To: Bob <sip:bob@biloxi.example.com>
The To header field contains the information about the called party or the recipient of the request, Bob in this example.

Call-ID

Call-ID: 3848276298220188511@atlanta.example.com
The Call-ID header field is a unique ID identifying the SIP call. All messages containing this call-id will be assigned to the same SIP call.

Contact

Contact: <sip:alice@client.atlanta.example.com;transport=tcp>
The Contact header field provides a SIP or SIPS URI that should be used to contact the sender of the INVITE, Alice.

Diversion

Diversion: Carol <sip:carol@atlanta.example.com>;privacy=off;reason=no-answer;counter=1;screen=no
The diversion header contains the redirection information of the call. It includes the contact information of the device that forwards the INVITE, and also the reason for diversion.

Remote Party ID

Remote-Party-ID: Alice <sip:alice@atlanta.example.com>
This SIP header is considered obsolete, but is still used to convey the calling telephone number and source IP address.

P-Asserted-Identity

P-Asserted-Identity: Alice <sip:alice@atlanta.example.com>
The P-Asserted-Identity header field is an important SIP header used among trusted SIP entities (typically intermediaries) to carry the identity of the user sending a SIP message as it was verified by authentication. This header is commonly used in call centers who need to present the calling number of its customer, rather than it actual telephone number.

P-Charge-Info

P-Charge-Info: <sip:eve@atlanta.example.com>
The P-Charge-Info header is used to convey billing information about the party to be charged.

P-Source-Device

>P-Source-Device: 216.3.128.12
Content-Type: application/sdp
Content-Length: 151
This is a special header and includes the IP address of the source device through a Back to Back User Agent

X-Header

X-BroadWorks-DNC: network-address=sip:+9876543210@127.0.0.101;user=phone
A SIP header that begins with X can be used to convey any information. For example, An X-Header in a SIP INVITE is often used to convey a subscriber account number for billing.

User-Agent

User-Agent: X-Lite release 1104o stamp 56125
The User-Agent header field contains information about the UAC originating the request. It describes the source device that generated the SIP INVITE.

Connection Information

c= IN IP4 192.0.2.101
This is the source IP address and connection type for the audio stream.
This was one of the simpler SIP INVITE requests, and it could be more complex depending on the call flow.
The SIP INVITE is an important request method, and the information it contains could be used not just for session initiation, but also for such crucial applications as fraud detection. A SIP Analytics-driven Fraud Detection allows for real-time call blocking or call diversion.

viernes, 16 de noviembre de 2018

pjsip realtime

https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime#SettingupPJSIPRealtime-InstallingDependencies


https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime

https://wiki.asterisk.org/wiki/display/AST/Sorcery



sudo apt-get install python-setuptools
For Python 3.x
sudo apt-get install python3-setuptools

martes, 13 de noviembre de 2018

Admin GUI Dashboard Error after module update today

fwconsole ma upgrade dashboard --edge

https://community.freepbx.org/t/admin-gui-dashboard-error-after-module-update-today/53703

lunes, 22 de octubre de 2018

Ubuntu 18 Asterisk CDR ODBC

https://community.asterisk.org/t/call-detail-records-are-not-saving-in-cdr/76743/6


Install packages
apt-get install unixodbc-dev unixodbc-bin unixodbc
/etc/odbc.ini
[asterisk-mysql]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = asterisk
Server = localhost
UserName = root
Password = ‘’
Port = 3306
Socket = /var/run/mysqld/mysqld.sock

This lib need to be downloaded from MYSQL SITE
/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
FileUsage = 1

/etc/asterisk/cdr_adaptive_odbc.conf
[asterisk-mysql]
connection=asterisk-mysql
table=cdr
alias start => calldate

/etc/asterisk/res_odbc.conf
[asterisk-mysql]
enabled => yes
dsn => asterisk-mysql
username => root
password => ‘’
pre-connect => yes

assuming asterisk db exist create the table
CREATE TABLE cdr (
calldate datetime NULL ,
clid varchar(80) NOT NULL default ‘’,
src varchar(80) NOT NULL default ‘’,
dst varchar(80) NOT NULL default ‘’,
dcontext varchar(80) NOT NULL default ‘’,
channel varchar(80) NOT NULL default ‘’,
dstchannel varchar(80) NOT NULL default ‘’,
lastapp varchar(80) NOT NULL default ‘’,
lastdata varchar(80) NOT NULL default ‘’,
duration int(11) NOT NULL default ‘0’,
billsec int(11) NOT NULL default ‘0’,
disposition varchar(45) NOT NULL default ‘’,
amaflags int(11) NOT NULL default ‘0’,
accountcode varchar(20) NOT NULL default ‘’,
uniqueid varchar(32) NOT NULL default ‘’,
userfield varchar(255) NOT NULL default ‘’
);
restart asterisk
service asterisk restart

viernes, 19 de octubre de 2018

Debugging SIP Messages the Traditional Way PJSIP

Debugging SIP Messages the Traditional Way

Since its release, the PJSIP stack has provided logging of SIP message traffic via the pjsip set logger  CLI command. This dumps all received and transmitted SIP messages as a VERBOSE message. This is useful for two scenarios:
  1. When wanting to log all SIP messages in an Asterisk log file.
  2. When attempting to debug SIP messages in real-time via the CLI.
In the first scenario, the existing CLI command works just fine. However, when attempting to debug live SIP calls on a production system with pjsip set logger , the amount of traffic will often flood the CLI. This makes it incredibly difficult to debug SIP calls via the CLI, requiring the use of either the generated log file (which can also be large), or third party tools (such as Wireshark or tcpdump).
While third party tools are often fantastic for helping troubleshoot VoIP issues, on some production systems, it may not be possible to install said tools. As such, it’s still sometimes nice if Asterisk can help troubleshoot issues as well. Coming in Asterisk 13.8.0, a new module – res_pjsip_history  – has been added that provides capturing, filtering, and display of SIP messages. In this post, we’ll cover how to use the module, as well as potential avenues for future enhancements to its functionality.

Using the PJSIP History Module

The PJSIP history module maintains an in-memory history of all sent/received SIP messages that pass through the PJSIP stack. Because the history is stored in-memory, it does not start capturing until told to, and users should be careful to turn off the capture and not leave it running. You can run your system out of memory if you leave it on permanently!

Capturing Messages

To start capturing, run the pjsip set history on  command:
You can stop capturing by running the pjsip set history off  command:
This doesn’t clear the captured history, it merely stops capturing new SIP messages. You can re-enable the capture by running pjsip set history on  again. To clear the history, run pjsip set history clear :

Manipulating a Capture

All of that is fine and good, but how do we look at captured messages?
To show the entire history, we can use pjsip show history , which will provide a summary of the history:
That can be a lot of messages on a busy system. To look at a particular SIP message, we can tell Asterisk to display a specific entry:
Note that the entry numbers are displayed in the left hand column, and are simply a monotonically increasing value for each SIP message received or transmitted. Now that we have a particular INVITE request, we could filter our SIP messages further. pjsip show history  supports a simple filter query syntax similar to SQL or other query languages. To see everything in this dialog, we can filter by SIP Call-ID using pjsip show history where sip.msg.call-id = "3-14157@127.0.1.1" :
There are a number of fields currently supported by the pjsip show history  command, including:
  • number : The PJSIP history entry number
  • timestamp : The time the SIP message was sent or received
  • addr : The source/destination address the SIP message was received from/transmitted to
  • sip.msg.request.method : The SIP request method
  • sip.msg.call-id : The SIP Call-ID header value
The query syntax supports all normal boolean operators, as well as a regex operator ‘LIKE’. This provides quite a bit of flexibility when searching through a large SIP history.

Extending the PJSIP History Filters

Of course, there are a lot of fields in a SIP message that are not currently supported by the pjsip show history  command. In the first release of this module, we wanted to focus on providing what we thought were the most useful fields, as opposed to a comprehensive list of headers/fields that may not be terribly useful. If, however, there is a field that you think would be useful to have, the module is relatively easy to extend!
First, we’d define a new entry to the table of allowed_fields , shown below:
We need to provide three things for an entry here:
  • symbol : The name of the field we want the user to enter. Each one of these in the table has to be unique.
  • return_type : The type of value the user has to enter. This has to be one of the OPT_XXX  types defined ininclude/asterisk/config_options.h . The functions that define how a boolean operator will handle the field will understand the values defined there, and will know how to interpret the field’s type. Note thatOPT_NOOP_T  is used for timestamps, and OPT_SOCKADDR_T  for IP addresses.
  • get_field : Our callback function that determines how to extract the field’s actual value from a PJSIP history entry.
The next step is simply to define the callback function that is referenced by the get_field  attribute. A callback function takes in a pointer to a struct pjsip_history_entry  instance, and must return a void  pointer to the field in that struct  that is the value to be used in the expression. For example, the SIP Call-ID header is extracted as shown below:
The boolean expression evaluators will know that the field pointed to by this function is a string as thereturn_type  attribute in the allowed_fields  table is a OPT_CHAR_ARRAY_T , and will handle it accordingly.