理解SIP消息体--UNDERSTANDING SIP MESSAGE BODIES

https://andrewjprokop.wordpress.com/2014/04/07/understanding-sip-message-bodies/

I was born and raised in Arizona, but for many years I’ve called Minnesota home. Yes, I understand that most people make the opposite move, but I truly love it here and no one is twisting my arm to stay. Okay, the first few winters were brutal, but I’ve even grown to appreciate/tolerate those.

我在亚利桑那州出生和长大,但多年来我一直把明尼苏达州当作家。是的,我知道大多数人会做出相反的举动,但我真的很喜欢这里,没有人强迫我留下来。好吧,最初的几个冬天是残酷的,但我已经开始欣赏/容忍它们了。

Minnesota is known as the land of ten thousand lakes, but I’ve heard that it’s actually closer to twelve thousand. It wouldn’t surprise me if the number was even higher. Even here in the Twin Cities, you don’t have to drive very far to find a sizable lake. Coming from hot and dry Arizona, it was a shock to live around so much liquid.

明尼苏达州万湖之州而闻名,但我听说它实际上接近1.2万个湖泊。如果这个数字更高,我也不会感到惊讶。即使在双城,你也不用开很远就能找到一个很大的湖。我来自炎热干燥的亚利桑那州,住在这么多的液体周围真是令人震惊。

Besides all these bodies of water, Minnesota is birthplace of our former governor, Jesse “the Body” Ventura. Politics aside, he was an extremely colorful character that raised the visibility of the state far more than nearly all the previous governors combined.

除了这些水域之外,明尼苏达州还是我们的前州长杰西·文图拉的出生地。撇开政治不谈,他是一个极其丰富多彩的人物,他在该州的知名度远远超过了几乎所有前任州长的总和。

So, what does this have to do with SIP? Why, SIP message bodies, of course. On its own, SIP can establish sessions between two or more entities, but it’s those message bodies that make SIP more than an academic toy.

那么,这和SIP有什么关系呢?当然是SIP消息体。SIP本身可以在两个或多个实体之间建立会话,但是正是这些消息体使SIP不仅仅是一个学术玩具。

You may have heard it said that SIP is media agnostic. This means that SIP can establish a media connection of any type. Everyone is familiar with voice, video, and instant message. I once worked on a piece of software that used SIP to play chess across an IP network. The media consisted of the chess moves. I also wrote a SIP application that sent the contents of a clipboard from one PC to another.

你可能听说过SIP是媒体不可知的。这意味着SIP可以建立任何类型的媒体连接。每个人都熟悉语音、视频和即时消息。我曾经做过一个软件,它使用SIP在IP网络上下棋。媒体报道的是国际象棋的走法。我还编写了一个SIP应用程序,它将剪贴板的内容从一台PC发送到另一台PC。

There are no limits to the kinds of data connections SIP can facilitate.

SIP对数据连接类型无限制

There are two things that make SIP media independent. First, there is the SIP message body. Contained with the message body is a description of the media used by the session. For example, Session Description Protocol (SDP) is used for voice and video transmissions. XML is often used for instant message. My chess and clipboard programs used a homegrown descriptor that looked very similar to SDP.

有两样东西使SIP媒体相对独立。第一,是消息体。包含在消息体中的是会话使用的媒体的描述。举个例子,会话描述协议(SDP)用于描述声音和视频传输。XML经常被用于即时通信。我的国际象棋和剪贴板程序使用了一个自成体系的描述符,看起来非常类似于SDP。

For more information on SDP, please refer to my article, Understanding Session Description Protocol (SDP).

想得到更多SDP的信息,请参考我的文章《理解SDP》

Second, SIP supports several headers that are used to define and describe the message body. Specifically, they are:

第二,SIP支持用于定义和描述消息体的数个header,具体来说,他们是:

Content-Type: Content-Type indicates the media type of the message body sent to the recipient. Examples include application/SDP and text/html.

content-Type:内容类型指示发送给收件人的消息体的媒体类型。例如包括application/SDP 和text/html

Content-Length: Content-Length indicates the size of the message body in octets (8-bit bytes). SIP messages that do not contain a message body will set Content-Length to 0 (zero).

content-length:消息长度用字节定义了消息体的大小。sip消息不包含消息体那么消息长度设为0

Content-Language. Content-Language defines the language of the message body. For instance, a value of “fr” indicates that the message body is in French.

content-language:内容语言定义了消息体的语言。例如,fr值表示消息体是用的法语

Content-Encoding. When present, Content-Encoding indicates what additional encodings have been applied to the message body and thus what decoding mechanism must be applied in order to read it. For example, qzip or tar are valid values for a compressed message body.

