Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
understanding-SIP.pdf
Скачиваний:
118
Добавлен:
01.03.2016
Размер:
4 Мб
Скачать
☆

104

SIP: Understanding the Session Initiation Protocol

4.2.3Presence and Instant Messaging URLs

The pres URL scheme is defined [25] as a URL scheme that represents a “presentity” or presence agent. The im URL scheme is defined [25] as a URL scheme that represents an “instant inbox” or an instant message client. Both URL schemes do not represent a new protocol but are resolved using DNS SRV resource records, which return another URI that indicates the actual presence or instant messaging protocol. For example, if the presence agent reference by the presence URL:

pres:user@example.com

supports SIP presence, the DNS SRV query would return a SIP URI, for example:

sip:user@example.com

This would then allow a presence agent to send a SUBSCRIBE to this SIP URI to obtain the presence agent of this user.

The same procedure would be used for resolving an im URL into a SIP URI for sending a MESSAGE request.

4.3 Tags

A tag is a cryptographically random number with at least 32 bits of randomness, which is added to To and From headers to uniquely identify a dialog. The examples in Chapters 2 and 16 show the use of the tag header parameter. The To header in the initial INVITE will not contain a tag. A caller must include a tag in the From header, although an RFC 2543 UA generally will not do so as it is optional in that specification. Excluding 100 Trying, all responses will have a tag added to the To header. The sending or receiving of a response containing a From tag creates an early dialog. A tag returned in a 200 OK response is then incorporated as a dialog identifier and used in all future requests for this Call-ID. A tag is never copied across calls. Any response generated by a proxy will have a tag added by the proxy. An ACK generated by either a UA or a proxy will always copy the From tag of the response in the ACK request.

If a UAC receives responses containing different tags, this means that the responses are from different UASs, and the INVITE has been forked. It is up to the UAC as to how to deal with this situation. For example, the UAC could establish separate sessions with each of the responding UAS. The dialogs would contain the same From, Call-ID, and CSeq, but would have different tags in the To header. The UAC also could BYE certain legs and establish only one session.

Note that tags are not part of the To or From URI but are part of the header and always placed outside any “<>”.

SIP Request Messages

105

4.4 Message Bodies

Message bodies in SIP may contain various types of information. They may contain SDP information, which can be used to convey media information, QoS, or even security information.

The optional Content-Disposition header is used to indicate the intended use of the message body. If not present, the function is assumed to be session, which means that the body describes a media session. Besides session, the other defined function is render, which means that the message body should be presented to the user or otherwise used or displayed. This could be used to pass a small JPEG image file or URI.

The format of the message body is indicated by the Content-Type header. If a message contains a message body, the message must include a Content-Type header. All UAs must support a Content-Type of application/sdp. The encoding scheme of the message body is indicated in the Content-Encoding header. If not specified, the encoding is assumed to be text/plain. The specification of a Content-Encoding scheme allows the message body to be compressed.

The Content-Length header contains the number of octets in the message body. If there is no message body, the Content-Length header should still be included but with a value of 0. Because multiple SIP messages can be sent in a TCP stream, the Content-Length count is a reliable way to detect when one message ends and another begins. If a Content-Length is not present, the UAC must assume that the message body continues until the end of the UDP datagram, or until the TCP connection is closed, depending on the transport protocol.

Message bodies can have multiple parts if they are encoded using Multipart Internet Mail Extensions (MIME). Message bodies in SIP, however, should be small enough so that they do not exceed the UDP MTU of the network. Proxies may reject requests with large message bodies with a 413 Request Entity Too Large response, since processing large messages can load a server. Guidelines for SIP handling of message bodies is described in [31].

As mentioned in the previous section, SIP carries message bodies the same way that e-mails carry attachments. It is possible to carry multiple message bodies within a single SIP message. This is done using a multipart MIME body. The Content-Type is listed as multipart/mime, and a separator is defined, which is used by the parser to separate the message. Any SIP request or response that can contain a message body may carry a multipart MIME body. An example is in SIP-T (see Section 11.2) in which an INVITE carries both a SDP message body (application/sdp) and an encapsulated ISUP message (application/isup). An example multipart MIME is:

