Principles of XMPP protocol

Source: Internet
Author: User
Tags rfc

XMPP (Scalable Message Processing site protocol) is based on the Extensible Markup Language (XML) protocol, which is used for instant messaging (IM) and online on-site detection. It facilitates quasi-real-time operations between servers. This protocol may eventually allow Internet users to send instant messages to anyone else on the Internet, even if the operating system is different from the browser.

The predecessor of XMPP is jabber, an open-source network instant communication protocol. XMPP has been standardized by IETF International Standards Organization. The core results of standardization are divided into two parts;

 

In IETF, the IM protocol is divided into four types: instant message and attendance protocol (IMPP) session Initiation Protocol for instant messaging and presence leveraging extensions, simple), and scalable message attendance protocol (XMPP ). IMPP was initially developed to create a standardized protocol, but today IMPP has become a basic Protocol Unit, defining the core feature set that all Instant Messaging Protocols should support.

The XMPP and simple protocols are architectures that help implement the specifications described in IMPP. Prim was initially based on the instant messaging protocol, similar to XMPP and simple, but it is no longer used

1. the XMPP protocol is open and developed by the JSF open-source community. XMPP does not belong to any organization or individual, but to the whole community, which fundamentally guarantees its openness.

2. the XMPP protocol has good scalability. In XMPP, both instant messages and on-site information are structured information based on XML, Which is exchanged between communication entities in the form of XML stanza. XMPP plays a role in the common transmission layer of XML structured data. It embeds attendance and context sensitive information into XML structured data, in this way, data is delivered to the most appropriate resources with high efficiency. Applications built based on XML have good semantic integrity and scalability.

3. Distributed Network Architecture. The XMPP protocol is based on the client/server architecture, but the XMPP protocol does not have such restrictions. The network architecture is very similar to email, but it is not integrated with any specific network architecture and is widely used.

4. XMPP is flexible. In addition to instant messaging applications, XMPP can also be used in network management, content feed, collaboration tools, file sharing, gaming, remote system monitoring, and so on.

