Network basics of basic computer series-network protocols and basic computer networks

Source: Internet
Author: User
Tags subdomain subdomain name

Network basics of basic computer series-network protocols and basic computer networks

What's the network protocol

A computer with hardware, operating systems, and software already has functions that can be used. However, to realize communication between a computer and a computer, a series of standards must be followed.Internet Protocol. The function of Internet protocol is to define how computers access the Internet and how computers connect to the Internet communicate.

Internet protocols are divided into osi Layer-7 protocol or TCP/IP layer-5 protocol based on different functions (in fact, as long as you master the layer-5 TCP/IP layer, it is enough to be forced in front of your friends ).

Layer 5 TCP/IP refers to the physical layer, data link layer, network layer, transmission layer, and application layer.

  Physical LayerIt basically refers to physical interfaces so that computers can access the Internet and communicate with each other. The function of the physical layer is to send High Voltage Based on the electrical characteristics. The high voltage corresponds to number 1, and the low voltage corresponds to number 0 (that is, 10101010 in binary ).

Digital Link LayerThe function is to define the electrical signal grouping method. WhereEthernet protocolA set of electrical signals are defined to form a data packet, which consists of header and data. The header contains the source address, target address, and data type. If the two computers are in the same network environment (that is, in the same LAN), computer A sends packets through broadcast, the header of the packet contains its own mac address and IP address of the target computer B. After receiving the packet, B identifies the target IP address as its own IP address. After confirming that the packet is correct, B sends A packet to, the header contains its own mac address. After the two computers Know each other's mac address, the two computers can communicate with each other. This method of mutual understanding isARP Protocol.

  Network LayerThe function is to introduce a new set of addresses to distinguish different LAN addresses, that is, network addresses. This function followsIP protocol. The network layer allows communication between two computers in different local networks. The processing method is similar to the ARP Protocol. However, the IP address of the gateway is added in the middle to confirm the mac address between the two computers.

  

By default, all web services use port 80, for example, Baidu www.baidu.com: 80.

The uri address is divided into three parts:

Protocol Part: http ://

Domain name section: the name of the website we are familiar with. the IP address of the server can be obtained through the domain name.

Resource part: After opening the link, remove the remaining part of the Protocol Part domain name.

After the network is connectedDhcp protocolObtain the IP address, gateway address, DNS address, and so on.

Applications used by users are located at the application layer,Application LayerThe function is to define the data format of the application.

That is, the process of sending data, from top to bottom is the user layer, transmission layer, network layer, data link layer and physical layer. After the data of the previous layer reaches the current layer, it becomes the data of the current layer. After adding the header of the current layer, it is transmitted to the next layer. After receiving the data, the data containing the header is regarded as the data of the current layer, add the header of this layer again. The last data has only one header, which is sent to the receiver through the physical interface. The receiver then unpacks the packet layer by layer.

 

Socket

We know that if two processes need to communicate, the most basic premise is that they can uniquely identify a process. In local process communication, we can use PID to uniquely identify a process, however, the PID is only unique locally, and the two processes in the network have a high chance of PID conflict. At this time, we need to set up another path. We know that the IP address on the IP layer can uniquely identify the host, the TCP layer protocol and port number can uniquely identify a process on the host, so that we can use the IP address + protocol + port number to uniquely identify a process on the network.

After the processes in the network can be uniquely identified, they can use socket for communication. What is socket? We often translate a socket into a socket, which is an abstraction layer between the application layer and the transport layer, it abstracts the complex operations on the TCP/IP layer into several simple interfaces for the application layer to call and Implement Process Communication in the network.

Note: There will be a blog about socket network programming later on the socket knowledge. Here I just want to mention it.

 

The network communication process is as follows:

1. Local acquisition (four elements required by the host)

  • Local IP Address
  • Subnet Mask
  • IP address of the Gateway
  • Dns ip Address

There are two ways to obtain these four elements:

Static retrieval: manually enter the configuration

Dynamic retrieval: obtained through dhcp protocol

Ethernet header Ip Header Udp Header Dhcp Packet

 

 

 

