Friday, January 6, 2012

Asterisk: SIP Subscribe/Notify and MWI event

SIP specific event notification is described well in RFC 3265
SIP Message Wait Indication Event (MWI) is described well in RFC 3842

Event notification allows any SIP client (IP Phones) to monitor the state of another device. If UA1 wants to know the status of UA2, it sends a SUBSCRIBE request to a server that is aware of the state of UA2 or it can directly send a SUBSCRIBE request to UA2. If the SUBSCRIBE request is successful, then UA1 is notified with SIP NOTIFY message every time UA2 changes the state.
This mechanism is widely used to control Busy Lamp Field (BLF) lamps.

Message Waiting Lamps or MWI are controlled by NOTIFY message, and as per RFC3842 explicit subscription is not required.

SIP signalling for MWI (captured on server/pbx):

Server sending the NOTIFY message to IP phone ( Extension 57644)

NOTIFY sip:57644@192.168.2.10 SIP/2.0
Via: SIP/2.0/UDP sipserver.phone:5060;branch=z9hG4bK490bfd1d
Max-Forwards: 70
From: "pbx" <sip:pbx@sipserver.phone&gt;;tag=as5bea1e93
To: <sip:57644@192.168.2.10>
Contact: <sip:pbx@sipserver.phone:5060>
Call-ID: 154a4e1246b2d33f7257e1c965625efa@sipserver.phone:5060
CSeq: 102 NOTIFY
User-Agent: Asterisk PBX 1.8.7.1
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 93

Messages-Waiting: no
Message-Account: sip:pbx@sipserver.phone:5060
Voice-Message: 0/2 (0/0)

---

IP Phone responding to the server by sending 200 OK

<--- SIP read from UDP:192.168.2.10:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP sipserver.phone:5060;branch=z9hG4bK490bfd1d
From: "pbx" <sip:pbx@sipserver.phone>;tag=as5bea1e93
To: "57644" <sip:57644@192.168.2.10>;tag=886BDB1C-E1C3AFC1
CSeq: 102 NOTIFY
Call-ID: 154a4e1246b2d33f7257e1c965625efa@sipserver.phone:5060
Contact: <sip:57644@192.168.2.10>
Event: message-summary
User-Agent: PolycomSoundPointIP-SPIP_331-UA/3.3.2.0413
Accept-Language: en
Content-Length: 0

MWI activation in Polycom phone and Asterisk:

#vi /etc/asterisk/voicemail.conf
[default]
57644 => 1234,John Doe, John.Doe@xyz.com

#vi /etc/aterisk/sip.conf
[
57644 ]
type=friend
host=dynamic
username=
57644
callerid="John Doe" <57644 >
secret=mypassword
mailbox=
57644

pbx CLI> sip show peer 57644
* Name : 57644
- - - -
- - - -
Mailbox : 57644
Call limit : 0
Max forwards : 0
Dynamic : Yes
Callerid : "John Doe" <57644>
MaxCallBR : 384 kbps
Expire : 205
- - - -
- - - -
Addr->IP : 192.168.2.10:5060
Defaddr->IP : (null)
Prim.Transp. : UDP
Allowed.Trsp : UDP
Reg. exten :
Def. Username: 57644
SIP Options : (none)
Codecs : 0x4 (ulaw)
Codec Order : (ulaw:20)
Auto-Framing : No
100 on REG : No
Status : Unmonitored
Useragent : PolycomSoundPointIP-SPIP_331-UA/3.3.2.0413
Reg. Contact : sip:57644@192.168.2.10


Asterisk automatically sends NOTIFY message to IP phone provided that the phone is registered correctly with Asterisk and Asterisk knows which voicemail box is associated with that extension. You can check that by issuing the asterisk CLI command #sip show peer

Reg. Contact : sip:57644@192.168.2.10 tells you that phone is successfully registered.
Mailbox : 57644
tells you that Asterisk knows that voicemail box 57644 is associated with that phone. That association is defined in sip.conf.



1 comment: