Network protocol - Communications protocol

Network protocols | Communication protocol

Recently in learning and thinking, what a thing to benefit long-term learning it?
I think, can do, the answer in the closing remarks -

Foreword

目前所有的文章思想格式都是:知识+情感。
知识:对于所有的知识点的描述。力求不含任何的自我感情色彩。
情感:用我自己的方式,解读知识点。力求通俗易懂,完美透析知识。

text

All protocols need to have the three elements of the agreement .
As the network protocol, just to name a knowledge point, apparently no taste, so I used the question and answer method.

Three elements of the agreement

  • The syntax is the contents of this section to comply with certain rules and formats.
    • For example, the brackets in pairs, to end with a semicolon and so on.
  • Semantics , it is this piece of content to represent some kind of sense.
    • Such as digital subtracting the number is significant, minus the digital text in general does not make sense.
  • Order , before doing that, after doing.
    • For example, you can add some value, then subtract a certain value.

Note: The three elements of the protocol can communicate with the computer guarantor no obstacle -

The origin of network protocols

Question: understand the agreement between computers and people, understand what the protocol is, how to control multiple machines?

ANSWER: By agreement can only get a machine that want to control multiple machines, network protocol must pass before they can collaborate with each other so that multiple machines together to accomplish one thing.

On the network protocol

Question: how the browser displays the page data do?

Answer: The browser may display a page, just as the Internet protocol adopted. Then take a look to see the entire process:

1) Enter the browser URL: www.baidu.com

2) browser only know the domain name, do not know the IP and port access.

a: this time will first look for any IP address in DNS host their own DNS cache table hosts file,

b: If you do not find, you will go to local DNS server to find;

c: If not found, it will go to the root domain name server to find;

d: If you do not find, and he went looking for the top-level domain name server;

e: If you do not find, and he went looking for the secondary domain name server (this must be found, if still not found, it indicates there is no live registered the domain name)

f: Just find the first will set the appropriate domain names and corresponding IP information is cached in the local DMS server, making it easy to find the next;

g: just find, will be followed by the corresponding domain names and corresponding IP information is cached in the hosts file next time to find;

h: In this case the browser will know that the access to the corresponding IP address.

g: general server port 80 is the default port (port 80 this port belongs to a public network, you can not change they want to change, you can not change !!!)

3) has been obtained based on the IP information, the browser will start packing request information packets this time can be obtained using http / https encapsulated data. DNS, HTTP, HTTPS is an application layer, or five. At this time, the data is encapsulated information request, and does not include port ip.

a: For general requests, usually http protocol;

b: For payment requests, using the https protocol.

4) four-layer, i.e. the transport layer, receiving data packets from the application layer, packaged programming through socket. At this point will add the source port and destination port information (detection port itself). Operating systems are often judged by the port, which process it gets the package should be given. There are two transport layer protocols:

a: TCP, a connection-oriented protocol, in this way it is generally

b: UDP, a connectionless protocol, when the probe request routing by using udp.

5) three layers, i.e. the network layer, receiving a packet from the transport layer. By IP protocol, add the destination and source IP information IP information. The operating system will make the appropriate judgment for the current destination IP.

6) Layer, i.e. the data link layer, receiving packets from the network layer. Package goal / Mac address and the Mac address of the gateway host.

a: time when the present target IP unit belong to the same local area network, will be directly used as the ARP protocol, the broadcast mode, the MAC address of the target host ip by way roar. For datagram encapsulation.

b: the present time when the target IP unit does not belong to the same local area network, will be directly used as the ARP protocol, a broadcast manner, the current gateway (typically is 192.168.1.1/24) MAC address by way roar. For datagram encapsulation.

c: When the native operating system starts, it will be configured DHCP protocol IP address, subnet mask, default gateway information.

7) physical layer, receiving data packets from the data link layer, the packet switch card using a binary sent out.

8-1) If the current local area network, the target host directly receives the requested information.

8-2) If it is not the current local area network, the data arrives at the gateway, the gateway will remove the Mac address, and then remove the IP header, check exemplar, a position where hair look.
General gateway is a router, a 3-layer devices, and routers will communicate with each other, how to get where they need to go, using OSPF and BGP routing protocol.
At this point we continue to use the ARP call another LAN gateway, get his Mac address and the Mac address of the current datagram changed to target Mac gateway address.

9) of the packet destination gateway, remove Mac head, remove the head ip is current LAN, this time using the ARP protocol call target host ip, Mac request information, and then changed to the first Mac mac first target host.

10) At this time, the target server host acquires the bag, remove the Mac head, remove the ip head, handed the bag to the TCP layer, there will be a port corresponding process listens for requests. At this first operation carried a reply packet, explain this to me that you have received, you wait for my news!

a: If the unit has not been returned until the host server information, then the time TCP resends once, waits until it receives a reply so far. You do not need to refresh the page, automatic operation.

b: When the TCP problem, this time the browser application layer request for retransmission.

c: the target server, Tomcat will generally have a similar receptionist, handling information requests, distributed processing corresponding process, and collect the results process. The use of RPC calls can be realized, based on the HTTP protocol HTTP packets inside, there is a remote procedure call directly encapsulated TCP packet inside.

After 11) ends the processing request destination server, re-encapsulated data packet, the source simply interchanged ip ip with the target, the source and the target Mac Mac interchangeably.

12) go through a long journey, this machine to obtain the requested data, the browser will get the response data for rendering display,

Detailed network hierarchy

Question: We all know that the network is hierarchical, but why should layered it?

Answer: a hierarchical network, which belongs to the idea of ​​divide and rule, each layer carry out their duties. Then take a look, each layer is how it works.

1) When the packets through the network when the network port, if the network port is configured promiscuous mode, all packets will have to take incoming process

2) When the received data packets on the network, grab down the mac see if it is his own master,

a: mac not their host, discards

b: Mac is the host of his own, it sent three processing

3) three-layer, network layer, two-story brought to see the package, won first see if the host ip ip's,

a: ip not their host, the data forwards (this is the problem of conflict mac)

b: ip is the host of its own, it is sent to the four treatment

4) four layers, namely the transport layer, TCP or UDP protocol to see if this is a tcp, normal package directly to the listening port of the process, if it is initiated or a response packet, when the host need to reply to a received packet the confirmation message.

5) five layers, i.e. the application layer, the corresponding processing packets in a different process.

6) If the application layer continues to request data to the data layers of the package sent out.

The relationship between the network layers

Issue: Whether the network layer 7 or 5 layers, or 4 layers, each layer of what the relationship between the upper layer and the next layer is?

Answer: the network hierarchy, the next layer, will be received, from the upper layer packet encapsulation. A layer, the next layer from the packet data will be unpacked.
Each layer only in the event of his work in this layer of.

As long as the network is running the package are complete. There can be no lower upper, upper absolutely impossible not lower.

All packets on the network, must be encapsulated IP layer and the MAC layer, or advertised packets.

Question: network transmission, the top layer at the time of transmission, and the bottom are doing?

Answer: As long as the upper layer to contract, the lower will work, and need mac encapsulation IP packets can be sent out from the network port.

Conclusion

Network protocol, I suppose I feel that as a ready fighting in the front line in the programming world, or as a technician, must master the ability to comprehend their own time but unfortunately too late!
However , the first step is always himself, and also go all the way ~

Guess you like

Origin www.cnblogs.com/Kate-liu/p/11285898.html