Introduction to Network Principles (Basic)

Table of contents

1. Network division

1. Local Area Network (LAN)

concept

Establishment of LAN (connection method)

2. Wide Area Network (WAN)

concept

Second, the basics of network communication

1.IP address

concept

Format

composition

Classification

Special IP

2. Port number (port)

concept

Format

Notice

3. Five-tuple

4. Subnet mask

Format

effect

Calculation

5.MAC address

concept

effect

special MAC address

6. Hop-by-hop network transmission

explain

Summarize IP address and MAC address

Three, agreement

1. Understand the agreement

concept

Three elements

Embodiment

2. Protocol layering

The role of stratification

3. OSI seven-layer model

concept

seven layer model

4.TCP/IP five-layer (four-layer) model

concept

five layer model 

5. Layers of network devices

Four, packaging and distribution 

foreword

1. Encapsulation

concept

Packaging process

2. Divide

concept

process


1. Network division

1. Local Area Network (LAN)

concept

  • Local area network, that is, Local Area Network, referred to as LAN
  • Local means that the local area network is local, a kind of private network formed locally
  • The hosts in the local area network can facilitate network communication, also known as intranet
  • It is impossible to communicate between LAN and LAN without connection

Establishment of LAN (connection method)

1) Based on network cable direct connection

2) Build based on hub

3) Build based on the switch

4) Based on switches and routers

2. Wide Area Network (WAN)

concept

  • Wide area network, namely Wide Area Network, referred to as WAN
  • Through routers, multiple LANs are connected to form a large-scale network physically, forming a wide area network.
  • LANs inside the WAN are all subnets

Second, the basics of network communication

1.IP address

concept

  • IP address (Internet Protocol Address) refers to the Internet Protocol address, also translated into the Internet Protocol address

Format

  • The IP address is a 32-bit binary number, usually divided into 4 "8-bit binary numbers" (that is, 4 bytes)
  • Or called four decimal numbers 0-255

composition

The IP address is divided into two parts, the network number and the host number

  • Network number : identify the network segment, and ensure that the two network segments connected to each other have different identifications;
  • Host number : Identify the host. In the same network segment, hosts have the same network number, but must have different host numbers ;

By properly setting the network number and host number, it can be guaranteed that the IP address of each host is unique in the interconnected network.

Classification

Classification scope Applicable network Number of networks The maximum number of connections to the host
Class A 0.0.0.0 ~ 127.255.255.255 large network 126 16777214(
-2)
Class B 128.0.0.0 ~
191.255.255.255
medium scale
network
about
16000
65534( -2)
Class C 192.0.0.0 ~
223.255.255.255
small network - 254( -2)
Class D 224.0.0.0 ~
239.255.255.255
Class E 240.0.0.0 ~
247.255.255.255

Remarks: The maximum number of connections of the host minus 2 is to deduct the special IP address whose host number is all 0 and all 1 

Special IP

  • Set all the host addresses in the IP address to 0, which becomes the network number, representing this LAN;
  • Set all the host addresses in the IP address to 1, which becomes the broadcast address, which is used to send data packets to all hosts connected to each other in the same link;
  • The IP address of 127.* is used for the local loopback (loop back) test, usually 127.0.0.1
  • The local loopback is mainly used for the network communication from the local machine to the local machine (the internal system will not use the network for performance),
  • For programs that develop network communication (that is, network programming), the common development method is local-to-local network communication. 

2. Port number (port)

concept

  • In network communication, the IP address is used to identify the network address of the host, and the port number can identify the process of sending and receiving data in the host
  • Simply put: the port number is used to locate the process in the host

Format

The port number is a number ranging from 0 to 65535. In network communication, a process can send and receive network data by binding a port number.

Notice

Two different processes cannot bind the same port number, but one process can bind multiple port numbers

3. Five-tuple

In the TCP/IP protocol, a five-tuple is used to identify a network communication:

  1. Source IP : Identifies the source host
  2. Source port number : Identify the process in the source host that sends data for this communication
  3. Destination IP : Identify the destination host
  4. Destination port number : Identifies the process of receiving data for this communication in the destination host
  5. Protocol number : identifies the data format agreed upon by the sending process and the receiving process

4. Subnet mask

Format

  • The subnet mask format is the same as the IP address, which is also a 32-bit binary number. The left side is the network bit, represented by the binary number "1", and the number of 1 is equal to the length of the network bit; the right side is the host bit, represented by the binary number "0", and the number of 0 is equal to the length of the host bit.
  • The subnet mask can also be represented by adding all high-order 1s in binary, for example, the above subnet mask can also be represented as 24.

effect

(1) Divide A, B, and C three types of IP address subnets

(2) During network communication, the subnet mask and IP address can be used to calculate the network number (the network number after subnetting) and the host number (the host number after subnetting). Generally used to judge whether the destination IP and this IP are in the same network segment 

Calculation

  • Perform a "bitwise AND" operation on the IP address and the subnet mask (binary same bit, and operation, both are 1 and the result is 1, otherwise it is 0), and the result is the network number.
  • Invert the subnet mask binary bit by bit, and then calculate with the IP address bits to get the host number
decimal binary
IP address 180.210.242.131 10110100.11010010.11110010.10000011
subnet mask 255.255.248.0 11111111.11111111.11111000.00000000
network number 180.210.240.0 10110100.11010010.11110000.00000000
host number 0.0.2.131 00000000.00000000.00000010.10000011

5.MAC address

concept

MAC address, namely Media Access Control Address, is used to identify the hardware physical address of the network device

