The network layer

Section 1 Network layer Services

The main function of the network layer is to send network layer datagrams from the source host to the destination host.

The main features include:

  • Forwarding: Packet transfer from input interface to output interface.
  • Route selection: Determines the route or path that a packet passes through.

Section two: Datagram network and virtual circuit network

According to whether the connection service is provided at the network layer or not, packet-switched networks can be divided into virtual circuit networks that provide connection service only at the network layer and datagram networks that provide connectionless service only at the network layer.

Virtual circuit network

Virtual network: Provides connection-oriented packet switching services at the network layer. Before the communication, the two parties need to establish the virtual circuit, and then remove the virtual circuit after the communication.

The characteristics of

  • Establish a network layer logical connection.
  • There is no need to allocate exclusive resources (as opposed to circuit switching) to each virtual circuit.
  • Sends packets sequentially along the virtual circuit path according to the virtual circuit number.


Virtual circuit

A virtual circuit (VC) consists of three elements:

  • A path (that is, a series of links and packet switches) from the source host to the destination host.
  • Each link on the path has a virtual circuit identifier (VCID).
  • The forwarding table of each packet switch on this path records the connection relation of the virtual circuit id.


Virtual circuit packet switching classification

Virtual circuit packet switching has two types: permanent and switched.

Permanent virtual circuit: a virtual circuit that is extracted and built for long-term use. The setup time of the virtual circuit is negligible.

Switched virtual circuit: a temporary virtual circuit established according to communication needs and immediately removed after communication. The time cost of establishing and removing the virtual circuit sometimes has a relatively large impact.

Datagram network

Datagram network: a network for routing by destination host address.

The characteristics of

  • No connection: The two parties do not need to establish a connection before the communication starts.
  • Each packet is transmitted as a separate datagram and may take a different path.
  • Groups may be out of order and lost.

Section 3 Network Interconnection and network interconnection equipment

Heterogeneous network interconnection

Heterogeneous network: The two networks use different communication technologies and protocols.

Basic strategies for heterogeneous network interconnection:

  • Protocol conversion

    • Protocol conversion mechanism uses a class of network intermediate devices that support protocol conversion between heterogeneous networks to implement data packet conversion and forwarding between heterogeneous networks.
  • Build a virtual Internet

The router

The main task of a router is to obtain and maintain routing information and forward packets. From the perspective of functional architecture, it can be divided into input port, switching structure, output port and routing processor.

The input port

The input port is responsible for receiving signals from the physical interface, restoring data link layer frames, extracting IP datagrams, retrieving the routing table according to the destination IP address of IP datagrams, and deciding which output port to switch IP datagrams to.

Exchange structure

The switching structure is responsible for forwarding packets. The IP datagrams of the input port are switched to the specified output port.

Switching structures There are three switching structures for forwarding packets:

  • Based on memory swapping
  • Bus-based switching
  • Network based switching

The performance of switching structures largely determines the performance of routers. The performance rankings of the three switching structures are as follows:

Network based Switching > Bus based Switching > Memory based switching

Output port

The output port first provides a cache queuing function, queues and switches to the generation sending packet of the port, and continuously takes out packets from the queue to encapsulate data frames at the data link layer and sends them out through physical lines.

Routing processor

The routing processor is the CPU of the router, which is responsible for executing various instructions of the router, including the running of routing protocol, routing calculation and routing table update and maintenance.

Section 4 Network congestion control

Flow control VS congestion control

Flow control

The data sending party adjusts the data sending rate and data volume according to the data receiving ability of the data receiving party, including receiving cache and processing speed, to avoid the data flooding of the data receiving party.


Congestion control

Adjust the data transmission rate and data volume according to the network capacity or network congestion.


conclusion

Congestion control mainly considers the network environment between the end systems to make the network load not exceed the transmission capacity of the network.

Traffic control mainly considers the data receiving and processing capability of the receiving end to ensure that the sending rate of the sending end does not exceed the receiving capability of the receiving end.

