36 pictures explain computer network knowledge points in detail

点击上方“C语言与CPP编程”,选择“关注/置顶/星标公众号”
干货福利,第一时间送达!

An overview of computer networks

f3930210ef71cd3b62b84a7de94c59de.png

1.1 Classification of computer networks

According to the scope of the network: Wide Area Network (WAN), Metropolitan Area Network (MAN), Local Area Network (LAN);

By network user: public network, private network.

1.2 The Hierarchy of Computer Networks

8f89f1762c672741c3b5b3ecba131680.png

Comparison of TCP/IP four-layer model and OSI architecture:

2c1822af532d52a31c735cd352f6e80f.png

1.3 Basic Principles of Hierarchical Structure Design

  • The layers are independent of each other;

  • Each layer needs to have enough flexibility;

  • Complete decoupling between layers.

1e7dbbace8ba3e3fb5b49ace57f666c5.png

1.4 Performance Indicators of Computer Networks

Rate: bps=bit/s Delay: Sending delay, propagation delay, queuing delay, processing delay Round trip time RTT: The time it takes for a data packet to go back and forth in end-to-end communication.

2. Physical layer

The role of the physical layer: connect different physical devices and transmit bit streams. This layer provides upper-layer protocols with a reliable physical medium for transmitting data. Simply put, the physical layer ensures that the original data can be transmitted over various physical media.

Physical layer device:

  • Repeater [Repeater, also called amplifier]: the regeneration signal of the same local area network; the network segments of the two ports must have the same protocol; 5-4-3 procedure: in 10BASE-5 Ethernet, a maximum of 4 repeaters can be connected in series, 5 segments There can only be 3 connected hosts in the;

  • Hub: Regenerate and amplify the signal of the same local area network (multi-port repeater); half-duplex, can not isolate the collision domain or the broadcast domain.

The basic concept of a channel: A channel is a medium that transmits information in one direction, and a communication circuit consists of a transmit channel and a receive channel.

  • Simplex communication channel: a channel that can only communicate in one direction without feedback in the opposite direction;

  • Half-duplex communication channel: both parties can send and receive information, but neither can send or receive at the same time;

  • Full-duplex communication channel: Both parties can transmit and receive at the same time.

3. Data link layer

3.1 Data Link Layer Overview

The data link layer provides services to the network layer on the basis of the services provided by the physical layer. Its most basic service is to reliably transmit the data from the network layer to the network layer of the target machine of the adjacent node. The data link layer provides reliable transmission over unreliable physical media.

The role of this layer includes: physical address addressing, data framing, flow control, data error detection, retransmission and so on.

Important points about the data link layer:

  • The data link layer provides reliable data transmission for the network layer;

  • The basic data unit is frame;

  • The main protocol: Ethernet protocol;

  • Two important device names: bridge and switch.

Encapsulation into frames: A "frame" is the basic unit of data at the data link layer :

bff52b33209f6b90b5061773aa30194a.png

Transparent transmission: "Transparent" means that even if the control character is in the frame data, it should be treated as if it does not exist. That is, add the escape character ESC before the control character.

ed266f78b3947c1f931804aa48cebe2b.png

3.2 Error monitoring at the data link layer

Error detection: Parity, Cyclic Redundancy Check (CRC)

  • Parity - Limitation: When two bits are wrong, no error is detected.

  • Cyclic Redundancy Check Code: A fixed-digit check code is generated based on the transmitted or stored data.

3.3 Maximum Transmission Unit MTU

The maximum transmission unit MTU (Maximum Transmission Unit), the data frame of the data link layer is not infinite, and the length of the data frame is limited by the MTU.

Path MTU: Determined by the minimum value of MTU in the link.

803602cd6511277e845fbf97e490b82b.png

3.4 Detailed explanation of Ethernet protocol

MAC address: Each device has a unique MAC address, a total of 48 bits, expressed in hexadecimal.

Ethernet protocol: It is a widely used local area network technology and is a protocol applied to the data link layer. Using Ethernet, the data frame transmission of adjacent devices can be completed:

