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

SIP Request Messages

87

Table 4.9

Mandatory Header Fields in a SUBSCRIBE

Via

To

From

Call-ID

CSeq

Max-Forwards

Contact

Event

Allow-Events

4.1.8NOTIFY

The NOTIFY method [5] is used by a user agent to convey information about the occurrence of a particular event. A NOTIFY is always sent within a dialog when a subscription exists between the subscriber and the notifier. However, it is possible for a subscription to be established using non-SIP means (no SUBSCRIBE is sent) and may also be implicit in another SIP request type (for example, a REFER establishes an implicit subscription). Since it is sent within a dialog, the NOTIFY will contain a To tag, From tag, and existing Call-ID. A basic call flow showing NOTIFY is in Figure 4.5.

A NOTIFY request normally receives a 200 OK response to indicate that it has been received. If a 481 Dialog/Transaction Does Not Exist response is received, the subscription is automatically terminated and no more NOTIFYs are sent.

NOTIFY requests contain an Event header field indicating the package and a Subscription-State header field indicating the current state of the subscription. The Event header field will contain the package name used in the subscription. Currently defined packages are listed in Table 4.8. The Subscription-State header field will either be active, pending, or terminated.

A NOTIFY is always sent at the start of a subscription and at the termination of a subscription. If a NOTIFY contains incremental (delta) state information, the message body will contain a state version number that will be incremented by 1 for each NOTIFY sent. This way, the receiver of the NOTIFY can tell if information is missing or received out of sequence.

An example NOTIFY request is shown here:

NOTIFY sip:tyoung@parlour.elasticity.co.uk SIP/2.0 Via SIP/2.0/UDP cartouche.rosettastone.org:5060 ;branch=z9hG4bK3841323

Max-Forwards: 70

To: Thomas Young <sip:tyoung@elasticity.co.uk>;tag=1814 From: <sip:ptolemy@rosettastone.org>;tag=5363956k Call-ID: 452k59252058dkfj34924lk34

CSeq: 3 NOTIFY

Contact: <sip:ptolemy@cartouche.rosettastone.org>

88

SIP: Understanding the Session Initiation Protocol

Event: dialog

Subscription-State: active;expires=180

Allow-Events: dialog

Content-Type: application/xml+dialog

Content-Length: ...

(XML Message body not shown...)

Table 4.10 lists the mandatory header fields in a NOTIFY request.

4.1.9PUBLISH

The PUBLISH method [17] is used by a user agent to send (or publish) event state information to a server known as an event state compositor (ESC). PUBLISH is most useful when there are multiple sources of event information, such as a number of devices sharing the same AOR. In this case, to find the complete state, another UA would need to subscribe individually to all the devices. Instead, the UA can subscribe to the ESC. Individual UAs send PUBLISHes to the ESC, which processes them and puts them together, generating NOTIFYs to watchers as shown in Figure 4.6.

An example PUBLISH request is shown here:

PUBLISH sip:percy@lowell.edu SIP/2.0

Via SIP/2.0/UDP telescope32.lowell.edu:54620 ;branch=z9hG4bK43d132s3

Max-Forwards: 70

To: <sip:percy@lowell.edu>

From: <sip:percy@lowell.edu>;tag=5645fg432f Call-ID: 34jdUhwiQhd72e

CSeq: 352 PUBLISH

Contact: <sip:percy@telescope32.lowell.edu:54620> Event: presence

Min-Expires: 1800 Expires: 3600 Allow-Events: presence

Content-Type: application/xml+pidf

Table 4.10

Mandatory Header Fields in a NOTIFY

To

Via

To

From

Call-ID

CSeq

Max-Forwards

Event

Allow-Events

Subscription-State

 

 

 

SIP Request Messages

89

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 4.6 PUBLISH call flow example.

Content-Length: ...

(XML Message body not shown...)

A PUBLISH request is similar to a NOTIFY, except it is not sent in a dialog. A PUBLISH request must contain an Expires header field and a Min-Expires header field. The Expires header field indicates the maximum time when the ESC may discard the event state information, unless it is updated or refreshed. The Min-Expires header field indicates the minimum expiration that the ESC may choose. In the 200 OK response to the PUBLISH, the Expires header field will indicate the value chosen by the ESC, which must be between the Min-Expires and Expires intervals. If the Min-Expires interval is too short, the ESC may respond with a 423 Interval Too Brief response containing a Min-Expires interval acceptable to the ESC. The presence UA must then republish the information using this interval.

When an ESC receives and processes a PUBLISH it generates an entity-tag, a unique identifier for this piece of event state information, and returns the tag in a SIP-ETag header field of the 200 OK response. For example, here is a 200 OK response to the above PUBLISH:

SIP/2.0 200 OK

Via SIP/2.0/UDP telescope32.lowell.edu:54620 ;branch=z9hG4bK43d132s3;received=173.34.3.1 Max-Forwards: 70

To: <sip:percy@lowell.edu>;tag=23211d From: <sip:percy@lowell.edu>;tag=5645fg432f

90

SIP: Understanding the Session Initiation Protocol

Call-ID: 34jdUhwiQhd72e

CSeq: 352 PUBLISH

Event: presence

Expires: 1800

SIP-ETag: dkfiei4RIUOwqwe23

Allow-Events: presence

Content-Length: 0

Using the entity-tag, the publisher can update a previously published state. In this case, to refresh the previously published state, a PUBLISH containing a SIP- If-Match header field is used containing the assigned entity-tag, but not containing a body. In this way, the state can be refreshed without having to send the information again. For example, this PUBLISH could be used to refresh the first publication, provided it is received within the 30 minute interval:

PUBLISH sip:percy@lowell.edu SIP/2.0

Via SIP/2.0/UDP telescope32.lowell.edu:54620 ;branch=z9hG4bK743d32s3a

Max-Forwards: 70

To: <sip:percy@lowell.edu>

From: <sip:percy@lowell.edu>;tag=458234kdf Call-ID: 739238dkd2df

CSeq: 352 PUBLISH

Contact: <sip:percy@telescope32.lowell.edu:54620> CSeq: 353 PUBLISH

Event: presence Min-Expires: 1800 Expires: 3600 Allow-Events: presence

SIP-If-Match: dkfiei4RIUOwqwe23 Content-Length: 0

If the state had expired, or been updated such that the entity-tag no longer matches or is not valid, the ESC would return a 412 Conditional Request

Table 4.11

Mandatory Header Fields in a PUBLISH

To

Via

To

From

Call-ID

CSeq

Max-Forwards

Contact

Event

Allow-Events

Expires

Min-Expires

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