Computer network top-down approach notes 03

"Computer Network Top-Down Method" Study Notes 03: Network Layer.

The network layer provides host-to-host communication services. Every host and router in the network has a network layer part. The network layer can be broken down into two parts, the data plane and the control plane.

Chapter 4 Network Layer: Data Plane

1 Overview

The task of the network layer is to obtain the message segment of the source host, encapsulate it into a datagram, and send the datagram to the network layer of the destination host through forwarding by the router. It can be said that the role of the network layer is to move packets from one host to another. The functions of the network layer can be divided into two parts:

  • Forwarding: A router-local action by a router that moves packets from an input link to the appropriate output link. It is the main task of the data plane.
  • Routing: Determining the end-to-end path that a packet will take to move.

This chapter mainly discusses the forwarding function of the network layer.

2. How the router works

The router consists of the following components:

  • input port
  • switching fabric
  • Output port
  • routing processor

Input port processing

Input port processing:

线路端接----->数据链路处理(协议,拆封)----->查找,转发,排队----->交换结构

At the input port, the router will use the forwarding table to look up the output port and then hand the packet off to the switching fabric. The forwarding table is calculated and updated by the routing processor. The forwarding table may be calculated by the routing protocol, or it may receive the content from the remote SDN controller and then copy it to the line card.

exchange

Through the switching fabric, routers forward packets from an input port to an output port. There are several ways to exchange:

  • Memory switching: The switching of the earliest routers was completed under the direct control of the routing processor. The input and output ports were similar to IO devices. After receiving the packet, a signal was sent to the processor through an interrupt. The processor extracted the destination address and transferred it to the processor. The packet is copied to the output port's buffer. Modern router lookup and packet storage of destination addresses is handled by the input line card.
  • Switching over the bus: The input port transmits the packet directly to the output port via a bus. The input port needs to plan a label for the group in advance to indicate the local output port. All output ports can receive the group from the bus, but only the output port that matches the label saves the group and removes the label.
  • Switching over an interconnection network: Switching over a more complex interconnection network, such as a crossbar network.

Output port processing

The output ports are handled as follows:

交换结构----->排队(缓存管理)----->数据链路处理(协议,封装)----->线路端接

queue

Queuing may occur at the input port or at the output port, depending on the traffic load, the rate of the switching fabric, etc. As the queue grows and router cache space is exhausted, packet loss occurs.

At the input port, if two packets are sent to the same output port, one packet will be blocked and must wait in the queue. The packet queued behind the waiting packet also has to wait, although its output port is not occupied. This phenomenon is called line front blocking in the input queuing switch.

At the output port, because the output port's sending rate is limited, a queue may also form. When there is not enough memory to cache a packet, arriving packets must be discarded, or one or more queued packets must be deleted to make room for new packets. In some cases, dropping a packet before the buffer is full can provide a congestion signal to the sender. The strategy for packet dropping and marking is called an active queue management algorithm.

Routers need cache to absorb fluctuations in traffic load. For many years, the empirical value for cache length has been RTT multiplied by link capacity C. Recent research shows that when a large number of TCP flows through a link, the number of caches is B=RTT*C*n^(-1/2).

How queued packets are transmitted through the output link requires the use of packet scheduling strategies. Commonly used strategies include the following:

  • first in first out
  • priority queuing
  • Circular queuing
  • Weighted Fair Queuing (WFQ): Based on round-robin queuing, each class is assigned a weight, and the service received by this class is this weight/the sum of the weights of all classes. However, in fact, the transmission of one packet cannot be interrupted to start transmitting another packet, so it is unrealistic to guarantee the weight.

3.Internet Protocol

3.1 IPv4 datagram header format

  • Version: Indicates the version of the IP protocol
  • Header length: 4 bytes, indicating the length of the IP datagram header. The value of this field is in units of 4 bytes. The minimum value is 5, indicating that there is only a fixed part of 20 bytes. The maximum value is 15, indicating IP data. The header contains a 20-byte fixed part and a maximum 40-byte variable part.
  • Optional field: used to support debugging, measurement, security, etc. Since the variable length increases the overhead of the router processing IP datagrams, it is rarely used in practice.
  • Padding: Padding ensures that the IP datagram header is an integer multiple of 4 bytes
  • Differentiated Service Field: Use numerical values ​​to provide different levels of service quality. This field is generally not used.
  • Total length field: Indicates the total length of the IP datagram (header + data load)
  • Identifiers, flags, and fragment offsets are used for IP datagram fragmentation. When the IP datagram length exceeds the maximum length of the frame's data payload (maximum transmission unit MTU), it cannot be encapsulated and needs to be fragmented.
    • Identification: Each fragmented datagram of the same datagram has the same identification. The IP software maintains a counter. Every time a datagram is generated, the count is incremented by 1 and the value is assigned to the identification field.
    • Flag: 3bit
      • DF bit: 1 means fragmentation is allowed
      • MF bit: 1 means there are still fragments, 0 means this is the last fragment
      • Reserved bit: must be 0
    • Slice offset: in units of 8 bytes. Indicates that the data payload portion of a fragmented datagram is offset from its original datagram position.
  • Time to live TTL: initially in seconds, the maximum life cycle is 255 seconds, minus the time spent on this router when forwarding by the router. Now in hop count, -1 when forwarded by the router.
  • Protocol field: Indicates what kind of protocol data unit the data part is
    • 1: ICMP message
    • 6: TCP message
  • Header checksum: Use Internet checksum to detect header errors during transmission. Since the IP layer does not provide reliable transmission services, in IPv6, routers no longer calculate header checksums.

3.2 IPv4 datagram fragmentation

The maximum amount of data that a link layer frame can carry is called the maximum transmission unit MTU . The size of each IP datagram is limited by the MTU. During transmission, different links may have different MTUs, which results in the IP datagram having to be split into multiple parts. In order to avoid affecting the performance of routers, the designers of IPv4 put the reassembly work of datagrams into the end system . When the network layer of the destination host receives a series of datagrams, it reassembles the IPv4 datagrams through the identifier, flag and fragment offset fields in the IP datagram header.

3.3 IPv4 addressing

The boundary between a host and a physical link is called an interface, and the boundary between a router and any link is also called an interface. Every host and router can send and receive IP datagrams, so each interface has its own IP address. Each IP address is 32 bits long and expressed in dotted decimal notation. For example: 192.32.216.9/24. /24 represents the subnet mask , which means that the first 24 bits of a subnet are the same, and the last 8 bits are used to distinguish hosts in the subnet. Note that router interfaces can also form subnets.

In early IP addresses, the network part was limited to 8, 16, and 24 bits, thus dividing the subnet into three types of networks: A, B, and C. This kind of addressing is called classified addressing . Since classified addressing is not flexible enough, there are only three classifications. CIDR classless inter-domain routing is now used , and IP addresses are expressed as abcd/x.

Each interface needs an IP address. This address is not assigned when the device is produced, but obtained. First of all, if an organization wants to obtain an address, it needs to request from the ISP, and the IP address allocation of the ISP is managed by the Internet Assigned Names and Numbers Corporation. Once an organization obtains a block of addresses, it can allocate IP addresses one by one to the hosts and router interfaces within the organization. IP addresses in routers are often configured manually by administrators. The configuration of the host address can be done manually, but it is mainly done using the Dynamic Host Configuration Protocol DHCP . DHCP allows the host to automatically obtain a temporary IP address, and also allows the host to obtain subnet mask, first-hop router address (default gateway), DNS server address and other information. DHCP is called a plug-and-play protocol or a zero-configuration protocol because of its ability to automatically connect a host to a network. Each subnet has a DHCP server, or a relay agent. The process for a host to obtain an IP address through DHCP is as follows:

  • DHCP server discovery: The host sends a DHCP discovery message to port 67 in a UDP packet . The source IP address is 0.0.0.0, and the destination IP address is the broadcast address 255.255.255.255.
  • Provided by the DHCP server: After receiving the DHCP discovery message, the DHCP server broadcasts a response message. The content of the message includes the IP address, lease period, etc.
  • DHCP request: The customer sends a DHCP request message to the selected DHCP server (there may be multiple DHCP servers, and the customer can choose the best) and echoes the configuration parameters.
  • DHCP ACK: The server responds to the request with a DHCP ACK message.

