XEP-xxxx: DMUC3: Distributed MUC

Abstract
This document provides a protocol for reducing the bandwidth cost of local users contributing to a remote MUC over a constrained link through a local mirror of the MUC room.
Author
Wayne Franklin
Copyright
© 2011 – 2011 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

ProtoXEP

WARNING: This document has not yet been accepted for consideration or approved in any official manner by the XMPP Standards Foundation, and this document is not yet an XMPP Extension Protocol (XEP). If this document is accepted as a XEP by the XMPP Council, it will be published at <https://xmpp.org/extensions/> and announced on the <standards@xmpp.org> mailing list.
Type
Standards Track
Version
0.0.1 (2011-01-25)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

1.1 Motiviation

The primary motivation for Distributed Multi-User Chat (DMUC) is to minimize the server-to-server (S2S) traffic that is required for Multi-User Chat (MUC). In constrained environments, the traffic on the S2S link can cause severe degradation of service. Much of the S2S message traffic can be eliminated if each local server keeps a mirror of the chat room and responds to its local users on behalf of the actual MUC room.

1.2 Requirements

MUC uses lots of bandwidth. Sometimes the network link that S2S traffic is carried on is heavily constrained. This protocol reduces the amount of traffic going across S2S through local mirrors of remote MUC rooms. It needs no bandwidth for remote rooms without local occupants.

1.3 Requirements

The following is a list of goals for the design of this extension:

2. Terminology

2.1 General Terms

master
The the actual MUC server
mirror
A mirror for a master MUC room on another machine

2.2 Actors

The following JIDs are used in this document.

fairfax.tridsys.com
XMPP server where the master MUC room is located
conference.fairfax.tridsys.com
MUC service on fairfax.tridsys.com.
chatroom@conference.fairfax.tridsys.com
MUC room.
kevin@fairfax.tridsys.com
User on fairfax.tridsys.com
scott@fairfax.tridsys.com
Another user on fairfax.tridsys.com
raleigh.tridsys.com
A remote service, connected to fairfax.tridsys.com over constrained link
mirror.raleigh.tridsys.com
DMUC service on raleigh.tridsys.com
wayne@raleigh.tridsys.com
User on raleigh.tridsys.com
keith@raleigh.tridsys.com
Another user on raleigh.tridsys.com

3. Use Cases

3.1 Discovering Server Support

Support for Distributed MUC in a given server instance SHOULD be determined using Service Discovery (XEP-0030) [2]. A conforming server MUST respond to disco#info requests.

3.1.1 Disco to determine support

To determine if a server or service supports Distributed MUC, the requesting entity SHOULD send a disco#info request to it.

Example 1. Disco request for distributed MUC support
<iq type='get'
    from='raleigh.tridsys.com'
    to='conference.fairfax.tridsys.com'
    id='info1'>
    <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>

If the server supports Distributed MUC, it MUST include a feature in the response.

Example 2. Disco response for server supporting distributed MUC
<iq type='result'
    from='conference.fairfax.tridsys.com'
    to='raleigh.tridsys.com'
    id='info1'>
    <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
        <feature var='http://tridsys.com/protocol/dmuc'/>
    ...
    </query>
</iq>

3.2 Joining

3.2.1 Success case

User wayne@raleigh.tridsys.com/TransVerse wants to join MUC room chatroom@conference.fairfax.tridsys.com. At this point mirror.raleigh.tridsys.com knows nothing of the chatroom@conference.fairfax.tridsys.com MUC, and no existing mirror is in place beyond mirror.raleigh.tridsys.com being willing to mirror for wayne@raleigh.tridsys.com/TransVerse.

Example 3. User joins MUC through a mirror
<presence
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>

raleigh.tridsys.com determines that this message is bound for a MUC service supporting DMUC and sends it to the real MUC with an additional tag.

Example 4. Mirror service joins the target MUC
<presence
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'>
  <dmuc xmlns='http://tridsys.com/protocol/dmuc'
    from='mirror.raleigh.tridsys.com'/>
