Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Computer Foundation-Network Protocol

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

one。 Principle of network communication

Network communication technology refers to the technology that collects, stores, processes and transmits data in the form of graphics and characters through computers and network communication equipment, so that information resources can be fully shared. Network uses physical links to connect isolated workstations or hosts together to form a data link, so as to achieve the purpose of resource sharing and communication. Communication is the exchange and transmission of information between people through some media.

The principle of network communication is the network protocol. Nowadays, there are many network protocols, and there are three most commonly used network protocols in local area network: NETBEUI, IPX/SPX and cross-platform TCP/IP. Network protocol is the bridge of communication between networks.

Second, an introduction to the .OSI seven-tier model:

The seven-tier OSI models are:

Physical layer; data link layer; network layer; transport layer; session layer; presentation layer; application layer

two。 Functions and protocols of each layer:

Application layer file transfer, email, file service, virtual terminal TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet

There is no protocol for data formatting, transcoding and data encryption in the presentation layer.

There is no agreement for the session layer to release or establish contact with other contacts.

The transport layer provides an end-to-end interface TCP,UDP

The network layer chooses the routing IP,ICMP,RIP,OSPF,BGP,IGMP for the packet

The data link layer transmits addressed frames and the error detection function SLIP,CSLIP,PPP,ARP,RARP,MTU

The physical layer transmits data ISO2110,IEEE802,IEEE802.2 on physical media in the form of binary data.

Third, the explanation of tcp/ip five-layer model

We put the application layer, session layer and application layer in the application layer, so the tcp/ IP five-layer models are: data link layer; network layer; transport layer; application layer and then explain the characteristics and main protocols in layers.

Each layer runs a specific protocol, getting closer and closer to the user up and down to the hardware.

Layer 1: physical layer (PhysicalLayer)

1. The physical layer provides mechanical, electronic, functional and normative characteristics for the creation, maintenance, and dismantling of physical links needed to transmit data. Simply put, the physical layer ensures that the original data can be transmitted over a variety of physical media.

two。 The main function of the physical layer is to provide data transmission path and data transmission for data-side equipment.

1. It provides a data transmission path for data-side devices, which can be a physical media or a plurality of physical media. A complete data transfer, including activating a physical connection, transferring data, and terminating a physical connection. The so-called activation means that no matter how many physical media are involved, it is necessary to connect the two data terminal devices to form a path.

two。 To transfer data, the physical layer should form an entity suitable for the needs of data transmission to serve the data transmission. One is to ensure that the data can pass through it correctly, and the other is to provide sufficient bandwidth (bandwidth is the number of bits (BIT) that can pass per second) to reduce congestion on the channel. The mode of data transmission can meet the needs of point-to-point, point-to-multipoint, serial or parallel, half-duplex or full-duplex, synchronous or asynchronous transmission.

Layer 2: data Link layer (DataLinkLayer):

On the basis of the bit stream service provided by the physical layer, the data link between the adjacent nodes is established, the error-free transmission of the data frame (Frame) on the channel is provided through error control, and the action series on each circuit is carried out. The data link layer provides reliable transmission over unreliable physical media. The functions of this layer include: physical address addressing, data framing, flow control, data error detection, retransmission and so on. At this layer, the unit of data is called frame. Representatives of data link layer protocols include: SDLC, HDLC, PPP, STP, frame Relay and so on.

Mac address:

Each Nic leaves the factory with a world's unique mac address, 48 bits in binary length, usually represented by a 12-bit hexadecimal number (the first six digits are the manufacturer number and the last six digits are the pipeline number).

Broadcast:

With the mac address, two hosts in the same network can communicate (one host obtains the mac address of the other host through the arp protocol). The way to broadcast communication is as follows: if a host wants to communicate with another host, it will send its own message to all the hosts in the local area network. After receiving it, these hosts will check whether the mac address is their own. If so, receive it, otherwise discard it.

Layer 3: network layer (Network layer):

