Network layer combing of computer network

Preface

This article combs the knowledge of the network layer.

Network layer overview

The main task of the network layer is to transmit packets from the source to the destination, provide communication services for different hosts on the packet switching network, and achieve transparent data transmission between the two network systems. The network layer transmission unit is a datagram.

  • Network layer functions:
    routing and packet forwarding (best path)
    shield network differences, provide transparent transmission, that is, rely on router heterogeneous network interconnection (wifi, 4G, intranet)
    packet encapsulation and decapsulation
    Congestion control

image.png

Network layer data exchange technology

Data exchange technology mainly refers to the data exchange function provided by the intermediate nodes of the network.
From the perspective of the development of data exchange technology at the entire network layer, the exchange technology has gone through a process from circuit switching and message switching to the most commonly used packet switching.
Message switching and packet switching are both store-and-forward switching technologies. The so-called store-forward is to store the message when it reaches the router, wait for the router to allocate resources and then forward the data packet.
image.png

Why data exchange

image.png
It adopts the switching network mode, which is formed by interconnecting a large number of switching devices, which not only reduces the demand for switching ports, but also realizes long-distance communication.

Data exchange method

image.png

1. Circuit Switching

Circuit Switching (Circuit Switching, also known as circuit switching) is the most primitive data exchange method. It is a data exchange method that uses switchable physical communication lines to directly connect the two parties in the network.
Circuit switching is a connection-oriented service. Before two computers exchange data through the communication subnet, an actual physical line connection must be established in the communication subnet.
The main feature of circuit switching is that a dedicated data path needs to be established between a pair of users before data exchange. The three stages of circuit establishment, data transmission and circuit release are required during the entire data transmission process. Exclusive resource.
The most common examples are telephone switching systems and ISDN (Integrated Services Digital Network) systems.

  • Advantages:
    small communication delay,
    orderly transmission,
    no conflict
    , strong real-time

  • Disadvantages
    Long time to establish connection
    , exclusive line, low use efficiency, poor
    flexibility,
    no error control capability (no error detection and correction, only simple forwarding)

2. Message Exchange

Message Switching (Message Switching) refers to a data exchange method in which messages are stored and forwarded in units of messages (Message, an information segment of complete data).
In the message exchange mode, the message is the data unit exchanged and transmitted in the network, that is, the data block to be sent by the station at one time. It contains the complete data information to be sent. The length may be inconsistent, and the length is unlimited and can be change.

  • Advantages:
    no need to establish a connection,
    store and forward, dynamic allocation of lines,
    high
    line reliability, high line utilization,
    multi-target services

  • Disadvantages:
    store and forward delay
    , variable size of message, need large buffer space for network node

3. Packet switching

Packet switching is the division of large data blocks into small data blocks for transmission and parallel transmission.

  • Advantages:
    no need to establish a connection,
    store and forward, dynamically allocate lines,
    high
    line reliability, high line utilization
    , easier storage management than message exchange

  • Disadvantages:
    store and forward delay,
    need to transmit extra amount of information, when
    out of order to the destination host, it is necessary to sort and reorganize packets

  • Packet switching includes datagram mode and virtual circuit mode.
    image.png

3. 1. Datagram

The datagram method provides a connectionless service for the network layer, that is, the transmission path is not determined in advance for the transmission of the packet. Each packet determines the transmission path independently, and the transmission path of different packets may be different. This is currently widely used.

Each packet carries a source address and a destination address, and the router forwards the packet according to the destination address of the packet: builds a forwarding table based on the routing protocol; retrieves the forwarding table; each packet independently selects a route.

3. 2. Virtual circuit mode

The virtual circuit mode provides connection services for the network layer, that is, first determine the transmission path for packet transmission (establish a connection), and then transmit a series of packets along the path (connection). The series of packets have the same transmission path, and the connection is removed after the transmission is completed.
The virtual circuit is the fusion of packet switching and circuit switching, combining the advantages of the two.

Virtual circuit: A path similar to a circuit (logical connection) from the source host to the destination host. All nodes on the path must maintain the establishment of this virtual circuit, and maintain a virtual circuit table. Each entry records an open Information about the virtual circuit.
Each packet carries a virtual circuit number instead of a destination address. The router will retrieve the virtual circuit number to select the next hop when forwarding.
image.png

