Skip to content

Implement Full RFC 4028 Session Timer Compliance #39

Description

@thorsager

Summary

We have a simplified session timer implementation that adds Session-Expires: <seconds>;refresher=uac headers to outbound trunk INVITEs and tears down calls when the timer expires. This issue tracks the remaining work needed for full RFC 4028 compliance.

Current Implementation

  • internal/trunk/config.go: SessionExpiresSec int field on Trunk
  • internal/b2bua/handler.go: Adds Session-Expires header in handleTrunkInvite, starts a timer goroutine in handleTrunk200OK via trunkSessionTimer
  • Server always acts as refresher=uac and only tears down on expiry
  • No Min-SE handling, no UPDATE/re-INVITE support

Required for Full Compliance

1. Min-SE Header Negotiation

  • Parse incoming Min-SE header and adjust Session-Expires accordingly
  • If the peer requests a minimum that is larger than our configured value, respond with 422 (Session Interval Too Small) and include Min-SE in the response (RFC 4028 §5)

2. refresher=uas Support

  • Allow the peer to act as the session refresher
  • When refresher=uas is received, the server must respond to re-INVITEs or UPDATEs that refresh the session
  • Track the refresher role in the Call struct

3. UPDATE Method Handling (RFC 3311)

  • The current SIP parser already defines SIPMethodUPDATE but no handler processes UPDATE requests
  • Must handle UPDATE for session refresh when the peer is the refresher
  • Respond to UPDATE with 200 OK, reset the session timer

4. Session Interval Too Small (422 Response)

  • If a peer sends Session-Expires with an interval below our Min-SE, respond with 422 and include acceptable Min-SE
  • Handle 422 responses from peers and retry with a larger interval

5. Per-Call Session Timer Tracking

  • Store session timer state in the Call struct (or a new SessionTimer struct)
  • Track: interval, refresher role, last refresh time, timer goroutine reference
  • Reset the timer on any mid-dialog request or response (INVITE re-negotiation, UPDATE, 200 OK)

6. Consistent Timer Reset

  • Any mid-dialog SIP message (re-INVITE, UPDATE, PRACK, INFO) should reset the session timer
  • Current implementation uses a fixed time.After that ignores mid-dialog activity

7. Re-INVITE Handling for Session Refresh

  • When the server is the refresher, it must send re-INVITE or UPDATE before the session expires
  • Handle re-INVITE responses and reset the timer accordingly

References

  • RFC 4028 — Session Timers in the Session Initiation Protocol (SIP)
    • §4: Overview of session timer mechanism
    • §5: UAC behavior (generating Session-Expires, handling 422)
    • §6: UAS behavior (processing Session-Expires)
    • §7: Proxy/B2BUA behavior
    • §8: Refresher role determination
    • §9: Formal syntax
  • RFC 3311 — The Session Initiation Protocol (SIP) UPDATE Method
    • Defines UPDATE for mid-dialog session parameter updates
  • RFC 6026 — Correct Transaction Handling for 2xx Responses to re-INVITEs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions