XMPP is an XML-based protocol, which inherits the flexible development in the XML environment. Therefore, XMPP-based applications are extremely scalable. After the expansion, XMPP can handle the needs of users by sending extended information, and establish applications such as content publishing systems and address-based services on top of XMPP. Moreover, XMPP includes a software protocol for the server side, so that it can talk to another, which makes it easier for developers to build customer applications or add functions to a well-equipped system. XMPP (Extensible Message Processing Field Protocol) is a protocol based on Extensible Markup Language (XML), which is used for instant messaging (IM) and online field detection. It promotes quasi-instant operation between servers. This protocol may eventually allow Internet users to send instant messages to anyone else on the Internet, even if their operating systems and browsers are different. The predecessor of XMPP was Jabber, an instant messaging protocol generated by an open source organization. XMPP is currently being standardized by the IETF International Standards Organization.

1 XMPP address and data structure

1.1 Physical address

The overall framework of XMPP is shown in Figure 1. In the figure, the addresses of various entities of the XMPP framework (such as XMPP clients, servers, and gateways) are called Jabber IdenTIfier (JID) addresses. JID uniquely determines the independent object or entity for instant messaging and online status information communication, and is compatible with the corresponding entity identification and online status information of Other instant communication systems (such as MSN, etc.). The grammar rule is: [node "@"] domain name ["/" resource], where the length of each domain cannot exceed 1,023 bytes, and the total length is a maximum of 3,071 bytes.

Three roles are defined in XMPP: client, server, and gateway. Communication can occur bidirectionally between any two of the three. The server also undertakes client information recording, connection management and information routing functions. The gateway undertakes the interconnection with the heterogeneous instant communication system. The heterogeneous system may include SMS (Short Message), MSN, ICQ, etc. The basic network form is that a single client connects to a single server via TCP / IP, and then transmits XML on top. The instructions transmitted are related to instant messaging. In the past, these commands were either sent in binary format (such as QQ), or they were sent in plain text with space and parameters and line feeds (such as MSN). The logic of the instant messaging commands transmitted by XMPP is similar to the past, but the form of the protocol has become plain text in XML format. This not only makes parsing easy, but also easy for people to read, which facilitates development and troubleshooting. The core part of XMPP is a streaming protocol that sends XML in segments on the network. This streaming protocol is the basis for XMPP's instant messaging commands and a very important network basic protocol that can be further utilized. So it can be said that XMPP uses XML to transmit the XML stream.

The domain name specifies the XMPP server to which the entity is connected. Each available XMPP server has a complete domain name, which can be found in the domain name system (DNS); nodes can represent a user, a type of application, or a service, and all nodes correspond to an accurate domain name; resources are used to identify The user's special objects (such as device or location) allow a user to connect to the same XMPP server with multiple resources at the same time.

1.2 Data structure of XMPP

Because XMPP is an XML-based protocol, users can define tags according to their needs, express almost any kind of structured data, and easily create customized applications or add functions.

1.2.1 Three top-level XML elements

The three key top-level XML elements defined by XMPP are , with (Info / query), each element can contain a large amount of data through attributes and namespaces, both of which are part of XMPP.

The element is used to contain the content of messages sent between two XMPP entities; The element represents entity availability information. There are two types of availability information: "available" and "unavailable"; The element is used to construct a conversation between two entities, and allows the entities to transfer requests and responses in XML format back and forth to obtain or set public user information, such as names.

The problem of name conflicts in instant messaging is solved using the XML namespace feature. The XML namespace defines a method for defining elements and attributes by linking elements and attributes used in XML with Uniform Resource Locator (URL) references. Uniform resource locator (URL) is an identification method used to completely describe the addresses of web pages and other resources on the Internet. Each web page on the Internet has a unique name identifier, usually called a URL address. This address can be a local disk or a computer on the local area network, and more is a site on the Internet. Simply put, a URL is a web address, commonly known as a "web address".

1.2.2 XMPP data structure

From a structural point of view, XMPP has three kinds of data: XML stream, stream authentication and XML section. The XML stream is a container for entities to exchange XML elements. Start with The end is the standard method for data transmission between the two parties in an asynchronous manner. It is at the outermost layer in the entire XMPP communication process; the XML section is the structured information unit that the entity transmits through the XML stream. In the XML stream, the depth is 1 Tags at the beginning and end with sub-tags of depth 1, these tags are , with .

XMPP plays the role of a general "transport layer" for XML streams. The XML stream contains transmitted authentication information and live messages. XMPP can efficiently route data to the most appropriate request source, and simplify the implementation on the client to the greatest extent, making it possible to exchange information in real time across applications.

2 Working process

(1) Nodes (such as yb, pt) connect to the local server.

â‘ XMPP users apply for a socket connection on the server by opening an XML stream from the client to the server.

SEND:

to = ′ sdpt.com ′

xmlns = 'jabber: client'

xmlns: stream = 'http: //etherx.jabber.org/streams'>

â‘¡ The server responds by opening an XML stream from the server to the client.

RECV:

from = ′ sdpt.com ′

id = ′ 180763465 ′

xmlns = 'jabber: client'

xmlns: stream = 'http: //etherx.jabber.org/streams'>

(2) The node applies to the local server for login.

â‘  The user asks for the information to be provided when logging in to the server.

SEND:

yb

â‘¡ The server responds to the user and informs the user of the information required for login.

â‘¢ The user provides the required information.

â‘£ The server responds with an empty iq element of type "result", indicating that the login is successful.

RECV:

⑤ The yb user sends the current status to the server, indicating that it is online.

SEND:

Online

(3) The user obtains the roster, and the friend adds a contact (such as yb learns that the friend sd is online).

(4) Send messages between users (such as yb to sd).

The user sends a message:

SEND:

Where are you?

The server adds a source address based on the XMPP user's session information, so that when the receiver receives the message, the source address is already included in the message.

(5) The XMPP server searches, connects to and authenticates the target server based on the domain name in the target JID (such as sdpt.com uses DNS to find jabber.org, connects to the jabber.org server and authenticates)

(6) The XMPP server jabber.org confirms that sd is connected to the server, and yb is authorized to communicate with sd.

(7) Data flows between yb and sd.

(8) Users log out, only need to close when logging out .

Krisun mobile radio

Guangzhou Etmy Technology Co., Ltd. , https://www.digitaltalkie.com