Introduction to the implementation principle of XMPP protocol (transfer)

This article introduces the principle and related information of the XMPP protocol.

 

Introduction to XMPP Protocol  

XMPP (Extensible Messageing and Presence Protocol: Extensible Message and Presence 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), Process Initiation Protocol SIP (SIMPLE) extended for instant messaging and space balance.

 

Among the four protocols, XMPP is the most flexible. XMPP is an XML-based protocol that inherits the flexibility of development in an XML environment. Therefore, XMPP-based applications are highly scalable. The extended XMPP can deal with the needs of users by sending extended information, and build applications such as content publishing systems and address-based services on top of XMPP. Furthermore, XMPP includes software protocols for the server side to talk to one another, which makes it easier for developers to build client applications or add functionality to a provisioned system.

 

1. What is XMPP?

The predecessor of XMPP is Jabber, a network instant messaging protocol produced by an open source form organization. XMPP is currently standardized by the IETF International Standards Organization. The core results of standardization are divided into two parts; The core XML streaming protocol The instant messaging extension application based on XML streaming The definition of the core XML streaming protocol enables XMPP to work on a more standardized platform than previous network communication protocols. With the help of XML's easy to parse and read characteristics, the XMPP protocol can be very beautiful. The instant messaging extension application part of XMPP is based on an abstract definition of instant messaging by IETF before, and it has advanced features such as complete functions and perfection with other instant messaging protocols that have been widely used, such as AIM and QQ.

 

2. What is the basic network structure of XMPP ?

Three roles are defined in XMPP, client, server, and gateway. Communication can occur bidirectionally between any two of these three. The server also undertakes the functions of client information recording, connection management and information routing. The gateway is responsible for the interconnection with the heterogeneous instant messaging system, and the heterogeneous system may include SMS (short message), MSN, ICQ, etc. The basic form of networking is that a single client connects to a single server via TCP/IP, and then transmits XML over it.

 

3. What does XMPP transmit over TCP?

The transmissions are commands related to instant messaging. In the past, these commands were either sent in binary form (such as QQ), or sent in the form of plain text commands plus spaces, parameters and line breaks (such as MSN). The logic of the instant messaging instructions transmitted by XMPP is similar to that of the past, except that the form of the protocol has become plain text in XML format. This not only makes parsing easier, but also makes it easier for people to read, which facilitates development and error checking. The core part of XMPP is a streaming protocol that sends XML in segments over the network. This stream protocol is the transmission basis of XMPP's instant messaging instructions, and it is also a very important network basic protocol that can be further utilized. So it can be said that XMPP uses TCP to transmit XML streams.

 

How the XMPP protocol works:

 

 

 

4. XMPP protocol address format:

 

 

5. XMPP message format: 

 

 

 

 

 

 

 

6. Core XML Streaming Protocol

Instant Messaging Extension Application Based on XML FreeEIM Streaming

The definition of XMPP's core XML streaming protocol enables XMPP to operate on a more standardized platform than previous network communication protocols. With the help of XML's easy to parse and read characteristics, the XMPP protocol can be very beautiful.

The instant messaging extension application part of XMPP is based on an abstract definition of instant messaging by IETF before, and it has advanced features such as complete functions and perfection with other instant messaging protocols that have been widely used, such as AIM and QQ.

Jingle, an extension of XMPP, enables it to support voice and video. 

The official document of XMPP is RFC 3920. 

 

7. XMPP application example

For example, what does a so-called XML stream look 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 communication... Client: <message from='juliet_example_com' to='romeo_example_net' xml:lang='en'> Client: <body>Art thou not Romeo, and a Montague?</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 a document point of view, all XML text sent by the client or server is concatenated together, 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> between <stream> and </stream> are the so-called XML Stanzas. The basic mode of XMPP core protocol communication is to first establish 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 according to the information sent by the client and the logic of the program. But this process is not a question-and-answer process, and it is possible to send a letter from one party to the other at any time. The final stage of communication is </stream>closing the stream, 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. Popular explanation:

In fact, XMPP is a data transmission protocol very similar to the http protocol. Its process is like the process of "unpacking --> packaging". Users only need to understand the type it accepts and the type it returns. You can make good use of xmpp for data communication.

 

Reprint address: http://www.cnblogs.com/hanyonglu/archive/2012/03/04/2378956.html 

 

complete.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326761598&siteId=291194637