effect

  • The host has one or more network cards, and the router has two or more network cards; each network card has a unique MAC address.
  • Network communication, that is, network data transmission, is essentially a network hardware device that sends data to or receives data from a network card.
  • At the hardware level, the network physical address of the network device can only be identified based on the MAC address

special MAC address

  • Broadcast datagram: Send a broadcast datagram, which means sending datagrams to all hosts on the same network segment
  • The MAC address of the broadcast datagram is: FF:FF:FF:FF:FF:FF

6. Hop-by-hop network transmission

explain

In general, although we have entered the IP address during network transmission, in fact, the network transmission does not go all at once, but through the MAC address, from one device to another and finally to the destination device

Summarize IP address and MAC address

  • The IP address describes the overall starting point and end point of the journey; it is the network logical address used by people

  • The MAC address describes the start and end of each interval on the road, that is, the start and end of each hop; it is the network physical address used by network hardware devices

Three, agreement

1. Understand the agreement

concept

  • Protocol, the abbreviation of network protocol, network protocol is a set of conventions and rules that all network devices that network communication (that is, network data transmission) must follow.
  • Such as how to establish a connection, how to identify each other, etc., only by following this agreement can computers communicate with each other
  • Usually three elements must be followed: syntax, semantics, and timing

Three elements

  1. Syntax: the structure or format of data and control information
  2. Semantics: What kind of control information needs to be sent, what kind of action to complete and what kind of response to make
  3. Timing, that is, a detailed description of the order in which events are implemented

Embodiment

Protocol (protocol) is finally reflected in the format of data packets transmitted on the network

2. Protocol layering

The role of stratification

  • The biggest benefit of layering is similar to interface-oriented programming: define the interface specification between the two layers, and let both parties follow this specification to connect.
  • In the code, it is similar to defining an interface, one is the implementation class of the interface (provider, providing services), and the other is the use class of the interface (user, using services)
  • For the user, it doesn't care how the provider implements it, it only needs to use the interface
  • For the provider, using the feature of encapsulation hides the implementation details and only needs to open the interface

3. OSI seven-layer model

concept

OSI: Open System Interconnection, Open System Interconnection

  • The OSI seven-layer network model is a logical definition and specification: the network is logically divided into seven layers.
  • The OSI seven-layer model is a framework design method, and its main function is to help different types of hosts realize data transmission;
  • Its biggest advantage is that it clearly distinguishes the three concepts of service, interface and protocol. The concept is clear and the theory is relatively complete. Realize reliable communication between different systems and different networks through seven hierarchical structural models

seven layer model

Note: the session layer and the presentation layer have not landed 

4.TCP/IP five-layer (four-layer) model

concept

  • TCP/IP is a synonym for a group of protocols, and it also includes many protocols, which form the TCP/IP protocol cluster.
  • The TCP/IP communication protocol adopts a 5-layer hierarchical structure, and each layer calls the network provided by its next layer to fulfill its own needs.

five layer model 

  1. Application layer : Responsible for communication between applications, such as Simple Email Transfer (SMTP), File Transfer Protocol (FTP), Network Remote Access Protocol (Telnet), etc. Our network programming is mainly aimed at the application layer.
  2. Transport layer : Responsible for data transmission between two hosts. Such as the Transmission Control Protocol (TCP), which can ensure that data is reliably sent from the source host to the destination host.
  3. Network layer : Responsible for address management and routing. For example, in the IP protocol, a host is identified by an IP address, and a data transmission line (route) between two hosts is planned through a routing table. Routers work at the network layer.
  4. Data link layer : Responsible for the transmission and identification of data frames between devices. For example, the driver of the network card device, frame synchronization (that is, what signal is detected from the network line is counted as the beginning of a new frame), conflict detection (automatic retransmission if a conflict is detected), data error checking, etc. There are standards such as Ethernet, Token Ring, and Wireless LAN. A switch (Switch) works at the data link layer.
  5. Physical layer : responsible for the transmission of optical/electrical signals. For example, the network cable (twisted pair) commonly used in Ethernet, the coaxial cable used in early Ethernet (now mainly used in cable TV), optical fiber, and the current wifi wireless network using electromagnetic waves all belong to the concept of the physical layer. The capability of the physical layer determines the maximum transmission rate, transmission distance, anti-interference and so on. Hub (Hub) works at the physical layer

5. Layers of network devices

  • For a host , its operating system kernel implements the content from the transport layer to the physical layer , which is the lower four layers of the TCP/IP five-layer model ;
  • For a router , it implements from the network layer to the physical layer , that is, the lower three layers of the TCP/IP five-layer model ;
  • For a switch , it implements from the data link layer to the physical layer , that is, the lower two layers of the TCP/IP five-layer model ;
  • For hubs , it only implements the physical layer

Four, packaging and distribution 

foreword

  • Different protocol layers have different names for data packets, which are called segments at the transport layer , datagrams at the network layer , and frames at the link layer
  • The header information contains information such as how long the header is, how long the payload is, and what the upper layer protocol is.

1. Encapsulation

concept

  • When the application layer data is sent to the network through the protocol stack, each layer protocol must add a data header (header), called encapsulation (Encapsulation)
  • In layman's terms, when passing through each layer model, it needs to be encapsulated in the protocol format of this layer and sent to the next layer

Packaging process

 

2. Divide

concept

  • After the data is encapsulated into a frame, it is sent to the transmission medium. After reaching the destination host, each layer protocol strips off the corresponding header, and according to the "upper layer protocol field" in the header, the data is handed over to the corresponding upper layer protocol for processing.
  • In layman's terms, when passing through each layer of protocol, use the same protocol for analysis, and then hand it over to the upper layer

process

Guess you like

Origin blog.csdn.net/qq_54773998/article/details/124153380