There are two types of network layering models: OSI model and TCP/IP model. The OSI model has a total of seven layers, while the TCP/IP model is similar to the OSI model but has only four layers.

The OSI model

The entire process of OSI is Open Systems Interconncection, which is formulated by International Organization for Standardization (ISO). OSI is a general-purpose framework for network communication. It has seven layers and defines how data is handled at each layer.

The layer number Layer of note
7 The Application layer (Application)
6 The Presentation layer (the Presentation)
5 The Session layer (Session)
4 The Transport layer (Transport)
3 The Network layer (Network) The router
2 Data Link Layer switches
1 The Physical layer (Physical) Network card, Hub

All People Seem To Need Data Processing.

Layer 7 — Application Layer

The word “application” should be distinguished from an application. When users use a browser to open a web page, they need to use the domain name resolution service provided by DNS to obtain the IP address corresponding to the url, and then download the page content through another protocol HTTP. The two protocols that emerge from this process (DNS and HTTP) are both protocols that work at the application layer.

Other common protocols at the application layer:

  • FTP: 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: protocol for receiving mails from the POP3 server.
  • SMTP: indicates the mail sending protocol. Users send mails through the SMTP server.

Layer 6 — Presentation Layer

The “representation” here is the representation of the index data. The main functions of this layer: transformation, compression and encryption. The most common encryption protocol that works at the presentation Layer is Secure Sockets Layer (SSL). Encryption protocols do not necessarily work at the presentation layer. For example, IPSec(Internet Protocol Security) works at the layer 3 network layer.

Layer 5 — Session Layer

You can think of a “session” as a logical connection between two application processes through which the two applications exchange data over a period of time. The purpose of the session layer is to provide the necessary methods for creating, managing, and terminating sessions. These methods generally take the form of an API(Application Program Interface). Common apis include NetBIOS(Network Basic Input/Output System), Remote Procedure Call (RPC), and Socket APIS.

The session layer is also responsible for managing and determining transport modes. Computers can transmit data in three modes: Simplex, half-duplex, and full-duplex.

  • Simplex: Data can be transmitted in one direction only.
  • Half-duplex: data can be transmitted in one direction at a time. However, only one direction can be transmitted at a time.
  • Full-duplex: Data can be transmitted bidirectional at the same time.

Layer 4 — Transport layer

The transport layer provides data transfer services. “Transmission” here refers to end-to-end or host-to-host transmission.

The two most important protocols at the transport layer are TCP and UDP. TCP is connection-oriented and UDP is connection-less.

Transmission Control Protocol (TCP)

TCP must establish a connection before transmitting data. TCP does a lot to provide reliable data transmission, including establishing, managing, and terminating connections, acknowledgements, and retransmissions. At the same time TCP also provides segmentation and reorganization, Flow Control and so on.

User Datagram Protocol (UDP)

UDP is a simple transport layer protocol, so it does not provide reliable data transmission. In simple terms, UDP simply packages the data sent to it by an application into a UDP Datagram, which is then passed to IP. TCP divides the data sent by applications into TCP segments of appropriate size, while UDP simply packages all the data sent into a UDP datagram. Therefore, when writing programs that use UDP, we should not write too much data to UDP at one time. Otherwise, IP address segmentation may occur.

Since there may be many applications that use TCP/UDP at the same time, and all of them hand over data to TCP/UDP, and TCP/UDP receives data from IP that contains points to different applications, there needs to be a way to distinguish (identify) applications. This method is multiplexed or decomposed by Port number. The port number is a 16-bit binary integer ranging from 0 to 65535.

Multiplexing is just when an application gives data to TCP or UDP. TCP splits the data into TCP segments and UDP generates a UDP datagram. In these TCP segments and UDP datagrams, the application-specified source port number is used to identify the sending application (process), and the target port number is used to indicate the target application that should receive the data on the target machine.

Demultiplexing is the inverse process of multiplexing. When TCP or UDP on the target machine receives TCP segments and UDP messages, it checks their target port numbers and distributes the data to different applications (processes) based on the different target port numbers.

Layer 3 — Network Layer

The network layer is mainly concerned with getting data from one device to another. The network layer needs to provide three basic functions: address, routing, segmentation, and reorganization. Additional functionality, such as error handling and diagnostics, is also required.

