The importance of computer networks in the IT industry

IT is Internet technology, engaged in work and the network has a great relationship, the front end is responsible for and background (server) interaction, IT must go through the network, so understand some network knowledge is very helpful.

A classic interview question

Q: What is the process of entering a url in a browser and seeing the page?

Everyone has their own answer, so here’s my answer to this question:

  • The browser accesses the DNS server and obtains the IP address corresponding to the entered domain name
  • Browse the connection requests that are processed through HTTP and IP protocols and then sent to the Internet
  • Over the Internet, routers use complex algorithms to find the ‘optimal path’ to route requests based on the destination IP address
  • Locate the network card of the target IP computer (server) and establish a connection through a three-way handshake
  • The server parses the request and returns the desired page to the browser
  • The browser takes the data and analyzes the DOM structure and CSS to form a renderTree and renders it to the page
  • Steps 1-6 are repeated for resources that need to be requested from the server during rendering

This series will continue with the answers above to the network essentials that the front end must know:

  • DNS server and cross-domain problems
  • Layered models of computer networks
  • IP address and MAC address
  • Computer networking knowledge that the front end must know – (cross domain, proxy, local storage)
  • Computer network knowledge the front-end must know — (TCP)
  • What the front end must know about computer networking — (HTTP)
  • Computer network knowledge that the front-end must know — (XSS, CSRF, and HTTPS)

Network model data processing process

DNS server, IP address, and MAC address

The MAC address

  1. In the Internet, data is sent and transmitted between calculators through network cards, so the establishment of a connection between computers is also the establishment of a connection between two network cards.
  2. Each network card has a globally unique address to identify itself, which is never repeated
  3. MAC address A 48-bit binary address, usually divided into six segments, expressed in hexadecimal

The IP address

What is an IP address

  1. The Internet has a word because it is structured like an invisible network connecting computers all over the world, and routers and computers belong to one node in this network.
  2. The network portion of an IP address is uniformly assigned by the Internet Address Assignment Agency, which ensures that the IP address is unique and used to identify a node in the network.
  3. IP addresses are made up of 32 bits, which divide networks into A, B, and C, thus forming A type postcode thing to represent networks and subnetworks
  4. All IP addresses are 1, that is, 255.255.255.255, which is called restricted broadcast address. If a packet is used as a target address, it can be understood as sending to all hosts on all networks
  5. All zeros in the IP address are 0.0.0.0, which indicates the IP address at startup. It is the IP address that has not been assigned
  6. 127 is used to test the local host. All IP addresses starting with 127 represent the local host except 127.255.255.255

Network id and host ID

The network number indicates the range and size of the network. For example, the IP address range of class A networks: 1.0.0.0 to 127.0.0.0 indicates that there are 126 class A networks (1.0.0.0 to 126.0.0), and the remaining 0.0.0 to 1.1.1 indicates that there can be 2^24-1 hosts under each network. B, C and so on.

Public and private addresses

  • The IP addresses of Class A networks range from 1.0.0.0 to 127.0.0.0. The private IP addresses of Class A networks range from 10.0.0.0 to 10.255.255.255
  • Class B network IP addresses range from 128.1.0.0 to 191.255.0.0. Class B private IP addresses range from 172.16.0.0 to 172.31.255.255
  • Class C network IP addresses range from 192.0.1.0 to 223.255.255.0. Class C private IP addresses range from 192.168.0.0 to 192.168.255.255
  • All networks except private networks have public IP addresses

A public network is an IP address identified on the Internet, while a private address cannot be used to identify a host on the Internet. A private address can only identify a host on a private network or LAN. For example, Beijing is a public address, and Nanjing Street is a private address, because Beijing has Nanjing Street, Jiangxi also has Nanjing Street, can not use Nanjing Street as a public address.

Subnet and subnet mask

  • A subnet mask, also called a subnet mask, is used to specify which bits of an IP address identify the subnet where a host resides, and which bits identify the host.
  • A subnet mask cannot exist alone. It must be used together with an IP address. It has only one function, that is, it divides an IP address into network address and host address.
  • The subnet mask also contains 32 binary bits. The network part of the corresponding IP address is represented by 1, and the host part of the corresponding IP address is represented by 0
  • The default subnet mask for class A addresses is 255.0.0.0
  • Default subnet mask 255.255.0.0 for class B addresses
  • The default subnet mask of a Class C address is 255.255.255.0