</presence>

chatroom@conference.fairfax.tridsys.com recognises that the mirror service is now mirrorring it, and performs the usual ACL checks as if wayne@tridsys.com/TransVerse had joined directly, sending presence to all occupants. The master MUC will be able to take advantage of the fact that the rosters are being maintained by the distributed MUC services and send one presence with no <addresses/> (see Extended Stanza Addressing (XEP-0033) [1]) block to the mirrors. The mirrors can then forward the <presence/> to each of their locally attached users that are in the room.

If this mirror is unknown to the master, the room configuration MUST be sent to the new mirror. The room configuration will contain information like if the room is moderated, how much history, who is allowed in the room, etc.

Example 5. MUC sends room configuration to DMUC
<iq from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='mirror.raleigh.tridsys.com'
    id='iq1'
    type='set'>
  <config xmlns='urn:xmpp:dmuc:0'>
    <x xmlns='jabber:x:data' type='form'>
      <field type='hidden' var='FORM_TYPE'>
	<value>http://jabber.org/protocol/muc#roomconfig</value>
      </field>
      ...
    </x>
  </config>
</iq>

Upon receiving the room configuration, the mirror MUST respond.

Example 6. DMUC responds to room configuration
<iq from='mirror.raleigh.tridsys.com'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    id='iq1'
    type='result'/>

The master room MUST now send the roster to the mirror.

Example 7. MUC sends roster to DMUC
<iq from='chatroom@conference.fairfax.tridsys.com'
    to='mirror.raleigh.tridsys.com'
    id='roster1'
    type='set'>
  <roster xmlns='urn:xmpp:dmuc:0'>
    <item affiliation='owner'
	jid='scott@fairfax.tridsys.com' name='Scott'/>
    <item affiliation='admin'
	jid='kevin@fairfax.tridsys.com' name='Kevin'/>
    <item affiliation='none'
	jid='wayne@raleigh.tridsys.com' name='Wayne'/>
    <item affiliation='none'
	jid='keith@raleigh.tridsys.com' name='Keith'/>
  </roster>
</iq>

The mirror MUST send a response to the roster.

Example 8. DMUC sends response to roster
<iq from='mirror.raleigh.tridsys.com'
    to='chatroom@conference.fairfax.tridsys.com'
    type='result'/>

The new mirror SHOULD request room history. See Multi-User Chat (XEP-0045) [3] for details.

Example 9. DMUC sends history request to MUC
<iq from='mirror.raleigh.tridsys.com'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    id='history'
    type='get'>
  <room xmlns='urn:xmpp:dmuc:0'
	id='chatroom@conference.fairfax.tridsys.com'>
    <history xmlns='http://jabber.org/protocol/muc'/>
  </room>
</iq>

The history request MAY include any attributes specified in Multi-User Chat (XEP-0045) [3], such as 'maxchars', 'maxstanzas', 'seconds', and 'since'.

Example 10. MUC sends history to DMUC
<iq from='chatroom@conference.fairfax.tridsys.com'
    to='mirror.raleigh.tridsys.com'
    id='history1'
    type='result'>
  <history xmlns='http://jabber.org/protocol/muc'>
    <message xmlns='jabber:client'
	from='chatroom@conference.fairfax.tridsys.com/Wayne' type='groupchat'>
      <body>All work and no play makes Jack a dull boy</body>
      <delay xmlns='urn:xmpp:delay'
	from='wayne@raleigh.tridsys.com/TransVerse'
	stamp='2011-01-19T08:02:43Z'/>
    </message>
    ...
    </message>
    <message xmlns='jabber:client'
	from='chatroom@conference.fairfax.tridsys.com/Scott' type='groupchat'>
      <body>All work and no play makes Jack a dull boy</body>
      <delay xmlns='urn:xmpp:delay'
	from='scott@fairfax.tridsys.com/TransVerse'
	stamp='2011-01-19T08:23:10Z'/>
      <body>All work and no play makes Jack a dull boy</body>
    </message>
  </history>
