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, coveringTCP / UDPThe agreement,HttpThe agreement,SocketWait, 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:OSIArchitecture,TCP / IPArchitecture, five-tier architecture
  • OSIArchitecture: concept clear & concept complete, but complex & impractical
  • TCP / IPArchitecture: contains a set of network protocols that form the basis of the InternetInternetCore protocol & is widely used in LAN and WAN
  • Five-tier architecture: ConvergedOSITCP / IPThe 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 / IPThe architecture is detailed as a resultTCP / IPThe architecture is more extensive, so the main explanation

  • OSIThe architecture is described in detail


2. The TCP protocol

Transmission Control Protocol

  1. Belongs to the transport layer communication protocol
  2. Based on theTCPThe application layer protocols ofHTTP,SMTP,FTP,TelnetPOP3

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

  1. Belongs to the transport layer communication protocol
  2. Based on theUDPThe application layer protocols ofTFTP,SNMPDNS

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.

  1. SocketNot a protocol, but a programming call interface (API), which belongs to the transport layer (which deals with how data is transmitted across the network)
  2. That is, throughSocketIn order for us to pass on the Android platformTCP/IPProtocol development
  3. 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
  • aSocketAn 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 BrowserurlAddress ->> 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:

  1. Network number: Identifies the network to which the host (or router) is connected. A network number must be unique across the Internet.
  2. 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

  • defineInternet Control Message Protocol, the Internet Control Message Protocol
  1. It is an IP layer protocol
  2. 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

  • definePacket InterNet Groper, namely, packet network detection
  1. isICMPAn important application of packets: IPCM is used to send back request and reply packets
  1. 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

    1. Multiple ICMP echo request packets are sent to the destination host
    2. The round-trip time is calculated based on the timestamp in the ICMP reply packet returned by the destination host
    3. 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 theCookieAuthentication & authentication process

  • Based on theTokenAuthentication & 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


Thumb up, please! Because your encouragement is the biggest motivation for my writing!


Welcome to follow carson_ho’s official wechat account