First, the computer network TCP / IP model
Difference 1.TCP and UDP protocols
a connection-based and connectionless;.
. B requirements for system resources (TCP more, UDP less);
c.UDP relatively simple program structure;
. D stream mode and packet mode data;
e.TCP ensure data correctness, UDP packet loss may, TCP order to ensure that data, UDP is not guaranteed. UDP (scenario IP telephony, real-time video conference)
Two, TCP three-way handshake and the four wave
Three-way handshake :
First handshake, sending a SYN packet, and then enters state SYN_SEND
Second handshake, ACK_SYN packet transmission, and then enters the SYN_RCVD (acceptable) status
Third handshake, A has entered the ESTABLISHED (established) state
Why do we need three-way handshake?
Three-way handshake aim is to establish a reliable communication channel, the main purpose is ** Both sides confirmed their own and each other's transmission and receiver normal **
Four wave:
1. A与B交谈结束之后,A要结束此次会话,对B说:我要关闭连接了(seq=u,FIN=1)。(第一次挥手,A进入FIN_WAIT_1)
2. B收到A的消息后说:确认,你要关闭连接了。(seq=v,ack=u+1,ACK=1)(第二次挥手,B进入CLOSE_WAIT)
3. A收到B的确认后,等了一段时间,因为B可能还有话要对他说。(此时A进入FIN-WAIT-2)
4. B说完了他要说的话(只是可能还有话说)之后,对A说,我要关闭连接了。(seq=w, ack=u+1,FIN=1,ACK=1)(第三次挥手)
5. A收到B要结束连接的消息后说:已收到你要关闭连接的消息。(seq=u+1,ack=w+1,ACK=1)(第四次挥手,然后A进入CLOSED)
6. B收到A的确认后,也进入CLOSED。
为什么要四次挥手?
根本原因是,一方发送FIN只表示自己发完了所有要发的数据,但还允许对方继续把没发完的数据发过来
三、HTTP协议
1.TCP属于传输层,用于数据传输 http属于应用层,用于数据的封装
四、GET请求和POST请求的区别
* 数据的类型、大小是否有限制:GET请求有限制;POST请求没有
* 安全性:GET请求提交的数据都在URL中,可见,不安全;相对来说POST请求更加安全
* JS中获取参数上的区别:GET请求在JS中是通过```Request.QueryString["xxx"]```获取URL中的参数,而POST请求在JS中是通过```Request.Form["xxx"]```获取Form表单中的参数