Review Board 1.7.16


RFC3261 Section 8.1.1.5. The sequence number value MUST be expressible as a 32-bit unsigned integer

Review Request #1699 - Created Jan. 26, 2012 and submitted

Alec Davis
Asterisk 1.8 and above
Reviewers
asterisk-dev
Asterisk
RFC 3261 Section 8.1 documents intial value of CSeq and it's maximum out side of a dialog.
  8.1 UAC Behavior
     This section covers UAC behavior outside of a dialog.
  8.1.1.5
     .. "The sequence number value MUST be expressible as a 32-bit unsigned integer and MUST be less than 2**31." 
     "Section 12.2.1.1 discusses construction of the CSeq for requests within a dialog."

RFC 3261 Section 12.2.1.1, documents the maximum value a seqno can get to within a dialog, 2^32-1. (136 years equals 2^32 seconds).
   "If the local sequence number is empty, an initial value MUST be chosen using the guidelines of Section 8.1.1.5"  
   .. "With a length of 32 bits, a client could generate, within a single call, one request a second for about 136 years before needing to wrap around."
  
===============================================================================

By defining INITIAL_CSEQ to values near the maximum, it can clearly be seen that asterisk will represent the cseqno as negative numbers as %d is used in most places.

//#define INITIAL_CSEQ              101    /*!< Our initial sip sequence number */
#define INITIAL_CSEQ              2147483640 /*!< Our initial sip sequence number */
#define INITIAL_CSEQ              4294967290UL   /*!< Our initial sip sequence number */ 

Examples below after a few messages with INITIAL_CSEQ set to 214783640

...
Call-ID: d469d55c9e9e81ae@192.168.y.yyy
CSeq: -2147483639 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 206

<?xml version="1.0"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="16" state="full" entity="sip:8612@192.168.x.xxx">

...
Call-ID: 7d1d964b7867eee008705e1e64386d4e@192.168.x.xxx:5060
CSeq: -5 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 92

Messages-Waiting: no
Message-Account: sip:asterisk@192.168.x.xxx
Voice-Message: 0/0 (0/0)

 
Noted that Notify for BLF and MWI, that the CSeq numbers now wrapped around to 0.

After using the 2nd maximum of 2^32 minus a few (#define INITIAL_CSEQ              4294967290UL) phones, BLF and MWI still workign as normal.

Previously the BLF would stop functioning after the minus values were reached.
Now it wraps around from 4294967295 to 0, as below.

Call-ID: c2aaba2919cfcd4a@192.168.y.yyy
CSeq: 4294967295 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 205

<?xml version="1.0"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="4" state="full" entity="sip:8612@192.168.x.xxx">
<dialog id="8612">

...
Call-ID: c2aaba2919cfcd4a@192.168.y.yyy
CSeq: 0 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 205

<?xml version="1.0"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="5" state="full" entity="sip:8612@192.168.x.xxx">
<dialog id="8612">
Review request changed
Updated (Jan. 27, 2012, 9:34 a.m.)
  • By defining INITIAL_CSEQ to values near the maximum, it can clearly be seen that asterisk will represent the cseqno as negative numbers as %d is used in most places.
    
    //#define INITIAL_CSEQ              101    /*!< Our initial sip sequence number */
    #define INITIAL_CSEQ              2147483640 /*!< Our initial sip sequence number */
    #define INITIAL_CSEQ              4294967290UL   /*!< Our initial sip sequence number */ 
    
    Examples below after a few messages with INITIAL_CSEQ set to 214783640
    
    ...
    Call-ID: d469d55c9e9e81ae@192.168.y.yyy
    CSeq: -2147483639 NOTIFY
    User-Agent: Asterisk PBX SVN-trunk-r352864M
    Subscription-State: active
    Event: dialog
    Content-Type: application/dialog-info+xml
    Content-Length: 206
    
    <?xml version="1.0"?>
    <dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="16" state="full" entity="sip:8612@192.168.x.xxx">
    
    ...
    Call-ID: 7d1d964b7867eee008705e1e64386d4e@192.168.x.xxx:5060
    CSeq: -5 NOTIFY
    User-Agent: Asterisk PBX SVN-trunk-r352864M
    Event: message-summary
    Content-Type: application/simple-message-summary
    Content-Length: 92
    
    Messages-Waiting: no
    Message-Account: sip:asterisk@192.168.x.xxx
    Voice-Message: 0/0 (0/0)

    RFC 3261 Section 8.1 documents intial value of CSeq and it's maximum out side of a dialog.
      8.1 UAC Behavior
         This section covers UAC behavior outside of a dialog.
      8.1.1.5
         .. "The sequence number value MUST be expressible as a 32-bit unsigned integer and MUST be less than 2**31." 
         "Section 12.2.1.1 discusses construction of the CSeq for requests within a dialog."
    
    RFC 3261 Section 12.2.1.1, documents the maximum value a seqno can get to within a dialog, 2^32-1. (136 years equals 2^32 seconds).
       "If the local sequence number is empty, an initial value MUST be chosen using the guidelines of Section 8.1.1.5"  
       .. "With a length of 32 bits, a client could generate, within a single call, one request a second for about 136 years before needing to wrap around."
      
    ===============================================================================
    
    By defining INITIAL_CSEQ to values near the maximum, it can clearly be seen that asterisk will represent the cseqno as negative numbers as %d is used in most places.
    
    //#define INITIAL_CSEQ              101    /*!< Our initial sip sequence number */
    #define INITIAL_CSEQ              2147483640 /*!< Our initial sip sequence number */
    #define INITIAL_CSEQ              4294967290UL   /*!< Our initial sip sequence number */ 
    
    Examples below after a few messages with INITIAL_CSEQ set to 214783640
    
    ...
    Call-ID: d469d55c9e9e81ae@192.168.y.yyy
    CSeq: -2147483639 NOTIFY
    User-Agent: Asterisk PBX SVN-trunk-r352864M
    Subscription-State: active
    Event: dialog
    Content-Type: application/dialog-info+xml
    Content-Length: 206
    
    <?xml version="1.0"?>
    <dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="16" state="full" entity="sip:8612@192.168.x.xxx">
    
    ...
    Call-ID: 7d1d964b7867eee008705e1e64386d4e@192.168.x.xxx:5060
    CSeq: -5 NOTIFY
    User-Agent: Asterisk PBX SVN-trunk-r352864M
    Event: message-summary
    Content-Type: application/simple-message-summary
    Content-Length: 92
    
    Messages-Waiting: no
    Message-Account: sip:asterisk@192.168.x.xxx
    Voice-Message: 0/0 (0/0)
    
     
Still has an INITIAL_CSEQ set to 2147483645 (2^31 - 2) to allow testing.
Ship it!
Posted (Jan. 30, 2012, 8:57 a.m.)
Like Terry said, try not to make extraneous changes beyond the scope of the review if possible. Still, go ahead and commit since there's nothing _wrong_ here.
  1. I don't see any comments from Terry.
    Pleae advise.
  2. Sorry, I meant the ship it, but this comment was meant for a different review. Sorry for the confusion.

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.