How XMPP is implemented

Source: Internet
Author: User
Tags abstract definition

This section describes the principles and related information of the XMPP protocol.

 

XMPP protocol Introduction

XMPP (Extensible Messageing and Presence Protocol: Extensible message and existing Protocol) is one of the four mainstream IM (IM: instant messaging, instant messaging) protocols. The other three are: instant messaging and space protocol (IMPP), space and instant messaging protocol (PRIM), start protocol for instant messaging and space balance expansion process (SIP (SIMPLE ).

 

XMPP is the most flexible among the four Protocols. XMPP is an XML-based protocol that inherits the flexible development in the XML environment. Therefore, XMPP-based applications are highly scalable. After the extension, XMPP can send extended information to meet user requirements, and create application processes such as the content publishing system and address-based services at the top of XMPP. In addition, XMPP includes a software protocol for the server to enable communication with the other, making it easier for developers to build customer applications or add functions to a system.

 

1. What is XMPP?

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; the core XML Stream Transmission Protocol is based on the XML Stream Transmission instant messaging extension application. The core XML Stream Transmission Protocol definition of XMPP enables XMPP to be deployed on a platform that is more standard than previous network communication protocols. With the help of XML's easy-to-parse and read features, the XMPP protocol can be very beautiful. The XMPP instant messaging extension application is based on an abstract definition of instant messaging by IETF prior to this, and is widely used with other instant messaging protocols, such as AIM, QQ and other advanced features are complete and improved.

 

2. What is the basic network structure of XMPP??

XMPP defines three roles: client, server, and gateway. Communication can take place between any two of the three. The server also undertakes the client information record, connection management and information routing functions. 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.

 

3. What does XMPP pass over TCP?

Commands related to instant messaging are transmitted. In the past, these commands were either sent in a binary format (for example, QQ), or sent in a text-only command with a space and a parameter with a line break (for example, MSN ). The logic of the instant messaging commands transmitted by XMPP is similar to that in the past, but the Protocol format is changed to plain text in XML format. This not only makes parsing easier, but also makes reading easier, facilitating development and troubleshooting. The core part of XMPP is a stream protocol that sends XML data in parts on the network. This stream protocol is the basis for transmitting XMPP instant messaging commands, and is also a very important basic network protocol that can be further used. Therefore, XMPP uses TCP to transmit XML streams.

 

How XMPP works:

 

 

 

4. XMPP protocol address format:

 

 

5. XMPP Message format:

 

 

 

 

 

 

 

6. Core XML Stream Transmission Protocol

Instant Messaging extension application based on XML FreeEIM Stream Transmission

The core XML Stream Transmission Protocol of XMPP enables XMPP to be deployed on a platform that is more standard than previous network communication protocols. With the help of XML's easy-to-parse and read features, the XMPP protocol can be very beautiful.

The XMPP instant messaging extension application is based on an abstract definition of instant messaging by IETF prior to this, and is widely used with other instant messaging protocols, such as AIM, QQ and other advanced features are complete and improved.

The XMPP extension protocol Jingle enables it to support voice and video.

The official XMPP documentation is RFC 3920.

 

7. XMPP application example

Let's take an example to see what the so-called XML Stream looks like?

Client: <? Xml version = '1. 0'?>

<Stream: stream

To = 'example _ com'

Xmlns = 'jabber: client'

Xmlns: stream = 'HTTP _ etherx_jabber_org/streams'

Version = '1. 0'>

Server: <? Xml version = '1. 0'?>

<Stream: stream

From = 'example _ com'

Id = 'someid'

Xmlns = 'jabber: client'

Xmlns: stream = 'HTTP _ etherx_jabber_org/streams'

Version = '1. 0'>

... Other communications...

Client: <message from = 'juliet _ example_com'

To = 'Romeo _ example_net'

Xml: lang = 'en'>

Client: <body> Art thou not Romeo, and a Montgomery? </Body>

Client: </message>

Server: <message from = 'Romeo _ example_net'

To = 'juliet _ example_com'

Xml: lang = 'en'>

Server: <body> Neither, fair saint, if either thee dislike. </body>

Server: </message>

Client: </stream: stream>

Server: </stream: stream>

 

 

From the document's point of view, all the XML texts sent by the client or server are concatenated, from <stream> to </stream> to form a complete XML document. The stream tag is the so-called XML Stream. XML elements such as <message>... </message> in the center of <stream> and </stream> are the so-called XML Stanza (XML section ). The basic mode of XMPP core protocol communication is to first create a stream, and then negotiate a bunch of security and other things. The intermediate communication process is that the client sends XML Stanza one by one. The server sends XML Stanza to the client based on the information sent by the client and the program logic. However, this process is not a question and answer. At any time, it is possible to send a letter from one party to the other. The final phase of communication is </stream> closing the stream and closing the TCP/IP connection.

 

8. XMPP system features:

1) Client/Server communication mode; (2) distributed network; (3) simple client; (4) XML data format.

 

9. General explanation:

In fact, XMPP is a data transmission protocol that is very similar to the http protocol. Its process is like the process of "unpackaging --> packaging". You only need to understand the type it accepts, and understand the type it returns, so that xmpp can be used for data communication.

 

Finally, I hope to reprint friends can respect the author's labor results, plus reprint address: http://www.cnblogs.com/hanyonglu/archive/2012/03/04/2378956.html thank you.

 

Complete.

 

 

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.