Cnxcc prepaid module: workshop on Kamailio World

This is a short tutorial on how to test the cnxcc module with live traffic and from any softphone. These are the things that you need:

Register from any softphone:
* server: cnxcc.caruizdiaz.com:5070
* username: anything between 5000-9999. Actually anything will work, but I’d rather use those numbering ranges
* password: anything. It is not required
* credit: you will get 1$ credit every time you register. If you place a call and run out of credit, just register again and you will get +1$ on your account.

Place a call: you can actually call to any number with the following pattern: “^09\d{8}$”. This basically means that you can call to a number starting with “09”, that has 8 digits afterwards. Example: 0981223344

You will run out of credit: after a little more than 10 seconds, you will run out of credit and your call will be terminated. Don’t worry, you will receive a SIP MESSAGE on you UA, if it supports it, telling you what just happened.

Recharge your line: if you want more credit, just re-REGISTER from your UA

Check you credit: by texting “credit” to destination “service“, from your UA that supports SIP MESSAGE.

Check the web: you can actually hang up somebody else’s call, or your call, from the web interface. It looks nice and you can log in using “guest” as username and “123456” password.

Call each other: you have the option to call other registered users, but for this, you have to know the number of the other person, or guess it randomly πŸ˜‰

Duplicated username: you may have chosen the same username that someone else did. If that’s the case, your call will last less than 10 seconds if you call simultaneously, or not even start if someone already exhausted the credit. In the latter case, you will receive a SIP MESSAGE telling you that you have no credit left ;).

These are the files involved in this project. I hope you find them useful.

The demo has no media relay configured, so, you won’t have audio unless you are calling each other on the same network.

linphone-cnxcccnxcc-csipsimple

 

