\section{Examples}
\label{sec:examples}

In the following examples, we often omit the message body and the
corresponding \header{Content-Length} and \header{Content-Type} header
fields for brevity.

\subsection{Registration}
\label{sec:examples:registration}

Bob registers on start-up.  The message flow is shown in Figure~\ref{fig:register}. \begin{changebar} Note 
that the authentication usually required for registration is not shown for simplicity. \end{changebar} 

\txtpsfigsize{!}{!}{register}{SIP Registration Example}

\begin{changebar}
\begin{verbatim}

F1 REGISTER Bob -> Registrar

  REGISTER sip:registrar.biloxi.com SIP/2.0
  Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7
  Max-Forwards: 70
  To: Bob <sip:bob@biloxi.com>
  From: Bob <sip:bob@biloxi.com>;tag=456248
  Call-ID: 843817637684230@998sdasdh09
  CSeq: 1826 REGISTER
  Contact: <sip:bob@192.0.2.4>
  Expires: 7200
  Content-Length: 0
\end{verbatim}
\end{changebar}

The registration expires after two hours.  The registrar responds with
a 200 OK:



\begin{verbatim}

F2 200 OK Registrar -> Bob

  SIP/2.0 200 OK
  Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7
   ;received=192.0.2.4
  To: Bob <sip:bob@biloxi.com>
  From: Bob <sip:bob@biloxi.com>;tag=456248
  Call-ID: 843817637684230@998sdasdh09
  CSeq: 1826 REGISTER
  Contact: <sip:bob@192.0.2.4>
  Expires: 7200
  Content-Length: 0

\end{verbatim}


\subsection{Session Setup}
\label{sec:examples:session-setup}

This example contains the full details of the example session setup in
Section~\ref{sec:overview-of-operations}.  The message flow is shown
in Figure~\ref{fig:trapezoid}. \begin{changebar} Note that these flows show
the minimum required set of header fields - some other header fields such as 
\header{Allow} and \header{Supported} would normally be present. \end{changebar}

\begin{verbatim}

F1 INVITE Alice -> atlanta.com proxy

  INVITE sip:bob@biloxi.com SIP/2.0
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
  Max-Forwards: 70
  To: Bob <sip:bob@biloxi.com>
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:alice@pc33.atlanta.com>
  Content-Type: application/sdp
  Content-Length: 142

  (Alice's SDP not shown)
\end{verbatim}


\begin{changebar}
\begin{verbatim}

F2 100 Trying atlanta.com proxy -> Alice

  SIP/2.0 100 Trying
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Content-Length: 0
\end{verbatim}


\begin{verbatim}

F3 INVITE atlanta.com proxy -> biloxi.com proxy

  INVITE sip:bob@biloxi.com SIP/2.0
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  Max-Forwards: 69
  To: Bob <sip:bob@biloxi.com>
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:alice@pc33.atlanta.com>
  Content-Type: application/sdp
  Content-Length: 142

  (Alice's SDP not shown)
\end{verbatim}



\begin{verbatim}

F4 100 Trying biloxi.com proxy -> atlanta.com proxy

  SIP/2.0 100 Trying
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Content-Length: 0
\end{verbatim}



\begin{verbatim}

F5 INVITE biloxi.com proxy -> Bob

  INVITE sip:bob@192.0.2.4 SIP/2.0
  Via: SIP/2.0/UDP server10.biloxi.com;branch=z9hG4bK4b43c2ff8.1
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  Max-Forwards: 68
  To: Bob <sip:bob@biloxi.com>
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:alice@pc33.atlanta.com>
  Content-Type: application/sdp
  Content-Length: 142

  (Alice's SDP not shown)
\end{verbatim}



\begin{verbatim}

F6 180 Ringing Bob -> biloxi.com proxy

  SIP/2.0 180 Ringing
  Via: SIP/2.0/UDP server10.biloxi.com;branch=z9hG4bK4b43c2ff8.1
   ;received=192.0.2.3
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  Contact: <sip:bob@192.0.2.4>
  CSeq: 314159 INVITE
  Content-Length: 0
\end{verbatim}



\begin{verbatim}

F7 180 Ringing biloxi.com proxy -> atlanta.com proxy

  SIP/2.0 180 Ringing
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  Contact: <sip:bob@192.0.2.4>
  CSeq: 314159 INVITE
  Content-Length: 0
\end{verbatim}



\begin{verbatim}

F8 180 Ringing atlanta.com proxy -> Alice

  SIP/2.0 180 Ringing
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  Contact: <sip:bob@192.0.2.4>
  CSeq: 314159 INVITE
  Content-Length: 0
\end{verbatim}



\begin{verbatim}

F9 200 OK Bob -> biloxi.com proxy

  SIP/2.0 200 OK
  Via: SIP/2.0/UDP server10.biloxi.com;branch=z9hG4bK4b43c2ff8.1
   ;received=192.0.2.3
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:bob@192.0.2.4>
  Content-Type: application/sdp
  Content-Length: 131

  (Bob's SDP not shown)
\end{verbatim}



\begin{verbatim}

F10 200 OK biloxi.com proxy -> atlanta.com proxy

  SIP/2.0 200 OK
  Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
   ;received=192.0.2.2
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:bob@192.0.2.4>
  Content-Type: application/sdp
  Content-Length: 131

  (Bob's SDP not shown)
\end{verbatim}



\begin{verbatim}

F11 200 OK atlanta.com proxy -> Alice

  SIP/2.0 200 OK
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
   ;received=192.0.2.1
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 INVITE
  Contact: <sip:bob@192.0.2.4>
  Content-Type: application/sdp
  Content-Length: 131

  (Bob's SDP not shown)
\end{verbatim}



\begin{verbatim}

F12 ACK Alice -> Bob

  ACK sip:bob@192.0.2.4 SIP/2.0
  Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds9
  Max-Forwards: 70
  To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  From: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 314159 ACK
  Content-Length: 0
\end{verbatim}


The media session between Alice and Bob is now established.

Bob hangs up first.  Note that Bob's SIP phone maintains its own
\header{CSeq} numbering space, which, in this example, begins with
231. Since Bob is making the request, the \header{To}
and \header{From} URIs and tags have been swapped.


\begin{verbatim}

F13 BYE Bob -> Alice

  BYE sip:alice@pc33.atlanta.com SIP/2.0
  Via: SIP/2.0/UDP 192.0.2.4;branch=z9hG4bKnashds10
  Max-Forwards: 70
  From: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  To: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 231 BYE
  Content-Length: 0
\end{verbatim}
\end{changebar}


\begin{verbatim}

F14 200 OK Alice -> Bob

  SIP/2.0 200 OK
  Via: SIP/2.0/UDP 192.0.2.4;branch=z9hG4bKnashds10
  From: Bob <sip:bob@biloxi.com>;tag=a6c85cf
  To: Alice <sip:alice@atlanta.com>;tag=1928301774
  Call-ID: a84b4c76e66710
  CSeq: 231 BYE
  Content-Length: 0
\end{verbatim}


The SIP Call Flows document~\citenonnorm{draft-ietf-sip-call-flows} contains
further examples of SIP messages.


