The network protocol network infrastructure ----

 

 

A. Operating system foundation

  Operating System: (Operating System, referred to as OS) is to manage and control the computer hardware and software resources of the computer program is run directly on the "bare metal" of the basic system software, any other software must be in order, with the support of the operating system run.

NOTE: Your computer (hardware) -> os-> Applications

 

II. Network communication theory

 

2.1 nature of the Internet is a series of network protocols

A hard has the operating system, then install the software you can normally use, but you can only own use

As such, everyone has to own a machine, but isolated from each other

How can we play together

However, internet exactly?

In fact, communication between two computers and two people call the communication between the principle is the same (China there are many areas, different regions have different dialects, for all the Chinese people can understand, we unified speak Mandarin)

Putonghua is the standard for communication between Chinese domestic people, is that if people of both countries exchange it?

The problem is, you can not ask a human / computer to master the language / standards around the world, so with the world unified communications standard: English

 

CONCLUSION: English to become a unified standard for all communications in the world, as if the computer located in the people around the world, the internet connection between two computers is actually

A series of uniform standards, which is called Internet Protocol, the nature of the Internet is a series of agreements, collectively called 'Internet Protocol' (Internet Protocol Suite).

Internet Protocol functions: how to define the computer access internet, and the computer communication standard of internet access.

 

2.2 osi seven layer protocol

Internet protocol according to different functions into seven or osi tcp / ip five or tcp / ip four

 

Each run common physical device

 

 

2.3 tcp / ip five models to explain

We application layer, presentation layer, session layer and the application layer for, from the perspective of tcp / ip five protocols to illustrate the origin and function of each layer, each of the main protocols clear

To understand the principles of the Internet communications.

First, the user perceives only the uppermost layer of the application layer, each layer from top to bottom are dependent on the next level, so we began to cut from one the most, is better understood

Each layer run a specific protocol, the higher up closer to the user, the more down closer to the hardware

2.3.1 Physical Layer

The origin of the physical layer: the above-mentioned, in order to play with isolation between the computer, it must access internet, implying that must be completed between the computer network

Physical layer functions: main transmitting low voltage (electric signal) based on the electrical characteristics, a high voltage corresponding to the number 1, a low voltage corresponding to the digital 0

 

2.3.2 Data Link Layer

The origin of the data link layer: a simple electrical signals 0 and 1 does not make any sense, must provide an electrical signal how many bits a groups of what it means

The data link layer: Defines the electric signal grouping

Ethernet protocols:

Early on each company has its own grouping, and later formed a unified standard that Ethernet protocol ethernet

ethernet provisions

  • A set of electrical signals constitute a data packet, called 'frame'
  • Each data frame is divided into: a header and a data head data of two parts
       head                        data                             

 

fixing head comprising :( 18 bytes)

  • Sender / source address of 6 bytes
  • Recipient / destination address, six bytes
  • Data type, six bytes

46 byte data comprising :( minimum, maximum 1500 bytes)

  • Specific contents of the packet

head shortest length + data length = 64 bytes, 1518 bytes maximum, it exceeds the maximum limit fragment transmission

mac address:

Source and destination addresses contained in the head Origin: ethernet predetermined internet access devices must have the card, the transmission and receiver means is address card address, i.e. the address mac

mac address: each NIC are fired on a world unique mac address, a length of 48 binary factory, generally indicated by 12 hexadecimal numbers (the first six numbers is the vendor, after six pipelined number)

broadcast:

With mac address, two hosts on the same network can communicate with the (host obtains a mac address of another host via arp protocol)

The most primitive way of using ethernet, broadcast communication mode, i.e. the basic computer communication by roar

 

2.3.3 Network Layer

The origin of the network layer: With ethernet, mac address, broadcast transmission mode, the computer in the world can communicate with each other, the problem is that the Internet is a worldwide

Isolated from each other a small local area network composed, so if all communications are broadcast using Ethernet, then a machine to send packets over the world will receive,

This problem is not just inefficient, it would be a disaster

On FIG Conclusion: we must find a way to distinguish between the computer belonging to the same broadcast domain, which is not, if it is transmitted by means of broadcast, if not,

