How to send SIP message using Python sockets

泄露秘密 提交于 2019-12-06 06:10:57

According to RFC 3261:

  1. Each header must start with a newline and there must be no whitespaces before header name.
  2. Minimal SIP request must contain To, From, CSeq, Call-ID, Max-Forwards and Via headers.

This means that you correctly added newline before To header, but your answer also incorrectly contains Froma header instead of From. Also, header P-Served-User is generally unnecessary.

Damian Silkowski

Ok I know, maybe it will help someone.

Proper format SIP message is as follows:

INVITE sip:user11@whatever SIP/2.0
To: <to>
Call-ID: <call_id>
<empty line>
body

So,

message = 'INVITE sip:user1110000000350@whatever.com SIP/2.0\r\nTo: <sip:user4110000000350@whatever.com>\r\nFroma: sip:user9990000000000@rider.com;tag=R400_BAD_REQUEST;taag=4488.1908442942.0\r\nP-Served-User: sip:user4110000000350@whatever.com\r\nCall-ID: 00000000-00001188-71C0873E-0@10.44.40.47\r\nCSeq: 1 INVITE\r\nContact: sip:user9990000000000@rider.com\r\nMax-Forwards: 70\r\nVia: SIP/2.0/TCP 10.44.40.47;branch=z9hG4bK1908442942.4488.0\r\nContent-Length: 10\r\n\r\nRandomText'

\r\n is very important without empty spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!