5. Security. In client-to-server communication, XMPP uses the Transport Layer Security (TLS) protocol as the encryption method for communication channels to ensure communication security. Any XMPP server can be independent from the public XMPP network (for example, in an enterprise's internal network), and SASL and TLS technologies are used to enhance the communication security. As shown in:

 

 

Composition of XMPP protocol

The main XMPP protocol templates and XMPP extensions that are widely used today:

RFC 3920 XMPP: core. Defines the network architecture of applications under the XMPP protocol framework, introduces XML Stream (XML Stream) and XML stanza (XML section), and specifies the XML tag used in the communication process of XMPP. The use of XML tags is basically a need for protocol openness and scalability. In addition, in terms of communication security, the TLS Secure Transmission Mechanism and SASL authentication mechanism are introduced into the kernel to seamlessly connect with XMPP, laying the foundation for the security and reliability of the Protocol. The core document also specifies the definition and processing of errors, the XML usage specification, the definition of jid (jabber identifier, Jabber identifier), and the naming convention. Therefore, this document is required for all XMPP-based applications.

RFC 3921: After a user successfully logs on to the server, the user releases services such as updating his/her online friend management and sending instant chat messages. All these businesses are completed through three basic XML sections: IQ stanza (IQ Section), presence stanza (presence Section), and message stanza (message section ). Rfc3921 also defines blocking policies as multiple blocking methods. It can be said that rfc3921 is a supplement to rfc3920. The two documents are combined to form a basic instant messaging protocol platform on which various applications can be developed.

XEP-0030 service search. A powerful protocol used to measure the features supported by other entities in the XMPP network.

XEP-0115 entity performance. One of the XEP-0030's custom through instant attendance can change the alternating ad feature in real time.

XEP-0045 multiplayer chat. A set of protocols defining the participation and management of multi-user chat rooms, similar to the relay chat on the Internet, have high security.

XEP-0096 file transfer. Defines the object transfer from one XMPP object to another.

XEP-0124 HTTP binding. Binding XMPP to HTTP instead of TCP is mainly used for devices that cannot maintain persistent TCP connections with the server.

XEP-0166 jingle. Specifies the overall architecture of multimedia communication negotiation.

XEP-0167 jingle audio content description format. Defines the process of voice transmission from one XMPP object to another.

XEP-0176 jingle ice (Interactive connectivity establishment) transport. ICE transmission mechanism, the file solves the problem of how to establish a connection to an object protected by the firewall or NAT (network address translation.

XEP-0177 jingle raw UDP Transport. The file describes how to establish a connection in the same network without a firewall.

XEP-0180 jingle video content description format. Defines the video transmission process from one XMPP object to another.

XEP-0181 jingle DTMF (Dual Tone Multi-frequency ).

XEP-0183 jingle telepathy transport method.

XMPP protocol network architecture

XMPP is a typical C/S architecture, instead of using P2P client-to-client architecture like most instant messaging software. That is to say, when two clients communicate in most cases, their messages are all transmitted through the server (there are also exceptions, such as when two clients transfer files ). this architecture is mainly used to simplify the client and put most of the work on the server. In this way, the work of the client is relatively simple, and when a function is added, mostly on the server side. shows the Framework Structure of the XMPP service. XMPP defines three roles: XMPP client, XMPP server, and gateway. communication can take place between any two of the three. the server also provides routing functions for client information recording, connection management, and information. gateways are interconnected with heterogeneous instant messaging systems. heterogeneous systems can include SMS, MSN, and ICQ. the basic network mode is that a single client connects to a single server through TCP/IP, and then transmits XML on it. The working principle is:

(1) connect the node to the server; (2) use the certificate in the local directory system to authenticate it; (3) Specify the target address for the node to notify the server of the Target status; (4) servers search, connect, and authenticate each other. (5) nodes interact with each other.

XMPP Client

An XMPP system design standard must support simple clients. In fact, the XMPP system architecture has few limitations on the client. An XMPP client must support the following functions:

1. Communicate with the XMPP server through a TCP socket;

2. parse the organized XML Information Package;

3. Understand the message data type.

XMPP transfers complexity from the client to the server. This makes it easy to write the client and update system functions. The XMPP client communicates with the server through XML on port 5222 of the TCP socket, without direct communication between the client.

The basic XMPP client must implement the following standard protocol (XEP-0211 ):

Rfc3920 Core Protocol Core

Rfc3921 instant messaging and attendance agreement instant messaging and presence

XEP-0030 Service Discovery

XEP-0115 entity capability entity capabilities

 

XMPP Server

 

The XMPP server follows two main rules:

L listen to the client connection and directly communicate with the client application;

L communicates with other XMPP servers;

XMPP open-source servers are generally designed to be modular and composed of different code packages, these code packages handle session management, communication between users and servers, communication between servers, DNS (Domain Name System) convert and store users' personal information and friend lists, retain information received by users when they go offline, register users, authenticate user identities and permissions, and filter information and system records according to user requirements.. In addition, servers can be expanded by attaching services, such as a complete security policy that allows connections to server components or clients to access gateways of other message systems.

Basic XMPP servers must implement the following standard protocols:

Rfc3920 Core Protocol Core

Rfc3921 instant messaging and attendance agreement instant messaging and presence

XEP-0030 Service Discovery

 

XMPP Gateway

 

XMPP is characterized by the ability to exchange information with other instant messaging systems and users' online conditions. Due to different protocols, XMPP and other systems must exchange information through protocol conversion. Currently, no mainstream Instant Messaging Protocols are available, therefore, the XMPP server itself does not implement conversion from other protocols, but its architecture allows the implementation of conversion. The server that implements this special function is called a gateway in the XMPP architecture ). Currently, XMPP implements protocol conversion with aim, ICQ, IRC, MSN massager, rss0.9, and Yahoo massager. Because of the existence of gateways, the XMPP architecture is actually compatible with all other instant communication networks, which undoubtedly greatly improves the flexibility and scalability of XMPP.

 

XMPP address format

An object is called a contact in the XMPP network structure. It has a unique identifier jabber identifier (jid), that is, the entity address, used to represent a jabber user, but it can also represent other content, such as a chat room. A valid jid includes a series of elements: (1) domain identifier; (2) node identifier; (3) Source (resource identifier ). the format is node @ domain/resource, node @ domain, similar to the address format of the email. domain is used to indicate the contacts of different devices or locations. This is optional. For example, if a registers a user on server1 and the user name is doom, the jid of A is doom @ serverl, when sending a message, specify doom @ serverl. You do not need to specify resource. However, when a logs on to this server, the jid of FL may be doom @ serverl or Exodus (if A is logged on with the Exodus software), or it may be doom @ serverl/PSI (if A is logged on with the Psi software ). resources are only used to identify user locations or devices. A user can connect to the same XMPP server with multiple resources at the same time.

 

XMPP Message format
XMPP defines three top-level XML elements: Message, presence, and IQ. The following describes these three elements.

 

<Message>

Send messages between two jabber users. The JSM (jabber Session Manager) is responsible for meeting all messages regardless of the target user's status. If the user is online, JSM is submitted immediately; otherwise, JSM is stored.

To: identifies the message receiver.

From: The sender's name or identifier (ID) O

Text: This element contains the information to be submitted to the target user.

The structure is as follows:

 

<Message to = 'lily @ jabber.org/contact' type = 'chat'>

<Body> Hello, are you busy? </body>

</Message>

 

<Presence>

Used to indicate the user's status, such as online, away, and DND. When a user is offline or changing his/her status, a presence element is inserted in the stream context to indicate his/her status. The structure is as follows:

<Presence>

From = 'lily @ jabber.com/contact'

To = 'yaoman @ jabber.com/contact'

<Status> online </status>

</Presence>

The <presence> element can take the following values:

Probe: used to send special requests to receive message Methods

Subscribe: when the recipient's status changes, the message is automatically sent to the sender.

 

 

<IQ>

A request/response mechanism is used to send a request from an entity, while another entity accepts the request and responds to the request. for example, the client inserts an element in the stream context to request the server to obtain its friends list. The server returns a result of the request.

<IQ> the main attribute is type. Including:

Get: Get the current domain value.

Set: set or replace the get query value.

Result: The query is successful.

Error: errors in queries and responses.

The structure is as follows:

<IQ from = 'lily @ jabber.com/contact'id='1364564666' type = 'result'>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.