Network Layer Foundation

The network layer is mainly responsible for the communication between two end nodes, also known as point-to-point communication.

The relationship between the network layer and data link layer

The data link layer is mainly responsible for the transmission of two nodes connected to the same data link. If multiple data links need to be crossed, the help of the network layer is required.

For example, a journey involves taking trains, cars, and planes, and the order of taking these means of transportation follows the schedule. A train or plane ticket can only be used within a specific vehicle (distinction), and this vehicle is now referred to as the data link layer, and the itinerary is the network layer.

To put it simply, data links provide only communication between two directly connected devices, while the network layer is responsible for communication between two networks that are not directly connected.

To summarize the functional differences between the two layers:

Network layer:

  • Heterogeneous network interconnection (communication between two non-directly connected networks)
  • Routing and forwarding (when the router forwards the user’s IP datagrams from the appropriate port based on the forwarding table)

Data link layer:

  • The establishment, removal, and separation of links
  • Frame demarcation and frame synchronization
  • Sequence control refers to the control of the sequence of sending and receiving frames
  • Error detection and recovery

The IP address

IP addresses are represented by 32 – bit positive integers. In computers, they are treated as binary, but are generally displayed as decimal, as shown in the figure

IP addresses are assigned to each network card connected to the Internet. Usually, a host has one network card, or ONE IP address, while a router has two network cards, or two IP addresses.

IP Address Composition

An IP address consists of a network id and a host ID. Network ids must be the same in the same network segment, but host ids must be different. Network identifiers on two different network segments must be different to ensure the uniqueness of IP addresses of devices connected to the network.

There are two ways to identify network identifiers and host identifiers. The first way is by fixed classification, and the second way is by subnet mask.

Let’s start with the first way:

  • In A Class A address, the first eight bits are the network ID and the last 24 bits are the host ID, that is, 0.0.0.0 to 127.0.0.0 are the network address of A.
  • Class B address: the first two bits of an address are 10. The first 16 bits are network addresses, and the last 16 bits are host addresses. That is, 128.0.0.0 to 191.255.0.0 are THE network addresses of B.
  • Class C address: the first three bits of an address are 110. The first eight bits are network addresses and the last eight bits are host addresses. That is, 192.168.0.0 to 239.255.255.0 are THE network addresses of C.
  • Class D address, the first four bits are 1110, the first 32 bits are network addresses, and the last eight bits are host addresses. That is, 224.0.0.0 to 239.255.255.255 are the network addresses of D. Often used for multicast.

The second way:

The network identity and host identification of an IP address are not restricted by category, but the identification of a subnet mask subdivides the subnet network into smaller networks.

The subnet mask is also a 32-bit positive integer. The corresponding network id part is all 1 and the host part is 0.

Examples are as follows:

The subnet mask can also be differentiated by /. For example, 172.20.0.0/16 indicates the first 16 bits of the network id.

Network layer transmission

During communication, the peer end must have the identification code similar to the address to communicate. In the data link layer, it has the MAC address, while in the network layer, it has the IP address.

Multiple hops routing

The transmission of IP addresses is controlled by routing, which is also called multi-hop routing. Multi-hop routing refers to that each time an IP packet is transmitted, it does not list all the IP addresses of the final IP address. Instead, the action of the next hop is not specified until the final IP address is forwarded through each range.

Compatible with data link layer

The transmission at the network layer must be compatible with various data links. For example, FDDI can transmit 4352 bytes, while MTU can transmit 1500 bytes. When an IP packet is transmitted at the same time, IP packets are fragmented. A large IP packet is divided into several smaller IP packets, which are then combined and sent to the next layer for processing at the other end.

Connectionless oriented

IP is connectionless. There is no need to establish a connection with the peer during transmission, and the packets are still sent regardless of whether the peer exists.

IP uses connectionless mainly because of simplification of connection and speed, facing every link is quite responsible, if every communication has to establish a connection will reduce the processing speed.

Oriented connection

Connection-oriented Service (TCP) is a protocol for two parties to establish a communication line in advance. The process includes establishing a connection, using a connection, and releasing a connection.

radio

Broadcast is to send packets to each other on the same data link, and the broadcast address is the address after the host address is changed to 1. Broadcasting is divided into direct broadcasting and local broadcasting.

Local broadcast:

In the case of the network address 192.168.0.0/24, the broadcast address is 192.168.0.255/24, and the IP packet at this address is blocked by the router, so it will not be transmitted.

Direct broadcast:

Direct broadcast is a packet sent from 192.168.0.1/24 to 192.168.1.255/24. When the router receives the packet, it sends the packet to 192.168.1.0/24 to 192.168.1.254/24.

multicast

Because broadcasting affects a terminal that does not need to receive information, a multicast approach emerges. For multicast, all hosts must comply with the multicast address and the router replicates the multicast packet distribution.

Global address and private address

With the development of the network, IP addresses are increasingly scarce, and there are two solutions to solve this problem, IPv6 and IPv4 with NAT (private address) technology.

Global addresses

In simple terms, all but private addresses are global addresses.

Private address

Private addresses are not fixed, but are assigned when the network is connected to the Internet. Therefore, private addresses can be the same in different network segments, but the network identifiers in the same network segment are limited. Private address ranges are as follows:

  • 10.0.0.0 to 10.255.255.255 (10/8)
  • 172.16.0.0 to 172.31.255.255 (172.16/12)
  • 192.168.0.0 to 192.168.255.255 (192.168/16)

If these private addresses need to access the Internet, NAT technology must be used.

Write in the last

Start a new network layer!

Diagram to TCP/IP

This will be updated irregularly as a recent long-term goal.