80ba2f325e14765a8af71f7b07a22a9b.png

LAN classification:

Ethernet Ethernet IEEE802.3:

  • Ethernet the first widely deployed high-speed local area network

  • Fast Ethernet data rate

  • Cheap Ethernet hardware and low network cost

Ethernet frame structure:

  • Type: Identifies the upper layer protocol (2 bytes)

  • Destination address and source address: MAC address (6 bytes each)

  • Data: Packet of the encapsulated upper layer protocol (46~1500 bytes)

  • CRC: Cyclic Redundancy Code (4 bytes)

  • The shortest Ethernet frame: the shortest Ethernet frame is 64 bytes; the Ethernet frame is 18 bytes except the data part; the data is the shortest 46 bytes;

MAC address (physical address, LAN address)

  • The MAC address length is 6 bytes, 48 ​​bits;

  • The MAC address is unique, and each network adapter corresponds to a MAC address;

  • Usually in hexadecimal notation, each byte represents a hexadecimal number, concatenated with - or :;

  • MAC broadcast address: FF-FF-FF-FF-FF-FF.

Fourth, the network layer

The purpose of the network layer is to realize the transparent transmission of data between two end systems, and the specific functions include addressing and routing, connection establishment, maintenance and termination. The data exchange technology is message exchange (basically replaced by packets): the store-and-forward method is adopted, and the data exchange unit is a message.

There are many protocols involved in the network layer, including the most important protocol, which is also the core protocol of TCP/IP - the IP protocol. The IP protocol is very simple, providing only unreliable, connectionless delivery services. The main functions of the IP protocol are: connectionless datagram transmission, datagram routing and error control.

The IP protocol is used in conjunction with the IP protocol to realize its functions, including the address resolution protocol ARP, the reverse address resolution protocol RARP, the Internet message protocol ICMP, and the Internet group management protocol IGMP. We will summarize the specific protocols in the following sections. The key points about the network layer are:

1. The network layer is responsible for routing packets between subnets. In addition, the network layer can also implement functions such as congestion control and Internet interconnection;
2. The basic data unit is IP datagram;
3. The main protocols included:

  • IP protocol (Internet Protocol, Internet Internet Protocol);

  • ICMP protocol (Internet Control Message Protocol, Internet Control Message Protocol);

  • ARP protocol (Address Resolution Protocol, address resolution protocol);

  • RARP protocol (Reverse Address Resolution Protocol, reverse address resolution protocol).
    4. Important equipment: router.

b0d8317557ddf979a9dc724250f99368.png

router related protocols

bf15029fc8c786b749e5496c07ff9c5a.png

4.1 Detailed explanation of IP protocol

The IP Internet Protocol is the core protocol of the Internet network layer. The emergence of virtual Internet: the actual computer network is intricate and complex; the physical devices use the IP protocol to shield the differences between the physical networks; when the hosts in the network use the IP protocol to connect, there is no need to pay attention to the network details, so a virtual network is formed.

1d59152ba2471b8c31d655776097b467.png

The IP protocol makes the complex real network into a virtual interconnected network; and solves the problem of datagram transmission path in the virtual network.

881f570ae0d4fcda6962ebb90ba4e015.png

Among them, the version refers to the version of the IP protocol, occupying 4 bits, such as IPv4 and IPv6; the length of the header indicates the length of the IP header, accounting for 4 bits, and the maximum value is 15; the total length indicates the total length of the IP datagram, accounting for 16 bits, the maximum value Bit 65535; TTL indicates the lifetime of the IP data packet in the network, occupying 8 bits; the protocol indicates the protocol of the specific data carried by the IP data, such as TCP and UDP.

4.2 Forwarding process of IP protocol

44f4199fde8cdf276ef70f7b0a23074a.png

4.3 Subnetting of IP Addresses

0c3de28f47a72ce7d88446b7dd7f4aad.png

Class A (8 network numbers + 24 host numbers), class B (16 network numbers + 16 host numbers), and class C (24 network numbers + 8 host numbers) can be used to identify hosts or routers in the network, and class D addresses are used as Group broadcast address, class E is reserved for addresses.