3.4 Network Address Translation

After a subnet obtains an address from the ISP, it can manage and assign addresses, but a subnet is likely to expand, such as in a home with more and more electronic devices. For this case, a simple method can be used to manage the addresses: Network Address Translation (NAT) . Addressing within a home network can be 10.0.0.0/8, which is a portion of the IP address space reserved by RFC for private networks such as home networks or regions with dedicated addresses. These addresses can only be used within a specific network and not in the larger network space. The function of a NAT-enabled router is to translate the private addresses in the home network and hide the internal details of the network from the outside world. All addresses leaving the home network are the same, and all destination IP addresses entering the network are also the same. The NAT router has a NAT routing table that associates the internal host IP address, source port number, and a new port number. The NAT router completes the forwarding of datagrams to the internal network.

In this way, the port number and IP of the internal network are converted to the new IP and new port number by NAT. If the internal network runs a server, there will be no determined well-known port for waiting. The solution is to use NAT traversal Tools and universal plug-and-play protocols.

3.5 IPv6

In order to cope with the problem of IPv4 address space exhaustion and to optimize problems in IPv4 practice, IPv6 was released. IPv6 has a 128-bit address capacity, so addresses will not be exhausted. Compared with IPv4, IPv6 does not support fragmentation and reassembly, directly discards datagrams, and uses ICMP messages to inform the sender to send smaller IP datagrams. The header checksum no longer exists, because the transport layer and data link layer have provided verification operations, so the verification of IP datagrams is removed, which also reduces the time of processing packets. Because there is a TTL field in the header, each original The checksum must be recalculated. The migration from IPv4 to IPv6 is now underway, and methods such as building tunnels have been implemented in practice. However, many difficulties and time still need to be resolved to completely complete this migration.

Chapter 5 Network Layer: Control Plane

1 Overview

The control functions of the network layer include controlling how routers forward datagrams along the end-to-end path from the source host to the destination host, and controlling how network layer components and services are configured and managed. There are two ways to accomplish these control functions:

  • Per-router control: Each router contains forwarding and routing functions. Each router has a routing component that communicates with other routers to calculate the value of the forwarding table.
  • Logical centralized control: The logical centralized controller calculates and distributes forwarding tables for use by each router.

2. Routing algorithm

A routing algorithm is an algorithm that selects the best path from the sender to the receiver. The best path usually refers to the path with the minimum cost, and the cost may be determined by many factors. When considering the routing algorithm, it is assumed that the cost is given. There are many ways to classify routing algorithms:

Classified according to concentration and decentralization:

  • Centralized routing algorithm: uses complete global network status information to calculate the lowest cost path. This type of algorithm is often called the link state algorithm LS.
  • Decentralized routing algorithm: Routers calculate the lowest-cost path in an iterative, distributed manner. Nodes gradually calculate the lowest cost path through iterative calculations and information exchange with neighboring nodes. For example, the distance vector algorithm DV is a decentralized routing algorithm.

Classification according to static and dynamic:

  • Static routing algorithm: usually manually adjusted.
  • Dynamic routing algorithm: changes paths as network load and topology change.

Divided according to whether it is sensitive to load:

  • Load-sensitive algorithm: The link overhead changes dynamically, reflecting the congestion level of the underlying link. The routing algorithm tends to avoid congested links.
  • Load-sluggish algorithm: overhead does not change. Because overhead does not explicitly reflect congestion levels, today's router selection algorithms are load-insensitive.

Two Routing Algorithms
Link-state routing algorithm:
Each router broadcasts a link-state packet to all other routers in the network, which contains the links it is connected to and the cost. Each router has a complete view of the network and calculates the lowest-cost path through a link-state routing algorithm. Oscillation problems may occur.

Distance vector routing algorithm:
When a node detects a change in the link cost of its neighbor, it forwards the entire routing table to the directly adjacent node, and the adjacent node updates its own distance table accordingly, which is calculated through iteration Minimum distance path. Routing loops may occur.

3. Routing algorithm within the Internet Autonomous System: OSPF