</iq>
Example 11. MUC confirms room join
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='mirror.raleigh.tridsys.com'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='participant'/>
  </x>
</presence>
Example 12. MUC informs local users
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='scott@fairfax.tridsys.com/TransVerse'
   <x xmlns='http://jabber.org/protocol/muc#user'>
     <item affiliation='none' role='participant'/>
   </x>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='kevin@fairfax.tridsys.com/TransVerse'
   <x xmlns='http://jabber.org/protocol/muc#user'>
     <item affiliation='none' role='participant'/>
   </x>
</presence>

The mirror service on raleigh.tridsys.com then relays the message to all of the room members that are in the raleigh.tridsys.com domain.

Example 13. Mirror delivers the join to local users
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='wayne@raleigh.tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='participant'/>
  </x>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='keith@raleigh.tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='participant'/>
  </x>
</presence>

3.2.2 Failure case

If the master doesn't allow the user to join, it sends the standard MUC error to the mirror. The mirror SHOULD only send the rejection to the user that failed to join. Other users don't need to know.

If a message is targeted to a specific user, JID Escaping (XEP-0106) [4] will be used to pass along the user's JID. The mirror service can then truncate the string just before the @ and convert the \40 to an @ and the \2f to a / to get the target user's JID and then forward the packet to that user.

Example 14. Master rejects joins
<presence
    from='chatroom@conference.fairfax.tridsys.com'
    to='wayne\40raleigh.tridsys.com\2fTransVerse@mirror.raleigh.tridsys.com'
    type='error'>
  <x xmlns='http://jabber.org/protocol/muc'/>
  <error type='auth'>
    <registration-required
	xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</presence>

The mirror then extracts the user's JID and delivers the bad news to the user.

Example 15. Mirror delivers the join failure to the user
<presence
    from='chatroom@conference.fairfax.tridsys.com'
    to='wayne@raleigh.tridsys.com/TransVerse'
    type='error'>
  <x xmlns='http://jabber.org/protocol/muc'/>
  <error type='auth'>
    <registration-required
	xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</presence>

3.2.3 Joining the MUC directly

Now when a user joins the master directly it will do usual presence distribution to occupants (remembering the mirror is an occupant). Status codes are omitted from this example, see Multi-User Chat (XEP-0045) [3] for those.

Example 16. User joins the master MUC directly
<presence
    from='kevin@tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Kevin'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>
Example 17. MUC delivers the join to its occupants
<presence
    from='chatroom@conference.fairfax.tridsys.com/Kevin'
    to='kevin@tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Kevin'
    to='scott@tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>
Example 18. MUC delivers the join to the DMUC
<presence
    from='chatroom@conference.fairfax.tridsys.com/Kevin'
    to='mirror.raleigh.tridsys.com'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='admin' role='moderator'/>
  </x>
</presence>
Example 19. Mirror delivers join to its occupants
<presence
    from='chatroom@conference.fairfax.tridsys.com/Kevin'
    to='wayne@raleigh.tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Kevin'
    to='keith@raleigh.tridsys.com/TransVerse'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>

3.3 Leaving

3.3.1 Mirror-connected Users

The flow for a user leaving the mirror room is much the same as joining the mirror room:

Example 20. User leaves the mirror room
<presence
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    type='unavailable'/>
Example 21. Mirror sends unavailable presence to local users
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='wayne@raleigh.tridsys.com/TransVerse''
    type='unavailable'>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='keith@raleigh.tridsys.com/TransVerse''
    type='unavailable'>
</presence>
Example 22. Mirror sends unavailable presence to MUC
<presence
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    type='unavailable'/>

The master needs to send the presence to locally attached users and mirrors that did not send this message.

Example 23. MUC sends unavailable presence to occupants
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='kevin@tridsys.com/TransVerse'
    type='unavailable'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='none'/>
  </x>
</presence>
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='scott@tridsys.com/TransVerse'
    type='unavailable'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='none'/>
  </x>