7 thoughts on “Cnxcc prepaid module: workshop on Kamailio World”

  1. At the moment I get the forbidden error, while calling from my SNOM

    Sent to udp:107.170.102.188:5070 at 11/8/2014 18:43:24:645 (1223 bytes):

    INVITE sip:[email protected]:5070;user=phone SIP/2.0
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-2bmj1apewjwz;rport
    From: “7777” ;tag=63bl2ztb9e
    To:
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 1 INVITE
    Max-Forwards: 70
    Contact: ;reg-id=1
    X-Serialnumber: 000413412891
    P-Key-Flags: resolution=”31×13″, keys=”4″
    User-Agent: snom870/8.7.3.19
    Accept: application/sdp
    Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE
    Allow-Events: talk, hold, refer, call-info
    Supported: timer, 100rel, replaces, from-change
    Session-Expires: 3600;refresher=uas
    Min-SE: 90
    Content-Type: application/sdp
    Content-Length: 402

    v=0
    o=root 1110839919 1110839919 IN IP4 79.202.219.252
    s=call
    c=IN IP4 79.202.219.252
    t=0 0
    m=audio 20028 RTP/AVP 9 0 8 99 108 18 101
    a=direction:both
    a=rtpmap:9 G722/8000
    a=rtpmap:0 PCMU/8000
    a=rtpmap:8 PCMA/8000
    a=rtpmap:99 G726-32/8000
    a=rtpmap:108 AAL2-G726-32/8000
    a=rtpmap:18 G729/8000
    a=fmtp:18 annexb=no
    a=rtpmap:101 telephone-event/8000
    a=fmtp:101 0-15
    a=ptime:20
    a=sendrecv
    Received from udp:107.170.102.188:5070 at 11/8/2014 18:43:24:768 (368 bytes):

    SIP/2.0 100 trying — your call is important to us
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-2bmj1apewjwz;rport=3073
    From: “7777” ;tag=63bl2ztb9e
    To:
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 1 INVITE
    Server: kamailio (4.1.3 (x86_64/linux))
    Content-Length: 0

    Received from udp:107.170.102.188:5070 at 11/8/2014 18:43:24:787 (867 bytes):

    SIP/2.0 407 Proxy Authentication Required
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-2bmj1apewjwz;rport=3073
    From: “7777” ;tag=63bl2ztb9e
    To: ;tag=F6Zgg9m8FBr8e
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 1 INVITE
    User-Agent: FreeSWITCH-mod_sofia/1.2.24+git~20140513T183205Z~9af707ed20~64bit
    Accept: application/sdp
    Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
    Supported: timer, path, replaces
    Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
    Proxy-Authenticate: Digest realm=”cnxcc.caruizdiaz.com”, nonce=”9c55186e-2176-11e4-af84-1dbd4e65c7e3″, algorithm=MD5, qop=”auth”
    Content-Length: 0

    Sent to udp:107.170.102.188:5070 at 11/8/2014 18:43:24:790 (432 bytes):

    ACK sip:[email protected]:5070;user=phone SIP/2.0
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-2bmj1apewjwz;rport
    From: “7777” ;tag=63bl2ztb9e
    To: ;tag=F6Zgg9m8FBr8e
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 1 ACK
    Max-Forwards: 70
    Contact: ;reg-id=1
    Content-Length: 0

    Sent to udp:107.170.102.188:5070 at 11/8/2014 18:43:24:797 (1497 bytes):

    INVITE sip:[email protected]:5070;user=phone SIP/2.0
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-qrc6rnlixgdf;rport
    From: “7777” ;tag=63bl2ztb9e
    To:
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 2 INVITE
    Max-Forwards: 70
    Contact: ;reg-id=1
    X-Serialnumber: 000413412891
    P-Key-Flags: resolution=”31×13″, keys=”4″
    User-Agent: snom870/8.7.3.19
    Accept: application/sdp
    Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE
    Allow-Events: talk, hold, refer, call-info
    Supported: timer, 100rel, replaces, from-change
    Session-Expires: 3600;refresher=uas
    Min-SE: 90
    Proxy-Authorization: Digest username=”7777″,realm=”cnxcc.caruizdiaz.com”,nonce=”9c55186e-2176-11e4-af84-1dbd4e65c7e3″,uri=”sip:[email protected]:5070;user=phone”,qop=auth,nc=00000001,cnonce=”459f5447″,response=”6ce18ab860602da0e2a105a35a08c185″,algorithm=MD5
    Content-Type: application/sdp
    Content-Length: 402

    v=0
    o=root 1110839919 1110839919 IN IP4 79.202.219.252
    s=call
    c=IN IP4 79.202.219.252
    t=0 0
    m=audio 20028 RTP/AVP 9 0 8 99 108 18 101
    a=direction:both
    a=rtpmap:9 G722/8000
    a=rtpmap:0 PCMU/8000
    a=rtpmap:8 PCMA/8000
    a=rtpmap:99 G726-32/8000
    a=rtpmap:108 AAL2-G726-32/8000
    a=rtpmap:18 G729/8000
    a=fmtp:18 annexb=no
    a=rtpmap:101 telephone-event/8000
    a=fmtp:101 0-15
    a=ptime:20
    a=sendrecv
    Received from udp:107.170.102.188:5070 at 11/8/2014 18:43:24:922 (368 bytes):

    SIP/2.0 100 trying — your call is important to us
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-qrc6rnlixgdf;rport=3073
    From: “7777” ;tag=63bl2ztb9e
    To:
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 2 INVITE
    Server: kamailio (4.1.3 (x86_64/linux))
    Content-Length: 0

    Received from udp:107.170.102.188:5070 at 11/8/2014 18:43:24:940 (717 bytes):

    SIP/2.0 403 Forbidden
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-qrc6rnlixgdf;rport=3073
    From: “7777” ;tag=63bl2ztb9e
    To: ;tag=gFS9H45BDmeUa
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 2 INVITE
    User-Agent: FreeSWITCH-mod_sofia/1.2.24+git~20140513T183205Z~9af707ed20~64bit
    Accept: application/sdp
    Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
    Supported: timer, path, replaces
    Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
    Content-Length: 0

    Sent to udp:107.170.102.188:5070 at 11/8/2014 18:43:24:943 (432 bytes):

    ACK sip:[email protected]:5070;user=phone SIP/2.0
    Via: SIP/2.0/UDP 79.202.219.252:3073;branch=z9hG4bK-qrc6rnlixgdf;rport
    From: “7777” ;tag=63bl2ztb9e
    To: ;tag=gFS9H45BDmeUa
    Call-ID: acf2e8539b6f-9yjsas1gfru7
    CSeq: 2 ACK
    Max-Forwards: 70
    Contact: ;reg-id=1
    Content-Length: 0

Comments are closed.