It is impossible to have all routers implement the same routing algorithm. On the one hand, the scale of the Internet is so large that it is impractical to store all routing information in all hosts. On the other hand, each ISP has its own network of routers and wants to run the routers as it wishes, or hide the internal organization of the network from the outside. Therefore routers are usually organized into autonomous systems (AS), each AS consists of a group of routers under the same administrative control. Routers in the same AS run the same routing protocol and have information about each other. The routing algorithm running within an autonomous system is called an intra-autonomous system routing protocol.

The Open Shortest Path First (OSPF) algorithm is an algorithm widely used in AS internal routing selection on the Internet. OSPF uses flooding link state information and Dijkstra's shortest path algorithm. The cost of the link is configured by the network administrator. For example, if the link cost is set to 1, the minimum hop count routing is implemented. When using OSPF, the router broadcasts routing information to all other routers in the autonomous system. When the link status changes or after a specific period, the router broadcasts link status information. Advantages of OSPF include:

  • Security: Using authentication, only trusted routers can participate in the OSPF protocol within an AS.
  • Multiple paths with the same cost: For multiple paths with the same cost, OSPF allows the use of multiple paths.
  • Comprehensive support for unicast and multicast routing.
  • Supports hierarchical structures in a single AS: An OSPF autonomous system can hierarchically configure multiple areas, each area runs its own OSPF link state routing algorithm, routers only broadcast within the area, one or more border routers Responsible for providing routing options for packets flowing outside the area.

4.Routing between ISPs: BGP

The above-mentioned OSPF is a routing protocol within an AS. When a packet spans multiple ASs, a routing protocol between different ASs needs to be used. In the Internet, ASs run the same inter-AS routing protocol called Border Gateway Protocol BGP .

For BGP, as long as the packet is sent to the target network of the packet, there is no need to consider the issue of sending it to the target host. Therefore, in BGP, a destination is an address prefix, that is, a network. BGP sends packets to the target network through two means:

  • Obtains prefix reachability information from neighbor ASs. BGP allows each subnet to advertise its existence to other parts of the Internet, so that an AS knows the existence of a subnet and can deliver packets to this subnet.
  • Determine the best routing path: Based on policy and reachability information, the router will select the best possible routing path to transmit the packet.

The following analyzes the working principle of BGP from these two aspects.

4.1 Advertisement BGP routing information

A router is always within an AS or at the edge of an AS, and is therefore either a gateway router or an internal router. The gateway router is at the edge of the AS and is connected to the router of another AS. The existence of a network and the path to reach it are announced by routers by sending BGP messages. Routers exchange routing information by using a semi-permanent TCP connection on port 179. The connection between each router and the BGP messages sent are called BGP connections . The BGP connection spanning two ASs is external BGP (eBGP), and the BGP session of the router inside the AS is internal BGP (iBGP). The gateway router first informs the gateway router of another AS of its existence and reachability information (path) through eBGP. The router that receives the information uses iBGP to inform other routers in the same AS of the information, so that all routers in the AS can Know the path to another AS.

4.2 Routing selection

Before considering BGP routing strategies, you need to understand AS-PATH and NEXT-HOP. AS-PATH is the path from the current AS to an AS. Of course, if it is to be advertised to other ASs, the path must also add itself. For example, the path from AS1 to AS10 is AS2-AS5-AS10, then the advertised path is AS1-AS2-AS5-AS10. There may be multiple paths to an AS and therefore multiple AS-PATHs. NEXT-HOP is the router interface IP address of the AS-PATH starting address. The routing algorithm is an algorithm for selecting an appropriate path among multiple AS-PATHs. BGP uses the following rules in order to select routes until only one path remains:

  • The router's local preferences will take precedence. Local preferences are set by the network administrator.
  • Among the remaining routes, the route with the shortest AS is selected, using the distance vector algorithm. The distance is the hop count of the AS rather than the hop count of the router.
  • Among the remaining routes, select the route closest to the NEXT-HOP router.
  • If multiple routes are still left, use the BGP identifier to select the route.

Guess you like

Origin blog.csdn.net/Aaron503/article/details/130906496
Recommended