32efb0cf60232464506039ff4128ee44.png

4.4 Network Address Translation NAT Technology

It is used in a private network where multiple hosts access the Internet through a public IP, which slows down the consumption of IP addresses, but increases the complexity of network communication.

How NAT works:

For IP datagrams sent out from the intranet, replace its IP address with a legal public IP address owned by the NAT server, and record the replacement relationship in the NAT translation table;

For the IP datagram returned from the public Internet, the NAT translation table is retrieved according to its destination IP address, and the destination IP address is replaced with the retrieved internal private IP address, and then the IP datagram is forwarded to the internal network.

4.5 ARP protocol and RARP protocol

ARP (Address Resolution Protocol): Provides dynamic mapping from the IP address of the network card (network adapter) to the corresponding hardware address. The network layer 32-bit address can be converted into a data link layer MAC 48-bit address.

ARP is plug-and-play, an ARP table is automatically established, and does not require system administrators to configure.

53c59bd013e673fda3ed9929ae2ea298.png

The RARP (Reverse Address Resolution Protocol) protocol refers to the reverse address resolution protocol, which can convert the data link layer MAC 48-bit address into the network layer 32-bit address.

4.6 Detailed explanation of ICMP protocol

The Internet Control Message Protocol (Internet Control Message Protocol) can report error information or abnormal conditions. ICMP messages are encapsulated in IP datagrams.

5f8486be8deb75904a920cc680dd0ad1.png

Application of ICMP protocol:

  • Ping application: troubleshooting of network faults;

  • Traceroute application: It can detect the path that IP datagrams traverse in the network.

4.7 Overview of Routing at the Network Layer

Requirements for routing algorithms: correct and complete, computationally simple, adaptable to changes in the network, stable and fair.

Autonomous system AS: refers to the network equipment group under a management organization. The internal network of the AS is autonomously managed, and one or more entrances and exits are provided to the outside world. The routing protocol inside the autonomous system is an internal gateway protocol, such as RIP, OSPF, etc.; The routing protocol is an exterior gateway protocol, such as BGP.

Static routing: manual configuration, high difficulty and complexity;

Dynamic routing:

  • Link State Routing Algorithm LS: Sending information to all neighboring routes has fast convergence; global routing algorithm, when each router calculates a route, it needs to build the entire network topology; Dijkstra algorithm is used to find the shortest path from the source end to the destination end network ; Dijkstra algorithm

  • Distance-Vector Routing Algorithm DV: Sending information to all neighboring routes has slow convergence and there will be loops; the basis is the Bellman-Ford equation (BF equation for short);

4.8 RIP protocol of interior gateway routing protocol

Routing Information Protocol (RIP) [application layer], routing algorithm based on distance-vector, small AS (autonomous system), suitable for small networks; RIP packets are encapsulated into UDP datagrams.

RIP protocol features:

  • RIP uses the number of hops when measuring the path (each router maintains a record of the distance between itself and every other router);

  • The cost of RIP is defined between the source router and the destination subnet;

  • The network diameter that RIP is restricted to does not exceed 15 hops;

  • Exchange all information with the next door, 30 active times (broadcast).

4.9 OSPF protocol of interior gateway routing protocol

Open Shortest Path First (OSPF) [network layer], link-state-based routing algorithm (ie Dijkstra algorithm), larger-scale AS, suitable for large-scale networks, directly encapsulated in IP datagrams for transmission.

Advantages of OSPF protocol:

  • Safety;

  • Support multiple paths with the same cost;

  • Support for differentiated cost metrics;

  • Support unicast routing and multicast routing;

  • Hierarchical routing.

Comparison of RIP and OSPF (routing algorithm determines its nature):

fab9744b86c1759fd2ac403049cd918a.png

4.10 BGP protocol of external gateway routing protocol

BGP (Border Gateway Protocol) [application layer]: It is a protocol running between ASs to find a good route: all information is exchanged for the first time, and only the changed part is exchanged later, and BGP is encapsulated into a TCP segment.

