XMPP--XMPP agreement, advantages, disadvantages and optimization ideas

Source: Internet
Author: User

XMPP (extensible Messaging and Presence Protocol, formerly known as Jabber) protocol introduction

Extensible Message Processing Site Protocol (extensible Messaging and Presence Protocol, XMPP) is a near-end streaming instant-messaging protocol based on Extensible Markup Language (extensible Markup Language, XML). It embeds field and context sensitive information tags into XML structured data, enabling instant communication between people, application systems, and between people and applications
XMPP is an open protocol based on an XML schema. The basic part of XMPP has been approved by the Internet Engineering Task Force (IETF) in 2002-2004, and the future XMPP protocol will take for granted the Internet Protocol TCP/IP, HTTP, FTP, SMTP, Pop as an Internet standard.

XMPP protocol Content

Three roles, clients, servers, and gateways are defined in XMPP. Communication can occur bidirectional between any two of these three. The server also 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 include SMS (SMS), MSN,ICQ and so on. The basic network form is that a single client connects to a single server over TCP/IP and then transmits the XML over it.

XMPP Protocol Benefits

1. Distributed
The architecture of the XMPP network is similar to e-mail, and the XMPP core protocol communicates by first creating a stream,xmpp to pass the XML data stream with TCP, without a central master server. Anyone can run their own XMPP server, enabling individuals and organizations to take control of their real-time messaging experience

2. Security
The servers of any XMPP protocol can be independent of the public XMPP network (for example, within an intranet), and the reliable security of technologies such as SASL (1) and TLS (2) are available in the core XMPP technical specifications.
Xmpp–>sasl–>tls–>tcp–>ip

(1) SASL:SASL full name Simple authentication and Security Layer, is a method to expand the C/S mode verification capability mechanism. The postfix can use SASL to determine whether a user is authorized to use a forwarding service or to identify who is using your server. SASL provides a common method for adding validation support for connection-based protocols, while XMPP uses a common XML namespace to meet the needs of SASL
(2) TLS: Secure Transport Layer Protocol (TLS) is used to provide confidentiality and data integrity between two communication applications. The protocol consists of two tiers: the TLS recording Protocol (TLS record) and the TLS Handshake Protocol (TLS handshake).

3. Expandable
The power of the XML namespace allows anyone to build customized functionality on top of the core protocol.
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.

4. Good elasticity
In addition to applications that can be used in real-time communications, XMPP is widely available in network management, content feeds, collaboration tools, file sharing, gaming, remote system monitoring, and more.

5. Diversity
Companies and open source programs that use the XMPP protocol to build and distribute real-time applications and services are distributed in a variety of areas; using XMPP technology to develop software, resources and support sources are diverse, making you not trapped in a "kidnapping" dilemma

6. Distributed Network Architecture
The implementation of the XMPP protocol is based on the Client/server network architecture. But the XMPP protocol itself is not limited to this schema, and its architecture is very similar to e-mail, but it is not limited to this, so its application is very wide!

The composition of the XMPP protocol

The main XMPP protocol model and today's widely used XMPP extensions

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 a document that must be supported by all XMPP protocol-based 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, can change the ad function in real time.
XEP-0045 Multi-person Chat:A set of protocols that define the participation and management of multi-user chat rooms, similar to the Internet Relay Chat, with high security.
XEP-0096 File transfer:Defines a file transfer from one XMPP entity to another.
XEP-0124 HTTP Bindings:Bind XMPP to HTTP instead of TCP, primarily for devices that do not persist with server TCP connections.
XEP-0166 Jingle:The whole structure 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:Ice transport mechanism, which resolves 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 Disadvantages

No binary data
The XMPP protocol is encoded as a single long XML file, so it is not possible to provide modified binary data. File transfer using the HTTP protocol with BASE64 (3)
(3) Base64 is one of the most common encoding methods for transmitting 8Bit bytes of code on the network

Optimization Ideas

XMPP provides Electronic Business card protocol

vcard is an existing, widely used, user personal information storage standard, a bit like an electronic business card. The underlying function is to store and retrieve the user's electronic identity, which is expressed in XML, and the storage of the data depends on the implementation of all existing XMPP servers

XMPP System Features

Client/server communication mode, distributed network, simple client, XML data format.

Working principle

(1) the node (CLIENT1) is connected to the server;
(2) The server authenticates with the certificate in the local directory system;
(3) node specified target (CLIENT2) address, let the server inform the target State;
(4) The server finds, connects and authenticates each other;
(5) Interaction between nodes (CLIENT1 and Client2).

Dialogue Chestnut:
The client (Kuusipuu) connects to an XMPP server (AMESSAGE.DE:5222/TCP), sends a message (subject and content of "test 1449") to another client (Tero), and then logs off.

The user sends a connection request to the server
Kuusipuu:

<?xmlversion=‘1.0‘?><stream:stream xmlns:stream="http://etherx.jabber.org/streams"xmlns="jabber:client" to="amessage.de">

Server response to request
Amessage.de:

<stream:stream xmlns=‘jabber:client‘xmlns:stream=‘http://etherx.jabber.org/streams‘from=‘amessage.de‘ id=‘1461777714‘>

Server authenticates with the certificate of the local directory system
Kuusipuu:

<iq type="set" id="auth_2" to="amessage.de" ><query xmlns="jabber:iq:auth">  <username>kuusipuu</username>  <password>mypassword</password>  <resource>Work</resource> </query></iq>

Server returns the corresponding results to the client
Amessage.de:

<iq from="amessage.de" id=‘auth_2‘ type=‘result‘/>

The user sends a message request and logs off
Kuusipuu:

<message to="[email protected]" >    <subject>test 1449</subject>    <body>test 1449</body></message><presence type="unavailable" >    <status>Logged out</status></presence></stream:stream>

Server returns logoff information
Amessage.de:

</stream:stream>

The next article mainly from the code point of view of the server configuration based on XMPP, client, XMPP Gateway, XMPP address format, XMPP message format and so on I recently learned the relevant knowledge and summary, and briefly enumerate the corresponding examples.

jessonlv--Lu Guodong original article, reproduced please specify the Source: my blog: http://blog.csdn.net/jessonlv

XMPP--XMPP agreement, advantages, disadvantages and optimization ideas

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.