RADVISION Understanding SIP Servers PDF
RADVISION Understanding SIP Servers PDF
© 2002 RADVISION Ltd. All intellectual property rights in this publication are owned by
RADVISION Ltd. and are protected by United States copyright laws, other applicable copyright laws
and international treaty provisions. RADVISION Ltd. retains all rights not expressly granted.
No part of this publication may be reproduced in any form whatsoever or used to make any
derivative work without prior written approval by RADVISION Ltd.
No representation of warranties for fitness for any purpose other than what is specifically mentioned
in this guide is made either by RADVISION Ltd. or its agents.
RADVISION Ltd. reserves the right to revise this publication and make changes without obligation to
notify any person of such revisions or changes. RADVISION Ltd. may make improvements or
changes in the product(s) and/or the program(s) described in this documentation at any time.
If there is any software on removable media described in this publication, it is furnished under a
license agreement included with the product as a separate document. If you are unable to locate a
copy, please contact RADVISION Ltd. and a copy will be provided to you.
Unless otherwise indicated, RADVISION registered trademarks are registered in the United States
and other territories. All registered trademarks recognized.
Introduction 1
What is a SIP Server? 1
Register Server 2
Redirect Server 3
Proxy Server 6
Stateful and Stateless Proxies 6
Request Validation 9
Address Resolution 11
Determining the Target-set 11
DNS Resolution 12
Stateful Message Forwarding 12
CANCEL 16
Record-Routing 17
Loose Routing 18
Recursion on 3xx Responses 19
Forking 20
Authentication 23
Loop detection and Max Forwards 24
Message Spiraling 25
Outbound Proxy 26
Policy 26
RADVISION SIP Server Toolkit 27
SIP Server Toolkit Package 28
Operating System Support 28
RADVISION Family of SIP Development Solutions 28
Contents iii
iv Understanding SIP Servers
UNDERSTANDING SIP SERVERS
INTRODUCTION SIP Servers are essential network elements that enable SIP endpoints to
exchange messages, register user location, and seamlessly move between
networks. SIP Servers enable network operators to install routing and security
policies, authenticate users and manage user locations.
SIP Server applications may take many forms, but the SIP standard defines three
general types of server functionality that apply to all—proxy, redirect and
registrar servers. These standard functionalities can be used according to the
needs of the specific implementation.
With the advance of SIP, server logic has become increasingly complex. SIP
Servers need to deal with varying network topologies (such as public Internet
networks, cellular networks, broadband residential networks), complex routing
policies, security and SIP extensions. SIP Servers often need to handle high
message/transaction rates and yield real-time performance and scalability, high
throughput, and low delay. This chapter discusses the protocol aspects of SIP
Server behavior and the usage of the RADVISION SIP Server Toolkit to address
the challenges of effective SIP Server development.
WHAT IS A SIP The SIP baseline specification RFC3261 (previously RFC2543bis) divides SIP
SERVER? Server functionality into the following three parts:
SIP Registrar Server—handles location registration messages.
SIP Redirect Server—returns “contact this address” responses.
SIP Proxy Server—forwards SIP requests and responses.
The authors of SIP have made this functional separation for ease of
understanding, and not necessarily as a guideline for implementers. In other
words, it is acceptable to have one “box” do more than just one type of server
functionality. For example, a SIP Server may benefit from having a routing
capability to forward some SIP messages as a proxy and redirect others as a
redirect server. There are existing SIP Server implementations that have all three
types of functionality in one product running in the same process space, while
others prefer to distribute functionality, with different machines performing
different server functions. In fact, the SIP standard does not prohibit a SIP user
agent (endpoint) from having server capabilities, since user agents may redirect
Note The document version number may change as newer versions are
published.
REGISTRAR The SIP standard defines a registrar server as “a server that accepts REGISTER
SERVER requests and places the information it receives in those requests into the location
service for the domain it handles”. REGISTER requests are generated by clients
in order to establish or remove a mapping between their externally known SIP
address(es) and the address(es) they wish to be contacted at. The REGISTER
request can also be used to retrieve all the existing mappings saved for a specific
address.
The Registrar processes the REGISTER request for a specific set of domains. It
uses a “location service”—an abstract location database—in order to store and
retrieve location information. The location service may run on a remote machine
and may be contacted using any appropriate protocol (such as LDAP). The SIP
standard leaves this decision to the implementation. Some implementations may
co-locate the location service and the registrar server on the same machine.
A registrar server may authenticate incoming REGISTER requests using the 401
(Unauthenticated) response.
Registrar Location
Server 2: Store Service
1: Register 4: Lookup
acme.com
5: INVITE 3: INVITE
Proxy
bob@ph12345.
[email protected] 5: INVITE [email protected]
Bob Alice
ph1234 SIP.acme.com
REDIRECT SERVER Redirect server functionality is the simplest of the three functionalities. A
redirect server receives SIP requests and responds with 3xx (redirection)
responses, directing the client to contact an alternate set of SIP addresses. The
alternate addresses are returned as Contact headers in the response message.
Table 1-1 shows the 3xx responses that are currently defined by SIP.
Response Meaning
300 Multiple Choices The address in the request was resolved to several choices,
each with its own specific location, and the user (or user
agent) can select a preferred communication end point and
redirect its request to that location. This status response is
appropriate if the callee can be reached at several different
locations and the server cannot, or prefers not, to proxy the
request
Note: 301 and 302 responses can also contain multiple
Contact address. The difference is that they convey a more
specific reason for the redirection.
301 Moved Permanently The user can no longer be found at the address specified in
the Request-URI (the destination address in the request),
and the requesting client should retry at the new address
given by the Contact header field.
380 Alternative Service The call was not successful, but alternative services are
possible. The alternative services are described in the
message body of the response. The use of this response
code is still not defined in SIP and is for future use.
In most cases, 301 and 302 responses are used by redirect servers. 300 can also
be used, although it is more ambiguous to the calling client.
UA A Redirect Server UA B
INVITE X
302
Contact: B
ACK
INVITE B
200
ACK
The scenario in Figure 1-2 illustrates a redirection scenario. Note that the
second INVITE request is generated with the same dialog identifiers, Call-ID,
and To and From headers as the first INVITE request, but with a different CSeq
value.
Redirection allows servers to push back routing information for a request in a
response to the client, thereby aiding in locating the target of the request, while
taking themselves out of the loop of further messaging for this transaction.
Redirect servers typically are not aware of the state of dialogs (calls,
subscriptions), only of the state of the individual transactions they are handling,
making them transaction-stateful elements. Redirection is designed as a simple
and quick procedure, allowing for redirect servers to be highly scalable and to
yield high-performance. Redirect servers are sometimes used as a load
balancing devices.
Redirect servers may request user authentication with the use of the 407
response as explained below.
PROXY SERVER The SIP standard defines SIP proxies as “elements that route SIP requests to
user agent servers (UAS) and SIP responses to user agent clients (UAC). A
request may traverse several proxies on its way to a UAS. Each will make
routing decisions, modifying the request before forwarding it to the next
element. Responses will route through the same set of proxies traversed by the
request in the reverse order.”
It is useful to view Proxy Servers as SIP-level routers that forward SIP requests
and responses. However SIP proxies employ routing logic that is typically more
sophisticated than just automatically forwarding messages based on a routing
table. The SIP standard allows proxies to perform actions such as validate
requests, authenticate users, fork requests, resolve addresses, cancel pending
calls, Record-Route and Loose-Route, and detect and handle loops. The
versatility of SIP proxies allows the operator/system administrator to use the
proxies for different purposes and in different locations in the network (such as
edge proxy, core proxy and enterprise proxy). This versatility also allows for the
creation of a variety of proxy policies, such as routing calls only for
authenticated users that have no standing debt to the network service provider
operating the proxy. Proxies can be placed at the network of the service provider
or at the enterprise or SOHO premises. The 3GPP IMS architecture, for
example, uses proxies known as Call State Control Functions (CSCF in 3GPP
terminology) of different kinds for various purposes—as the first hop server that
communicates with the handset; as the element that accesses location
repositories and application servers and triggers services; and as the edge
element that communicates with proxies in foreign networks.
A proxy server is designed to be mostly transparent to user agents. Proxy servers
are allowed to change messages only in specific and limited ways. For example,
a proxy is not allowed to modify the SDP body of an INVITE. Apart from a few
exceptions, proxies cannot generate requests at their own initiative. Therefore a
proxy cannot terminate an existing call by generating a BYE request.
STATEFUL AND The SIP specification defines two types of SIP proxies:
STATELESS PROXIES Stateful proxy
Stateless proxy
STATELESS PROXY
A stateless proxy is a “simple message forwarder”, as described in the SIP
standard. When receiving a request, the stateless proxy processes the request
much like a stateful proxy, however the stateless proxy forwards the message in
a stateless fashion—without saving any transaction context. This means that
once the message is forwarded the proxy “forgets” ever handling this message.
Stateless forwarding allows for improved performance and scalability, but has
some consequences:
A stateless proxy cannot associate responses with forwarded
requests because it retains no knowledge of the requests it has
forwarded. Therefore, the proxy application cannot know if a
transaction was successful or not.
A stateless proxy cannot associate retransmissions of requests
and responses with the previous instance of these messages. It
processes retransmissions exactly as if this is the first copy of
the message it received.
STATEFUL PROXY
When stateful, the proxy processes transactions rather than individual messages.
The proxy manages two types of transactions—server transactions to receive
requests and return responses, and client transactions to send requests and
receive responses. An incoming request is processed by a server transaction and
then forwarded downstream by one or more client transactions (there may be
more the one in the case of parallel forking, for example). An incoming response
is received by the matching client transaction and forwarded back to the server
transaction. Associating between client and server transactions and managing
the overall state of this request is the responsibility of the proxy core object.
The proxy core object chooses the destination address(es) and instantiates one or
more client transaction objects accordingly. The proxy core object also collects
the responses from the different client transactions and chooses the response(s)
that will be sent upstream via the server transaction.
INV X
Client
Transaction
response
INV A INV Y
Server Client
Transaction Transaction
"best" response
response INV Z
Client
Transaction
response
A stateful proxy is aware of the state of transactions and message history, and
can therefore perform better-informed processing on incoming messages. For
example, a stateful proxy can identify a retransmission of an incoming message
and forward the message only in situations that require retransmission
forwarding, whereas a stateless proxy cannot identify retransmissions and has to
forward every message it encounters. A stateful proxy can also generate
retransmissions in cases of message loss. In addition, a stateful proxy can locally
process incoming CANCEL requests and generate CANCEL requests as
needed. Forking is also more natural for a stateful proxy (especially sequential
forking).
Statefulness, however, has the following drawbacks:
Memory consumption
The stateful proxy retains more memory per processed message
than a stateless proxy, and for a longer duration. This has a
negative impact on the maximal capacity of the proxy and limits
the number of concurrent calls/transactions it can handle.
REQUEST VALIDATION Before routing a request, a SIP Server (proxy or redirect) needs to validate the
request to make sure it can actually proceed with processing this message. The
message has to pass the following validity checks:
Authentication
If the SIP Server determines it has to authenticate the originator
of the message, it has to make sure the message contains
credentials that authenticate the user. If the message does not
contain credentials or the credentials failed to authenticate the
user, the proxy may return a 407 response containing a
challenge. The authentication procedure is explained in more
detail in Authentication on page 23.
ADDRESS RESOLUTION Once a proxy has validated an incoming request and decided to forward it, it
must determine the destination(s) to which the message is to be forwarded
before sending the messages. The proxy does two types of address resolution:
Determining the target-set—the proxy resolves the request SIP
destination address (Request URI) to a set of SIP addresses that
are mapped to it in some way.
DNS resolution—the proxy resolves each of the SIP destination
addresses to a transport address of the form:
{transport_protcol, IP address, port}
Note A SIP request may be forwarded to more than one destination address. An
example of such a case is a user that is simultaneously registered at several
locations. In this case, the proxy may decide to fork the request either sequentially
or in parallel.
DETERMINING THE The first process in address resolution, known as obtaining a target-set in the SIP
TARGET-SET specification, results in producing a set of SIP addresses. Essentially this stage
maps from SIP address to SIP addresses. (Some addresses in the target-set may
express explicit transport addresses by using the format
sip:user@ip_address;transport=xyz.)
A target-set is obtained in one of two ways:
Predefined target-set
This is the simpler case, where the destination address of the
request (Request-URI) is such that the proxy must
automatically forward to the destination address without trying
to resolve to other addresses. One such case is where the
request-URI is in a domain for which the SIP Server is not
responsible. For example, a proxy sip:proxy1.acme.com which
DNS RESOLUTION Before forwarding a message, the proxy must resolve the message to concrete
transport addresses which it can use in sending the message. Proxies, as other
SIP entities, use the DNS mechanism described in RFC 3263 (SIP: Locating SIP
Servers). Essentially, this is an algorithm that selectively uses SRV, NAPTR, A
and AAAA DNS queries to map a given SIP address to a prioritized set of
transport addresses of the form:
{transport_protocol, IP_address, port}
Using this advanced DNS scheme is recommended, since it allows building
highly available, load-balanced SIP networks with the possibility of dynamic
adjustment through DNS tables.
STATEFUL MESSAGE The message flows below illustrate the way a stateful SIP proxy forwards
FORWARDING different types of messages. The term “downstream” means in the direction of
the server (request direction); “upstream” means in the direction of the client
(response direction). For the sake of simplicity, the scenarios show only non-
forking proxies that Record-Route.
NON-INVITE REQUEST The scenario in Figure 1-4 shows Non-INVITE Request-Response message
flow through multiple proxies.
UA A P1 P2 UA B
REQUEST
REQUEST
REQUEST
2xx/3xx/4xx/5xx/6xx
2xx/3xx/4xx/5xx/6xx
2xx/3xx/4xx/5xx/6xx
INVITE-ACK When processing an INVITE request, a proxy typically responds with a 100
(Trying) response to stop INVITE retransmissions at the previous hop. All
received 1xx (provisional) responses except 100 are forwarded to the previous
hop. If the proxy does not receive a 100, it may retransmit the INVITE request
as necessary.
The scenario in Figure 1-5 shows INVITE-non-2xx-ACK message flow through
multiple proxies
UA A P1 P2 UA B
INVITE
100
INVITE
100 INVITE
3xx/4xx/5xx/6xx
3xx/4xx/5xx/6xx ACK
ACK
3xx/4xx/5xx/6xx
ACK
If a non-2xx response is received, the proxy generates the ACK request and
forwards the response upstream. Upon reception of a retransmission of the
response, the proxy will retransmit the ACK request.
INVITE-200-ACK The scenario in Figure 1-6 shows INVITE-200-ACK message flow through
multiple proxies.
UA A P1 P2 UA B
INVITE
100
INVITE
100 INVITE
200 OK 200 OK
200 OK
ACK
ACK
ACK
UA A P UA B
INVITE B
100
INVITE B
100
CANCEL
200
(for CANCEL)
CANCEL
200
(for CANCEL)
487
ACK
487
ACK
A stateful proxy may choose to generate a CANCEL request for any pending
INVITE request it has previously forwarded (subject to the rules of CANCEL as
defined by the SIP standard). This capability is put to use in parallel forking as
explained later in Parallel Forking on page 20.
A proxy receiving a CANCEL request must try and match it to an existing
INVITE context (proxy core object) and cancel any pending client transactions
associated with this INVITE, as illustrated in Figure 1-7 above. If an INVITE
context is not found, the proxy must statelessly forward the CANCEL request (it
may have statelessly forwarded the associated INVITE previously).
RECORD-ROUTING The scenario in Figure 1-8 shows message proxying without Record-Routing.
UA A P UA B
INVITE
100
INVITE
200
BYE
200
requests sent in the context of the subscription. Exceptions to these rules may
arise from the use of outbound proxy or from loose routing. For more
information, see Loose Routing on page 18 and Outbound Proxy on page 26.
Proxies should normally Record-Route only requests that set up a dialog
(currently INVITE and SUBSCRIBE). However, a proxy may add a Record-
Route header to any SIP request if it so wishes. SIP user agents do not change
their route-lists based on Record-Route headers in requests other than the initial
INVITE or SUBSCRIBE. It is recommended that proxies avoid adding Record-
Route headers to every request for reasons of processing time and message size.
Selective Record-Routing is highly important because it allows proxies to keep
track of some dialogs for their entire duration, while assisting others only in
their initial setup phase and then removing themselves from loop. This helps
proxies avoid spending resources on routing requests for dialogs that are of no
interest to them.
The Record-Routing mechanism was enhanced and fine-tuned numerous times
during the evolution of SIP in order to cope with various difficult cases. Today a
Record-Routing proxy is required to implement the following functionality:
Route information pre-processing
Route information post-processing
Rewriting Record-Route headers in responses (For example,
the case of a proxy that is routing between different domain
names.)
Loose Routing (see below)
LOOSE ROUTING A loose routing proxy (also known as Loose Router) is one that follows the
procedures defined for Record-Routing in RFC2543bis-08 and later. These
procedures allow a proxy to introduce more hops into the route-list regardless of
the final destination of the message. This enables a proxy to route a message
through a pre-defined set of other proxies before reaching its final destination.
Loose routing was added to the SIP specification due to requirements set by
wireless 3G standard bodies, such as the 3GPP, in order to allow for “intelligent”
routing of messages between visited and home networks.
RECURSION ON 3XX The scenario in Figure 1-9 shows recursion on 3xx Response
RESPONSES
UA A P Redirect Server UA B
INVITE X
100
INVITE X
100
302
Contact: B
ACK
INVITE B
200
200
ACK
ACK
A proxy, upon receiving a 3xx (Redirection) response, may choose to add the
contact address(es) provided in the 3xx response to the target set and possibly
generate a new copy of the request to this address(es), as illustrated in Figure 1-
9. This process is called recursion on 3xx responses. A proxy may do recursion
on3xx responses only if the Request-URI of the original request indicates an
address for which the proxy is responsible.
FORKING After processing an incoming request and building a target-set for it, the proxy
may choose to forward the request to multiple addresses. This process is called
forking and a proxy that supports it is called a forking proxy. Forking allows the
implementation of features such as simultaneously searching (ringing) for a user
in multiple user agent devices (desktop phone and cellular phone, for example),
finding the first available agent in a call-center, and Forward-on-Busy.
A proxy may choose to fork in several ways:
Parallel forking—the proxy forwards copies of the request to
multiple destinations simultaneously.
Sequential forking—the proxy forwards the request to one
target address at a time, waiting for a final response (failure)
before moving on to the next address.
Mixed forking—the proxy may choose to forward requests to
some target addresses in parallel while doing sequential
forwarding for others.
PARALLEL FORKING The scenario in Figure 1-10 (below) shows parallel forking.
UA A P1 UA B UA C
INVITE X
100
INVITE B
The Proxy looks-up X
and obtains two SIP INVITE C
addresses: B and C.
200
200
100
CANCEL
200
(for CANCEL)
487 Request Terminated
ACK
ACK
ACK
UA A P UA B UA C
INVITE X
100
INVITE B
The proxy looks up X
and obtains two SIP
addresses: B and C. 404 Not Found
ACK
INVITE C
200
200
ACK
ACK
UA A P UA B
INVITE B
407
+ challenge
ACK
INVITE B
+ credentials
100
INVITE B
200
200
ACK
ACK
When a UAC sends a request to a proxy server, the proxy server may decide to
authenticate the originator before the request is processed. The proxy can
challenge the originator to by returning a 407 response (Proxy Authentication
Required) with a Proxy-Authenticate header containing the challenge. The client
can re-send the request with a Proxy-Authorization header which provides the
credentials that match the challenge. A client may provide the credentials also
before being challenged in order to avoid the delay and extra processing of the
407 response (the credentials may be built according to cached challenges).
Both challenge and credentials are built using a cryptographic hash so that
certain values, such as password, are not sent in the clear.
Authentication by proxy is useful for the following:
INVITE bob@P1
P1 P2
Illegal Loop
MAX FORWARDS The Max-Forwards header field serves to limit the number of hops a request can
transit on the way to its destination. It consists of an integer that is decremented
by one at each hop. If the Max-Forwards value reaches 0 before the request
reaches its destination, it will be rejected with a 483 (Too Many Hops) error
response. The default initial value for Max-Forwards is 70.
This solution requires minimal processing by proxies and UACs, but has the
disadvantage of stopping the loop only after the message has been forwarded
enough times to exhaust the Max-Forwards value (70 hops by default).
LOOP DETECTION A proxy can optionally check for loops by employing a special loop detection
algorithm. The algorithm affects the way the proxy builds the Via-branch field
and mandates the proxy to do certain validations of the Via list in incoming
requests. Loop detection requires some extra processing per message, but
guarantees immediate detection of the loop as the proxy receives the message
for the second time.
MESSAGE SPIRALING Figure 1-14 shows an example of message spiraling (Legal Loops).
INVITE robert@P1
P1 P2
OUTBOUND PROXY Outbound proxy is a proxy that receives requests from a client regardless of the
destination of the messages (Request-URI) the client is sending. Simple clients
may choose to send every outbound message via an outbound proxy. Typically, a
user agent is manually configured with an outbound proxy, or can learn about
one through auto-configuration protocols.
Outbound proxies are important because they allow the creation of simple user
agents that do not have to be concerned with making routing decisions and DNS
queries. This is especially important in wireless devices which typically have
limited capabilities and resources but may roam to foreign networks.
A proxy that is suitable for use as an outbound proxy is one that is willing to
accept requests even though they are not intended for its domain and that do not
belong to a dialog that it has Record-Routed.
POLICY As explained above, SIP Servers have a wide array of possible ways to handle
incoming messages. A SIP Server has the freedom to make the following
decisions:
Where to route the request and based on which location
information source (location service/database/presence info/
other)
Proxy/Redirect/Reject
Stateful/Stateless forwarding
Record-routing
Forking—parallel/sequential/none
Authentication
Loop detection
These decisions can be made based on many factors, such as:
Message destination address (Request-URI)
Domain(s) managed by this server
Type of request (method)
Other message fields: From, To, Date, Priority …
External parameters, such as time of day
In this document, the collective set of rules that govern proxy routing decision
making is called Server Policy. Server Policies are typically set by the service
providers or administrators that install and configure the SIP Servers.
Because of the large number of input variables and output decisions that are
available for Server Policies, SIP Servers are highly versatile and flexible
elements. This is of key importance for deployment of SIP-based networks.
RADVISION SIP The RADVISION SIP Server Toolkit is a comprehensive framework for the
SERVER TOOLKIT development of any type of SIP Server application. The Toolkit includes an
implementation of fully-standard server functionality that is controllable
through multi-level APIs. SIP Server developers can easily and seamlessly
integrate the SIP Server library into their application and customize it according
to project needs, thus adding SIP Server capabilities to their implementation
quickly and effectively.
The SIP Server Toolkit was designed to specifically address the following
requirements.
Standards compliance
Interoperability
Robustness
Extensibility
Flexibility and Customization
Performance and Capacity
Maintainability
Portability
Minimizing Development Time and Cost
The SIP Server Toolkit is available for all major operating systems.
RADVISION The RADVISION SIP Server Toolkit is part of a complete family of SIP
FAMILY OF SIP technology products RADVISION provides for SIP developers.
DEVELOPMENT The other products include:
SOLUTIONS RADVISION SIP Toolkit—RADVISION’s award winning
development tool including SIP, SDP, RTP/RTCP Stacks.
RADVISION ProLabTM SIP Test Manager—a complete SIP lab
testing solution.
RADVISION Media Device Framework—a framework for the
development of IP phones and residential gateways.