Constructing and Deconstructing Messages

SIP is basically a communication protocol that provides the means for applications to send and receive messages. In the http://Vovida.org implementation, some of these messages are constructed from scratch, while others are constructed from the components of received messages.

When a SIP device receives an INVITE message, it uses the contents of the message to construct new messages. For example, to construct a 200 OK message , the application passes the received INVITE, thereby automatically filling in a large portion of required fields with data that is useful to the transaction. If some of these fields need to be changed, the application can make these changes before sending the message.

Building responses based on the request headers is a big time saver. ACKs are normally constructed out of SIP status responses to INVITE messages, and BYEs are built from the original INVITEs that were used to initiate the calls.

The following is a simplified look at how the SIP stack builds messages.

Sending

Here is a well-commented example of a sending program:

 #include "VovidaSipStack.hxx" #include "InviteMsg.hxx" int main() { // Here is the SIP stack for this message. The argument is the // SIP port for this program to receive SIP messages on. Sptr<SipTransceiverFilter> sipStack = new SipTransceiverFilter(5060); // Construct a SIP URI for the message. Sptr<SipUrl> toUrl = new SipUrl(Data("sip:user@domain.com")); // Construct a simple SIP INVITE. ...

Get Practical VoIP Using VOCAL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.