Timing issue with Asterisk-PJSIP when Link up-Down at PJSIP!

Hi,
I am using Asterisk 1.6.2.6 at server side. PJSIP version 1.8 at client side.
I have custom board which work as SIP phone which communicate with Soft-phone installed in Windows PC via Asterisk server.
Each SIP phones connected to network switch(we called it as member switch) so by Ethernet cable board & member switch connected to each other.
All member switches connected to Main network switch so network related issues solved by it. Server & soft-phone also connected to Main network switch.
But due to Power consumption issue, we decide that member switch should go to sleep mode till event not occurs.
For R n D we do following test:-

  1. Every thing is up & running properly. In Asterisk ‘sip show peers’ shows properly.
  2. stop the member switch(we simple off the power of that network switch). & look how much time takes to unregistered from Asterisk.
  3. wait for time t after unregistered event comes.(This waiting time t, we use 2,5,15 minutes etc)
  4. After waiting time t complete, start member switch.
  5. find out after how much time in Asterisk we can see sip phone registered.

For observation, i keep log level at 10.

Observation-

  1. When we wait for 2 min after unregistered, for Registration Asterisk-PJSIP takes 3 min 46 sec approx.
  2. When we wait for 5 min after unregistered, for Registration Asterisk-PJSIP takes 36-40 sec approx.
  3. When we wait for 15 mins after unregistered, for Registration Asterisk-PJSIP takes 1 min 50 sec approx.

For reduce this Registration time we do following changes & take above Observation:-

  1. As per ‘PJSIP-Dev-Guide.pdf’ page 13, we changes in PJSIP’s ‘sip_endpoint.c’ at Line no. 698.
    Original code:-
    /* timer_heap_poll should never ever returns negative value, or otherwise
     * ioqueue_poll() will block forever!
     */
    pj_assert(timeout.sec >= 0 && timeout.msec >= 0);
    if (timeout.msec >= 1000) timeout.msec = 999;

My changes code:-

    /* timer_heap_poll should never ever returns negative value, or otherwise
     * ioqueue_poll() will block forever!
     */
    pj_assert(timeout.sec >= 0 && timeout.msec >= 0);
    if (timeout.msec >= 1) timeout.msec = 1;

following is result of ‘sip show settings’:-

Global Settings:
----------------
  UDP SIP Port:           5060
  UDP Bindaddress:        0.0.0.0
  TCP SIP Port:           Disabled
  TLS SIP Port:           Disabled
  Videosupport:           No
  Textsupport:            No
  Ignore SDP sess. ver.:  No
  AutoCreate Peer:        No
  Match Auth Username:    No
  Allow unknown access:   Yes
  Allow subscriptions:    Yes
  Allow overlap dialing:  No
  Allow promsic. redir:   No
  Enable call counters:   No
  SIP domain support:     No
  Realm. auth:            No
  Our auth realm          asterisk
  Call to non-local dom.: Yes
  URI user is phone no:   No
  Always auth rejects:    No
  Direct RTP setup:       No
  User Agent:             Asterisk PBX 1.6.2.6
  SDP Session Name:       Asterisk PBX 1.6.2.6
  SDP Owner Name:         root
  Reg. context:           (not set)
  Regexten on Qualify:    No
  Caller ID:              asterisk
  From: Domain:           
  Record SIP history:     Off
  Call Events:            Off
  Auth. Failure Events:   Off
  T.38 support:           No
  T.38 EC mode:           Unknown
  T.38 MaxDtgrm:          -1
  SIP realtime:           Disabled
  Qualify Freq :          60000 ms

Network QoS Settings:
---------------------------
  IP ToS SIP:             CS0
  IP ToS RTP audio:       CS0
  IP ToS RTP video:       CS0
  IP ToS RTP text:        CS0
  802.1p CoS SIP:         4
  802.1p CoS RTP audio:   5
  802.1p CoS RTP video:   6
  802.1p CoS RTP text:    5
  Jitterbuffer enabled:   No
  Jitterbuffer forced:    No
  Jitterbuffer max size:  -1
  Jitterbuffer resync:    -1
  Jitterbuffer impl:      
  Jitterbuffer log:       No