There may be many data links or communication subnets between two computers that communicate in a computer network. The task of the network layer is to select appropriate inter-network routing and switching nodes to ensure timely data transmission. The network layer consists of the frames provided by the data link layer into a packet, which is sealed with a network layer header, which contains logical address information-the network address of the source and destination site addresses.

The purpose of the network layer is to achieve transparent data transmission between the two end systems, including addressing and routing, connection establishment, maintenance and termination, and so on. It provides services so that the transport layer does not need to know about data transmission and switching technologies in the network.

IP protocol:

The protocol that specifies the network address is called the ip protocol, and the address it defines is called the ip address. The widely used v4 version, ipv4, specifies that the network address is represented by 32 bits in binary.

Range 0.0.0.0-255.255.255.255

An ip address is usually written in four decimal numbers, for example: 192.168.1.1

The ip address is divided into two parts:

Network part: identify subnet host part: identify host

Note: the simple ip address field only identifies the type of ip address, and the subnet of an ip cannot be identified from the network part or the host part.

Example: 192.168.1.1 and 192.168.2.1 cannot be determined to be in the same subnet

Subnet mask:

The so-called "subnet mask" is a parameter that represents the characteristics of the subnetwork. It is formally equivalent to the IP address, is also a 32-bit binary number, its network part is all 1, and the host part is all 0. For example, IP address 172.16.10.1, if it is known that the network part is the first 24 bits and the host part is the last 8 bits, then the subnet mask is 11111111.1111111111111111.00000000, which is 255.255.255.0 in decimal.

Knowing the subnet mask, we can determine whether any two IP addresses are on the same subnet. The method is to AND the two IP addresses and the subnet mask respectively (both digits are 1, the result is 1, otherwise it is 0), and then compare the results to see if they are the same. If so, it indicates that they are in the same subnet, otherwise they are not.

For example, it is known that the subnet masks of the IP addresses 172.16.10.1 and 172.16.10.2 are 255.255.255.0. Are they on the same subnet? Both of them and subnet mask perform AND operation respectively.

172.16.10.1: 10101100.00010000.00001010.000000001

255255.255.255.0: 11111111.11111111.11111111.00000000

The result of AND calculation is: 10101100.00010000.00001010.000000001-> 172.16.10.0

172.16.10.2:10101100.00010000.00001010.000000010

255255.255.255.0:11111111.11111111.11111111.00000000

The result of AND calculation is: 10101100.00010000.00001010.000000001-> 172.16.10.0

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

To sum up, the IP protocol has two main functions, one is to assign IP addresses to each computer, and the other is to determine which addresses are on the same subnet.

Layer 4: transport layer (Transport layer):

The task of the transport layer is to make the best use of network resources according to the characteristics of the communication subnet, to provide the function of establishing, maintaining and canceling the transmission connection between the session layers of the two end systems, and to be responsible for end-to-end reliable data transmission. At this layer, the protocol data unit for information transmission is called a segment or message. The representatives of transport layer protocols include TCP, UDP, SPX and so on.

The transport layer provides end-to-end services between host application processes. The basic functions are as follows:

(1) Segmentation and reorganization of data; (2) addressing by port number (port range 0-6553510-1023 is the port occupied by the system)

(3) connection management; (4) error control and flow control, error correction function

The transport layer should provide the reliability of communication services to the session layer and avoid errors such as error, loss, delay time disorder, repetition, disorder and so on.

Tcp protocol:

For reliable transmission, TCP packets have no length limit and can be infinitely long in theory, but in order to ensure the efficiency of the network, the length of TCP packets usually does not exceed the length of IP packets to ensure that a single TCP packet does not have to be segmented.

Ethernet header ip header tcp header data

Udp protocol:

Unreliable transmission, the "header" section has a total of only 8 bytes, with a total length of no more than 65535 bytes, which fits into an IP packet.

Ethernet header ip header udp header data

:

Tcp message:

Tcp three handshakes and four waves:

Layer 5 Application layer (Application layer):

The application layer provides an interface for operating systems or network applications to access network services. The representatives of application layer protocols include: Telnet, FTP, HTTP, SNMP and so on.