5. Transport layer

The first is end-to-end, the host-to-host level. The transport layer is responsible for segmenting the upper layer data and providing end-to-end, reliable or unreliable transmission. In addition, the transport layer also handles end-to-end error control and flow control issues.

The task of the transport layer is to make the best use of network resources according to the characteristics of the communication subnet, provide the functions of establishing, maintaining and canceling the transmission connection between the session layers of the two end systems, and be responsible for end-to-end reliable data transmission. At this layer, the protocol data units in which information is conveyed are called segments or packets.

The network layer only transmits the data packets sent by the source node to the destination node according to the network address, while the transport layer is responsible for reliably transmitting the data to the corresponding port.

Important points about the network layer:

  • The transport layer is responsible for segmenting the upper layer data and providing end-to-end, reliable or unreliable transmission and end-to-end error control and flow control issues;

  • The main protocols included: TCP protocol (Transmission Control Protocol, Transmission Control Protocol), UDP protocol (User Datagram Protocol, User Datagram Protocol);

  • Important equipment: Gateway.

055586f58cc10051fc02524df00bb6f8.png

7236ed3921cb24c9075276f86fa84353.png

5.1 Detailed explanation of UDP protocol

UDP (User Datagram Protocol: User Datagram Protocol) is a very simple protocol.

808af5d8f83f002616eee1976ae244ef.png

Features of UDP protocol:

  • UDP is a connectionless protocol;

  • UDP does not guarantee reliable delivery of data;

  • UDP is message-oriented;

  • UDP has no congestion control;

  • UDP header overhead is small.

UDP datagram structure:

Header: 8B, four fields/2B [source port | destination port | UDP length | checksum] Data field: application data

6fd8b0986756ce6a96ae4614a0ccf2a3.png

5.2 Detailed explanation of TCP protocol

TCP (Transmission Control Protocol: Transmission Control Protocol) is a very complex protocol in computer networks.

42e379cba01ce244b13c0547fb5959de.png

Features of the TCP protocol:

  • Segment and reassemble application layer packets;

  • Realize reuse and decomposition for the application layer;

  • Realize end-to-end flow control;

  • congestion control;

  • Transport layer addressing;

  • Perform error detection on the received message (both the header and the data part are error-detected);

  • Realize end-to-end reliable data transmission control between processes.

Features of the TCP protocol:

  • TCP is a connection-oriented protocol;

  • TCP is a byte stream oriented protocol;

  • A TCP connection has two ends, that is, point-to-point communication;

  • TCP provides reliable transport services;

  • The TCP protocol provides full-duplex communication (each TCP connection can only be one-to-one);

5.2.1 TCP segment structure:

Maximum segment length: The maximum length of the application layer data encapsulated in the segment.

e82f60ba51eebb42ef4e9aea8e1017e6.png

TCP header:

  • Sequence number field: The sequence number of TCP is to number each byte of each application layer data

  • Confirmation sequence number field: the byte sequence number expected to receive data from the other party, that is, the byte corresponding to the sequence number has not been received. identified with ack_seq;

  • The shortest length of the header of a TCP segment is 20B and the longest is 60 bytes. But the length must be an integer multiple of 4B

The role of TCP markers:

9f93c5c3852488fe48f30380335e9d09.png

5.3 Basic Principles of Reliable Transmission

Fundamental:

  • Unreliable transmission channels may occur in data transmission: bit errors, out-of-order, retransmission, loss

  • Measures taken to achieve reliable data transmission over unreliable channels:

Error detection: use coding to detect bit errors in the process of data packet transmission Confirmation: the receiver feeds back the receiving status to the sender Retransmission: the sender resends the data that the receiver did not receive correctly Sequence number: ensures that the data is submitted in sequence Timer: resolves the data loss problem;

Stop-Wait Protocol: It is the simplest reliable transmission protocol, but the utilization rate of the channel is not high.

Continuous ARQ (Automatic Repeat reQuest: Automatic Repeat Request) protocol: sliding window + cumulative confirmation, which greatly improves the utilization of the channel.