As an analogy, suppose A train line passes from point A to point B. If in order to adapt to the parking capacity of the parking lot at B, to adjust or restrict the release rate of vehicles at A, this is flow control; Congestion control is defined as restricting the speed at which vehicles are released from Point A to point B in order to avoid traffic congestion on the road network from point A to point B, or to eliminate traffic congestion that has occurred.

Generally speaking, there are four main reasons for congestion:

  • Limited buffer capacity (limited parking space)
  • Limited bandwidth of transmission lines (limited road transmission)
  • Limited processing capacity of network nodes (limited processing capacity of toll stations)
  • Some part of the network is down (there is a car accident)

Congestion on a network means that the load is temporarily larger than the processing capacity of network resources. To solve congestion, you can increase network resources or reduce network load.

Increase network resources: Allocate more available resources to each node before network congestion occurs to reduce the possibility of congestion, which is called congestion prevention.

Reducing network load: This policy is generally used to reduce the current network load to eliminate congestion when the network load exceeds resources. This policy is commonly called congestion elimination.

Traffic aware routing

Traffic aware routing: dynamically adjusts network load to divert network traffic to different links to balance network load, alleviating or avoiding congestion (congestion prevention).

This approach also has its drawbacks and may cause the entire network to oscillate. There are two methods to solve the flapping problem: One is multi-path routing, that is, the traffic between two areas is transmitted on two different links so that the load on either link is not too heavy. In the other case, the traffic on the overloaded link is slowly transferred to the other link rather than all the traffic is transferred from one link to the other link at a time.

Access control

Access control is a congestion prevention technology widely used in virtual circuit networks.

Basic idea: new virtual circuit audit, if the new virtual circuit will lead to network congestion, then the network refused to establish the new virtual circuit.

How do you determine whether you have the ability to accept new virtual circuits without congestion? Therefore, some method is needed to quantify the traffic and congestion in the network. The common method is to judge whether it is capable of accepting new virtual circuits without congestion based on average flow and instantaneous flow.

Flow control

When network congestion occurs, you can adjust the rate at which data is sent to the network to eliminate the congestion.

  1. Perception of congestion

  2. Congestion handling: Notifies its upstream nodes of congestion information so that they can slow down the transmission rate.

Treatment methods:

(1) Suppression group: return a suppression group to the source host of the congested datagram.

(2) Back pressure: make the inhibition group exert inhibition effect at every hop on the path from congested node to source node.

Load shedding

Load shedding: Another method of eliminating congestion is to reduce network load by selectively and actively discarding some datagrams, thereby relieving or eliminating congestion. If a datagram in a router is not processed in time and may be discarded, the router actively discards the datagram.

How to select datagrams to discard:

1. Discard new groups, such as GBN (N step back).

2. Discard old groupings: real-time video streams

Section 5 Internet Network Layer

Section 6 Routing algorithm and Routing protocol

Routing algorithm

When a packet reaches a router, the packet is forwarded based on the destination IP address of the packet on the Internet. In a virtual circuit network, routing algorithms are needed to forward packets according to the VCID of packets.

Function of routing algorithm

Find an optimal path from the source router to the destination router given a set of routers in the network and links between routers.

Routing algorithm classification

Routing algorithms can be divided into global routing algorithms and distributed routing algorithms according to whether they calculate routes based on global network information.

Global routing algorithm

According to the complete network information (that is, the complete network topology), to calculate the shortest path. This algorithm does not mean that route calculation is performed only on a certain router, but that each router obtains complete network topology information when calculating routes. The most representative global routing algorithm is the link state routing algorithm (LS algorithm).

Distributed routing algorithm