</presence>
Example 24. MUC sends unavailable presence to DMUC
<presence
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='mirror.raleigh.tridsys.com'
    type='unavailable'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='none' role='none'/>
  </x>
</presence>

3.3.2 Direct-connection Users

Distribution of presence for users parting when connected directly to the MUC is identical to distribution of presence for users joining directly to the MUC.

3.3.3 Status changes

Distribution of presence for users changing status is the same as that for joining and parting.

3.4 Sending a Message to All Occupants

3.4.1 Normal use

Normal fan-out like presence

Example 25. Mirror user sends a message to the room
<message
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    type='groupchat'>
  <body>All work and no play makes Jack a dull boy.</body>
</message>
Example 26. DMUC sends the message to its users
<message
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='wayne@raleigh.tridsys.com/TransVerse'
    type='groupchat'>
  <body>All work and no play makes Jack a dull boy.</body>
</message>
<message
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='keith@raleigh.tridsys.com/TransVerse'
    type='groupchat'>
  <body>All work and no play makes Jack a dull boy.</body>
</message>
Example 27. Mirror sends the message to the MUC
<message
    from='wayne@raleigh.tridsys.com/TransVerse'
    to='chatroom@conference.fairfax.tridsys.com/Wayne'
    type='groupchat'>
</message>

The local server sends out this message to local users.

Example 28. MUC sends the message to the occupants
<message
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='scott@fairfax.tridsys.com/TransVerse'
    type='groupchat'>
  <body>All work and no play makes Jack a dull boy.</body>
</message>
<message
    from='chatroom@conference.fairfax.tridsys.com/Wayne'
    to='kevin@fairfax.tridsys.com/TransVerse'
    type='groupchat'>
  <body>All work and no play makes Jack a dull boy.</body>
</message>

3.5 Connection to master is lost

If the connection is lost to the master MUC, the mirrors should be able to continue on.

It is the responsibility of the mirrored DMUC to send unavailable presence on behalf of any user that is not attached locally.

It is the responsibility of the master MUC to send unavailable presence on behalf of the users attached to the disconnected remote domain to all local users and affected mirrors.

When the connection is re-established, there will be a flood of queued up presences and messages. Because presence information is most likely out of date, the master MUC should send all current presence information to the mirror. The mirror, should also send presence for its users to the master MUC.

3.6 Administration Use Cases

To perform administration of the MUC, connect directly to the MUC and follow the standard process.

4. Business Rules

5. Security Considerations

This allows a MUC mirror to mirror for another JID, so should only be deployed in scenarios where either the mirror service is trusted, or it is known that the users of the mirror service are in the same security domain as the mirror service.

6. IANA Considerations

None.

7. XMPP Registrar Considerations

Needs a namespace.

8. XML Schema

When advanced.


Appendices

Appendix A: Document Information

Series
XEP
Number
xxxx
Publisher
XMPP Standards Foundation
Status
ProtoXEP
Type
Standards Track
Version
0.0.1
Last Updated
2011-01-25
Approving Body
XMPP Council
Dependencies
XMPP Core, XEP-0030, XEP-0033, XEP-0045, XEP-0106
Supersedes
None
Superseded By
None
Short Name
DMUC

This document in other formats: XML  PDF

Appendix B: Author Information

Wayne Franklin
Email
wayne.franklin@tridsys.com

Copyright

This XMPP Extension Protocol is copyright (c) 2011 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising out of the use or inability to use the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0033: Extended Stanza Addressing <https://xmpp.org/extensions/xep-0033.html>.

2. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

3. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.

4. XEP-0106: JID Escaping <https://xmpp.org/extensions/xep-0106.html>.

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 0.0.1 (2011-01-25)

    First draft.

    waf

Appendix I: Bib(La)TeX Entry

@report{franklin2011dmuc,
  title = {DMUC3: Distributed MUC},
  author = {Franklin, Wayne},
  type = {XEP},
  number = {xxxx},
  version = {0.0.1},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-xxxx.html},
  date = {2011-01-25/2011-01-25},
}

END