On the way (to distribute packets to different broadcast domain / subnet) using the route, mac address are indistinguishable, it is only related with vendors

Network layer function: the introduction of a new address is used to distinguish between different broadcast domain / subnet, this address is the network address

IP protocol:

  • Agreement called network address ip protocol, which defines the address of the called ip address, v4 version i.e. widely used IPv4, which provides 32-bit network address is represented by binary
  • Range 0.0.0.0-255.255.255.255
  • An ip address written as four decimal numbers generally, for example: 172.16.10.1

ip address into two portions

  • Network components: identify the subnet
  • Host part: identify the host

Note: pure ip address only identifies the type ip address from the network or host portion of a part can not identify which ip subnet

Example: 172.16.10.1 and 172.16.10.2 and both can not be determined in the same subnet

Subnet Mask

The so-called "Subnet Mask", a parameter that represents the sub-network features. It is identical in form to the IP address is a 32-bit binary number, which is a part of all network, host-part 0. For example, IP address, 172.16.10.1, if known network is a front portion 24, the main part 8, the subnet mask is 11111111.11111111.11111111.00000000 written as a decimal is 255.255.255.0.

 

Know "Subnet Mask", we will be able to judge whether any two IP addresses in the same subnet. The two methods are the IP address and subnet mask were the AND operation (two digits are 1, the operation result is 1, and 0 otherwise), and compare the results are the same, and if so, to show that they are in the same sub network, otherwise it is not.

 

For example, a known IP address 172.16.10.1 and 172.16.10.2 subnet mask is 255.255.255.0, ask whether they are in the same subnet? Both AND operation with the subnet mask, respectively,

172.16.10.1:10101100.00010000.00001010.000000001

255255.255.255.0:11111111.11111111.11111111.00000000

AND operation results obtained network address: 10101100.00010000.00001010.000000001-> 172.16.10.0

 

172.16.10.2:10101100.00010000.00001010.000000010

255255.255.255.0:11111111.11111111.11111111.00000000

AND operation results obtained network address: 10101100.00010000.00001010.000000001-> 172.16.10.0

The result is 172.16.10.0, so they are in the same subnet.

In summary, the role of IP protocol There are two, one is assigned an IP address for each computer, and the other is to determine which address in the same subnet.

ip packet

ip packet is also divided into head and data portions are not required to define a single ip packet fields, directly into the data portion of the Ethernet packet

 

head: 20 to 60 bytes in length

data: up to 65,515 bytes.

Ethernet packets and "data" section, only a maximum of 1500 bytes. Therefore, if the IP packet exceeds 1500 bytes, it will need to be split into several Ethernet packets, transmitted separately.

 

Ethernet header                ip head                                     ip data                                

 

 

 ARP protocol

arp protocol Origin: basic computer communication by a roar that broadcast the way, all the upper package to be the last package on the Ethernet header and then sent via Ethernet protocol, Ethernet protocol when talking about, I learned that the door

Mac broadcast communication is based on the realization of the computer at the time of contracting, acquiring its own is easy mac, mac how to obtain the target host, you need arp protocol

arp protocol functions: send a broadcast packet, the destination hosts mac address

 

Protocol works: Each host ip is known

For example: Host 172.16.10.10/24 access 172.16.10.11/24

A: First distinguish themselves through which the subnet ip address and subnet mask

Scenes Packet Address
The same subnet Target host mac, the target host ip
Different subnets Gateway mac, the target host ip

 

 

 

II: Analysis 172.16.10.10/24 and 172.16.10.11/24 in the same network (if not the same network, then the following table for the target ip 172.16.10.1, was acquired by arp mac gateway)

  Source mac Target mac Source ip Target ip Data section
Sending host Sending end mac FF: FF: FF: FF: FF: FF 172.16.10.10/24 172.16.10.11/24 data

 

 

III: This package will be sent by broadcasting in the network from which the transmit side, after the host receives all packets disassembled, found ip for their target, in response to, return to their mac

 

2.3.4 Transport Layer

The origin of the transport layer: ip network layer to help us distinguish between subnets, mac Ethernet layer to help us find the host, and then we use are applications, may also open qq on your computer, Storm video, and other applications program,

