
In the previous two articles, we looked at the basics of SIP communication.
- SIP client interaction. Part 1 (Simple Interaction)
- SIP client interaction. Part 2 (Interaction with the use of a proxy server)
')
Next, I propose to deal with such an important component of SIP, as SIP URI. We encountered them before when we talked about the fields From, To and others, but did not pay them enough attention.
In this short article, we will look at what URIs are and what they are composed of. In the next article we will focus on the URI and URL in the SIP protocol.
URI
Wikipedia says the following: URI (English Uniform Resource Identifier) ​​- a unified (uniform) resource identifier. In English manners pronounced as [yu-ar-ai], in Russian more often they say [uri]. A URI is a sequence of characters that identifies an abstract or physical resource. Previously called the Universal Resource Identifier - a universal resource identifier.In this case, the URI can indicate both the location of the resource (URL) and its name (URN). And can contain both. That is, the URL and URN are special cases of the URI.
A URI is constructed according to certain rules and consists of a mandatory scheme and a hierarchical part, as well as optional requests (preceded by a "?") And a fragment (preceded by "#"). The hierarchical part, in turn, consists of the optional Authority (I think the translation will only complicate understanding) and the obligatory path. Authority includes Userinfo (login and password), host and port. In addition, the path may contain so-called parameters. Parameters are not used often, but we are lucky - they are present in the SIP URI. On the diagram, it looks like this:

It looks quite confusing, so here’s an example:

URL
URL (Uniform Resource Locator) specifies the path (location) of the object and the method of accessing it. For example,
en.wikipedia.org/wiki/Main_Page points to the main page of English Wikipedia and suggests using the http protocol as an access method.
The URL is described in
RFC 1738 . This RFC describes various schemes for the ftp, http, nntp, etc. protocols. Since the URL is a special case of a URI, the scheme in general looks exactly the same, but one or another part of it is relevant for different protocols. For example, for the telnet protocol, the URL scheme is as follows:
Interesting fact: Tim Berners-Lee, the founder of the URL, later regretted that he had dotted the domain names within the URL. The URL could look like this:
URN
URN is not used within SIP, but without it the story would be incomplete.
URN (Uniform Resource Name) is the unique name of the object. The URN includes the namespace name and identifier in that space. A typical example of a URN is an ISDN Book Name. A URN consists of an NID (namespace identifier or namespace identifier) ​​and an NSS (namespace-specific string or unique for a given namespace name). Schematically it looks like this:

To make it completely clear, I will give the following example. Suppose we want to describe a certain Ivan.
In this case, the URN will look like this:
Russian passport: Ivan Ivanov, passport series 1234 number 123456 . Where the “passport of the Russian Federation” is the name of the namespace identifier, and “Ivanov Ivan Ivanovich, passport series 1234 number 123456” is a unique name in this space.
With this URN, we uniquely identify Ivan, but we will not be able to determine his location. This is where the URL helps. It may look something like this:
car: city N / street M / apartment L. Where “machine” is the method of access, and “city N ...” is the way.
Summarize. The URN Response identifies the resource by name and answers the “What?” Question. URL - indicates the path and method of access to the resource and answers the questions "Where?" And "How?". At the same time, the URN and URL are special cases of the URI.