In the algorithm, the node will not (don’t need to try to get the entire network topology information, nodes need to get connected with link “cost” of information, as well as notices of neighbor nodes to other nodes of the shortest distance (estimated) information, through constant iterative calculation, eventually learn through which neighbors may have the shortest distance to the destination node. The most representative distributed routing algorithm is distance vector routing (DV algorithm).

Link state routing algorithm

Link-state routing algorithm is a global routing algorithm. Each router needs to build a topology of the entire network when calculating routes.

Calculate the shortest path – Dijkstra algorithm

Distance vector routing algorithm

Each node calculates and updates the shortest distance to each destination node based on the direct link distance between the node and its neighbor and the distance vector exchanged by the neighbor. Then the new distance vector is notified to all its neighbors until the distance vector no longer changes.

Hierarchical routing

Whether link-state routing algorithm (LS algorithm) or distance vector routing algorithm (DV algorithm), if applied to large-scale networks with a large number of network devices, both the broadcast of link-state groups and the exchange of distance vectors will greatly consume network bandwidth and time. Therefore, the most effective and feasible solution to realize large-scale network routing is hierarchical routing.

Hierarchical routing divides the routing of large-scale Internet into two layers: intra-autonomous system routing and inter-autonomous system routing.

In a hierarchical routing network, the routing table of a router is set by both intra-AS and inter-AS routing protocols.

Internet routing protocol

  • The Internet’s intra-autonomous System routing protocol is called internal Gateway Protocol (IGP)

    • Routing Information Protocol (RIP)
    • Open Shortest Path First protocol (OSPF)
  • The Inter-Autonomous System routing protocol for the Internet is called the External Gateway Protocol (EGP)

    • Border Gateway Protocol (BGP)

RIP

RIP is a protocol based on the distance vector routing algorithm.

RIP uses the DV algorithm to provide the following features:

  • The hop count is used to measure the path, that is, the cost of each link is 1.
  • The cost is defined between the source router and the destination subnet. The cost of the shortest path is defined along the route from the router to the destination subnetThe source routerThe purpose of subnetNumber of subnets passed by the shortest path of.
  • Restricted to autonomous systems whose network diameter does not exceed 15 hops.

In RIP, adjacent routers exchange distance vectors through RIP response packets at a frequency of about 30 seconds.

OSPF

RIP is a protocol based on the link-state routing algorithm. It uses Dijkstra algorithm to solve the shortest path.

OSPF more advantages

1 ️ ⃣ security. All OSPF packets are authenticated, preventing malicious intruders from injecting incorrect routing information into the forwarding table of the router.

2️ support multiple same cost paths. OSPF allows multiple paths with the same cost. In this way, all traffic is sent to one path if there are multiple paths with the same cost from source to destination. This feature helps to balance network traffic.

3️ discount cost measurement. OSPF allows you to set different cost metrics for the same link according to the TOS of IP datagrams, so that different types of network traffic can be diverted.

4️ support unicast and multicast routing.

5️ layering route.


RIP packets are encapsulated into UDP packets for transmission, whereas OSPF packets are encapsulated into IP packets for transmission.

BGP

BGP exchanges routing information across autonomous systems.

BGP provides the following functions:

1️ accessibility information of a subnet obtained from adjacent AS.

2️ communication of a subnet accessibility information across AS to all routers in local AS.

3️ Based on the accessibility information of a subnet and AS routing policy, the best route to the subnet is determined.

Summary of this section

Routing is one of the important functions of network layer. Routing algorithms usually abstract the network into a weighted undirected graph to calculate the optimal path. Typical routing algorithms include link state routing algorithm, distance vector routing algorithm and hierarchical routing strategy. Hierarchical routing solves the problem of large – scale network routing. Hierarchical routing divides network routing into two layers: intra-autonomous system routing protocol and inter-autonomous system routing protocol. Typical routing protocols on the Internet include INTRA-AS routing protocols RIP and OSPF and inter-AS routing protocols BGP. RIP is based on the distance vector routing algorithm, OSPF is based on the link state routing algorithm, and BGP can be regarded as the path vector routing algorithm. RIP packets are encapsulated into UDP packets for transmission, OSPF packets are encapsulated into IP datagrams for transmission, and BGP packets are encapsulated into TCP packets for transmission.