Network Settings:
---------------------------
  SIP address remapping:  Disabled, no localnet list
  Externhost:             <none>
  Externip:               0.0.0.0:0
  Externrefresh:          10
  Internal IP:            10.111.17.3:5060
  STUN server:            0.0.0.0:0

Global Signalling Settings:
---------------------------
  Codecs:                 0x8100e (gsm|ulaw|alaw|g722|h263)
  Codec Order:            g722:20
  Relax DTMF:             No
  RFC2833 Compensation:   No
  Compact SIP headers:    No
  RTP Keepalive:          0 (Disabled)
  RTP Timeout:            0 (Disabled)
  RTP Hold Timeout:       0 (Disabled)
  MWI NOTIFY mime type:   application/simple-message-summary
  DNS SRV lookup:         Yes
  Pedantic SIP support:   No
  Reg. min duration       60 secs
  Reg. max duration:      3600 secs
  Reg. default duration:  120 secs
  Outbound reg. timeout:  20 secs
  Outbound reg. attempts: 0
  Notify ringing state:   Yes
    Include CID:          No
  Notify hold state:      No
  SIP Transfer mode:      open
  Max Call Bitrate:       384 kbps
  Auto-Framing:           No
  Outb. proxy:            <not set> 
  Session Timers:         Accept
  Session Refresher:      uas
  Session Expires:        1800 secs
  Session Min-SE:         90 secs
  Timer T1:               500
  Timer T1 minimum:       100
  Timer B:                32000
  No premature media:     Yes

Default Settings:
-----------------
  Allowed transports:     UDP
  Outbound transport:     UDP
  Context:                default
  Nat:                    RFC3581
  DTMF:                   rfc2833
  Qualify:                0
  Use ClientCode:         No
  Progress inband:        Never
  Language:               
  MOH Interpret:          default
  MOH Suggest:            
  Voice Mail Extension:   asterisk

----

following result of ‘sip show peer 0066’:-


  * Name       : 0066
  Secret       : <Set>
  MD5Secret    : <Not set>
  Remote Secret: <Not set>
  Context      : users
  Subscr.Cont. : <Not set>
  Language     : 
  AMA flags    : Unknown
  Transfer mode: open
  CallingPres  : Presentation Allowed, Not Screened
  Callgroup    : 
  Pickupgroup  : 
  Mailbox      : 
  VM Extension : asterisk
  LastMsgsSent : 32767/65535
  Call limit   : 0
  Dynamic      : Yes
  Callerid     : "" <>
  MaxCallBR    : 384 kbps
  Expire       : 61
  Insecure     : port,invite
  Nat          : RFC3581
  ACL          : No
  T.38 support : No
  T.38 EC mode : Unknown
  T.38 MaxDtgrm: -1
  DirectMedia  : Yes
  PromiscRedir : No
  User=Phone   : No
  Video Support: No
  Text Support : No
  Ign SDP ver  : No
  Trust RPID   : No
  Send RPID    : No
  Subscriptions: Yes
  Overlap dial : No
  DTMFmode     : rfc2833
  Timer T1     : 500
  Timer B      : 32000
  ToHost       : 
  Addr->IP     : 10.111.17.66 Port 5060
  Defaddr->IP  : 0.0.0.0 Port 5060
  Prim.Transp. : UDP
  Allowed.Trsp : UDP
  Def. Username: 0066
  SIP Options  : (none)
  Codecs       : 0x8100e (gsm|ulaw|alaw|g722|h263)
  Codec Order  : (g722:20)
  Auto-Framing :  No 
  100 on REG   : No
  Status       : Unmonitored
  Useragent    : PJSUA v1.8/arm-none-linux-gnueabi
  Reg. Contact : sip:0066@10.111.17.66:5060
  Qualify Freq : 60000 ms
  Sess-Timers  : Accept
  Sess-Refresh : uas
  Sess-Expires : 1800 secs
  Min-Sess     : 90 secs
  Parkinglot   :

I tried to change in ‘Sess-Expires’ & ‘Min-Sess’ in sip.conf but there is no change in observation!
Question:-

  1. At where i should make change so after network switch turn on, then in very less time PJSIP register at Asterisk?
    Need help.