sipinvite

SIP: How to compile a TRYING response to an INVITE


I'm developing an application in Python able to manage SIP transactions. I don't need to answer or send/receive media, I'd just like to take track of an incoming call and send an INIVTE with a CANCEL after (it's very simple). I succeeded in writing the code to get the incoming SIP messages and send responses, but something is wrong about the content of the messages. For example: I receive an INVITE and I want to answer with TRYING. The application intercepts the INVITE, reads the content of the message and send a TRYING, but the server doesn't recognize the TRYING as related to the INVITE and keeps sending the INVITE.

What's wrong with the TRYING message?

The messages:

Session Initiation Protocol (INVITE)
    Request-Line: INVITE sip:0662279775@127.0.1.1:5060 SIP/2.0
    Message Header
        Via: SIP/2.0/UDP 79.98.45.133:5060;branch=z9hG4bK2f7cb45b;rport
        Max-Forwards: 70
        From: <sip:xxxxxxx@79.98.45.133>;tag=as35f49270
        To: <sip:yyyyyyy@127.0.1.1:5060>
        Contact: <sip:xxxxxxx@79.98.45.133:5060>
        Call-ID: 0e23cffb0fdc0fbe19949dd042d668ac@79.98.45.133:5060
        [Generated Call-ID: 0e23cffb0fdc0fbe19949dd042d668ac@79.98.45.133:5060]
        CSeq: 102 INVITE
        User-Agent: MOR Softswitch
        Date: Mon, 30 Sep 2024 14:18:02 GMT
        Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
        Supported: replaces, timer
        Content-Type: application/sdp
        Content-Length: 361
    Message Body

No.     Time           Source                Destination           Protocol Length Info
     33 6.391889       192.168.178.83        79.98.45.133          SIP      324    Status: 100 Trying | 

Frame 33: 324 bytes on wire (2592 bits), 324 bytes captured (2592 bits)
Ethernet II, Src: HewlettP_cc:df:08 (68:b5:99:cc:df:08), Dst: AVMAudio_bb:b4:a0 (38:10:d5:bb:b4:a0)
Internet Protocol Version 4, Src: 192.168.178.83, Dst: 79.98.45.133
User Datagram Protocol, Src Port: 38119, Dst Port: 5060
Session Initiation Protocol (100)
    Status-Line: SIP/2.0 100 Trying
    Message Header
        Via: SIP/2.0/UDP 79.98.45.133:5060; branch=z9hG4bK2f7cb45b
        From: <sip:xxxxxxx@79.98.45.133>; tag=as35f49270
        To: <sip:yyyyyyy@127.0.1.1:5060>
        Call-ID:  0e23cffb0fdc0fbe19949dd042d668ac
        [Generated Call-ID: 0e23cffb0fdc0fbe19949dd042d668ac]
        Cseq: 102 INVITE
        User-Agent: PythonSIPClient
        Content-Length: 0

Solution

  • Your code should copy value of the 'Call-ID' header from original INVITE and put it in the TRYING. According to provided pcap fragment it skips part of this value and adds extra space before it. Also there is mistake in 'CSeq' header name:

    Call-ID: 0e23cffb0fdc0fbe19949dd042d668ac@79.98.45.133:5060
    Call-ID:  0e23cffb0fdc0fbe19949dd042d668ac
    
    CSeq: 102 INVITE
    Cseq: 102 INVITE