TCP / IP network protocol acquaintance

First, what is the protocol?

Agreement is between two or more objects to one or more of the requirements set by the agreement, that at what time, what the situation what to do.

Example: Xiao Qiang Xiao Ming and agreed together on weekends to play the Sundance Kid game consoles, but if there are power outages delved again into the nest.

Second, what is the TCP / IP protocol?

TCP / IP protocol is to meet the communications needs of the world's thousands of network devices designed for a convention.

For example: You download a movie from a Web site, how to achieve it?

First web server and your computer to recognize each other,需要 IP协议;

For thousands of kilometers across the Internet to find a path leading to your computer,需要路由协议;

In order not to lose data transfer film disorder was repeated,需要 TCP协议;

Also you can receive a movie with the FTP protocol. Single agreement is a single agreement, TCP as an example,

Timeout agreed how to do communication?

Data loss how to do?

Disorder how to do?

Network congestion how to do? And so on.

Three, TCP / IP protocol Why so many?

Agreement is not much, but more than the needs of each specific protocols are generated from the actual demand. More demand, the more problems, in order to solve one problem, but there have been a number of agreements.

For example: general payment page is https, because security needs;

Multicast occurs because the network demand requirements;

IP over AOS occurs because the astronauts demand convenient access to the Internet and so on.

Four, TCP / IP protocol Why layered?

"Layered" thinking can be applied to many areas, it is an effective way of simplifying complex issues.

The benefits of protocol layering: layer protocol can focus on this issue, the direct use of underlying services provided, while providing services to the upper layers and each layer changes do not affect other layers.

For example:

Classic four-layer model: 应用层—>传输层—>网络层—>物理层(链路层)

Fifth, how TCP / IP protocols Easy?

要点1: Remember "network protocol due to demand generated to solve practical problems for the purpose", so learning a protocol must understand its application scenarios and proposed purpose.

要点2:Choose a good introductory tutorial. I highly recommend Professor Xie Xiren "computer network", the concept of the book is clear, clear thinking, not superficial and not very thorough and exhaustive, and now has been out to the sixth edition of the book read no less than three times.

要点3:For a protocol-depth understanding of its message format is the key to learning. After the agreement is programmed "data structure + algorithm", message format is the "data structure."

要点4:Be sure to hands-on labs, which can deepen understanding of the agreement. For example, you can use a network packet capture (eg wireshark) learning algorithms for a protocol, such as ARP discovery process, TCP handshake protocol, the principles of TFTP file transfer. Also you can network programming, such as a simple network attack software production.

Six, TCP / IP layered:

7. Each protocol layer packing and unpacking process:

When the browser sends information to the service during a communication protocol, it will be divided into four layers:

First, the application layer (http protocol), some of the information package to be transmitted.

Secondly, the transport layer (tcp protocol), TCP protocol of the application layer data package.

Then, to the network layer (protocol ip), find the corresponding server by ip.

Finally, the link layer (physical data transmission media through).

One on each layer will be packaged right.

Eight browser to access the web page of the entire process:

Nine, for example: shopping online request process

1. The trend between the layers

The client (browser) -> application layer (http, https, DNS) -> transport layer (TCP, UDP) -> network layer (IP) -> Physical Layer -> Server

-> Physical layer -> Network Layer -> Transport Layer -> Application Layer -> specific application processing

2. Specific request procedure

You start by entering in the browser https://www.kaola.com , this is a URL. Browser only know the name

Is "www.kaola.com", then it opens the address book to find (DNS), finds the corresponding IP (106.114.138.24) address,

Know the specific IP address, browser start packing requests (HTTP):

After the application layer package, the package will browser application layer to the next layer to complete, is achieved by programming socket. The next layer is the transport layer (TCP, UDP), TCP protocol which will have two ports, a browser is listening ports, one electricity supplier server listening port. Operating systems are often judged by the port, which process it gets the package should be given.

传输层封装完毕后,浏览器会将包交给操作系统的网络层。网络层的协议是 IP 协议。在 IP 协议
里面会有源 IP 地址,即浏览器所在机器的 IP 地址和目标 IP 地址,也即电商网站所在服务器的
IP 地址。

于是操作系统将 IP 包交给了下一层,也就是MAC 层。网卡再将包发出去。由于这个包里面是
有 MAC 地址的,因而它能够到达网关。
网关收到包之后,会根据自己的知识,判断下一步应该怎么走。网关往往是一个路由器,到某个
IP 地址应该怎么走,这个叫作路由表。

走到最后一个网关后,通过 IP 找到具体的机器,通过端口找到对应的应用进行处理该笔请求。

3.服务器端处理流程

参考资料:

①书籍《图解HTTP》

②极客时间|趣谈网络协议 --刘超

Guess you like

Origin www.cnblogs.com/tester-ggf/p/11962943.html