Network layer related protocols

Slowly sort out afterwards, and temporarily sort out the IP protocol.

IP protocol

  • IP protocol
    At present, computer networks, especially TCP/IP networks, use datagram packet switching methods the most, and IP protocol is the most typical communication protocol used to connect multiple packet switching networks.
    The IP protocol is a connectionless service. It is responsible for transmitting datagrams between the source address and the destination address. Then, in order to meet the requirements of different networks for the packet size, the packets from the upper layer need to be segmented, and finally the local network protocol is called to The datagram is sent to the next gateway or destination computer.
    The main function of the IP protocol is to transmit datagrams on the interconnected network, and transmit datagrams among IP modules until they reach the destination module. There are IP modules on every host and gateway in the network. The datagram is sent to the destination address through the routing processing network address among the modules.

  • Functions:
    addressing,
    datagram encapsulation,
    segmentation and reassembly

IPv4 datagram header format

image.png

  • Header length: the length of the packet header, the unit is 4B, the minimum is 5, that is, the minimum length is 20B.
  • Version: IPv4/IPv6
  • Total length: header + data, expressed in 16 bits, the unit is 1B, that is, 2^16-1 = 65535byte; however, it will be fragmented due to the MTU limit, and it will not be so large.
  • Identification: Fragments of the same datagram use the same identification.
  • Slice offset: Indicate the relative position of a slice in the original group after a longer group of slices. The unit is 8B, so except for the last fragment, the length of each fragment must be an integer multiple of 8B.
  • Time to live: If there is no router, it will be reduced by 1, and it will be discarded when it becomes 0.
  • Protocol: The protocol of the data part. TCP is 6 and UDP is 17.
  • The data part is the segment of the transport layer.

image.png

Network layer equipment

router

A router is a special-purpose computer with multiple input ports and multiple output ports, and its task is to forward packets.
image.png
image.png
image.png

The difference between three-tier equipment

Router: can interconnect two network segments with different network layer protocols.
Bridge: It can interconnect two network segments with different physical layer and link layer.
Hub: Cannot connect two network segments with different physical layers.
image.png

Q&A

1. TCP connection-oriented elaboration

The so-called connection-oriented characteristics of TCP and the establishment of virtual circuits seem to be fundamentally different from virtual circuit services at the network layer. The protocols for services with virtual circuits at the network layer typically include X.25 and frame relay used in wide area networks. These two protocols need to establish a so-called virtual circuit number when establishing a connection. There is a filled-in virtual circuit number in the transmitted data unit. The data unit follows the established virtual circuit along the established direction (a certain router sequence). ) To the receiving end, this can ensure that the data unit arrives at the receiving end in an orderly manner, and it can also guarantee reliable transmission.

The TCP connection-oriented service only performs a three-way handshake when establishing a connection. The specific host-to-host transmission is from the network layer, which is the routing service provided by the IP layer, while the IP layer sends and forwards packets out of order. For example, A simple example, if the IP protocol and X.25 protocol (assuming that these two protocols are used in the same case) specify a link from A to B when establishing a connection, if the link from A to B is at a certain moment In the event of congestion, the IP protocol may make the packet arrive at A to choose another route, while X.25 can only use some flow control measures to control the sending speed of the sender, but it will not choose a path other than A to B, so TCP The so-called virtual circuit and the virtual circuit service of the network layer are not a concept at all.

The virtual circuit service of the network layer really specifies a link sequence, and data can only be sent to the receiving end in an orderly manner in this specified link, while the virtual circuit of TCP only relies on its congestion control, flow control and error control. To make the received message segment appear to be in order (in the sliding window mechanism, the following byte stream may arrive first or the byte is lost, so it can be seen that TCP cannot guarantee the reliability of real transmission. It only relies on error control to ensure that the correct data stream can be reliably received), but the TCP segment is actually unreliable and unnecessary when it is transmitted on the network.

A TCP problem, how is the so-called TCP connection-oriented virtual circuit realized?

Guess you like

Origin blog.csdn.net/u014099894/article/details/112427277