Fourth, the network; communication process:

1. Native configuration:

The IP address of this machine: 192.168.1.10

Subnet mask: 255.255.255.0

IP address of the gateway: 192.168.1.1

IP address of DNS: 114.114.114.114

Description:

To achieve network communication, each host needs to have four elements:

a. The IP address of this machine b. Subnet mask c. IP address of the gateway IP address of d.DNS

There are two ways to obtain the local ip address:

The ① static address is to manually configure ip; ② to dynamically obtain the DHCP assignment of both partners.

How DHCP works:

1.Discover: the client requests the IP address

2.Offer: server corresponding request

3.Request: the client chooses an ip address

4.ACK: server confirmation.

two。 Open a browser and want to access Google, enter the URL: www.google.com in the address bar.

3.dns protocol (based on udp protocol)

Description:

How DNS works: step 1: the client makes a domain name resolution request and sends the request to the local domain name server. Step 2: when the local domain name server receives the request, it will first query the local cache. If there is a record entry, the local domain name server will directly return the query results. Step 3: if the record is not in the local cache, the local domain name server sends the request directly to the root domain name server. the root domain name server then returns to the local domain name server the address of the primary domain name server of the queried domain (the subdomain of the root). Step 4: the local server sends a request to the domain name server returned in the previous step, and then the server that accepts the request queries its own cache, and if there is no such record, it returns the address of the relevant subordinate domain name server. Step 5: repeat step 4 until you find the correct record. Step 6: the local domain name server saves the returned results to the cache for next use and returns the results to the client.

Global 13 root dns:

A.root-servers.net198.41.0.4 USA

B.root-servers.net192.228.79.201 USA (also supports IPv6)

C.root-servers.net192.33.4.12 France

D.root-servers.net128.8.10.90 USA

E.root-servers.net192.203.230.10 USA

F.root-servers.net192.5.5.241 USA (also supports IPv6)

G.root-servers.net192.112.36.4 USA

H.root-servers.net128.63.2.53 USA (also supports IPv6)

I.root-servers.net192.36.148.17 Sweden

J.root-servers.net192.58.128.30 USA

K.root-servers.net193.0.14.129 UK (also supports IPv6)

L.root-servers.net198.32.64.12 USA

M.root-servers.net202.12.27.33 Japan (also supports IPv6)

The content of the 4.HTTP section, similar to the following:

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 this part, which is 4960 bytes long, will be embedded in the TCP packet.

5. TCP protocol

The port of the TCP packet needs to be set, the HTTP port of the receiver (Google) is 80 by default, and the port of the sender (native) is a randomly generated integer between 1024 and 65535, assuming 51775.

The header length of the TCP packet is 20 bytes, plus the packet embedded in HTTP, the total length is 4980 bytes.

6. IP protocol

The TCP packet is then embedded in the IP packet. The IP packet needs to set the IP address of both sides, which is known, the sender is 192.168.1.100 (native) and the receiver is 172.194.72.105 (Google).

The header length of the IP packet is 20 bytes. With the embedded TCP packet, the total length becomes 5000 bytes.

7. Ethernet protocol

Finally, the IP packet is embedded in the Ethernet packet. The Ethernet packet needs to set the MAC address of both sides, the sender is the local network card MAC address, and the receiver is the MAC address of the gateway 192.168.1.1 (obtained through the ARP protocol).

The maximum length of the data portion of an Ethernet packet is 1500 bytes, while today's IP packet length is 5000 bytes. Therefore, the IP packet must be divided into four packets. Because each packet has its own IP header (20 bytes), the length of the IP packets for the four packets is 1500, 1500, 1500, and 560, respectively.

8. Server-side response

After being forwarded by multiple gateways, Google's server 172.194.72.105 received these four Ethernet packets.

According to the sequence number of the IP header, Google puts the four packets together, takes out the complete TCP packet, reads out the "HTTP request" in it, makes a "HTTP response", and sends it back using the TCP protocol.

After receiving the HTTP response, the machine can display the web page and complete a network communication.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report