University Learning Network Foundation when the teacher said, the network from the bottom up into the physical layer, Data link layer, network layer, transport layer, Session layer, presentation layer and application layer. Through the preliminary understanding, I know that the IP protocol corresponds to the network layer, the TCP protocol corresponds to the transport layer, and the HTTP protocol corresponds to the application layer, the three are not inherently comparable, the socket is the TCP/IP protocol encapsulation and application (programmer level). It can also be said that the TPC/IP protocol is the Transport Layer protocol, mainly to solve how the data in the network transmission, and HTTP is the application layer protocol, mainly to solve how to package the data. Regarding the relationship between TCP/IP and HTTP protocol, the network has a relatively easy to understand introduction:
"When we transmit data, we can only use the (Transport Layer) TCP/IP protocol, but in that case, if there is no application layer, it will not be able to identify the data content, if you want to make the transferred data meaningful, you must use the Application layer protocol, the application layer protocol, such as HTTP, FTP, Telnet, etc., You can also define the application layer protocol yourself. The web uses the HTTP protocol as an application-layer protocol to encapsulate HTTP text information and then send it to the network using TCP/IP as the Transport layer protocol. ”
And we usually say the most socket is what, in fact, the socket is the TCP/IP protocol encapsulation, the socket itself is not a protocol, but a call interface (API), through the socket, we can use the TCP/IP protocol. In fact, the socket is not necessarily associated with the TCP/IP protocol. The socket programming interface is designed to adapt to other network protocols as well. So, the advent of sockets just makes it easier for programmers to use the TCP/IP protocol stack, which is an abstraction of the TCP/IP protocol, thus forming some of the most basic function interfaces we know, such as Create, listen, connect, accept, send, Read and write, and so on. The network has a section on the socket and TCP/IP protocol relationship is relatively easy to understand:
"TCP/IP is just a stack of protocols, just like operating systems, which must be implemented in a specific way, as well as providing an external interface for operations." This is like the operating system will provide a standard programming interface, such as the Win32 programming interface, TCP/IP should also provide the interface for programmers to do network development, this is the socket programming interface. ”
About the TCP/IP protocol only, with the broad and profound I think not too, just check the online about this kind of information and books only the number of documents to know, this I intend to buy some classic books (such as "TCP/IP Detailed: Volume One, Volume II, Volume three") to learn, Today, we summarize some of the knowledge based on TCP/IP protocol-based applications and programming interfaces, which is just a lot of HTTP and sockets.
CSDN has a comparative image of the description: HTTP is a sedan, providing a specific form of encapsulation or display data; the socket is the engine that provides the ability to communicate on the network.
In fact, the transport layer TCP is based on the network layer of IP protocol, and the application layer of the HTTP protocol is based on the transport layer of the TCP protocol, and the socket itself is not a protocol, as mentioned above, it just provides a TCP or UDP programming interface.
Here are some of the important concepts that are often encountered in a written test or interview and are summarized here.
One. What is a three-time handshake for a TCP connection
First handshake: The client sends a SYN packet (SYN=J) to the server and enters the Syn_send state, waiting for the server to confirm;
Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=J+1), and also send itself a SYN packet (syn=k), that is, the Syn+ack packet, when the server enters the SYN_RECV state;
Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and the server enter the established state, and the handshake is completed three times.
The data is not included in the packets that are delivered during the handshake, and the client and server formally begin transmitting the data after the three handshake is complete. Ideally, once a TCP connection is established, the TCP connection is maintained until either side of the communication actively closes the connection. When disconnected, both the server and the client can initiate a request to disconnect the TCP connection, and the disconnection process requires a "four handshake" (the process is not fine-grained, that is, the server interacts with the client and finally determines the disconnection)
Two. To establish a network connection using a socket
Establishing a socket connection requires at least one pair of sockets, one running on the client, called Clientsocket, and the other running on the server side, called ServerSocket.
The connection between sockets is divided into three steps: Server listening, client request, connection acknowledgement.
1. Server monitoring: Server-side sockets do not locate specific client sockets, but are waiting for the status of the connection, real-time monitoring network status, waiting for the client connection request.
2. Client request: Refers to the client's socket to make a connection request, to connect to the target is the server-side socket. To do this, the client's socket must first describe the socket of the server it is connecting to, indicate the address and port number of the server-side socket, and then make a connection request to the server-side socket.
3. Connection confirmation: When a server-side socket hears or receives a connection request from a client socket, it responds to a client socket request, establishes a new thread, sends a description of the server-side socket to the client, and once the client confirms the description, the two sides formally establish the connection. While the server-side socket continues to be in the listening state, it continues to receive connection requests from other client sockets.
Three. Features of HTTP links
The HTTP protocol, the Hypertext Transfer Protocol (hypertext Transfer Protocol), is the foundation of Web networking and one of the most commonly used protocols for mobile networking, an application built on the TCP protocol.
The most notable feature of an HTTP connection is that each request sent by the client requires a server loopback response, and the connection is actively released after the request has ended. The process from establishing a connection to closing a connection is called a "one-time connection."
Four. The difference between TCP and UDP
1. TCP is link-oriented, although the network's insecure instability determines how many times the handshake can not guarantee the reliability of the connection, but the TCP three handshake at least (in fact, to a large extent guaranteed) to ensure the reliability of the connection, and UDP is not a connection-oriented, UDP transmission data before the connection with the other party, the data received is not sent to confirm the signal, the sender does not know whether the data will be properly received, of course, there is no need to resend, so that UDP is a non-connected, unreliable data transmission protocol.
2. Also due to the characteristics of 1, so that the cost of UDP more small data transmission rate is higher, because there is no need to send and receive data confirmation, so UDP real-time better.
Know the difference between TCP and UDP, it is not difficult to understand why the use of TCP transmission protocol MSN than UDP transmission file slow, but can not say that QQ communication is not safe, because the programmer can manually verify the data sent and received by UDP, For example, the sender of each packet number and then by the receiver to verify AH what, even so, UDP because the package on the underlying protocol does not adopt a TCP-like "three-time handshake" to achieve the TCP can not achieve the transmission efficiency.
Five, XMPP
XMPP is a subset of XML based on standard Common Markup Language protocol, which inherits the flexible development in XML environment. As a result, XMPP-based applications have super-scalable capability. The extended XMPP can handle the user's needs by sending extended information, as well as creating applications such as content publishing systems and address-based services at the top of XMPP. Furthermore, XMPP contains a software protocol for the server side that enables it to talk to another, making it easier for developers to build customer applications or add functionality to a well-equipped system.
Extensible Communication and Presentation Protocol (XMPP) can be used for streaming XML data in service class real-time communication, presentation, and demand response services. XMPP is based on the Jabber protocol, while Jabber is an open protocol commonly used in instant messaging. XMPP is the IETF's formalization of the base XML streaming protocols for instant messaging and presence developed within T He Jabber Open-source community in 1999
XMPP (Extensible Messaging Field Protocol) is an Extensible Markup Language (XML)-based protocol that is used for instant messaging (IM) and online field probing. It facilitates quasi-immediate operation between servers. This agreement may eventually 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 currently being standardized by the IETF International Standards Organization. The core results of standardization are divided into two parts;
the core XML Stream Transfer Protocol
application of instant communication extension based on Xmlfreeeim stream transmission
The definition of the core XML streaming protocol for XMPP enables XMPP to be on a more standardized platform than the previous network communication protocol. With the help of XML's easy parsing and reading features, the protocol of XMPP can be very beautiful.
the Instant Messenger extension Application section of XMPP is based on an abstract definition of instant messaging by the IETF prior to this, with other widely used instant messaging protocols such as AIM,QQ, which are functionally complete and perfect.
XMPP's extended protocol jingle makes IT support voice and video.
the official documentation for XMPP is RFC 3920.
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.
The transmission is an instruction related to instant messaging. In the past, these commands are either sent in 2 binary form (such as QQ), or with a plain text instruction plus a space plus a parameter plus a newline character (such as MSN). The logic of the instant communication Instructions transmitted by XMPP is similar to the previous ones, except that the form of the protocol becomes plain text in XML format. This not only makes the analysis easy, people are also easy to read, convenient development and error-checking. The central part of XMPP is a streaming protocol that sends XML over the network. This streaming protocol is the basis for the delivery of XMPP's instant messaging instructions and is also a very important network infrastructure protocol that can be further exploited. So it can be said that XMPP uses TCP to transmit the XML stream.
Advantages
The XMPP protocol is free, open, open, and easy to understand. And in the client, server, components, source code library, etc., have been various implementations.
The Internet Engineering Working Group (IETF) has formally listed Jabber's core XML streaming protocol as a recognized real-time communication and presence technology in the name of XMPP. The technical specifications for XMPP have been defined in RFC 3920 and RFC 3921. Any IM vendor who follows the XMPP protocol can connect to Google Talk.
The first Jabber (now XMPP) technology was developed by Jeremie Miller in 1998 and is now fairly stable, with hundreds of developers working on XMPP technology. Tens of thousands of XMPP servers operate on the internet today, and millions of people use XMPP real-time messaging software.
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.
servers of any XMPP protocol can be independent of the public XMPP network (for example, within an intranet), and reliable security using technologies such as SASL and TLS are built into the core XMPP technical specifications.
the power of the XML namespace allows anyone to build a custom function on top of the core protocol, and for the sake of maintaining permeability, the common extension is the XMPP Standard Foundation.
In addition to applications that can be used in real-time communication, XMPP also works with network management, content feeds, collaboration tools, file sharing, gaming, remote system monitoring, and more.
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.
Disadvantages
With the presence of data traffic for servers that typically exceed 70% of the XMPP protocol and nearly 60% of them being repeatedly forwarded, the XMPP protocol currently has a large overhead in the presence of data available to multiple recipients. The new protocol is being studied to alleviate the problem.
The XMPP protocol is encoded as a single long XML file, so it is not possible to provide modified binary data. Therefore, the file Transfer Protocol uses external HTTP as well. If unavoidable, the XMPP protocol also provides Base64 for all data that is encoded with the file transfer. For other binary data encryption sessions (encrypted conversations) or graphical icons (graphic icons) Use the same method as embedded.
Tags: Http, Socket, TCP/IP, tcp/ip,http,socket,xmpp differences, XMPP
article category Http, Socket, TCP/IP, XMPP
The difference between TCP/IP,HTTP,SOCKET,XMPP