The Internet Protocol (IP), the most important Protocol on the network layer, is designed for these functions. There are two versions of IP, IPv4 and IPv6. The main difference between the two is the use of different bits of binary integers as addresses: IPv4 uses 32-bit binary addresses and IPv6 uses 128-bit binary addresses. IPv4 addresses consist of four digits separated by dots. The value of each digit ranges from 0 to 255, that is, one byte, for example, 192.168.1.1. IPv6 representation method for 8 words separated by a colon (word, 16-bit binary), every word is expressed in hexadecimal to, such as 2012:0000-4528:7 d76:3 c2b: 05 AD: 3 f57:1 c98.

Layer 2 — Data Link layer

The network layer is concerned with how to send data from one device to another device, which may be on the local network or in a distant network. The data link layer is concerned with sending data to the local network. Local Area Network (LAN) technologies such as Ethernet, Token Ring, Fiber Distributed Data Interface (FDDI) and 802.11 (WiFi) are defined in this layer. The data Link layer is divided into two sub-layers: Logical Link Control layer and Media Access Control layer.

Data link layer also has an important concept, namely MAC address, also known as physical address, hardware address, Ethernet address and so on. Each Network Interface Card has a unique MAC address. The data link layer uses the MAC address to ensure that data can be correctly sent to the target device. A MAC address is a 48-bit binary integer. It is usually expressed as six hexadecimal integers separated by hyphens (-), for example, 14-FE-b5-B0-2b-96.

Layer 1 — Physical layer

The physical layer is at the bottom of the OSI, through which all other layers of data must ultimately be sent. Functions of the physical layer include:

  • Hardware specifications define how cables, connectors, wireless receivers, etc., work. Network devices such as network cards and hubs also work at the physical layer.
  • Encoding and signaling, the physical layer converts binary 0s and 1s in a computer into signals that can be transmitted over physical media.
  • After the data has been converted into signals (in the case of twisted-pair cables, electrical pulses), the physical layer is responsible for the actual sending and receiving of the signals.

TCP/IP model

TCP/IP model is divided into four layers: Application layer, Host-to-host Transport layer, Internet layer and Network Interface layer.

The physical layer is not included in the TCP/IP model. In addition, two important protocols, Address Resolution Protocol (ARP) and Reverse Address Resolution Protocol (RARP), In the OSI model it is generally considered to be located between layer 2 data link layer and layer 3 network layer, while in the TCP/IP model it is located at the network interface layer.

conclusion

The data for the sender application always starts at the top layer and works its way down to the physical layer; Accordingly, data is received at the physical layer of the receiver and then distributed up the hierarchy to the specific application process through the application layer. In the process of the data layer down, each layer will perform some encapsulation of the data (such as packaging or coding); As the data layers move up, each layer performs some kind of inverse processing (such as unpacking or decoding) on the data. These processes of data processing and reverse processing are used to implement this layer of services.

TCP/IP is a transport-layer protocol that deals with how data is transferred over the network, while HTTP is an application-layer protocol that deals with how data is packaged. The connection between TCP/IP and HTTP is a simple one. “We could just use [transport layer] TCP/IP when we’re transferring data, but then without the application layer, you can’t recognize the content of the data. If you want to make sense of the data being transferred, you have to use application layer protocols, and there are many application layer protocols, like HTTP, FTP, TELNET, etc., You can also define application layer protocols. The WEB uses HTTP as an application-layer protocol to encapsulate HTTP text, and then uses TCP/IP as a transport-layer protocol to send it to the network.”

The term TCP/IP stands for Transmission Control Protocol/Internet Protocol and refers to a series of protocols. “IP” stands for the Internet protocol used by TCP and UDP to send packets from one network to another. the
Think of IP as a kind of highwayIt allows other protocols to drive on it and find exits to other computers.
TCP and UDP are “trucks” on the highway, carrying goods like HTTP, file transfer protocols such as FTP.
As you can probably understand, TCP and UDP are transport layer protocols used for things like FTP, HTTP, and SMTP. Although both TCP and UDP are used to transport other protocols, they have one significant difference: TCP provides guaranteed data transfer, while UDP does not. This means that TCP has a special mechanism to ensure that data passes safely and error-free from one endpoint to another, whereas UDP does not provide any such guarantees.
HTTP(Hypertext Transfer Protocol) is a protocol that uses TCP to transfer information between two computers, typically a Web server and a client. The client sends an HTTP request to the Web server using a Web browser, and the Web server sends the requested information to the client.
As shown in the following figure, HTTP is an application-layer protocol used to package data, while TCP/IP is a transport layer protocol used to send data in any format to the network.

The following chart attempts to show the position of the different TCP/IP and other protocols in the original OSI model:

