Pjsip note

  • pjsua的 启动参数可以这样设置 :

    前提是 服务器在 , 设置的来源是 pjsip手册:


    设置以后, 在手机上用zoiper 注册到 , 然后用pjsua 程序 先 m 命令, 再输入:

    就可以打电话到手机 , 是注册以后, 在服务器看到的当前用户信息 。


  • pjsua 重要的结构

a) endpoint

注意每个 endpoint 维护着一个 module 数组



My VPS asterisk settings

  • source path :  /usr/src/asterisk-certified-13.18-cert3
  • /etc/init.d/asterisk status

/etc/init.d/asterisk restart

/etc/init.d/asterisk stop



Asterisk v13 AMI Q&A

  •  how to define AMI recv which event ?

in /etc/asterisk/manager.conf

change :  read = cdr   (prior request is :  in cdr_manager.conf , set enabled = yes in the general section )

only read cdr event mean do not include such as :

Event: Newexten

Event: Newstate

Event: DialEnd      …..

if want to check these event ,  the form should be :   read = call,cdr


    •  Why in dispatched  cdr event , duration not same with dest dialplan duration ?

in dest asterisk extensions.conf , I set :


So all the calls ‘s duration should be 30 sec  , why the example is 27 sec ?

temp conclusion :  Duration and BillableSeconds in Cdr event is not correct .


  •  190  ‘s outgoing call why use “autodialer” dialplan ???




If asterisk have a log of “asterisk -rvvv” ? — configure of logger.conf


Above is a /etc/asterisk/logger.conf example ,


Red font part will record every in cli to  /var/log/asterisk/full 

asterisk cdr and max concurrent call

location is :  /var/log/asterisk/cdr-csv/Master.csv


能有多少 concurrent calls :




Master.csv 的记录和实际一致吗?

concurrent calls = 280 ,  没有丢cdr的情况



怎么从 Master.csv 产生这样的报表 :

hour 1400 – generated x calls, with x duration
hour 1500 – Generated X calls with X duration

answer: group excel file by hourly : reference from this article :


google key word : excel group by time period 



cdr 字段 in  Master.csv


  1. accountcode: What account number to use: account, (string, 20 characters)
  2. src: Caller*ID number (string, 80 characters)
  3. dst: Destination extension (string, 80 characters)
  4. dcontext: Destination context (string, 80 characters)
  5. clid: Caller*ID with text (80 characters)
  6. channel: Channel used (80 characters)
  7. dstchannel: Destination channel if appropriate (80 characters)
  8. lastapp: Last application if appropriate (80 characters)
  9. lastdata: Last application data (arguments) (80 characters)
  10. start: Start of call (date/time)
  11. answer: Answer of call (date/time)
  12. end: End of call (date/time)
  13. duration: Total time in system, in seconds (integer)
  14. billsec: Total time call is up, in seconds (integer)
  15. disposition: What happened to the call: ANSWERED, NO ANSWER, BUSY, FAILED
  16. amaflags: What flags to use: see amaflags::DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.

2018-6 To do list

  •  globle <–> csl callflow online  (当前只存在于 cctb1 ,cctb2 没有)

6月21 号 globe will ready , 开始测试 ,   according to Yasser

现在是 6.29 ,还没开始测试 , Yasser 说的话不能信。

but still need make cctb2

  •  make pack callflow run together with ree-idd on cctb1 and cctb2   (已解决)


  • 规范pack callflow error code (from xueliang)

  • 用 early media 播 A party 的 prompt  , 比如 not enough balance ,   not exist  pack  (已解决 )     ,  见

already send email to TB support to ask 

early media 是为了不计 A party 的 duration , 查 cdr 表确认不是这样

  • pack callflow make outgoing call 时 , 要用codec g711 ,    (已解决)

同时, 把 CVHCallflow.cpp 的这句注释掉


  • CSimpleCall 的 ispack 函数是怎么判断来电是 pack 还是 ree-idd的 ?

调用 sp_TB_CFValidate , 此存储过程存在于 pack 数据库,

当前 simplecall 程序判断 来电走哪个 callflow 的方法是 :

如果ispack 的返回值是1 :  pack

返回值 2 : reeidd

  •  cctb1 连 asterisk 190 , asterisk 186 的 call generator

当前问题 : 从190 出的电话不能到 cctb1

现在可以了, 原先是因为 cctb1 IP 写错 , cctb1 的 ip 和 cctb1 host 的 IP 弄混了

  • 存储过程逻辑里, 有没有白名单的概念 ? (From Kit)


  • pack callflow 的 cdr 能不能对的上

a)  AB connected


b) AB not connected

if A  call for pack not exist   :    CDR  not found in DB pack2018_cdr , but can be found in daily report

c) can not route

d) error happen

  • sp_TB_Disconnected 和 sp_TB_DisconnectedFailed 的区别

when leg B duration > 0 ,  call  sp_TB_Disconnected

else ,  call  sp_TB_DisconnectedFailed


发现, 当执行

, 返回值为0 , 但 实际cdr没有存进去

这是因为 需要 callid, 但一开始 callid 是 sp_connect_b的输出参数 (xueliang 已解决

  •  每一个错误代码都试一遍

a)  sp_chargeInit 返回值 = 74001,74002  ,  how to simulate this ?

b)                                                   74003     pack_not_exist                     已试过

c)                                                   74004    no_balance

d)                                                  74005,74006              modem pool

e)                                                 74007 , 74008

d)                                                74009                      another_is_ongoing




How to use asternet send command to asterisk

  • asternet download site :



  • asterisk server side config  (manager.conf)


deny + permit mean only allow this IP  visit

read = call mean afer connect AMI and asterisk  , asterisk only send call event to AMI ,this can avoid too many event been sent to AMI , since AMI is UDP connection .

  •  modify of asternet program :

a) in





their cresponding function is :


above code will let AMI recv call event include :  dialbegin , dialend , and hangup ,  then write these info in datagridview

add a button , in its click event , write :



this will generate 100 calls to asterisk , especially notice :


without this property , calls will not success . this answer come from my ask queston in :




  • here is full code    AsterNET   ,  pls check  winform project .



2018-6-1 modify 


上述方法是把 cdr 写到 datagridview 里, 但是,当cdr非常多的时候就不适合, 因此, 换一种方法, 只记录打通的电话次数和total duration ,  实现如下:


在 form 类定义



in some buttone ‘s click event , add :


in manager_DialEnd function , add


in call-hangup-events , add



textbox2  and textbox3 use to write calls and durations



in winform class , define


in construct function , write :

add function


start timer




How to use asternet generate calls and monitor event

  • download asternet , set loging usename and pwd as manager.conf define .


  • after success login ,   use this code to make  a pjsip call


crespponding dialplan is :


  • if u  already login your zoiper to server ‘s sip contract 6001 , you will hear the ring .


  • if use this code


will invoke local channel calls on server .  cresponding dialplan is :


  • how to monitor event :



add :


full code of the three delegate functions is :


  • un-finish target : how to continuely  make many calls ?



sloved : can not register contract

  • Problem :


  • solution :

in cli , run


  • PS

some answer said :   in [AOR] section  of pjsip.conf


but after try , find not effect