(1) The "Ethernet header" at the top, which is used to set the MAC address of the sender (Local Machine) and the MAC address of the receiver (DHCP server. The former is the MAC address of the local Nic. If you do not know the latter, enter a broadcast address: FF-FF.

(2) set the sender's IP address and the receiver's IP address. At this time, the local machine does not know the two. Therefore, the sender's IP address is set to 0.0.0.0, and the receiver's IP address is set to 255.255.255.255.

(3) set the sender port and receiver port in the "UDP Header" at the end. This part is stipulated by the DHCP protocol. The sender is port 68 and the receiver is port 67.

This packet can be sent after being constructed. Ethernet is broadcast transmission, and each computer in the same subnetwork receives the packet. Because the recipient's MAC address is a FF-FF-FF-FF-FF-FF, can not see who is sent, so each computer that receives this package, you must also analyze the IP address of this package, in order to determine whether to send to yourself. When the IP address of the sender is 0.0.0.0 and the receiver is 255.255.255.255, the DHCP server knows that "this package is sent to me", and other computers can discard this package. Next, the DHCP server reads the data content of this packet, assigns an IP address, and sends a "DHCP response" packet back. The structure of the response packet is similar. The MAC address of the Ethernet header is the NIC address of both parties, and the IP address of the IP header is the IP address of the DHCP server (sender) and 255.255.255.255.255 (receiver ), the UDP header ports are 67 (sender) and 68 (receiver). The IP address assigned to the request end and the specific parameters of the network are included in the Data section.

After receiving the response packet, the newly added computer knows its IP address, subnet mask, gateway address, DNS server, and other parameters.

 

2. Open your browser and enter www.google.com in the address bar to access Google.

3. dns protocol (based on udp Protocol)

Top-level domain name:. com ,. net ,. org ,. cn and so on are international top-level domain names. According to the current international Internet domain name system, international top-level domain names are divided into two categories: Class top-level domain names (gTLD) and geographical top-level domain names (ccTLD. CATEGORY top-level domain names are domain names ending with "COM", "NET", "ORG", "BIZ", and "INFO", which are managed by foreign companies. A geographic top-level domain name ends with a country or region code. For example, "CN" represents China, and "UK" represents UK. Geographic top-level domain names are generally managed by various countries or regions.

Second-level domain name: second-level domain name is a geographical domain name based on top-level domain names, compared to China's second-level domain names, such as .com.cn, .net.cn, .org.cn, .gd.cn. a subdomain name is a subdomain name of its parent domain name. It is equivalent to a parent domain name of abc.com. A subdomain name is www.abc.com or * .abc.com.
Generally, a second-level domain name is a record of a domain name. For example, alidiedie.com is a domain name and www.alidiedie.com is a commonly used record. This is usually used by default, however, all domain names similar to * .alidiedie.com are called the second-level domain names of alidiedie.com.

4. HTTP Content

5. TCP protocol

TCP data packets must be configured with a port. The HTTP port of the receiver (Google) is 80 by default, and the sender (local) port is a random integer between 1024-65535, which is assumed to be 51775.

 

The header length of a TCP packet is 20 bytes, and the total length of the packet embedded with HTTP is 4980 bytes.

 

6. IP protocol

 

Then, the TCP packet is embedded into the IP packet. IP packets must be set to the IP addresses of both parties. This is known. The sender is 192.168.1.100 (Local Machine), and the receiver is 172.194.72.105 (Google ).

 

The Header Length of the IP data packet is 20 bytes, and the total length of the embedded TCP data packet is 5000 bytes.

 

7. Ethernet protocol

 

Finally, IP data packets are embedded into Ethernet data packets. For an Ethernet packet, you must set the MAC address of both parties. the sender is the MAC address of the local Nic, and the receiver is the MAC address of the gateway 192.168.1.1 (obtained through ARP ).

 

The maximum length of an Ethernet data packet is 1500 bytes, and the current IP data packet length is 5000 bytes. Therefore, IP data packets must be divided into four packages. Because each packet has its own IP header (20 bytes), the IP packet lengths of the four packets are 1500, 1500, 1500, and 560, respectively.

 

8. Server Response

 

After forwarding by multiple gateways, Google server 172.194.72.105 receives the four Ethernet packets.

 

According to the serial number of the IP header, Google puts together four packets, extracts the complete TCP packet, reads the "HTTP request" in it, and then generates an "HTTP Response ", send it back using the TCP protocol.

 

After the local machine receives the HTTP response, it can display the webpage and complete a network communication.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.