Network TCP / IP

 

 

 

TCP/IP

OSI 's "realization": TCP / IP

OSI seven-layer model

TCP / IP concepts-layer model

Features

TCP / IP protocol suite.

Application layer

Application layer

File transfer, e-mail, file services, virtual terminal

FTP,HTTP,SMTP,SNMP,Telnet

Presentation layer

Data formatting, code conversion, data encryption

no

Session Layer

Lift or establish a connection with other contacts

no

Transport Layer

Transport Layer

Provide end interface

TCP,UDP

Network layer

Network layer

Routing the data packet

IP,ICMP,RIP,OSPF,IGMP

data link layer

Link layer

Yo even frames and the transmission error detection function address

SLIP,CSLIP,PPP,ARP,RARP

Physical Layer

Binary data format of data transmitted on the physical medium

ISO2110,IEEE802,IEEE802.2

 

 

 

Common TCP port number has: HTTP 80, FTP 20/21, Telnet 23, SMTP 25, DNS 53 and the like; commonly reserved UDP port number has: DNS 53, BootP 67 (server) / 68 (client), TFTP 69, SNMP 161 and so on.

TCP three-way handshake

TCP Flags

      URG: Urgent Pointer flag

      ACK: acknowledgment number flag

      PSH: push flag

      RST: Reset the connection flags

      SYN: synchronous serial number, the process for establishing a connection

      FIN: finish flag, for releasing the connection (1: sender is no longer sending data)

 

"Handshake" to establish a connection, flow chart TCP three-way handshake is as follows:

 

 

 

In the TCP / IP protocol, TCP protocol provides reliable connectivity services, using 3-way handshake to establish a connection. (Sequence number i.e. the figure above x, y values)

1, the first handshake: a connection is established, the client sends a SYN packet (syn = j) to the server, and enters SYN_SEND state, waiting for the server to confirm.

2, second handshake: server receives a SYN packet, must confirm the customer SYN (ack = j + 1), while themselves sends a SYN packet (syn = k), i.e., SYN + ACK packet, then the server into SYN_RECV status.

3, third handshake: the client receives the SYN + ACK packet to the server, the server sends an acknowledgment packet ACK (ack = k + 1), this packet is sent, the client and server into the ESTAB_LISHED state, complete three-way handshake.

 

TCP talk about the four wave

Wave to terminate the connection, TCP flowchart four wave follows:

 

 

TCP uses four times and waved to release the connection

1, the first wave: client sending a the FIN, for closing the data transfer to the client's server, client enters FIN_WAIT_1 state.

2, the second wave: the server receives FIN, ACK to send a Client, confirmed that the received sequence number plus 1 (the same SYN, FIN a occupy a sequence number), to enter the server CLOSE_WAIT state.

3, the third wave: server sending a the FIN, for closing the data transfer to the client's server, server enters LAST_ACK state.

4, the fourth wave: the client receives the FIN, TIME_WAIT state into the client, and then sends an ACK to the server, confirmation of the received sequence number + 1, server enters the CLOSED state, four complete wave. (Client will be closed after 2MSL time)

 

TCP connection must go through 2MSL before the real release?

Sure you have enough time and they'll get an ACK packet

   Avoid confusion connect the old and new

 

UDP Introduction

UDP Features

1, the non-connection-oriented

2, does not maintain the connected state, supports simultaneous transmission of multiple clients to the same message

3, only packet header 8 bytes, smaller overhead

4, the throughput is limited only by the data generation rate, the transmission rate and performance of the machine

5, a best effort delivery, does not guarantee reliable delivery, no need to maintain complex link state table

6, the message information for the message, the application does not split or merged, filed

in conclusion

      TCP             UDP

1, connection-oriented vs connectionless

2, reliability vs no

3, orderliness vs No

4, come quickly slow vs fast (applicable to online media broadcasting, etc.)

5, the order of (20 bytes) vs 8 bytes

  

TCP sliding window

RTT and RTO

   RTT: transmitting a received data packet corresponding to the ACK, the time taken for

   RTO: retransmission interval (ack client sends a default start a timer, the timer starts when the server does not return packet corresponding to a new transmission at a certain time) (calculated elapsed RTT RTO)

 

HTTP Profile

Hypertext Transfer Protocol (HTTP) main features

1, supports the client / server model

2, quick and easy

3, a flexible (of any type of data transmission)

4, no connection (a connection limit per request, and the server processes requests the client after the client receives a response that is off to save transmission time .http1.1 default connection server default wait long before a certain time DISCONNECT ensure connectivity features)

5, stateless (stateless protocol handling things)

 

Step request / response

1, the client connects to the Web server

2, transmits an HTTP request

3, the server receives the request and returns an HTTP response

4, connected to a TCP connection release

5, the client browser parses the HTML content

 

In the process browser, enter the URL press Enter experiences

1, DNS resolve

2, TCP connection (to establish a TCP Once you find the IP address and port and server connections)

3, an HTTP request

4, the server processes the request and returns the HTTP packet

5, the browser parses rendering pages

6, the connection ends

 

HTTP status code

Five possible values

1,1 ××: just information - indicating that the request has been received, processing continues

2,2 ××: success - indicates that the request has been successfully received, understood, accepted

3,3 ××: Redirection - to fulfill the request must go a step further

4,4 ××: Client Error - The request syntax error or a request can not be achieved

5,5 ××: server-side error - server failed to achieve a legitimate request

 

Common status codes

1,200: normal return information - Success

2,400 (bad request): The client requests a syntax error, it can not be understood by the server

3,401 (unauthorized): unauthorized request, the status code must be used with www-authorized header field

4,403 (forbidden): server receives the request but is refusing to provide services

5,404 (not found): requested resource does not exist

6,500 (internal server error): unexpected server error occurred

7,503 (server unavailable): The server is currently unable to process the client's request, may return to normal after a period of time.

  

 

POST request and GET request

Three levels to answer

1, HTTP packet level: GET request information on the URL, POST on the packet body

2, the database level: GET accord of idempotent (a database operation and multiple operation is the same) and security, POST does not comply

3, other levels: GET can be cached, is not stored, POST

 

 

The difference between Cookie and Session

Cookie 's Profile

1, is a special message sent by the server to the client, in the form of text stored in the client

2, when the client requests again, the cookie will postback

3. When the server receives, it parses cookie content to generate corresponding end customers

 

Cookie settings and transmission process

 

 

 

Session Introduction

1, the mechanism of the server, the server information stored on

2, parsing client requests and operation session id, save state information needed

 

Session implementation

    Use the cookie to achieve

 

 

 

Cookie difference and the Session

1, cookie data is stored on the customer's browser, session data stored on the server

2, session cookie relative to safer

3, taking into account the burden lighten the server should use the cookie

 

 

The difference between HTTP and HTTPS

 

1, HTTPS need to apply for CA certificates, HTTP does not require

2, HTTPS ciphertext transmission, HTTP cleartext

3, different connectors, HTTPS port 443, HTTP port 80

4, HTTPS = HTTP + encryption + authentication + integrity protection, the more secure HTTP

 

 

About Socket

 

 

 

 

 

 

Common TCP port number has: HTTP 80, FTP 20/21, Telnet 23, SMTP 25, DNS 53 and the like; commonly reserved UDP port number has: DNS 53, BootP 67 (server) / 68 (client), TFTP 69, SNMP 161 and so on.

 

Guess you like

Origin www.cnblogs.com/long88-club/p/11415296.html