preface
- The computer network foundation is the program ape need to master the knowledge, is also the interview process often examined content, but often ignored
- Today, I would like to present a detailed & clear study guide to the basics of computer networking, covering
TCP / UDP
The agreement,Http
The agreement,Socket
Wait, I hope you like it.
directory
1. Computer network architecture
1.1 introduction
- Defines the layers of a computer network + the set of its protocols
- Function Defines the functions that the computer network can perform
1.2 Structure Introduction
- Computer network architecture is divided into three types:
OSI
Architecture,TCP
/IP
Architecture, five-tier architecture
OSI
Architecture: concept clear & concept complete, but complex & impracticalTCP
/IP
Architecture: contains a set of network protocols that form the basis of the InternetInternet
Core protocol & is widely used in LAN and WAN- Five-tier architecture: Converged
OSI
与TCP
/IP
The purpose of the architecture is to learn & explain computer principles
The lower three layers are communication subnets, responsible for data transmission; the third layer is resource subnets, equivalent to computer system, to complete data processing; The transport layer connects the above and below
TCP
/IP
The architecture is detailed as a resultTCP
/IP
The architecture is more extensive, so the main explanation
OSI
The architecture is described in detail
2. The TCP protocol
Transmission Control Protocol
- Belongs to the transport layer communication protocol
- Based on the
TCP
The application layer protocols ofHTTP
,SMTP
,FTP
,Telnet
和POP3
Other knowledge about TCP: such as three handshakes, four waves, error-free control principle, etc., please see the article: Computer network: this is a comprehensive and detailed TCP protocol walkthrough
3. The UDP protocol
3.1 define
User Datagram Protocol
- Belongs to the transport layer communication protocol
- Based on the
UDP
The application layer protocols ofTFTP
,SNMP
与DNS
3.2 the characteristics of
Connectionless, unreliable, packet oriented, no congestion control, described as follows:
3.3 the advantages and disadvantages
- Advantages: Fast speed
- Disadvantages: Easy to lose messages (especially when the network is poor)
3.4 Application Scenarios (Corresponding to Application-Layer Protocols)
High communication speed is required
For example, domain name translation: DNS File transfer: FTP Network management: SNMP Remote file server: NFS
3.5 Segment Format
- A UDP packet segment consists of two fields: data field & header field
- Here is the header (8 bytes, 4 fields)
3.6 Differences between TCP and UDP
4. The HTTP protocol
-
Introduction to the
-
For more information about how it works, message segments, etc., see article: This is a comprehensive and detailed explanation of HTTP
5. Socket
5.1 introduction
- Socket is an intermediate software abstraction layer for communication between application layer and TCP/IP protocol family. It is represented as a programming interface (API) that encapsulates TCP/IP protocol family.
Socket
Not a protocol, but a programming call interface (API
), which belongs to the transport layer (which deals with how data is transmitted across the network)- That is, through
Socket
In order for us to pass on the Android platformTCP/IP
Protocol development- Users can communicate by calling the Socket to organize data in accordance with the specified protocol
- 2. A pair of sockets:
Socket ={(IP address 1:PORT number), (IP address 2:PORT number)}Copy the code
- a
Socket
An instance uniquely represents a communication link for an application on a host
5.2 Other Knowledge
Regarding the Socket principle, the mechanism process & uses the way, the concrete see article: Android: this is a very detailed Socket uses the walkthrough
6. Other knowledge
6.1 Enter a value in the Browserurl
Address ->> Process for displaying the home page
Open a web page, which protocols will be used throughout the process
6.2 IP Address (IPv4 Address)
-
Defines a globally unique identifier for every host (or router) connected to the Internet
-
Component IP address = 32 bits = network number + host number; IP address ::={< Network number >, < Host number >}
Among them:
- Network number: Identifies the network to which the host (or router) is connected. A network number must be unique across the Internet.
- Host NUMBER: Identifies the host (or router). The network range indicated by the network number in front of a host number must be unique.
The number of bytes used by the host number and network number varies with IP addresses of different types. Therefore, an IP address is unique in the entire network
- Classification Traditional IP addresses are classified into five categories: A, B, C, D, and E
The difference lies in the number of bytes between the network number and the host number
- Note: Some IP addresses are used for special purposes and cannot be used as host IP addresses
6.3 the ICMP protocol
- define
Internet Control Message Protocol
, the Internet Control Message Protocol
- It is an IP layer protocol
- Note: THE ICMP packet is not a high-level protocol, but is the data of the IP layer datagram and the header of the datagram to form an IP datagram
- Function to forward IP packets more effectively & improve the chance of successful delivery
It also allows hosts/routers to report errors & exceptions
-
Category ICMP error report packet & ICMP query packet
-
The main applications are PING (packet detection) and Traceroute (tracing the path of a packet from the source to the destination. Principle = Sending a series of IP datagrams from the source host to the destination host).
The following section describes the Ping process
6.4 Ping Process
- define
Packet InterNet Groper
, namely, packet network detection
- is
ICMP
An important application of packets: IPCM is used to send back request and reply packets
- It is an example of the application layer directly using ICMP at the network layer, without passing TCP and UDP at the transport layer
-
Function Tests the connectivity of two hosts
-
The principle of
- Multiple ICMP echo request packets are sent to the destination host
- The round-trip time is calculated based on the timestamp in the ICMP reply packet returned by the destination host
- The IP address sent to the destination host, the number of packets sent, received, and lost, and the minimum, maximum, and average round trip time are displayed
-
The process assumes that there are two hosts: (Destination host) PC1: IP = 192.168.1.1 (source host) PC2: IP = 192.168.1.2
6.5 Differences between Routers and Switches
6.6 the Cookie and Session
- Introduction to the
- Difference & Contrast
6.7 the Cookie and Token
- Introduction to the
- Based on the
Cookie
Authentication & authentication process
- Based on the
Token
Authentication & authentication process
7. To summarize
-
This paper comprehensively explains the basic knowledge of development: computer network
-
I’ll continue with the basics of programming development, and you can follow Carson_Ho’s development notes if you’re interested