Then we find the ip and mac with a specific host, how to identify applications on this host, the answer is a port, a port that is associated with the application of the card number.

Transport layer functions: establishing a communication port to port

Added: 0-65535,0-1023 port range for the port occupied by the system

tcp protocol:

Reliable transmission, TCP packet length is not limited, and can be theoretically infinite, but in order to ensure the efficiency of the network, typically the length of the TCP packet does not exceed the length of the IP packet, to ensure that a single TCP packet re-segmentation is not necessary.

Ethernet header ip head               tcp head               data                                                    

 

udp protocol:

Unreliable transport, "header" section of only a total of eight bytes, a total length of no more than 65,535 bytes, exactly into an IP packet.

Ethernet header ip head                      udp head                            data                                           

 

tcp packets

tcp three-way handshake and four wave

 

2.3.5 Application Layer

The origin of the application layer: the user is using the application, are working at the application layer, is the development of the Internet, everyone can develop their own applications, a variety of data, data must be provided in the form of good organization 

Application layer functions: a predetermined data format of the application.

Example: TCP protocol data can be transferred to various programs, such as Email, WWW, FTP and the like. So, there must be agreement provides different e-mail, Web pages, FTP data format, these application protocols constitute the "application level."

 

 

2.3.6 socket

We know that a prerequisite if the two processes need to be able to be able to communicate basic uniquely identifies a process, in the local process communication, we can use the PID to uniquely identify a process, but only two PID process locally unique network PID conflict a great chance, this time we need to open up that path, and we know the ip address of the IP layer uniquely identify the host, and TCP layer protocol and port number uniquely identify a host process, so we can use the ip address + protocol and port number that uniquely identifies a process network.

After the process of the network can be uniquely marked, they can use the socket to communicate, what is the socket it? We often translated into socket sockets, socket is an abstraction layer between the application layer and the transport layer, it is the TCP / IP layer of abstraction for the complex operations a few simple interface layer calls have been achieved with the supply process in the network communication.

socket originated in UNIX, in thinking everything is a file Unix philosophy, socket is a "open - Read / Write - Off" mode of implementation, server and client are maintained a "file" in the open after the connection is established, you can to write their own content for other file read or read other contents, close the file at the end of the communication.

 

III. Communication between the network

I want to achieve communication network, each host need to have four elements

  • IP address of the machine
  • Subnet Mask
  • IP address of the gateway
  • DNS IP addresses

It acquired four elements are two ways

1. Static Acquisition

That manual configuration

2. Dynamic acquisition

Obtained by dhcp

Ethernet header ip head udp head dhcp packet

 

(1) foremost "Ethernet header", is provided originator (native) and the MAC address of the recipient (DHCP server) MAC address. The former is the MAC address of the machine card, which then do not know, fill a broadcast address: FF-FF-FF-FF-FF-FF.

 

(2) behind the "IP header", and set the IP addresses of the recipient of the message sender. At this time, for both, the machine did not know. Thus, the message sender's IP address to 0.0.0.0, IP address of the receiver is set to 255.255.255.255.

 

(3) the last "the UDP header", set the port and the receiver port of the message sender. This part is good agreement DHCP, message sender port 68, port 67 is the receiver.

 

After the packet has been constructed, it can be issued. Ethernet is a broadcast transmission, every computer on the same subnet have received this package. Because the MAC address of the recipient is FF-FF-FF-FF-FF-FF, I can not see who is sent, so the computer each receive this package, must also analyze the IP address of the packet to determine not sent to their own. When you see the message sender IP address is 0.0.0.0, the recipient is 255.255.255.255, then DHCP server knows "this package is sent to me," while other computers can discard the packet.

 

Next, DHCP server reads the data content of this package, assign an IP address, send back a "DHCP response" packet. This structure is similar to the response packet, MAC address, the Ethernet header is both card address, IP address of the IP header is the IP address of the DHCP server (originator) and 255.255.255.255 (receiver), UDP header port 67 (originator) and 68 (receiver), the specific parameters of the requester IP address assigned to the network and this is included in the Data section.

 

The newly added computer receives this response packet, so they know their IP address, subnet mask, gateway address, DNS server, etc. parameters

 

