13. - SIP Proxies, Gateways and SIP Routing

Proxies and SIP routing

Stateless proxy: forgets about the SIP request once it has been forwarded. As the transaction is quick and simple, these scale very well to cope with a lot of requests and can also be very fast. They are very well suited to the core of a SIP network but they cannot provide services such as call forking.

image.png

Stateful proxy: By knowing the state of a transaction a stateful proxy can provide many more services such as call forking as the example shows below.

image.png

Via and Record-Route

Some of the most important elements of a SIP message are VIA and Record-Route they help prevent loops and can govern the path the SIP message takes, it is worth nothing that no all SIP providers take full advantage of these records and any wireshark/ethereal traces you may take can differ depending on the SIP provider and SIP phones or PBX you are using at the time.

image.png

VIA details

Via records are added to a SIP message as follow

image.png

If Proxy - Redirect Servers are used, once the INVITE transaction is accomplished, User Agents will know each others direct IP addresses (from the contact field) and carry out the subsequent transactions bypassing the intermediary proxies. This will mean less number of VIA entries than if the Proxy maintains the Call State, also VIA headersa re useed by Proxies to see if any 'Looping' of the message has occurred. if they received a message that includes their own IP address in a VIA record a 482 (loop detected) response is returned to the sender.

Routing Examples 1

image.png

Now this Invite will travel to the PSTN

image.png

Next is the 200 OK received from the PSTN phone

image.png

Now our Phone will send an ACK, the message needs to end up at the gatway so we can see the following

This process is known as Loose Routing <sip:172.20.40.4;lr=on we can see lr is displayed on the Route record, sometimes we see lr=on but this is not required as part of the RFC326 so simply lr is use.

image.png

Record-Route defined

There are so many records when sending a 'Request' message, which is used?

First it will use Route, then Contact (if there is no Route), From (if there is no Contact, 

The Record-Route header is added into requests from UA clients by proxy servers that want to be in the path of follow on request or the same call-id value. The UA client will then use the entries to route subsequent requests and the details from Record-Route are copied into the responses under the Route header. Note: not all proxies will add their details into the header

Contact Headers determine the destination placed in the Request-URI for the following requests and can be used to bypass proxies that do not have an entry in the Record-Route header.

From Headers are used for following requests from the UAS to the UAC if there is no Contact of Record-Route header.


Session Policies

In SIP, session policies are used to control and enforce rules and restrictions on sessions between SIP user agents. Session policies can be applied to various aspects of a session, such as call routing, media handling, security, and resource allocation.

For example, a session policy can specify that calls from a certain group of users should always be routed through a specific SIP proxy, or that media streams must be encrypted using a certain algorithm. Session policies can also be used to enforce restrictions on bandwidth usage or to limit the duration of a session.

SIP session policies are typically implemented using a combination of configuration settings and network devices such as firewalls, routers, and session border controllers (SBCs). These devices can be configured to inspect SIP messages and apply policy rules based on the contents of those messages.

Session policies can be useful in a variety of SIP deployment scenarios, such as in enterprise networks where security and compliance are important, or in service provider networks where quality of service (QoS) and resource allocation are critical. By enforcing policy rules, session policies help to ensure that sessions are conducted in a secure and reliable manner, while also optimizing the use of network resources.

image.png

SIP Gateways

There is a common misconception of what a gateway does, have a look at the slide below, the IP address of this router is also common known as default gateway, is not a gateway its the default router.

The SIP/PSTN gateway actually converts SIP signalling and VoIP traffic to a different format ready for the PSTN - It is actually carrying out 'Real' Gateway functions.

image.png

The main purpuse of the SIP/PSTN gateway to the PSSTN is to provide Signalling and Media conversion between the SIP and PSTN networks, here you can see the SIP/SDP messages hit the signaling gateway and convert the signaling to ISDN and RTP packets hit the media gateway for voice.

image.png

Gateway Location and routing with TRIP

image.png

image.png

image.png


Revision #3
Created 6 May 2023 18:41:19 by Cesar Gzz
Updated 7 May 2023 01:22:36 by Cesar Gzz