5.3.1 Reliable Transmission of TCP Protocol

Based on the continuous ARQ protocol, in some cases, the efficiency of retransmission is not high, and some bytes that have been successfully received will be repeatedly transmitted.

5.3.2 Flow Control of TCP Protocol

Flow control: Let the sender not send too fast. The TCP protocol uses a sliding window to implement flow control.

d2dcb22411f3400bbf0e08c4ea2a42f1.png

5.4 Congestion Control of TCP Protocol

The difference between congestion control and flow control: flow control considers the control of point-to-point traffic, while congestion control considers the entire network, which is a global consideration. Congestion control method: slow start algorithm + congestion avoidance algorithm.

Slow start and congestion avoidance:

  • [Slow start] The congestion window increases exponentially from 1;

  • When the threshold is reached, enter [Congestion Avoidance], which becomes +1 growth;

  • [Timeout], the threshold becomes half of the current cwnd (cannot be <2);

  • From [Slow Start], the congestion window grows exponentially from 1.

ac59ce014401c2a96ffaba1f7e1036b4.png

Fast retransmission and fast recovery:

  • The sender receives 3 redundant ACKs in a row and executes [fast retransmission] without waiting for the timer to expire;

  • Execute [Quick Recovery], the threshold becomes half of the current cwnd (cannot be < 2), and enter [Congestion Avoidance] from this new ssthresh point.

ad6cba8d6cdfa1f4ac6700cc51b8d3d9.png

5.5 Three-way handshake of TCP connection (important)

TCP three-way handshake use instructions:

081d9634a6330307ddbbacfa637b8258.png

Interviewer: Why do you need a three-way handshake?

  • The first handshake: the client sends a request, and the server knows that the client can send it;

  • The second handshake: the server sends a confirmation, and the client knows that the server can send and receive;

  • Third handshake: The client sends an acknowledgment, at which point the server knows that the client can receive.

Establish a connection (three-way handshake):

The first time: the client sends a connection request segment to the server, and establishes a connection request control segment (SYN=1), indicating that the sequence number of the first data byte of the transmitted segment is x, and this sequence number represents the entire segment. The sequence number (seq=x); the client enters SYN_SEND (synchronous sending state);

The second time: the server sends back the confirmation segment, agrees to establish the confirmation segment of the new connection (SYN=1), the confirmation sequence number field is valid (ACK=1), and the server tells the client that the segment sequence number is y (seq=y) , indicating that the server has received the segment with the client's serial number x, and is ready to accept the segment with the client's serial number x+1 (ack_seq=x+1); the server enters SYN_RCVD from LISTEN (synchronously received state);

The third time: the client confirms the same connection to the server. The confirmation sequence number field is valid (ACK=1), the sequence number of the client's segment is x+1 (seq=x+1), and the client expects to accept the server sequence Segment number y+1 (ack_seq=y+1); when the client sends an ack, the client enters the ESTABLISHED state; when the service receives the ack sent by the client, it also enters the ESTABLISHED state; the third handshake can be carried data;

984e0672909bab5b6f53e000c8e6e76c.png

5.6 Four waves of TCP connections (important)

Release the connection (four waves)

The first time: the client sends a connection release segment to the server, the sender data is sent, and the connection is requested to be released (FIN=1), and the sequence number of the first data byte transmitted is x (seq=x); client status Enter FIN_WAIT_1 from ESTABLISHED (termination wait 1 state);

The second time: the server sends an acknowledgement segment to the client, and the acknowledgement field is valid (ACK=1), the data sequence number transmitted by the server is y (seq=y), and the server expects to receive the client data sequence number is x+1 (ack_seq=x+1 ); the server state enters CLOSE_WAIT (close waiting) from ESTABLISHED; after the client receives the ACK segment, it enters FIN_WAIT_2 from FIN_WAIT_1;

The third time: the server sends a connection release segment to the client, requesting to release the connection (FIN=1), and confirms that the field number is valid (ACK=1), indicating that the server expects to receive client data with a sequence number of x+1 (ack_seq=x+1 ); Indicates that the first byte sequence number transmitted by itself is y+1 (seq=y+1); the server state is entered from CLOSE_WAIT to LAST_ACK (last confirmation state);

