Introduction to the principle of XMPP protocol

Source: Internet
Author: User
Tags rfc

XMPP (Extensible Message Processing Field Protocol) is an Extensible Markup Language (XML)-based protocol that is used for instant messaging (IM) and on-line on-site probing. It facilitates the quasi-immediate operation between servers. The agreement may finally allow Internet users to send instant messages to anyone else on the internet, even if their operating systems and browsers are different.

XMPP's predecessor was Jabber, an open source form of organization-generated network Instant Messaging protocol. XMPP is now being standardized by the IETF International Standards Organization. The core results of standardization are divided into two parts;

In the IETF, the IM protocol is divided into four protocols, namely instant information and Presence Protocol (Instant Messaging and Presence Protocol, IMPP), presence and Instant Messaging Protocol (presence and Instant Messaging Protocol, PRIM), Session Initiation protocol for Instant Messaging and Presence Extensions (Session Initiation Protocol for Instant Messaging and Presence leveraging Extensions, Simple), as well as the extensible Message Presence Protocol (XMPP). IMPP was originally developed to create a standardized protocol, but today, IMPP has evolved into a basic protocol unit that defines the core set of features that all instant messaging protocols should support.

XMPP and simple two protocols are architectures that help implement the specifications described in the IMPP protocol. PRIM was originally a protocol based on instant messaging, similar to XMPP and simple, but no longer used


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

2. The XMPP protocol has good extensibility. In XMPP, both instant messages and presence information are XML-based structured information exchanged between communication entities in the form of an XML section (XML Stanza). XMPP plays the role of the universal Transport layer of XML structured data, which embeds presence and context-sensitive information into XML structured data, allowing the data to be delivered to the most appropriate resource with great efficiency. The application based on XML has good semantic integrity and extensibility.

3. Distributed network architecture. The XMPP protocol is based on the Client/server architecture, but the XMPP protocol itself does not have this limitation. The architecture of the network is very similar to e-mail, but there is no combination of any particular network architecture and the scope of application is wide.

4. XMPP has very good elasticity. In addition to the applications available for Instant messaging, XMPP can be used in network management, content feeds, collaboration tools, file sharing, gaming, remote system monitoring, and more.

5. Security. XMPP uses the TLS (Transport Layer Security) protocol as the communication channel encryption method in Client-to-server communication, and server-to-server communication to ensure the security of communication. No matter what xmppserver can be independent of the public XMPP network (as in the intranet), the use of technologies such as SASL and TLS enhances communication security. For example, as seen in:

XMPP Composition of the agreement

The basic XMPP protocol template and the most widely used XMPP extensions today:

rfc 3920 XMPP: Core. Defines the network architecture applied under the XMPP protocol framework, introduces the XML stream (XML flow) and XML Stanza (XML section), and specifies the XML tags that the XMPP protocol uses in the communication process. The use of XML tags is fundamentally the need for openness and extensibility of protocols. In addition, in the security aspect of communication, the TLS secure transmission mechanism and the SASL authentication mechanism are introduced into the kernel, and the connection with XMPP is seamless, which lays the foundation for the security and reliability of the protocol. The Core document also specifies the definition and handling of errors, the use of XML, the definition of JID (Jabber identifier,jabber identifiers), naming conventions, and so on. So this is the document that all the XMPP protocol-based apps must support.

RFC 3921: After users have successfully logged in to the server, they announce a business that updates their online friend management, sends instant chat messages, and so on. All of these businesses are completed through three main XML sections: IQ Stanza (IQ section), Presence Stanza (presence), Message Stanza (Message section). The RFC3921 also defines the congestion strategy, which is defined as a variety of clogging methods. To be able to say, RFC3921 is the full complement of RFC3920. Together, two documents form a major Instant Messaging protocol platform that can be used to develop a wide variety of applications.

XEP-0030 Service Search. A powerful protocol for determining the features supported by other entities in the XMPP network.

XEP-0115 solid performance. One of XEP-0030 's customizable, instant-on-the-fly, enables real-time changes to the alternating ad function.

XEP-0045 Chat with many people. A set of protocols that define the participation and management of multi-user chat rooms, similar to the Internet Relay Chat, with very high security.

XEP-0096 file transfer. Defines a file transfer from one XMPP entity to another.

XEP-0124 HTTP bindings. The XMPP is bound to HTTP instead of TCP, and is primarily used for devices that are not durable to maintain connections to servertcp.

XEP-0166 jingle. The overall architecture of multimedia communication negotiation is stipulated.

XEP-0167 jingle Audio Content Description Format. Defines the voice transfer process from one XMPP entity to another.

XEP-0176 jingle ICE (Interactive Connectivity Establishment) Transport. The ice transport mechanism, which captures the issue of how to make a connection to an entity that is protected by a firewall or NAT (Network Address translation).

XEP-0177 jingle Raw UDP Transport. A pure UDP transport mechanism that describes how to establish a connection under the same network without a firewall.

