No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0174.xml 48KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Serverless Messaging</title>
  10. <abstract>This specification defines how to communicate over local or wide-area networks using the principles of zero-configuration networking for endpoint discovery and the syntax of XML streams and XMPP messaging for real-time communication. This method uses DNS-based Service Discovery and Multicast DNS to discover entities that support the protocol, including their IP addresses and preferred ports. Any two entities can then negotiate a serverless connection using XML streams in order to exchange XMPP message and IQ stanzas.</abstract>
  12. <number>0174</number>
  13. <status>Final</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. <spec>RFC 3927</spec>
  21. <spec>RFC 6762</spec>
  22. <spec>RFC 6763</spec>
  23. </dependencies>
  24. <supersedes/>
  25. <supersededby/>
  26. <shortname>linklocal</shortname>
  27. <registry/>
  28. &stpeter;
  29. <revision>
  30. <version>2.0.1</version>
  31. <date>2018-02-08</date>
  32. <initials>cs</initials>
  33. <remark><p>Fix incorrect STARTTLS examples.</p></remark>
  34. </revision>
  35. <revision>
  36. <version>2.0</version>
  37. <date>2008-11-26</date>
  38. <initials>psa</initials>
  39. <remark><p>Per a vote of the XMPP Council, advanced specification to Final; corrected TXT record format in conformance with draft-cheshire-dnsext-dns-sd; clarified a number of issues related to DNS-SD and Multicast DNS; as an optimization, recommended sending of disco#info data in stream features; removed reference to Encrypted Sessions specification from the security considerations.</p></remark>
  40. </revision>
  41. <revision>
  42. <version>1.2</version>
  43. <date>2008-09-03</date>
  44. <initials>psa</initials>
  45. <remark><p>Clarified handling of stream closes.</p></remark>
  46. </revision>
  47. <revision>
  48. <version>1.1</version>
  49. <date>2008-03-05</date>
  50. <initials>psa</initials>
  51. <remark><p>Clarified order of publishing and querying DNS records; corrected several DNS errors in the text and examples; added friendly How It Works section; added implementation note about port choice; updated TXT records to reflect version 1.5 of XEP-0115; updated registry; generalized text to handle usage of wide-area DNS-SD.</p></remark>
  52. </revision>
  53. <revision>
  54. <version>1.0</version>
  55. <date>2007-06-12</date>
  56. <initials>psa</initials>
  57. <remark><p>Per a vote of the XMPP Council, advanced status to Draft; XMPP Registrar assigned linklocal shortname and created appropriate registry.</p></remark>
  58. </revision>
  59. <revision>
  60. <version>0.16</version>
  61. <date>2007-05-30</date>
  62. <initials>psa</initials>
  63. <remark><p>Updated the definition of port.p2pj TXT record so that it is not hardcoded to 5298 but instead tracks the port advertised via SRV; updated the IANA considerations to reflect acceptance of the proposed registration change by the maintainers of the website.</p></remark>
  64. </revision>
  65. <revision>
  66. <version>0.15</version>
  67. <date>2007-05-14</date>
  68. <initials>psa</initials>
  69. <remark><p>Updated IANA Considerations to reflect proposed modifications to DNS-SD registration.</p></remark>
  70. </revision>
  71. <revision>
  72. <version>0.14</version>
  73. <date>2007-05-11</date>
  74. <initials>psa</initials>
  75. <remark><p>Specified that email and jid TXT values can contain a space-separated list of addresses; clarified roster display rules; clarified rules for handling presence name collisions; added security consideration about lack of validation for TXT record data.</p></remark>
  76. </revision>
  77. <revision>
  78. <version>0.13</version>
  79. <date>2007-03-28</date>
  80. <initials>psa</initials>
  81. <remark><p>Clarified handling of stream version.</p></remark>
  82. </revision>
  83. <revision>
  84. <version>0.12</version>
  85. <date>2007-03-26</date>
  86. <initials>psa</initials>
  87. <remark><p>Specified creation of registry for TXT records and hardcoded txtvers record value at 1.</p></remark>
  88. </revision>
  89. <revision>
  90. <version>0.11</version>
  91. <date>2007-03-14</date>
  92. <initials>psa</initials>
  93. <remark><p>Added section on capabilities discovery; added TXT records corresponding to the node, ver, and ext attributes from XEP-0115; changed textvers value to 2.</p></remark>
  94. </revision>
  95. <revision>
  96. <version>0.10</version>
  97. <date>2007-03-13</date>
  98. <initials>psa</initials>
  99. <remark><p>Added nick TXT key; added note about use of AAAA records with IPv6; specified that from and to addresses are recommended for stream headers; encouraged implementations to send XMPP stream features.</p></remark>
  100. </revision>
  101. <revision>
  102. <version>0.9</version>
  103. <date>2006-12-22</date>
  104. <initials>psa</initials>
  105. <remark><p>Updated the security considerations to recommend either TLS+SASL at the stream layer or encrypted sessions at the messaging layer.</p></remark>
  106. </revision>
  107. <revision>
  108. <version>0.8</version>
  109. <date>2006-07-31</date>
  110. <initials>psa</initials>
  111. <remark><p>Recommended use of TLS and SASL for stream security.</p></remark>
  112. </revision>
  113. <revision>
  114. <version>0.7</version>
  115. <date>2006-06-06</date>
  116. <initials>psa</initials>
  117. <remark><p>Further clarified internationalization considerations.</p></remark>
  118. </revision>
  119. <revision>
  120. <version>0.6</version>
  121. <date>2006-06-05</date>
  122. <initials>psa</initials>
  123. <remark><p>Clarified internationalization considerations and use of mDNS in unicast mode for avatar retrieval.</p></remark>
  124. </revision>
  125. <revision>
  126. <version>0.5</version>
  127. <date>2006-04-14</date>
  128. <initials>psa</initials>
  129. <remark><p>Specified presence name conflict resolution procedure, offline procedure, use of DNS NULL record for icons, and handling of multiple network interfaces.</p></remark>
  130. </revision>
  131. <revision>
  132. <version>0.4</version>
  133. <date>2006-03-16</date>
  134. <initials>psa</initials>
  135. <remark><p>Corrected PTR format and client discovery process.</p></remark>
  136. </revision>
  137. <revision>
  138. <version>0.3</version>
  139. <date>2006-02-23</date>
  140. <initials>psa</initials>
  141. <remark><p>Added more details about DNS setup and stream initiation; specified internationalization considerations.</p></remark>
  142. </revision>
  143. <revision>
  144. <version>0.2</version>
  145. <date>2006-02-22</date>
  146. <initials>psa</initials>
  147. <remark><p>Corrected information about Service Instance Name format, p2pj port, and presence discovery process.</p></remark>
  148. </revision>
  149. <revision>
  150. <version>0.1</version>
  151. <date>2006-02-09</date>
  152. <initials>psa</initials>
  153. <remark><p>Initial version; changed title to Link-Local Messaging.</p></remark>
  154. </revision>
  155. <revision>
  156. <version>0.0.1</version>
  157. <date>2006-02-07</date>
  158. <initials>psa</initials>
  159. <remark><p>First draft.</p></remark>
  160. </revision>
  161. </header>
  162. <section1 topic='Introduction' anchor='intro'>
  163. <section2 topic='Motivation' anchor='motivation'>
  164. <p>The Extensible Messaging and Presence Protocol (XMPP) as defined in &xmppcore; does not support direct client-to-client interactions, since it requires authentication with a server: an XMPP client is allowed access to the network only after it has authenticated with a server, and the server will not grant access if authentication fails for any reason. If an unauthenticated client attempts to communicate directly with another client, such communication will fail because all XMPP communications are sent through one or more servers and a client cannot inject messages onto the network unless it first authenticates with a server.</p>
  165. <p>However, it is possible to establish an XMPP-like communication system on a local (or even wide-area) network using the principles of zero-configuration networking. In this situation, the clients obviate the XMPP requirement for authentication with a server by relying on zero-configuration networking to establish serverless communication using the _presence._tcp DNS SRV service type. Once discovery has been completed, the clients are able to negotiate an XML stream between themselves and then exchange messages and other structured data using the XMPP &MESSAGE; and &IQ; stanzas.</p>
  166. <p>Serverless messaging is typically restricted to a local network (or ad-hoc wide-area network) because of how zero-configuration networking works. It is impossible for clients that communicate via this serverless mode to insert messages into an XMPP network, which is why this kind of "mesh" is most accurately referred to as an XMPP-like system that exists outside the context of existing XMPP networks (though see the <link url='#security'>Security Considerations</link> regarding the ability to "forward" messages from a serverless mesh to an XMPP network or vice-versa).</p>
  167. <p>Such a "mesh" can be quite valuable in certain circumstances. For instance, participants in a trade show or conference, users of the same wifi hotspot, or employees on the same local area network can communicate without the need for a pre-configured server. For this reason, support for serverless messaging has been a feature of Apple's iChat client when operating in Bonjour (formerly Rendezvous) mode since 2002. Because it is desirable for other Jabber/XMPP clients to support such functionality, this document describes how to use zero-configuration networking as the basis for serverless communication, mainly for use on local links (although the protocol can also be used on ad-hoc wide-area networks).</p>
  168. </section2>
  169. <section2 topic='How It Works' anchor='howitworks'>
  170. <p>This section provides a friendly introduction to serverless messaging. The examples show usage on a local link using dynamically configured link-local addresses as described in &rfc3927; (see the <link url='#impl-wide'>Wide-Area Networks</link> section of this document regarding non-local usage).</p>
  171. <p>Imagine that you are a Shakespearean character named Juliet. You are are using your laptop computer (a machine named "pronto") at a wifi hotspot in downtown Verona and you want to find other people to chat with on an ad-hoc basis (i.e., not people in your normal XMPP roster). Therefore your chat client advertises a serverless address of "juliet@pronto" so that other people can dynamically find you at the hotspot. Your client does this by invoking a daemon on your machine that supports DNS-based Service Discovery ("DNS-SD") as defined in &rfc6763; and Multicast DNS ("mDNS") as defined in &rfc6762;. As a result, the daemon (1) publishes the following DNS records to the multicast DNS address (or FF02::FB for IPv6) and (2) listens for multicast DNS queries requesting these records:</p>
  172. <code><![CDATA[
  173. pronto.local. A
  174. juliet@pronto._presence._tcp.local. SRV 5562 pronto.local.
  175. _presence._tcp.local. PTR juliet@pronto._presence._tcp.local.
  176. ]]></code>
  177. <p>The meaning of these records is as follows:</p>
  178. <ul>
  179. <li>The A record specifies the IP address at which the "pronto" machine will listen for connections.</li>
  180. <li>The SRV record (see &rfc2782;) maps the presence service instance "juliet@pronto" to the machine "pronto.local." on port 5562.</li>
  181. <li>The PTR ("pointer") record (see &rfc2317; and &rfc1886;) says that there is a service of type "presence" on the local subnet (".local.") called "juliet@pronto" and that the service communicates over TCP.</li>
  182. </ul>
  183. <p>Your chat client also wants to advertise some information about you (subject to your control so that you don't divulge private information). Therefore it invokes the mDNS daemon to also publish a single DNS TXT record (see &rfc1464;) that encapsulates some strings of information, where the record name is the same as the SRV record and the record value follows the format described in the <link url='#txt'>TXT Record</link> section of this document. The strings are typically key-value pairs such as the following:</p>
  184. <code><![CDATA[
  185. txtvers=1
  186. 1st=Juliet
  187. email=juliet@capulet.lit
  188. hash=sha-1
  189. jid=juliet@capulet.lit
  190. last=Capulet
  191. msg=Hanging out downtown
  192. nick=JuliC
  193. node=
  194. phsh=a3839614e1a382bcfebbcf20464f519e81770813
  195. port.p2pj=5562
  196. status=avail
  197. vc=CA!
  198. ver=QgayPKawpkPSDYmwT/WM94uAlu0=
  199. ]]></code>
  200. <p>Other people at the hotspot can also advertise similar DNS records for use on the local link. Essentially, the mDNS daemons running on all of the machines at the hotspot collectively manage the ".local." domain, which has meaning only at the hotspot (not across the broader Internet). Queries and responses for services on the local link occur via multicast DNS over UDP port 5353 instead of via normal DNS unicast over UDP port 53. When a new machine joins the local link, it can send out queries for any number of service types, to which the other machines will reply. For the purpose of serverless messaging we are interested only in the "presence" service, but many other services could exist on the local link (see <link url=''></link> for a complete list).</p>
  201. <p>Now let us imagine that a fine young gentleman named Romeo joins the hotspot and that his chat client (actually his mDNS daemon) sends out multicast DNS queries for services of type "presence". To do this, his client essentially reverses the order of DNS record publication (explained above) by asking for pointers to presence services (i.e., PTR records that match "_presence._tcp.local."), querying each service for its service instance and port (i.e., SRV record), mapping each service instance to an IP address (i.e., A record), and finding out additional information about the entity using the service (i.e., TXT record parameters). <note>As explained in the DNS-SD specification, these queries might all be returned in the same answer.</note> As a result, Romeo's client will discover any number of local presence services, among them a service named "juliet@pronto" (with some intriguing TXT record parameters) at IP address and port 5562. Being a romantic fellow, he then initiates a chat with you by opening an XML stream to the advertised IP address and port.</p>
  202. <code><![CDATA[
  203. <?xml version='1.0'?>
  204. <stream:stream
  205. xmlns='jabber:client'
  206. xmlns:stream=''
  207. from='romeo@forza'
  208. to='juliet@pronto'
  209. version='1.0'>
  210. ]]></code>
  211. <p>Your client then responds with a response stream header.</p>
  212. <code><![CDATA[
  213. <?xml version='1.0'?>
  214. <stream:stream
  215. xmlns='jabber:client'
  216. xmlns:stream=''
  217. from='juliet@pronto'
  218. to='romeo@forza'
  219. version='1.0'>
  220. ]]></code>
  221. <p>Romeo then sends you an XMPP message.</p>
  222. <code><![CDATA[
  223. <message from='romeo@forza' to='juliet@pronto'>
  224. <body>M'lady, I would be pleased to make your acquaintance.</body>
  225. </message>
  226. ]]></code>
  227. <p>And you reply.</p>
  228. <code><![CDATA[
  229. <message from='juliet@pronto' to='romeo@forza'>
  230. <body>Art thou not Romeo, and a Montague?</body>
  231. </message>
  232. ]]></code>
  233. <p>You chat with Romeo for a while, then your client closes the stream.</p>
  234. <code><![CDATA[
  235. </stream:stream>
  236. ]]></code>
  237. <p>And Romeo's client does the same.</p>
  238. <code><![CDATA[
  239. </stream:stream>
  240. ]]></code>
  241. <p>Finally you decide to head home, so your mDNS daemon sends a Multicast DNS "Goodbye" packet for your PTR record. As a result, everyone else at the hotspot receives a Multicast DNS "Remove" event, at which point they cancel any outstanding A, SRV, TXT, or NULL record queries related to your presence service.</p>
  242. </section2>
  243. </section1>
  244. <section1 topic='Glossary' anchor='glossary'>
  245. <table caption='Terminology'>
  246. <tr>
  247. <th>Term</th>
  248. <th>Description</th>
  249. </tr>
  250. <tr>
  251. <td>Bonjour</td>
  252. <td>Apple Computer's implementation of zero-configuration networking, formerly known as Rendezvous. See &lt;<link url=''></link>&gt;.</td>
  253. </tr>
  254. <tr>
  255. <td>DNS-SD</td>
  256. <td>A convention for naming and structuring DNS SRV records such that a client can dynamically discover a domain for a service using only standard DNS queries. See <cite>draft-cheshire-dnsext-dns-sd</cite>. For a full list of registered DNS-SD records, see &lt;<link url=''></link>&gt;.</td>
  257. </tr>
  258. <tr>
  259. <td>Multicast DNS (mDNS)</td>
  260. <td>A technology that provides the ability to perform DNS-like operations on a local link in the absence of any conventional unicast DNS server. See <cite>draft-cheshire-dnsext-multicastdns</cite>.</td>
  261. </tr>
  262. <tr>
  263. <td>Zero-configuration networking</td>
  264. <td>A set of technologies that enable the use of the Internet Protocol for local or wide-area communications. See &lt;<link url=''></link>&gt;.</td>
  265. </tr>
  266. </table>
  267. </section1>
  268. <section1 topic='DNS Records' anchor='dns'>
  269. <p>In order to advertise its availability for serverless messaging, a client MUST publish four different kinds of DNS records:</p>
  270. <ol>
  271. <li>
  272. <p>A PTR record of the following form:</p>
  273. <code><![CDATA[
  274. _presence._tcp.local. PTR user@machine._presence._tcp.local.
  275. ]]></code>
  276. </li>
  277. <li>
  278. <p>An address ("A" or "AAAA") record of the following form (where the IP address can be either an IPv4 address or an IPv6 address):</p>
  279. <code><![CDATA[
  280. machine.local. A ip-address
  281. ]]></code>
  282. </li>
  283. <li>
  284. <p>An SRV record of the following form:</p>
  285. <code><![CDATA[
  286. user@machine._presence._tcp.local <ttl> SRV <priority> <weight> port-number machine.local.
  287. ]]></code>
  288. </li>
  289. <li>
  290. <p>A TXT record whose name is the same as the SRV record and whose value follows the format described in the <link url='#txt'>TXT Record</link> section of this document, consisting of a set of strings that typically represent a series of key-value pairs such as the following:</p>
  291. <code><![CDATA[
  292. txtvers=1
  293. 1st=user-first-name
  294. email=user-email-address
  295. hash=entity-capabilities-algorithm
  296. jid=user-jabber-id
  297. last=user-last-name
  298. msg=freeform-availability-status
  299. n=entity-capabilities-application-name
  300. nick=user-nickname
  301. node=application-identifier
  302. n=entity-capabilities-operating-system
  303. phsh=sha1-hash-of-avatar
  304. port.p2pj=5562
  305. status=avail-away-or-dnd
  306. vc=capabilities-string
  307. ver=entity-capabilities-identity
  308. ]]></code>
  309. <p>Note: The DNS-SD specification stipulates that the TXT record MUST be published, but that it MAY contain no more than a single zero byte (e.g., if the user does not wish to publish any personal information).</p>
  310. </li>
  311. </ol>
  312. <p>The "machine" is the name of the computer, the "user" is the system username of the principal currently logged into the computer, the "port" can be any unassigned port number, and the "ip-address" is the physical address of the computer on the local network.</p>
  313. <p>So, for example, if the machine name is "pronto", the username is "juliet", the chosen port is "5562", the IP address is "", and the personal information is that plausibly associated with a certain Shakespearean character, the DNS records would be as follows:</p>
  314. <code><![CDATA[
  315. _presence._tcp.local. PTR juliet@pronto._presence._tcp.local.
  316. juliet@pronto._presence._tcp.local. SRV 5562 pronto.local.
  317. pronto.local. A
  318. juliet@pronto._presence._tcp.local. IN TXT
  319. "txtvers=1"
  320. "1st=Juliet"
  321. "email=juliet@capulet.lit "
  322. "hash=sha-1"
  323. "jid=juliet@capulet.lit"
  324. "last=Capulet"
  325. "msg=Hanging out downtown"
  326. "nick=JuliC"
  327. "node="
  328. "phsh=a3839614e1a382bcfebbcf20464f519e81770813"
  329. "port.p2pj=5562"
  330. "status=avail"
  331. "vc=CA!"
  332. "ver=QgayPKawpkPSDYmwT/WM94uAlu0=""
  333. ]]></code>
  334. <p>The IPv4 and IPv6 addresses associated with a machine might vary depending on the local network to which the machine is connected. For example, on an Ethernet connection the physical address might be "" but when the machine is connected to a wireless network the physical address might change to "". See <cite>RFC 3927</cite> for details.</p>
  335. <p>If the machine name asserted by a client is already taken by another machine on the network, the client MUST assert a different machine name, which SHOULD be formed by adding the character "-" and digit "1" to the end of the machine name string (e.g., "pronto-1"), adding the character "-" and digit "2" if the resulting machine name is already taken (e.g., "pronto-2"), and similarly incrementing the digit until a unique machine name is constructed.</p>
  336. <p>If the username asserted by a client is already taken by another application on the machine, the client MUST assert a different username, which SHOULD be formed by adding the character "-" and digit "1" to the end of the username string (e.g., "juliet-1"), adding the character "-" and digit "2" if the resulting username is already taken (e.g., "juliet-2"), and similarly incrementing the digit until a unique username is constructed.</p>
  337. <section2 topic='TXT Record' anchor='txt'>
  338. <p>DNS-SD enables service definitions to include a TXT record that specifies parameters to be used in the context of the relevant service type. The name of the TXT record is the same as that of the SRV record (i.e., "user@machine._presence._tcp.local."). The value of the TXT record is one or more strings, where each string is a parameter that usually takes the form of a key-value pair.</p>
  339. <p>In the context of serverless messaging, the following rules apply:</p>
  340. <ol>
  341. <li>The entire TXT record needs to comply with the suggested maximum TXT record size (see Section 6.3 of the DNS-SD specification).</li>
  342. <li>A given key MUST NOT occur more than once in a given TXT record value (see Section 6.4 of the DNS-SD specification).</li>
  343. <li>The first parameter in the TXT record value SHOULD be "txtvers" (see Section 6.7 of the DNS-SD specification).</li>
  344. </ol>
  345. <p>The &REGISTRAR; maintains a registry of the parameters that can be used in the TXT record value for the _presence._tcp service type, as specified in the <link url='#registrar'>XMPP Registrar Considerations</link> section of this document. Those parameters are not listed here. It is OPTIONAL to include any of these TXT record parameters, and an implementation MUST NOT fail (i.e., MUST enable serverless messaging) even if none of the parameters are provided by another entity. However, as mentioned the TXT record MUST be published (although its value MAY be a single zero byte).</p>
  346. <p>Most of the registered TXT record parameters relate to human users, in which context certain parameters are of greater interest than others, e.g. "msg", "nick", and "status"; however, serverless messaging can be used by non-human entities (e.g., devices).</p>
  347. <p>Note: See the <link url='#security'>Security Considerations</link> section of this document regarding the inclusion of information that can have an impact on personal privacy (e.g., the "1st", "last", "nick", "email", and "jid" parameters).</p>
  348. </section2>
  349. </section1>
  350. <section1 topic='Discovering Other Users' anchor='disco'>
  351. <p>In order to discover other users, a client sends an mDNS request for PTR records that match "_presence._tcp.local.". The client then receives replies from all machines that advertise support for serverless messaging. <note>The replies will include a record corresponding to the client itself; the client MUST filter out this result.</note> In accordance with Section 13 of the DNS-SD specification, these replies can include the SRV, A/AAAA, and TXT records in the Additional Section of the DNS message (subject to the size limits described in Section 19 of the Multicast DNS specification).</p>
  352. <p>The client MAY then find out detailed information about each machine by sending SRV and TXT queries <note>These questions MAY all be sent in one DNS query packet.</note> to "user@machine.local." for each machine; however, to preserve bandwidth, the client SHOULD NOT send these queries unless it is about to initiate communication with the other user, and it MUST cancel the queries after it has received a response).
  353. </p>
  354. </section1>
  355. <section1 topic='Exchanging Presence' anchor='presence'>
  356. <p>When the _presence._tcp service is used, presence is exchanged via the format described in the <link url='#txt'>TXT Record</link> section of this document. In particular, presence information is not pushed as in XMPP (see &rfc3921;). Instead, clients listen for presence announcements from other entities on the local link or wide-area network. Recommended rates for sending updates can be found in the Multicast DNS specification.</p>
  357. </section1>
  358. <section1 topic='Initiating an XML Stream' anchor='initiate'>
  359. <p>In order to exchange serverless messages, the initiator and recipient MUST first establish XML streams between themselves, as is familiar from <cite>RFC 6120</cite>.</p>
  360. <p>First, the initiator opens a TCP connection at the IP address and port discovered via the DNS lookup for an entity and opens an XML stream to the recipient, which SHOULD include 'to' and 'from' address:</p>
  361. <example caption="Initiator Opens a Stream"><![CDATA[
  362. I: <?xml version='1.0'?>
  363. <stream:stream
  364. xmlns='jabber:client'
  365. xmlns:stream=''
  366. from='romeo@forza'
  367. to='juliet@pronto'
  368. version='1.0'>
  369. ]]></example>
  370. <p>Note: If the initiator supports stream features and the other stream-related aspects of XMPP 1.0 as specified in <cite>RFC 6120</cite>, then it SHOULD include the version='1.0' flag as shown in the previous example.</p>
  371. <p>The recipient then responds with a stream header as well:</p>
  372. <example caption="Recipient Sends Stream Header Response"><![CDATA[
  373. R: <?xml version='1.0'?>
  374. <stream:stream
  375. xmlns='jabber:client'
  376. xmlns:stream=''
  377. from='juliet@pronto'
  378. to='romeo@forza'
  379. version='1.0'>
  380. ]]></example>
  381. <p>If both the initiator and recipient included the version='1.0' flag, the recipient SHOULD also send stream features as specified in <cite>RFC 6120</cite>:</p>
  382. <example caption="Recipient Sends Stream Features"><![CDATA[
  383. R: <stream:features>
  384. <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
  385. <required/>
  386. </starttls>
  387. </stream:features>
  388. ]]></example>
  389. <p>The exchange of stream headers results in an unencrypted and unauthenticated channel between the two entities. See the <link url='#security'>Security Considerations</link> section of this document regarding methods for authenticating and encrypting the stream.</p>
  390. </section1>
  391. <section1 topic='Exchanging Stanzas' anchor='exchange'>
  392. <p>Once the streams are established, either entity then can send XMPP message or IQ stanzas by specifying 'to' and 'from' addresses using the logical addresses: <note>The to and from addresses MUST be of the form "user@machine" as discovered via SRV (this is the &lt;Instance&gt; portion of the Service Instance Name).</note></p>
  393. <example caption="Sending a Message"><![CDATA[
  394. <message from='romeo@forza' to='juliet@pronto'>
  395. <body>M'lady, I would be pleased to make your acquaintance.</body>
  396. </message>
  397. ]]></example>
  398. <example caption="A Reply"><![CDATA[
  399. <message from='juliet@pronto' to='romeo@forza'>
  400. <body>Art thou not Romeo, and a Montague?</body>
  401. </message>
  402. ]]></example>
  403. </section1>
  404. <section1 topic='Ending an XML Stream' anchor='end'>
  405. <p>To end the chat, either party closes the XML stream:</p>
  406. <example caption="Ending the Chat"><![CDATA[
  407. R: </stream:stream>
  408. ]]></example>
  409. <p>The other party MUST then also close the stream in the other direction:</p>
  410. <example caption="Closing the Stream"><![CDATA[
  411. I: </stream:stream>
  412. ]]></example>
  413. <p>The closing party (i.e., the party that sent the first closing stream tag) then MUST close the TCP connection between them.</p>
  414. <p>Note: The closing party might receive additional stanzas from the other party after sending its closing stream tag and before receiving a closing stream tag from the other party (e.g., because of network latency or because the other party has messages queued up for delivery when it receives the closing party's closing stream tag). Therefore, the closing party needs to be prepared to handle such messages, which it SHOULD do by presenting them to the controlling user (if any).</p>
  415. </section1>
  416. <section1 topic='Going Offline' anchor='offline'>
  417. <p>In order to go offline, a link-local entity MUST send a Multicast DNS "Goodbye" packet for the user's PTR record as described in Section 11.2 of the Multicast DNS specification. As a result, all other entities on the local network will receive a Multicast DNS "Remove" event, at which point they MUST cancel any outstanding TXT, SRV, or NULL record queries for the offline user.</p>
  418. </section1>
  419. <section1 topic='Discovering Capabilities' anchor='caps'>
  420. <p>Because serverless communication does not involve the exchange of XMPP presence, it is not possible to use &xep0115; for capabilities discovery. Therefore, it is RECOMMENDED to instead include the node, hash, and ver TXT record parameters (and OPTIONAL to include the ext parameter). The values of these parameters MUST be the same as the values for the 'node', 'hash', 'ver', and 'ext' attributes that are advertised for the application in normal XMPP presence (if any) via the Entity Capabilities protocol as described in <cite>XEP-0115</cite>.</p>
  421. <p>As with Entity Capabilities over native XMPP networks, a client might not know the &xep0030; features associated with the 'ver' value advertised by another entity. However, in the case of serverless messaging there is no way for the client to discover the entity's supported features without initiating an XML stream to that entity and then sending a Service Discovery information ("disco#info") request over the negotiated stream.</p>
  422. <p>Unfortunately, full stream negotiation (including TLS and SASL if appropriate) can require a large number of packets. Therefore, as an optimization, it is RECOMMENDED for the receiving entity in a serverless XML stream negotiation to include its disco#info data (including node) as a stream feature, as shown in the following examples.</p>
  423. <example caption="Initiator Opens a Stream"><![CDATA[
  424. I: <?xml version='1.0'?>
  425. <stream:stream
  426. xmlns='jabber:client'
  427. xmlns:stream=''
  428. from='romeo@forza'
  429. to='juliet@pronto'
  430. version='1.0'>
  431. ]]></example>
  432. <example caption="Recipient Sends Stream Header Response"><![CDATA[
  433. R: <?xml version='1.0'?>
  434. <stream:stream
  435. xmlns='jabber:client'
  436. xmlns:stream=''
  437. from='juliet@pronto'
  438. to='romeo@forza'
  439. version='1.0'>
  440. ]]></example>
  441. <example caption="Recipient Sends Stream Features"><![CDATA[
  442. R: <stream:features>
  443. <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
  444. <required/>
  445. </starttls>
  446. <query xmlns=''
  447. node=''>
  448. <identity category='client' name='Exodus 0.9.1' type='pc'/>
  449. <feature var=''/>
  450. <feature var=''/>
  451. <feature var=''/>
  452. <feature var=''/>
  453. </query>
  454. </stream:features>
  455. ]]></example>
  456. <p>If the initiating entity was connecting to the receiving entity only to perform a Service Discovery query, it SHOULD then end the stream:</p>
  457. <example caption="Initiating Entity Terminates XML Stream"><![CDATA[
  458. I: </stream:stream>
  459. ]]></example>
  460. <example caption="Receiving Entity Mirrors Stream Termination"><![CDATA[
  461. R: </stream:stream>
  462. ]]></example>
  463. </section1>
  464. <section1 topic='Implementation Notes' anchor='impl'>
  465. <section2 topic='Multiple Network Interfaces' anchor='impl-network'>
  466. <p>Devices that use serverless messaging can have multiple network interfaces. As a result, it is possible to discover the same entity multiple times. Even if a client discovers the same presence name on multiple network interfaces, it MUST show only one entity in the serverless roster. In addition, because local IP addresses can be dynamically re-assigned, the client SHOULD NOT store the IP address to be used for communication when it discovers that address in the initial DNS lookup phase; instead, it SHOULD delay sending the Multicast DNS query until the client is ready to communicate with the other entity.</p>
  467. </section2>
  468. <section2 topic='Buddy Icons' anchor='impl-icons'>
  469. <p>If an entity has an associated icon (e.g., a user avatar or photo), its client SHOULD publish the raw binary data for that image via a DNS NULL record of the following form:</p>
  470. <code><![CDATA[
  471. _presence._tcp.local. IN NULL raw-binary-data-here
  472. ]]></code>
  473. <p>Note: In accordance with &rfc1035;, the data MUST be 65535 octets or less.</p>
  474. <p>After retrieving the "phsh" value from a Buddy's TXT record, a client SHOULD search its local picture database to learn the last recorded picture hash value for an entity and then compare it to the "phsh" value in the TXT record. If the values are equal, the client SHOULD use the local copy of the icon. If the picture hash values are not equal, the client SHOULD issue a Multicast DNS NULL record query to retrieve the new icon. After retrieving the NULL record, the client SHOULD replace the old "phsh" value in the picture database with the new "phsh" value and save the icon to disk. If the client needs to send a Multicast DNS query in order to retrieve the icon, it MUST cancel the NULL record query immediately after receiving a response containing the new picture data.</p>
  475. <p>If a user changes their picture, the user's client MUST update the NULL record with the contents of the new picture, calculate a new picture hash, and then update the "phsh" value in the TXT record with the new hash value. Since all users "logged into" serverless presence are monitoring for TXT record changes, they will see that the "phsh" value was changed; if they wish to view the new icon, their clients SHOULD issue a new Multicast DNS query to retrieve the updated picture.</p>
  476. </section2>
  477. <section2 topic='Port' anchor='impl-port'>
  478. <p>The port used for serverless messaging MAY be any unassigned port number, as determined by the messaging application on the device. The chosen port MUST be specified in the SRV record and applications MUST use the port specified in the SRV record. However, the chosen port SHOULD also be specifed in the "port.p2pj" TXT record for backwards-compatibility with older implementations, and if included the port specified in the TXT record MUST be the same as the port specified in the SRV record.</p>
  479. </section2>
  480. <section2 topic='Wide-Area Networks' anchor='impl-wide'>
  481. <p>Serverless messaging via the _presence._tcp DNS SRV service type is not limited to local networks, since it is possible to advertise this service type via Wide-Area DNS-SD as described at &lt;<link url=''></link>&gt;. Although the protocol is most commonly used on local networks, there is nothing intrinsic to the protocol that limits its use to peers on the same link, and it also works between any two peers that can discover each other via any profile of DNS-SD (whether local or wide-area). Naturally, the DNS records used in Wide-Area DNS-SD will not contain the ".local." domain, since the records are not intended for use over a local link.</p>
  482. </section2>
  483. <section2 topic='User Interface' anchor='impl-ui'>
  484. <p>The presence name to be used for display in a serverless "roster" SHOULD be obtained from the &lt;Instance&gt; portion of the received PTR record for each user; however, the client MAY instead display a name or nickname derived from the TXT record if available.</p>
  485. <p>A client MAY require user approval before allowing a human user to chat with other users over serverless messaging.</p>
  486. </section2>
  487. </section1>
  488. <section1 topic='Internationalization Considerations' anchor='i18n'>
  489. <p><cite>RFC 1035</cite> does not allow characters outside the &ascii; character range in DNS A records. Therefore the "machine" portion of an A record as used for serverless messaging MUST NOT contain characters outside the US-ASCII character range.</p>
  490. <p>Although <cite>RFC 2317</cite> and <cite>RFC 2782</cite> do not allow characters outside the US-ASCII character range in PTR and SRV records respectively, Section 4.1 of <cite>DNS-Based Service Discovery</cite> recommends support for UTF-8-encoded Unicode characters in the &lt;Instance&gt; portion of Service Instance Names, which in serverless messaging is the "user@machine" portion of the PTR or SRV record. This document adheres to the recommendation in <cite>DNS-Based Service Discovery</cite>. However, as mentioned above, the "machine" portion of the &lt;Instance&gt; portion MUST NOT contain characters outside the US-ASCII range.</p>
  491. <p>Although <cite>RFC 1464</cite> does not allow characters outside the US-ASCII character range in TXT records, Section 6.5 of <cite>DNS-Based Service Discovery</cite> mentions support for UTF-8-encoded Unicode characters in text record values (e.g., values of the TXT "msg" name). This document adheres to the recommendation in <cite>DNS-Based Service Discovery</cite>.</p>
  492. </section1>
  493. <section1 topic='Security Considerations' anchor='security'>
  494. <section2 topic='Authentication and Encryption' anchor='security-auth'>
  495. <p>XMPP networks use TLS (&rfc5246;) for channel encryption, SASL (&rfc4422;) for authentication, and the Domain Name System (&rfc1034;) for weak validation of server hostnames; these technologies help to ensure the identity of sending entities and to encrypt XML streams. By contrast, zero-configuration networking uses dynamic discovery and asserted machine names as the basis of sender identity. Therefore, serverless messaging does not result in authenticated identities in the same way that XMPP itself does, nor does it provide for an encrypted channel between entities.</p>
  496. <p>To secure communications between serverless entities, it is RECOMMENDED to negotiate the use of TLS and SASL for the XML stream as described in <cite>RFC 6120</cite>. However, subject to client configuration and local service policies, an entity MAY accept an unauthenticated and unencrypted channel, in which case the client SHOULD warn the human user that the channel is unauthenticated and unencrypted.</p>
  497. </section2>
  498. <section2 topic='Stanza Injection' anchor='security-inject'>
  499. <p>Because of fundamental differences between a true XMPP network and a serverless client "mesh", entities communicating via serverless messaging MUST NOT attempt to inject serverless traffic onto an XMPP network and an XMPP server MUST reject communications until an entity is properly authenticated in accordance with the rules defined in <cite>RFC 6120</cite>. However, a client on a serverless mesh MAY forward traffic to an XMPP network after having properly authenticated on such a network (e.g., to forward a message received on a serverless client mesh to a contact on an XMPP network).</p>
  500. </section2>
  501. <section2 topic='TXT Record Parameters' anchor='security-txt'>
  502. <p>Because there is no mechanism for validating the information that is published in DNS TXT records, it is possible for clients to "poison" this information (e.g., by publishing email addresses or Jabber IDs that are controlled by or associated with other users).</p>
  503. </section2>
  504. <section2 topic='Private Information' anchor='security-priv'>
  505. <p>The TXT record parameters optionally advertised as part of this protocol MAY result in exposure of privacy-sensitive information about a human user (such as full name, email address, and Jabber ID). A client MUST allow a user to disable publication of this personal information (e.g., via client configuration).</p>
  506. </section2>
  507. </section1>
  508. <section1 topic='IANA Considerations' anchor='iana'>
  509. <p>DNS-SD service type names are not yet managed by &IANA;. Section 19 of <cite>DNS-Based Service Discovery</cite> proposes an IANA allocation policy for unique application protocol or service type names. Until the proposal is adopted and in force, Section 19 points to &lt;<link url=''></link>&gt; regarding registration of service type names for DNS-SD.</p>
  510. <p>Before this specification was written, there was an existing registration for the "presence" service type, with registration information as follows:</p>
  511. <div class='indent'>
  512. <ol>
  513. <li>Short name: presence</li>
  514. <li>Long name: iChat AV</li>
  515. <li>Responsible person: Jens Alfke &lt;jens at;</li>
  516. <li>Defined TXT keys: txtvers, port.p2pj, phsh, vc, 1st, AIM, msg, status, last</li>
  517. </ol>
  518. </div>
  519. <p>On 2007-05-14, the XMPP Registrar submitted the following proposed modification to the existing registration, which was accepted on 2007-05-30:</p>
  520. <div class='indent'>
  521. <ol>
  522. <li>Short name: presence</li>
  523. <li>Long name: Link-Local Messaging</li>
  524. <li>Responsible person: XMPP Registrar &lt;registrar at;</li>
  525. <li>Protocol URL:</li>
  526. <li>Primary transport protocol: _tcp</li>
  527. <li>TXT record URL:</li>
  528. </ol>
  529. </div>
  530. </section1>
  531. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  532. <section2 topic='Link-Local Messaging TXT Record Parameters Registry' anchor='registrar-linklocal'>
  533. <p>The &REGISTRAR; maintains a registry of parameter strings contained in the TXT record advertised for serverless messaging (see &LINKLOCAL;).</p>
  534. <section3 topic='Registration Process' anchor='registrar-linklocal-process'>
  536. <code><![CDATA[
  537. <param>
  538. <name>The name of the parameter as used a key-value pair.</name>
  539. <desc>A natural-language description of the parameter.</desc>
  540. <status>
  541. The requirements status of the record. Should be one of:
  542. - required
  543. - recommended
  544. - optional
  545. - deprecated
  546. - obsolete
  547. </status>
  548. </param>
  549. ]]></code>
  550. <p>The registrant can register more than one parameter at a time, each contained in a separate &lt;record/&gt; element.</p>
  551. </section3>
  552. <section3 topic='Initial Registration' anchor='registrar-linklocal-reg'>
  553. <p>The following submission registers parameters in use as of June 2007. Refer to the registry itself for a complete and current list of parameters (this specification might or might not be revised when new parameters are registered).</p>
  554. <code><![CDATA[
  555. <param>
  556. <name>1st</name>
  557. <desc>The given or first name of the user.</desc>
  558. <status>optional</status>
  559. </param>
  560. <param>
  561. <name>email</name>
  562. <desc>
  563. The email address of the user; can contain a space-separated list
  564. of more than one email address.
  565. </desc>
  566. <status>optional</status>
  567. </param>
  568. <param>
  569. <name>ext</name>
  570. <desc>
  571. A space-separated list of extensions; the value of this record MUST
  572. be the same as that provided via normal XMPP presence (if applicable)
  573. in the 'ext' attribute specified in Entity Capabilities (XEP-0115).
  574. </desc>
  575. <status>optional</status>
  576. </param>
  577. <param>
  578. <name>hash</name>
  579. <desc>
  580. The hashing algorithm used to generated the 'ver' attribute in
  581. Entity Capabilities (XEP-0115) and therefore the ver parameter
  582. in Link-Local Messaging.
  583. </desc>
  584. <status>recommended</status>
  585. </param>
  586. <param>
  587. <name>jid</name>
  588. <desc>
  589. The Jabber ID of the user; can contain a space-separated list of
  590. more than one JID.
  591. </desc>
  592. <status>recommended</status>
  593. </param>
  594. <param>
  595. <name>last</name>
  596. <desc>The family or last name of the user.</desc>
  597. <status>optional</status>
  598. </param>
  599. <param>
  600. <name>msg</name>
  601. <desc>
  602. Natural-language text describing the user's state. This is
  603. equivalent to the XMPP &lt;status/&gt;; element.
  604. </desc>
  605. <status>optional</status>
  606. </param>
  607. <param>
  608. <name>nick</name>
  609. <desc>A friendly or informal name for the user.</desc>
  610. <status>recommended</status>
  611. </param>
  612. <param>
  613. <name>node</name>
  614. <desc>
  615. A unique identifier for the application; the value of this record MUST
  616. be the same as that provided via normal XMPP presence (if applicable)
  617. in the 'node' attribute specified in Entity Capabilities (XEP-0115).
  618. </desc>
  619. <status>recommended</status>
  620. </param>
  621. <param>
  622. <name>phsh</name>
  623. <desc>
  624. The SHA-1 hash of the user's avatar icon or photo. This SHOULD be
  625. requested using mDNS in unicast mode by sending a DNS query to the
  626. mDNS multicast address ( or its IPv6 equivalent FF02::FB).
  627. The client SHOULD keep a local cache of icons keyed by hash. If the
  628. phsh value is not in the cache, the client SHOULD fetch the unknown
  629. icon and then cache it. Implementations SHOULD also include logic for
  630. expiring avatar icons.
  631. </desc>
  632. <status>optional</status>
  633. </param>
  634. <param>
  635. <name>port.p2pj</name>
  636. <desc>
  637. The port for serverless communication. This MUST be the same as the
  638. value provided for SRV lookups. Clients MUST use the port discovered
  639. via SRV lookups and MUST ignore the value of this parameter. However,
  640. clients SHOULD advertise this parameter if it is important to ensure
  641. backwards-compatibility with some existing implementations. (Note: In
  642. some existing implementations this value was hardcoded to "5298".)
  643. </desc>
  644. <status>deprecated</status>
  645. </param>
  646. <param>
  647. <name>status</name>
  648. <desc>
  649. The presence availability of the user. Allowable values are "avail",
  650. "away", and "dnd", which map to mere XMPP presence (the user is
  651. available) and the XMPP &lt;show/&gt; values of "away" and "dnd",
  652. respectively; if the status record is not included, the status SHOULD
  653. be assumed to be "avail".
  654. </desc>
  655. <status>recommended</status>
  656. </param>
  657. <param>
  658. <name>txtvers</name>
  659. <desc>
  660. The version of the TXT record supported by the client. For backwards
  661. compatibility this is hardcoded at "1". This parameter SHOULD be the
  662. first one provided, in accordance with the DNS-SD specification.
  663. </desc>
  664. <status>deprecated</status>
  665. </param>
  666. <param>
  667. <name>vc</name>
  668. <desc>
  669. A flag advertising the user's ability to engage in audio or video
  670. conferencing. If the user is able to engage in audio conferencing,
  671. the string MUST include the "A" character. If the user is able to
  672. engage in video conferencing, the string MUST include the "V"
  673. character. If the user is able to engage in conferencing with more
  674. than one participant, the string MUST include the "C" character. If
  675. the user is not currently engaged in an audio or video conference,
  676. the string MUST include the "!" character. The order of characters
  677. in the string is immaterial. NOTE: This flag is included only for
  678. backwards-compatibility; implementations SHOULD use the node, ver,
  679. and ext parameters for more robust capabilities discovery as described
  680. in the Discovering Capabilities section of XEP-0174.
  681. </desc>
  682. <status>optional</status>
  683. </param>
  684. <param>
  685. <name>ver</name>
  686. <desc>
  687. A hashed string that defines the XMPP service discovery (XEP-0030)
  688. identity of the application and the XMPP service discovery features
  689. supported by the application; the value of this record MUST be the
  690. same as that provided via normal XMPP presence (if applicable) in
  691. the 'ver' attribute specified in Entity Capabilities (XEP-0115).
  692. </desc>
  693. <status>recommended</status>
  694. </param>
  695. ]]></code>
  696. </section3>
  697. </section2>
  698. </section1>
  699. <section1 topic='Acknowledgements' anchor='ack'>
  700. <p>Thanks to Emanuele Aina, Jens Alfke, Marco Barisione, Stuart Cheshire, Justin Karneges, Marc Krochmal, Eric St. Onge, and Sjoerd Simons for their input. Some of the explanatory concepts were loosely borrowed from &sipbonjour;.</p>
  701. </section1>
  702. </xep>