The difference between TCP/IP, Http, and socket

Source: Internet
Author: User
Tags file transfer protocol

1 , standard network hierarchy

The network is divided from bottom to top: physical layer, Data link layer, network layer, transport layer, Session layer, presentation layer and application layer.

The following diagram attempts to show the location of the different TCP/IP and other protocols in the original OSI model:

7

Application Layer

such as HTTP, SMTP, SNMP, FTP, Telnet, SIP, SSH, NFS, RTSP, XMPP, Whois, ENRP

6

Presentation Layer

such as XDR, ASN.1, SMB, AFP, NCP

5

Session Layer

For example ASAP, TLS, SSH, ISO 8327/ccitt x.225, RPC, NetBIOS, ASP, Winsock, BSD sockets

4

Transport Layer

such as TCP, UDP, RTP, SCTP, SPX, ATP, IL

3

Network layer

such as IP, ICMP, IGMP, IPX, BGP, OSPF, RIP, IGRP, EIGRP, ARP, RARP, x.

2

Data Link Layer

such as Ethernet, Token Ring, HDLC, Frame Relay, ISDN, ATM, IEEE 802.11, FDDI, PPP

1

Physical Layer

such as line, radio, optical fiber, homing pigeon

This is a very standard network hierarchical relationship, but the TCP/IP protocol simplifies this level,

2 , TCP/IP Protocol Cluster

TCP/IP is usually divided into four layer protocol system, application layer (Telnet, FTP and email, etc.), Transport layer (TCP, UDP), Network layer (IP, ICMP, IGMP, etc.) and link layer (device driver), each layer of each, the lower level is transparent to the upper layer

is an FTP two host running on the local area network, on the same level, both parties have one or more protocols to communicate. First recognize the TCP/IP protocol.

TCP/IP usually referred to as TCP/IP protocol cluster is a set of different protocols grouped together into a protocol cluster, listing four different levels of protocol, F T P is an application layer protocol, T C P is a Transport layer protocol, I p is a network layer protocol, and the Ethernet protocol is applied to the link layer.

In the T C p/i P protocol family, the network layer I p provides an unreliable service. In other words, it simply sends the packet from the source node to the destination node as quickly as possible, but does not provide any reliability guarantees. On the other hand, T C P provides a reliable transport layer on the unreliable I P-layer. In order to provide this reliable service, T C P adopts the mechanism of time-out retransmission, sending and receiving end-to-end acknowledgement packet, etc.

3 , the TCP/IP Simple Understanding of the Protocol

Terminology : TCP/IP stands for Transmission Control Protocol/Internet Protocol, which refers to a series of protocols. "IP" represents an Internet protocol in which TCP and UDP use the protocol to transfer packets from one network to another network. Think of IP as a highway that allows other protocols to travel and find the exits of other computers. TCP and UDP are "trucks" on highways, and the goods they carry are protocols like HTTP, File Transfer Protocol FTP, etc.

4. Drawing comprehension

5. Network Solution

Here are some of the important concepts that are often encountered in a written test or interview and are summarized here.

  One, what is the 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)

Ii. steps 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 the specific client sockets, but in the status of waiting for the connection, real-time monitoring network status, waiting for the client connection request.

2, client request: Refers to the client 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 the server side socket is heard or received the connection request of the client socket, it responds to the request of the client socket, establishes a new thread, sends the description of the server end 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.

 Third, the characteristics 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."

 iv. differences between TCP and UDP (Most of the exams are done.) It's getting rotten. I think--\\)

1, TCP is a link-oriented, although the security of the network instability characteristics determine how many times the handshake can not guarantee the reliability of the connection, but the TCP three handshake at a minimum (in fact, to a large extent guaranteed) to ensure the reliability of the connection;

And UDP is not connection-oriented, UDP transmission data before the connection with the other, the docking received data does not send a confirmation signal, the sender does not know whether the data will be received correctly, of course, there is no need to resend, so that UDP is a non-connected, unreliable data transmission protocol.

2, also due to 1 of the characteristics of the said, so that the cost of UDP smaller 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 programmers can manually authenticate UDP data, such as the sender of each packet number and then by the receiver to verify ah what?

Even so, UDP does not have a TCP-like "three-time handshake" on the package of the underlying protocol to achieve the transmission efficiency that TCP cannot achieve.

The difference between TCP/IP, Http, and socket

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.