There are two kinds of network layered models: OSI model and TCP/IP model. The OSI model is divided into seven tiers, and the TCP/IP model is similar to the OSI model, but is divided into four layers.
OSI model
The OSI process is open systems interconncection, which is interconnected by an opening system, which is developed by the ISO (International Organization for Standardization). OSI is a general framework for network communication, which is divided into seven layers and defines how data is processed at each level.
| Number of layers |
Layer Name |
Notes |
| 7 |
Application Layer (application) |
|
| 6 |
Presentation Layer (Presentation) |
|
| 5 |
Conversation Layer (session) |
|
| 4 |
Transport Layer (Transport) |
|
| 3 |
Networking Layer (Network) |
Router |
| 2 |
Data Link Layer |
Switch |
| 1 |
Physical Layer (physical) |
Network card, hub (hub) |
English shorthand: All people Seem to need Data processing.
Layer Seventh-Application layer (application)
The "app" here is different from the application.
When a user uses a browser to open a Web page, it needs to take advantage of DNS-provided domain name resolution service to obtain the corresponding IP address of the URL and then download the page content via another protocol HTTP. The two Protocols (DNS and HTTP) that occur during this process are protocols that work on the application layer.
Other common protocols for the application tier:
- ftp: A file transfer protocol used to transfer files between a client and an FTP server.
- DHCP: Dynamic Host Configuration Protocol, the DHCP server dynamically assigns IP addresses to clients.
- POP3: Mail receive protocol for receiving mail from the POP3 server.
- SMTP: A mail-sending protocol in which users send messages through an SMTP server.
Sixth Layer--presentation layer (Presentation)
The "representation" here refers to the representation of the data.
The main functions of this layer: conversion , compression and encryption .
SSL (Secure Sockets layer) is most commonly used for cryptographic protocols that work in the presentation layer. Cryptographic protocols do not necessarily need to work in the presentation layer, such as IPSec (Internet Protocol Security, Internet Protocol safety) that works in the third layer of the network layer.
Level fifth-session level
A "session" can be understood as a logical connection between two application processes, and two applications exchange data over a period of time through this logical connection. The role of the session layer is to provide the necessary methods for creating, managing, and terminating sessions. These methods typically occur in the form of APIs (application program Interface, application programming interfaces). Commonly used APIs are NetBIOS (network basic input/output System), RPC (remote Procedure Call), and socket API.
The session layer is also responsible for managing and determining the transport mode. The computer can transmit data in three modes: one-way (Simplex), half-duplex (Half-duplex), full-duplex (Full-duplex).
- Simplex: Data can only be transmitted in one direction.
- Half-duplex: Allows data to be transmitted one-way, but only one direction can be transmitted at a time, not bidirectional.
- Full-duplex: Data can be transmitted in both directions at the same time.
Fourth layer--Transport layer (Transport)
The Transport layer provides services for data transfer. The "transmission" here refers to the end-to-end (end-to-end) or host-to-host (host-to-host) transmission.
The two most important protocols on the transport layer are TCP and UDP. TCP is a connection-oriented protocol (connection-oriented), and UDP is a non-connected protocol (connection-less).
TCP (transmission Control Protocol, transmission protocol)
TCP must first establish a connection before transmitting the data. TCP does a lot of work to provide reliable data transfer, including establishing, managing, and terminating connections, confirmations, and retransmissions. TCP also provides fragmentation and reassembly, flow control, and so on.
UDP (user Datagram Protocol, Subscriber Datagram Protocol)
UDP is a simple transport layer protocol, so it does not provide reliable data transfer. Simply put, UDP simply packages the data sent by the application into a UDP datagram (UDP Datagram) and then sends the datagram to the IP.
TCP uses the data sent by the application into several TCP segments of the appropriate size (TCP Segment), while UDP simply packages all the sent data into a single UDP datagram, so when we write programs that use UDP, we cannot write too much data to UDP at once. Failure to do so may result in IP fragmentation.
Since there may be many applications that use TCP/UDP at the same time, they will hand over the data to TCP/UDP, and TCP/UDP will also receive data from the IP containing points to different applications, so there is a way to differentiate (identify) the application, This approach is multiplexed or multiplexed through the port number ( port). The port number is a 16-bit binary integer whose value range is 0~65535.
Multiplexing (multiplexing)
Multiplexing is when the application passes data to TCP or UDP, TCP divides the data into TCP segments, and UDP generates a UDP datagram. In these TCP and UDP datagrams, the source port number and destination port number specified by the application are populated, the source port number is used to identify the sending application (process), and the destination port number is used to indicate the target application that should receive the data on the target machine.
multi-Channel decomposition (demultiplexing)
Multi-channel decomposition is the inverse process of multiplexing. When TCP or UDP on the target machine receives the TCP segment and UDP datagram, the target port number is checked, and the data is distributed to different applications (processes) based on the different destination port numbers.
Layer three--network layer
The network layer is concerned primarily with how to send data from one device to another. The network layer needs to provide three basic functions: address , routing , fragmentation, and reassembly . Additional features, such as error handling and diagnostics, are also required.
The most important protocol IP (Internet Protocol) on the network layer is designed for these functions. There are now altogether two versions of IP IPv4 and IPv6. The main difference between the two is that a binary integer with a different number of digits is used as the address: IPv4 uses a 32-bit binary address, and IPV6 uses a 128-bit binary address. The address representation method for IPV4 is typically 4 digits separated by dots, and the range of values for each number is 0~255, which is the size of a byte, such as 192.168.1.1. IPV6 is represented by a colon separated by 8 words (word,16 bit binary), each word in hexadecimal notation, such as 2012:0000:4528:7d76:3c2b:05ad:3f57:1c98.
Second Layer-Data link layer
The network layer is concerned with how to send data from one device to another, which may be on a local network or in a remote network. The data link layer is concerned with how to send data to the local network. The LAN (local area network, LAN) technologies that we often talk about, such as Ethernet (Ethernet), token Ring, Fiber Distributed Data Interface (FDDI), and 802.11 (WiFi), are defined at this level.
The data link layer is also divided into two sub-layers: The logical Link Control layer (Logical link controls) and the Media access control layer (media access controls).
The data link layer also has an important concept, that is, the MAC address, some people call it physical address, hardware address, Ethernet address and so on. Each NIC (Network Interface card) has a unique MAC address, and the data link layer uses the MAC address to ensure that the data is correctly sent to the target device. The MAC address is a 48-bit binary integer that is typically represented by a-6 hexadecimal integer separated by--such as 14-fe-b5-b0-2b-96.
First Layer-Physical layer (physical)
The physical layer is at the bottom of the OSI, and all other layers of data must eventually be sent through the physical layer. The physical layer features include:
- The definition of hardware specifications, such as cables, connectors, wireless receivers and other working methods, network cards, hubs and other networking equipment also work in the physical layer.
- Encoding and signaling, the physical layer converts binary 0 and 1 in a computer into a signal that can be transmitted on a physical medium.
- The physical layer is responsible for the actual transmission and reception of the signal after the data has been converted into a signal (for example, a twisted pair cable is an electronic pulse signal).
TCP/IP model
The TCP/IP model is divided into four tiers: the application layer (application), the Transport layer (Host-to-host Transport), the Internet Layer (Internet), and the network interface layer (NET Interface).
The physical layer is not included in the TCP/IP model. In addition, two important protocol ARP (address Resolution Protocol, addresses Resolution Protocol) and RARP (Reverse address Resolution Protocol, reverse address Translation protocol), In the OSI model is generally considered to be located in the second layer of data link layer and the third layer of network layer, and in the TCP/IP model is located in the network interface layer.
Summarize
The data for the sender application always starts at the top, layers down, and eventually sends out through the physical layer, and accordingly, after the receiver's physical layer receives the data, the layers are eventually distributed through the application layer to the specific application process.
In the process of data layer down, each layer carries out some encapsulation (such as packaging or coding) of the data, while in the process of data layer upward, each layer will perform some inverse processing (such as unpacking or decoding) of the data. The process of data processing and inverse processing is to realize the service of this layer.
Network layering model