当前位置:网站首页>Network protocol concept
Network protocol concept
2022-07-07 11:25:00 【Full stack programmer webmaster】
## Concept
Hypertext Transfer Protocol, Hypertext transfer ( Transfer ) agreement , It is a protocol formulated by the client and server to transmit text . structure WWW The specific three technologies are as follows :
WWW: world wide web, web – HTML: Hypertext Markup Language, Hypertext markup language – HTTP: Hypertext Transfer Protocol, Hypertext transfer ( Transfer ) agreement (HTTP yes TCP/IP Application layer protocol ) – URL: Uniform Resource Locator, Uniform resource locator symbol
> URI: Uniform Resource Identitier, Unified resource identifier ,URL yes URI Subset
## TCP/IP
“` application layer (http/https/websocket/ftp…) => Definition : Text transfer protocol | Transport layer (tcp/udp) => Definition : port | The network layer (ip) => Definition :IP | The link layer (mac& Data packets ) => Definition : Data packets ,MAC Address | Physical layer ( optical cable / cable / Switch / route / terminal …) => Definition : Physics “`
TCP/IP:
– Explain a : Represent the tcp The protocol and ip agreement – Explain two : If you follow the five layer network architecture ,TCP/IP Represents the general name of all protocol clusters except the application layer
TCP/IP connect: TCP/IP Three handshakes of : “` Be marked with syn Data packets of ————-> Be marked with syn/ack Data packets of client <————- server Be marked with ack Data packets of ————–> “`
TCP/IP finish: TCP/IP Four handshakes : “` fin <————- ack client( or server) ————-> server( or client) fin ————-> ack <————- “`
## HTTP message
HTTP The message consists of three parts : – Start Line – Headers – Entity Body
HTTP There are two types of messages : – Request message – response message
### Request message Start Line
grammar : < Method > < request URL> < edition >
#### HTTP Method
+ get: Access to resources , Do not carry http body, Support query parameters , size 2KB + post: Transfer resources ,http body, The default size is 8M,1000 individual input variable + put: Transfer resources ,http body, Resource update + delete: Delete resources , Do not carry http body + patch: Transfer resources ,http body, Existing resources are partially updated + head: obtain http header, Do not carry http body + options: Get supported method, Do not carry http body + trace: track , Return the request loopback information , Do not carry http body + connect: Establish tunnel communication
### response message Start Line
grammar : < Method > < Status code > < The reason the phrase >
#### HTTP Status Code
+ 200: ok + 301: Permanent redirection + 302: Temporary redirection + 303: Temporary redirection , Asked to use get Request resources + 304: not modified, Return cache , It has nothing to do with redirection + 307: Temporary redirection , Strict disobedience post To get + 400: Parameter error + 401: Not through http authentication + 403: forbidden, unauthorized + 404: not found, No resources exist + 500: internet server error, Code error + 502: bad gateway,fastcgi What's coming back web server Don't understand + 503: service unavailable, Service not available + 504: gateway timeout,fastcgi Response timeout
### HTTP Header Fields
Common general head
+ Cache-Control: – no-cache: Do not cache expired caches – no-store: Don't cache + Pragma: no-cache, Do not use cache ,http1.1 Previous history field + Connection: – The control is no longer forwarded to the agent header field – Keep-Alive/Close: Persistent connection + Date: establish http Date of message
Common request headers
+ Accept: Media types and priorities that can be handled + Host: Target host domain name + Referer: Where did the request originate from the original resource URI + User-Agent: The name of the user agent that created the request + Cookie: cookie Information
Common response headers
+ Location: Redirect address + Server: Requested service web server Information about + Set-Cookie: To set up cookie Information – NAME: Key value pairs to set – expires: cookie Expiration time – path: Specify send cookie The catalog of – domain: Specify send cookie Domain name of – Secure: Only https Send next cookie – HostOnly: After designation javascript Can't read cookie + Keep-Alive:
HTTP At the beginning of the agreement, it will be disconnected after each connection TCP Connect , after HEADER Of connection Field definition Keep-Alive(HTTP 1.1 Default Persistent connection ), Representatives will not disconnect if neither party actively disconnects TCP Connect , It reduces every time you create HTTP When connecting TCP Connection consumption .
## Cookie/Session
+ Cookie: The working mechanism is user identification and state management , In order to manage the user's status, the server will pass through the client , Write some temporary data into the device Set-Cookie, When users access services , The service can retrieve the previously stored cookie. + Session: because http It's stateless , Context cannot be maintained between requests , So there it is session As session control , The server stores the user's session information .
## HTTPs
Concept : stay http The agreement adds ssl(secure socket layer) layer .
“` SSL layer | application layer | Transport layer | The network layer | The link layer | Physical layer “`
HTTPS The certification process “`
Initiate request —————————> server Issue a certificate <————————— server Certificate digital signature ( Encrypt with certificate authority public key ) —————————> Certification body Certificate digital signature verification passed client( Built in certificate authority certificate ) <————————— Certification body Public key encryption random cipher string ( The shared secret key of the future ) —————————> server Private key decryption ( Asymmetric encryption ) SSL End of agreement HTTP Agreement start <————————— server( Symmetric encryption ) Shared secret key encryption HTTP —————————> server( Symmetric encryption ) “`
+ Check the certificate certificate : The public secret key of the certificate authority verifies the digital signature of the certificate + Public key encryption establishes a connection : Asymmetric encryption + Shared key encryption
## Websocket
+ be based on http The protocol establishes the connection ,header Of upgrade The field conversion protocol is websocket + Full duplex communication , The client establishes a connection
## HTTP2
+ Multiplexing : Multiple requests share one tcp Connect + Full duplex communication + must https:// + The head of compression + Binary transmission
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113826.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢
The use of list and Its Simulation Implementation
Electron adding SQLite database
The database synchronization tool dbsync adds support for mongodb and es
Input type= "password" how to solve the problem of password automatically brought in
Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)
Antd select selector drop-down box follows the scroll bar to scroll through the solution
90后,辞职创业,说要卷死云数据库
Force buckle 1002 Find common characters
[untitled]
随机推荐
学习笔记|数据小白使用DataEase制作数据大屏
Apprentissage comparatif non supervisé des caractéristiques visuelles par les assignations de groupes de contrôle
'module 'object is not callable error
Multithreaded application (thread pool, singleton mode)
Rolling puddle Uni_ App (VIII)
Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
基于STC8G1K08的0.96寸IIC液晶屏驱动程序
Antd select selector drop-down box follows the scroll bar to scroll through the solution
Audit migration
JS array delete the specified element
Go Slice 比较
There are ways to improve self-discipline and self-control
The post-90s resigned and started a business, saying they would kill cloud database
Vuthink正确安装过程
[untitled]
RationalDMIS2022 高级编程宏程序
Wallhaven wallpaper desktop version
Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
2021-04-08
[C #] the solution of WinForm operation zoom (blur)