IV. Network communication flow

1. The machine acquires

  • IP address of the machine: 192.168.1.100
  • Subnet Mask: 255.255.255.0
  • Gateway IP address: 192.168.1.1
  • IP address of the DNS: 8.8.8.8

2. Open your browser and want to access Google, the URL in the address bar: www.google.com.

3.dns protocol (based on udp protocol)

 

13 root dns:

A.root-servers.net198.41.0.4 US
B.root-servers.net192.228.79.201 United States (the other support IPv6 )
C.root-servers.net192.33.4.12 France
D.root-servers.net128.8.10 .90 US
E.root-servers.net192.203.230.10 US
F.root-servers.net192.5.5.241 United States (the other support IPv6 )
G.root-servers.net192.112.36.4 US
H.root-servers. net128.63.2.53 United States (the other support IPv6 )
I.root-servers.net192.36.148.17 Sweden
J.root-servers.net192.58.128.30 US
K.root-servers.net193.0.14.129 Britain (another support IPv6)
L.root-servers.net198.32.64.12 US
M.root-servers.net202.12.27.33日本(another support IPv6)

 

The domain name defines: http: //jingyan.baidu.com/article/1974b289a649daf4b1f774cb.html

Top-level domains: the .com, .net, .org, .cn top-level domain is an international, etc., according to the current international Internet domain name system, the international top-level domains are divided into two categories: generic top-level domain (gTLD) and geographic top-level domain (ccTLD ) two kinds. GTLDs are domain names "COM", "NET", "ORG", "BIZ", "INFO" such as ending, by foreign companies responsible for the management. Geographical top-level domain is the country code for the end of the domain name, such as "CN" on behalf of China, "UK" on behalf of the United Kingdom. Geographical top-level domains are generally the responsibility of the management of each country or region.

Two domain names: top-level domain is a second level domain name based on the geographical domain, second-level domain analogy China has, .com.cn, .net.cn, .org.cn, .gd.cn and other sub-domain name is the. subdomains of the parent domain name, the domain name is abc.com analogy parent, or child domain is the www.abc.com * .abc.com.
Generally, a record is the second-level domain of the domain name, a domain name such as alidiedie.com, www.alidiedie.com which is more commonly used recording, this is usually the default, but similarly * .alidiedie.com domain to all the called two alidiedie.com

 

 

4.HTTP content portion, something like this:

 

GET / HTTP/1.1
Host: www.google.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1) ……
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8
Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3
Cookie: … …

 

We assume that the length of this section is 4960 bytes, it will be embedded in the TCP packet into.

 

5 TCP protocol

 

TCP packet need to set the port, the recipient (Google) default HTTP port 80, the sender (native) port is an integer between 1024-65535 a randomly generated, is assumed to be 51,775.

TCP packet header length is 20 bytes, plus the embedded HTTP packet, the total length becomes 4980 bytes.

 

6 IP protocol

 

Then, TCP packet re-embedding IP packet. IP packets need to set the IP address of both, as is known, the sender is 192.168.1.100 (native), the receiver is 172.194.72.105 (Google).

IP packet header length is 20 bytes, plus embedded TCP packet, the total length becomes 5000 bytes.

 

7 Ethernet protocol

 

Finally, IP packet embedded in an Ethernet packet. Ethernet packets need to set both the MAC address, sender MAC address-based machine, the recipient is a MAC address of gateway 192.168.1.1 (obtained by the ARP protocol).

Data portion of the Ethernet packet, the maximum length of 1500 bytes, and now the IP packet length is 5000 bytes. Thus, IP packet must be split into four data packets. Since each packet has its own IP header length (20 bytes), the IP packet data of the four packets were 1500,1500,1500,560.

 

 

8 in response to the server

 

After forwarding multiple gateways, Google's servers 172.194.72.105, I received four Ethernet packets.

The number of the IP header, Google will put together four packets, pulling the full TCP packet, and then read out the inside of the "HTTP request", and then make a "HTTP Response", and then sent back to the TCP protocol.

After the unit is received the HTTP response, the web page can be displayed to complete a communications network.

 

Guess you like

Origin www.cnblogs.com/shangping/p/12538640.html