7 The application layer For example,HTTP,SMTP,SNMP,FTP,Telnet,SIP,SSH,NFS,RTSP,XMPP,Whois,ENRP
6 The presentation layer For example,XDR,ASN.1,SMB,AFP,NCP
5 The session layer For example,ASAP,TLS,SSHISO 8327 / CCITT X.225,RPC,NetBIOS,ASP,Winsock,BSD sockets
4 The transport layer For example,TCP,UDP,RTP,SCTP,SPX,ATP,IL
3 The network layer For example,IP,ICMP,IGMP,IPX,BGP,OSPF,RIP,IGRP,EIGRP,ARP,RARP,X.25
2 Data link layer For example,Ethernet,Token ring,HDLC,Frame relay,ISDN,ATM,The IEEE 802.11,FDDI,PPP
1 The physical layer For example,line,radio,Optical fiber,A homing pigeon

Connection: the actual circulation of a transport layer that is established between two applications that communicate with each other. 2. Message: The basic unit of HTTP communication, consisting of a structured sequence of octuples transmitted over a connection. Request: A Request from the client to the server includes the method applied to the resource, the resource identifier, and the protocol version number 4. Response: Information returned from a server includes the VERSION number of the HTTP protocol, the status of the request (such as “succeeded” or “not found”), and the MIME type of the document. 5. Resource: Network data objects or services identified by URIs. Entity: A special representation of a data resource or reflection from a service resource, which may be wrapped in a request or response information. An entity includes the entity header information and the entity’s own content. 7. Client: An application that establishes connections for the purpose of sending requests. 8. Useragent: Client that initializes a request. They are browsers, editors, or other user tools. 9. Server: An application that accepts connections and returns information on requests. An Originserver is a server on which a given resource can reside or be created. Proxy: An intermediate program that acts as either a server or a client to establish requests for other clients. Requests are delivered internally or via possible translations to other servers. An agent must interpret and, if possible, override the request information before sending it. The proxy often acts as a portal to the client side through a firewall, and it can also act as a helper application to process requests through the protocol that have not been completed by the user agent. 12. Gateway: A server that acts as an intermediary between other servers. Unlike a proxy, a gateway accepts a request as if it were the source server for the requested resource; The requesting client is not aware that it is dealing with a gateway. A gateway often acts as a server-side portal through a firewall and as a protocol translator to access resources stored in non-HTTP systems. 13. Tunnel: an intermediary program that acts as a relay between two connections. Once activated, a channel is not considered an HTTP communication, although the channel may have been initialized by an HTTP request. When both ends of the relayed connection are closed, the channel disappears. Channels are often used when a Portal must exist or when intermediaries cannot interpret relay communications. 14. Cache: Local storage of information.

2. Send a request After opening a connection, the client sends a request message to the port on the server to complete the request. The format of the HTTP/1.0 request message is: Request message = line (general information HEAD | | request entity HEAD) CRLF [entity] content request line = request URL HTTP version number CRLF method = GET | HEAD | POST | extension methods U R L = protocol name, host name and directory and file name The methods in the request line describe the actions that should be performed on the specified resource. Common methods are GET, HEAD, and POST. Different request objects have different GET results. The mapping is as follows: Object GET result file File content program Execution result database query query result HEAD?? Ask the server to look for meta information about an object, not the object itself. POST?? The data is passed from the client to the server, and the POST method is used when further processing is required from the server and CGI. POST is mainly used to send the contents of a FORM in HTML text for CGI programs to process. An example of a request is: GEThttp://networking.zju.edu.cn/zju/index.htmHTTP/1.0 networking.zju.edu.cn/zju/index.htmHTTP/1.0 header information is also known as meta information, that is, the information of information, Conditional requests or responses can be implemented using meta-information. Request header???? Tell the server how to interpret the request, including the data type, compression method and language that the user can accept. Entity head?? Entity information type, length, compression method, last modification time, data validity period, etc. Real?? Request or reply object itself. 3. Sending a response After processing the client’s request, the server sends a response message to the client. The HTTP/1.0 response message format is as follows: Response message = status line (general information head head | | response entity) CRLF (solid content) status line version number = HTTP status code wrong account status code that response type 1 * said to keep 2 x request successfully received 3 x to complete the customer need to further refine request 4 x client error The information in the 5 x x server error response header includes the name of the server program, notification that the requested URL requires authentication, and when the requested resource can be used. 4. Close the connection


Source: CSDN