The fourth time: the client sends an acknowledgement segment to the server, and the acknowledgement field is valid (ACK=1), indicating that the data sequence number transmitted by the client is x+1 (seq=x+1), indicating that the client expects to receive the server data sequence number is y+1 +1 (ack_seq=y+1+1); the client state enters TIME_WAIT from FIN_WAIT_2, waits for 2MSL time, and enters CLOSED state; after the server receives the last ACK, it enters CLOSED from LAST_ACK;

eff4b3ef7cb3d4a8d4c8429d6656c785.png

04e4d61448d0268d8cc9067abc3e9077.png

Why do you need to wait for 2MSL?

  • The last message is not acknowledged;

  • Make sure that the sender's ACK can reach the receiver;

  • If not received within 2MSL, the receiver will resend;

  • Make sure that all packets of the current connection have expired.

6. Application layer

Provides an interface for the operating system or network application to access network services. Application layer focus:

  • The basic unit of data transmission is a message;

  • The main protocols included: FTP (File Transfer Protocol), Telnet (Remote Login Protocol), DNS (Domain Name Resolution Protocol), SMTP (Mail Transfer Protocol), POP3 Protocol (Post Office Protocol), HTTP Protocol (Hyper Text Transfer Protocol).

6.1 Detailed explanation of DNS

DNS (Domain Name System: Domain Name System) [C/S, UDP, Port 53]: Solve the problem that IP addresses are complex and difficult to remember, and store and complete the mapping from domain names to IP addresses of hosts within their jurisdiction.

The order of domain name resolution:

  • [1] Browser cache,

  • [2] Find the hosts file of the machine,

  • [3] Route cache,

  • [4] Find the DNS server (local domain name, top-level domain name, root domain name) -> iterative resolution, recursive query.

IP—>DNS service—>Easy-to-remember domain name

Domain names are composed of dots, letters and numbers, and are divided into top-level domains (com, cn, net, gov, org), second-level domains (baidu, taobao, qq, alibaba), and third-level domains (www) (12-2-0852 )

bb8ffe7ba823e28fa3df96f8f86f7867.png

6.2 Detailed explanation of DHCP protocol

DHCP (Dynamic Configuration Protocol: Dynamic Host Configuration Protocol): It is a local area network protocol and an application layer protocol that applies the UDP protocol. Function: Automatically assign IP addresses to users temporarily accessing the LAN.

6.3 Detailed explanation of HTTP protocol

File Transfer Protocol (FTP): Control connection (port 21): Transfer control information (connection, transfer request) in 7-bit ASCII format. It remains on for the entire session.

HTTP (HyperText Transfer Protocol: Hypertext Transfer Protocol) [TCP, port 80]: It is a reliable data transmission protocol. Before the browser sends and receives messages to the server, it first establishes a TCP connection. HTTP uses the TCP connection method (HTTP itself has no connection. ).

HTTP request message method:

  • GET: Request the specified page information and return the entity body;

  • POST: Submit data to the specified resource for processing requests;

  • DELETE: Request the server to delete the specified page;

  • HEAD: Request to read the header of the information identified by the URL, and only return the header;

  • OPETION: request information about some options;

  • PUT: Store a document at the specified URL.

b7ecaf8e562f2dfd35b7bdd3683bd0ad.png

4f15ee1910c9031f33caf84608c7ea5c.png

6.3.1 The structure of HTTP work

5d0536df857b47e9e5b55d81d877610a.png

6.3.2 Detailed Explanation of HTTPS Protocol

HTTPS (Secure) is a secure HTTP protocol, port number 443. Based on the HTTP protocol, it provides encrypted processing of data, verification of the identity of the counterparty, and data integrity protection through SSL or TLS.

END

Author: so it is

Original address: https://blog.csdn.net/Royalic/article/details/119985591


The copyright belongs to the original author, if there is any infringement, please contact to delete it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324186426&siteId=291194637