INVITE sip:refertarget@carol.example.com SIP/2.0

Via: SIP/2.0/UDP referree.example;branch=z9hG4bKffe209934aac To: sip:refertarget@carol.example.com

106

SIP: Understanding the Session Initiation Protocol

From: <sip:referree@referree.example>;tag=2909034023 Call-ID: 9023940-a34658d

CSeq: 9823409 INVITE Max-Forwards: 70

Contact: <sip:referree@bob.example.com> Referred-By: sip:referror@alice.example.com

;cid=%3C20398823.2UWQFN309shb3@alice.example.com%3E Content-Type: multipart/mixed; boundary=-*-boundary-*- Content-Length: ...

—-*-boundary-*-

Content-Type: application/sdp

Content-Length: ...

v=0

o=referree 2890844526 2890844526 IN IP4 referree.example s=Session SDP

c=IN IP4 referree.example t=0 0

m=audio 49172 RTP/AVP 0 a=rtpmap:0 PCMU/8000

—-*-boundary-*-

Content-Type: multipart/signed; protocol=”application/pkcs7-signature”; micalg=sha1; boundary=dragons39

Content-ID: <20398823.2UWQFN309shb3@alice.example.com> Content-Length: ...

-another-boundary- Content-Type: message/sipfrag

Content-Disposition: auth-id; handling=optional

From: sip:referror@alice.example.com Date: Thu, 21 Feb 2002 13:02:03 GMT Call-ID: 2203900ef0299349d9209f023a

Refer-To: sip:refertarget@carol.example.com Referred-By: sip:referror@alice.example.com

;cid=%3C20398823.2UWQFN309shb3@alice.example.com%3E

-another-boundary-

Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename=smime.p7s ;handling=required

(S/MIME data goes here)

—-*-boundary-*—-

Between each body part is a string, in this example -*-boundary-*- which is defined in the Content-Type header field.

SIP Request Messages

107

4.5 Conclusion

This chapter covered the six base methods in RFC 3261 plus the eight extension methods defined in other RFCs. In addition, SIP URIs, URLs, tags, and message bodies have been covered.

4.6Questions

Q4.1 Explain what happens when the expiration interval in an Expires header field in an INVITE expires.

Q4.2 For the three REGISTER requests sent (in this sequence) below, generate appropriate responses to each from the registrar.

REGISTER sip:registrar.athens.gr SIP/2.0

Via: SIP/2.0/UDP 201.202.203.204:5060;branch=z9hG4bK231U3

Max-Forwards:70

To: sip:euclid@athens.gr

From: <sip:euclid@athens.gr>;tag=543131

Call-ID: 48erl8132409wqer

CSeq: 1 REGISTER

Contact: <sip:euclid@parthenon.athens.gr>

Content-Length: 0

REGISTER sip:registrar.athens.gr SIP/2.0

Via: SIP/2.0/UDP 201.202.203.204:5060;branch=z9hG4bK3r13

Max-Forwards:70

To: sip:euclid@athens.gr

From: < sip:euclid@athens.gr>;tag=75653

Call-ID: 48erl8132409wqer

CSeq: 2 REGISTER

Contact: <mailto:euclid@geometry.org>

Content-Length: 0

REGISTER sip:registrar.athens.gr SIP/2.0

Via: SIP/2.0/UDP 201.202.203.204:5060;branch=z9hG4bK3313

Max-Forwards:70

To: sip:euclid@athens.gr

From: <sip:euclid@athens.gr>;tag=4d31f31

Call-ID: 48erl8132409wqer

CSeq: 3 REGISTER

Content-Length: 0

Q4.3 Is a message body permitted in an ACK? Give an example of this usage.

Q4.4 Explain what happens if a 200 OK and the CANCEL for the INVITE cross on the wire between a proxy and a UA.

Q4.5 If a SUBSCRIBE is forked by a proxy, and multiple subscriptions are established, how will the watcher know this and keep the subscriptions separate?

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]