The two IP addresses are 172.20.0.18 and 172.20.1.16 respectively, and the subnet mask is 255.255.255.0. The network ids of the two devices are 172.20.0 and 172.20.1 respectively. They cannot communicate with each other directly and therefore cannot be pinged through. To communicate with each other, the subnet mask needs to be changed to 255.255.0.0. Otherwise, the network can be divided using the subnet mask.

IP address and MAC address

  • MAC addresses are unique identifiers determined by different suppliers, so they cannot be regularized and regionalized. Therefore, IP addresses with the same uniqueness are used instead, because IP has the characteristics of classification and region lines.
  • The MAC address of a network adapter is fixed. The MAC address of a network adapter never changes after it is created. However, the IP address is not fixed because it is randomly assigned to the network adapter. For example: MAC address is you, Jiangxi Nanjing Street 18 and Beijing Nanjing Street 18 is IP address, as long as you assigned IP, you live inside, can find you through IP.

Layered models of computer networks

OSI seven layer model

  • The Application layer provides interface services between the network and user Application software
  • The Session layer (Session) provides a mechanism for establishing and maintaining communication between applications, including access authentication and Session management
  • Presentation layer provides formatted Presentation and transformation of data services, such as encryption and compression
  • Establish, maintain, and cancel transport connections to reliably transfer data (PC)
  • Network layer Handles routing between networks to ensure timely transmission of data (router)
  • DataLink layer (DataLink) is responsible for error-free data transmission, frame confirmation, error retransmission, etc. (switch)
  • Physics provides mechanical, electrical, functional, and process characteristics (network card, network cable, twisted pair, coaxial cable, repeater)

TCP/IP reference model

The above model is only an ideal and theoretical level, but the TCP/IP reference model is most used in reality:

  • The application layer
  • The transport layer
  • The network layer
  • Data link layer
  • The physical layer

Why stratification

  • Application layer: Users use a variety of network software with different functions, so the data parsing process is also different. Therefore, the application layer provides interface services between the network and user application software to adapt to the differences.
  • Transport layer: Data must be transmitted through the network, it will inevitably face many problems, such as the connection is not persistent, delay, packet loss and other problems will affect the stability of network transmission, so the transport layer provides the function of establishing, maintaining and canceling the transmission connection, responsible for the reliable transmission of data
  • Network layer, data transmission in the network, the network of institutions are complex, all roads to Rome, so there are a number of potential from sending to the receiving line, how to choose a route to ensure that the data arrive faster, it involves a lot of problems such as’ the shortest path algorithm, so the network layer routing between processing network, ensure the data transfer (router) in time
  • Data link layer: the router is responsible for IP address search in the Internet, but in the LAN, the use of private IP, this time needs to deal with the search and transmission between the LAN and private IP, so the data link layer is responsible for error-free transmission of data, frame confirmation, error retransmission, etc. (switch)
  • Physical layer: The transmission of the network is always through the media, so the physical layer provides network cards, network cables, twisted-pair cables, coaxial cables, Repeaters and other media

The TCP/IP reference model is layered above, but it has certain disadvantages, so it is extended above:

  • Session layer: Because tcp-based connections are not durable, a session layer is added below the application layer to provide mechanisms for establishing and maintaining communication between applications, including access authentication and session management cookie and session.
  • Presentation layer: Because THE TCP connection is insecure and prone to request interception and tampering, resulting in password leakage, injection attacks and other problems, the presentation layer is added on top of the transport layer to provide formatted presentation and transformation data services, such as encryption and compression

Router and Switch

  • A router is responsible for routing and connection between Internet nodes. It ensures the most efficient data transmission through the mapping of public IP addresses and MAC addresses of routers
  • Switches are used to map private IP addresses and MAC addresses on the LAN to process data transmission
  • Switches belong to the data link layer, and routers belong to the network layer. Data is continuously encapsulated and unencapsulated during transmission. Devices at each layer can only process data at one layer

Model data processing

Conclusion: IT is the Internet technology, engaged in the work and the network has a great relationship, the front end is responsible for and background (server) interaction, IT must go through the network, so understand some network knowledge is very helpful. The following will be introduced:

  1. Cross domain and proxy
  2. TCP
  3. HTTP
  4. HTTPS
  5. The illustration of HTTP
  6. Computer network