XEP-0180 jingle Video Content Description Format. Defines the video transfer process from one XMPP entity 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, not the same as most instant messaging software, using the P2pclient-to-client architecture, which means, in most cases, When two clients communicate, their messages are passed through the server (with exceptions, such as when a file is transferred in two clients). With this architecture, the main purpose is to simplify the client and put most of the work on the server side, so that the client's work is simpler and, when the functionality is added, it is mostly done on the server side. The framework structure of the XMPP service is, for example, seen. Three roles, xmppclient,xmppserver, gateways are defined in XMPP. Communication can occur in two directions between the random two of these three. At the same time, server assumes the client information record, connection management and information routing function. The gateway undertakes the interconnection with the heterogeneous instant communication system, and the heterogeneous system can contain SMS (SMS), MSN, ICQ and so on. The main network form is a single-client connection to a single server via TCP/IP, and then transfer XML over it, which works as follows:

(1) The node is connected to the server, (2) the server authenticates with the certificate in the local folder system, (3) The node specifies the destination address, the server informs the target State, (4) The server locates, connects and authenticates each other, and (5) interacts with the nodes.

Xmppclient

A design standard for the XMPP system is the need to support a simple client. In fact, the XMPP system architecture has only a few limitations on the client. The features that an XMPP client must support are:

1. Communicate with XMPP server via TCP sockets;

2. Parse well-organized XML packets;

3. Understand the message data type.

XMPP transfers complexity from the client to the server side. This makes client writing easy, and updating the system functionality is also easy. The XMPP client communicates with the server through XML on the 5222 port of the TCP socket without the need for direct communication between the client.

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

RFC3920 Core Protocols

RFC3921 Instant Messaging and Presence agreement instant Messaging and presence

XEP-0030 Services Discovery Service Discovery

XEP-0115 Entity capacity entities capabilities

Xmppserver

XMPP server follows two main rules:

L Monitor the client connection and communicate directly with the client application;

L Communication with other XMPP servers;

XMPP Open source server is generally designed to be modular, consisting of different code packages that handle session management, communication between users and servers, communication between servers, DNS (Domain Name System) transformations, Store the user's personal information and friends list, retain the user's information received at the time of the downline, user registration, user identity and authorization authentication, filtering information and system records according to the user's requirements. In addition, the server is able to extend through additional services, such as a full security policy, agreeing to the server component's connection or client selection, to gateways to other messaging systems.

The primary XMPP server must implement the following standard protocols

RFC3920 Core Protocols

RFC3921 Instant Messaging and Presence agreement instant Messaging and presence

XEP-0030 Services Discovery Service Discovery

XMPP Gateway

XMPP is characterized by the ability to exchange information and user online conditions with other instant messaging systems. Because of the different protocols, XMPP and other system exchange information must be implemented through the conversion of the Protocol, there are several mainstream instant communication protocols are not exposed, so the XMPP server itself is not implemented and other protocol conversion, but its schema agreed to the implementation of the transformation. The server that implements this particular feature is called the Gateway in the XMPP architecture. For now, XMPP implements protocol conversions with AIM, ICQ, IRC, MSN massager, RSS0.9, and Yahoo Massager. Because of the presence 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 entity is called a contact in the XMPP network structure, it has a unique identifier Jabber identifier (JID), which is the entity address, which is used to represent a jabber user, but can also represent other content, such as a chat room. A valid Jid consists of a series of elements: (1) domain name (domains identifier), (2) nodes (node identifier), and (3) source (resource identifier). It's formatted as [email protected]/resource,[email protected], the address format for similar e-mail messages. Domain is used to indicate a different device or location, this is optional, such as a on Server1 a user, username for Doom, then a Jid is[email protected], when sending a message, indicate[email protected]Yes, resource can not be specified, but a when logging in to this server, FL's Jid may be[email protected], Exodus (assuming a is logged in with Exodus software), or it may be [email protected]/psi(Suppose a is logged in with the PSI software). Resources are used only to identify the location or device belonging to the user, and a user can connect to the same XMPP server with multiple resources at the same time .

XMPP message Format
3 top-level XML elements are defined in XMPP: Message, Presence, IQ, described below for these three elements.

<Message>

Used to send information between two Jabber users. The JSM (Jabber Session Manager) is responsible for satisfying all messages, regardless of the state of the target user. Suppose the user commits the online JSM immediately, otherwise the JSM is stored.

To: Identifies the recipient of the message.

From: Refers to the sender's name or mark (ID) o

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

The structure is seen in the following example:

<message to= '[email protected]/contact ' type = ' Chat ' >

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

</message>

<Presence>

Used to indicate the user's status, such as online, Away, DND (Do Not disturb), etc. When a user goes offline or changes his or her state, a presence element is inserted in the context of the stream to indicate its state. The structure is seen in the following example:

<presence>

from = ' Lily @ jabber.com/contact '

to = ' Yaoman @ jabber.com/contact '

<status> Online </status>

</presence>

The <presence> element can take several values:

Probe: Used to send a special request to the Accept message method

Subscribe: When the recipient state changes, it sends the presence message to the sender voluntarily.

< IQ >

A request/response mechanism from an entity that sends a request, another entity accepts the request, and responds. For example, the client inserts an element into the context of the stream, asks the server for its friend list, and the server returns one, which is the result of the request.

<iq > Basic properties are type. Contains:

Get: Gets the current domain value.

Set: Sets or replaces the value of a get query.

Result: The description succeeded in responding to the previous query.

Error: Errors occurred in query and response.

The structure is seen in the following example:

<iq from = ' Lily @ jabber.com/contact ' id= ' 1364564666 ' type= ' result ' >

Introduction to the principle of XMPP protocol

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.