Difference between Peer, Contact and Device

Hello all,

I have been going through the events when a call is placed over a pjsip extension and I am getting events from DeviceStateChange, PeerStatus and ContactStatus. The events are mostly similar and kind of duplicate. So just wondering whats the difference between these three entities so that best one for my use case can be selected.


I guess you are referring to Asterisk Manager events that are documented here: Asterisk 18 AMI Events - Asterisk Project - Asterisk Project Wiki

I don’t see a lot of redundancy here, but that depends on what one is interested in. An endpoint is neither a contact nor a device and sometimes the difference matters and sometimes not. For example, you could easily move an endpoint to a different device and that generally means a different AOR and contact. I needed some time to get used to this level of abstraction…

Device State is technology independent. Contact status and peer status only have meaning for SIP and may well only be implemented for chan_pjsip. It looks to me as though device states are the only ones that change during a normal call.

Thanks for the replies. I am mostly interested to know when a SIP phone goes offline [unavailable] because of network issues. Which entity would be most appropriate?

Does it share an AOR? Are you interested in when the endpoint becomes unusable, or when the specific phone becomes unusable?

Only one SIP phone is configured per AOR. I am interested when a specific SIP phone gets unreachable.

In the current config, each phone has its own AOR, auth and endpoint defined.

16:12:45 ContactStatus for AOR test-sip Status: NonQualified RTT: 0 URI: sip:test-sip@103.xxx.xxx.161:47003
16:12:45 PeerStatus for Peer PJSIP/test-sip Status: Reachable
16:12:45 DeviceStateChange for Device PJSIP/test-sip Event DeviceStateChange State: NOT_INUSE
16:12:45 ContactStatus for AOR test-sip Status: Reachable RTT: 294803 URI: sip:test-sip@103.xxx.xxx.161:47003

16:19:25 PeerStatus for Peer PJSIP/test-sip Status: Unreachable
16:19:25 ContactStatus for AOR test-sip Status: Unreachable RTT: 0 URI: sip:test-sip@103.xxx.xxx.161:47003
16:19:25 DeviceStateChange for Device PJSIP/test-sip Event DeviceStateChange State: UNAVAILABLE

This is the result of a test program that listens and prints the events. Contact, Peer and Device emits an event when the phone becomes unreachable.

Their essentially all degenerate. I’d suggest looking at them in the order device, peer, contact, and use the first one that provides the information you need, as that order should be most general to most specific, and, for example device will tell you if non-VoIP devices have become unusable, e.g. because of an alarm on an ISDN link.

I would assume that peer and device would not show a fault if only one of multiple contacts was lost, but it looks like you need contact to see the round trip time.

1 Like

Thanks! I will do as suggested.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.