内容-编码:当出现内容编码时,它指示对消息体应用了哪些额外的编码,因此为了读取消息体必须应用哪些解码机制。例如,qzip或tar是压缩消息体的有效值。

Content-Disposition. Content-Disposition describes how the message body or message body type (see discussion of multipart MIME below) is to be interpreted.

content - dispose:它描述如何解释消息体或消息体类型(参见下面对多部分MIME的讨论)。

Of these headers, Content-Length will appear in every SIP message. As I mentioned earlier, a value of 0 indicates that there is no message body. However, if there is a message body, you will always see Content-Type. Content-Language isn’t required and defaults to English if the header isn’t present. Content-Encoding only appears if the message body has been encoded.

这些headers,content-length将会出现在每个sip消息中,就像我之前提过的,值0就代表它没有消息体。无论如何,如果有消息体,你将一定会看到content-type。content-language不是必须的,它如果不出现,则默认是英语。content-encoding只会在消息体被编码的时候出现

I will be honest and say that I rarely see Content-Disposition used in practice and when I have, it has always been set to “session.” Values such as “inline” and “render” are available, but I have yet to see those used in any of my SIP dealings.

说实话,我很少看到在实践中使用content-dispose,即使我看到了,它也总是被设置为session。可以使用内联和呈现等值,但我还没有看到在任何SIP交互中使用这些值。

What follows is SIP message with its message body. Note that Content-Encoding does not appear. This means that we can read the message body without having to first decode it.

下面是一个携带消息体的sip消息,注意那个content-encoding没出现,这就意味着我们不需要解码就能读取消息体的内容

PUBLISH sip:bob@mycompany.com SIP/2.0

Via: SIP/2.0/UDP 10.10.21.11;branch=z9hG4bK652hsge

To: <sip:bob@mycompany.com>

From: <sip:bob@mycompany.com>;tag=1234wxyz

Call-ID: 81818181@10.10.21.11

CSeq: 1 PUBLISH

Max-Forwards: 70

Expires: 3600

Event: presence

Content-Type: application/pidf+xml

Content-Length: 120

 

<?xml version=”1.0″ encoding=”UTF-8″?>

<presence xmlns=”urn:ietf:params:xml:ns:pidf”

entity=”pres:presentity@example.com”>

<tuple id=”efeef223″>

<status>

<basic>closed</basic>

</status>

<timestamp>2003-02-01T17:00:19Z</timestamp>

</tuple>

</presence>

Note that there is a single blank line between the end of the SIP message and the start of the message body. This is required by SIP. Also note that Content-Length counts the number of bytes after the blank line.

注意在sip消息的结尾和消息体的开头有一个单行空白行。这是sip所要求的,当然注意content-length计算空白行之后的字节数

The last thing I want to discuss is multipart MIME. I previously mentioned multipart MIME (MM) in my article, Call Recording With SIPREC. Simply put, MM is used when a message body is divided into more than one part. In the case of call recording, one part would be SDP and the other SIPREC extensions. These two parts are processed independently and aren’t required to be related in any manner.

我想讨论的最后一个东西是多部分的MIME。我之前在我的文章里提过MIME(https://andrewjprokop.wordpress.com/2014/02/26/call-recording-with-siprec/) 简而言之,MM被用于当消息体被分割成多于一个的部分。在电话录音的情况下,一部分会变成SDP另一部分成为SIPREC扩展。这两个部分是独立处理的,不需要以任何方式关联。

I’ve also seen MM used by Nortel CS1000 systems. The first part of an INVITE was SDP and the second consisted of Nortel proprietary values that would be ignored by non-Nortel SIP systems.

我也见过MM用于noratel cs1000系统,INVITE的第一分部是SDP,第二部分由nortel私有的值组成,非nortel的SIP系统会忽略这些sip信息

There is one more content header that comes into play with MM. Content-ID is used to “point” to a particular part. Content-ID allows one body to make reference to another. For more information, please find RFC 2045.

MM还提供了一个content header。content-id用于“指向”特定的部分。Content-ID允许一个主体引用另一个主体。更多信息,请参见RFC 2045。

Speaking of RFCs, if you require more information on multipart MIME, I suggest you read RFC 5621, Message Body Handing in the Session Initiation Protocol. You will learn far more there than I could ever dream to teach you.

说起RFCs,如果你需要更多关于multipart MIME的信息,我推荐你读RFC5621。你将比我梦想教你的还要多的知识

Well, there you have it. Everything you wanted to know about SIP message bodies, but were afraid to ask. Remember, message bodies are what makes SIP media independent and a protocol useful for everything from telephone calls to chess games.

好了,你知道了。您想知道的关于SIP消息体的一切,但又不敢问。请记住,消息体使SIP独立于媒体,并且是一种对从电话到象棋游戏的一切都有用的协议。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值