4. ๐Ÿบ Network layer

The main task is to transfer packets from the source to the destination and provide communication services for different hosts on the packet switching network. The unit of transmission at the network layer is the datagram.

Function 1: Route selection and packet forwarding

Routing (determining which path to take): Dynamically changing the selected routes based on the changes in the entire network topology obtained from the neighboring routers according to a complex distributed algorithm. Packet forwarding (action taken when a packet arrives): When the router forwards the user’s IP datagrams from the appropriate port according to the forwarding table.

Function 2: Heterogeneous network interconnection

To connect two or more computer networks by means of one or more intermediate systems to form a larger network. Intermediate equipment is divided into:

  1. Physical layer relay system: repeater, hub
  2. Data link layer relay system: bridge or switch
  3. Network layer relay system: router
  4. Relay systems above the network layer: gateways

Function 3: Congestion control

Congestion is a phenomenon that degrades network performance due to excessive packets in communication subnets.

Features and comparison of virtual circuit services and datagram services

Datagram service: connectionless service. Each packet carries a source and destination address. The router forwards the packet according to the destination address Virtual circuit service: the connection service combines the datagram mode and circuit switching mode. A circuit-like path (logical connection) from the source host to the destination host is maintained. All nodes on the path maintain the establishment of the virtual circuit, and each entry records the information of an open virtual circuit.

IP address and default subnet mask

Traditional IP addresses are classified into five types: A, B, C, D, and E. No matter what type of IP address, it consists of a network number and a host number.

  • Class A address: the first eight bits of the network number are 0.
  • Class B address: the first 16 digits of the network number are 10.
  • Class C address: the first 24 digits of the network number are 110.
  • Class D address: the first eight digits of the network number are 1110.
  • Class E address: the first eight digits of the network number are 1111.
Network class Maximum number of available networks Maximum number of hosts per network Default subnet mask
A
2 7 2 2 ^ 7-2

2 24 2 2 ^ {24} – 2
255.0.0.0
B
2 14 2 2 ^ {14} – 2

2 16 2 2 ^ {16} – 2
255.255.0.0
C
2 21 2 2 ^ {21} – 2

2 8 2 2 ^ {8} – 2
255.255.255.0

Network address translation NAT

Install the NAT software on the router that connects to the Internet on a private network. The router that has the NAT software installed is called a NAT router and has at least one valid external global IP address. When forwarding IP packets, the NAT router must change its IP address. A common router works only at the network layer, but a NAT router needs to view and translate port numbers at the transport layer when forwarding packets.

subnetting

Basic idea:

Borrow a number of bits from the host number as the subnet number, of course, the host number is reduced by the same bit. The three-level IP address structure is as follows:

IP address ={< network number >,< subnet number >,< host number >}

Note:After subnets are created for an organization, the organization still acts as a network. That is, networks outside the organization do not see subnets within the organization.

Subnet mask

All host ids are 0 and all others are 1

Subnet mask problem

The IP address is 141.14.72.24 and the subnet mask is 255.255.192.0. . 0

0-1-0-0-1-0-0-0 (72) 1-1-0 0 0 0 0 0 (192) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0-1-0-0-0-0-0-0 (64).Copy the code

Therefore, the network address is 141.14.64.0

Unclassified addressing CIDR

1. Eliminate the traditional A class,B class,C class address and subnets concept. CIDR notation: The IP address is followed by a “/” and then the number of digits of the network prefix (which can be of any length). Fuse the subnet address and subnet mask to facilitate subnets

CIDR combines contiguous IP addresses with the same network prefix into a “CIDR address block”

The MAC address

The address used by the data link layer, which is planar. IP addresses are used at and above the network layer. IP addresses are placed at the head of IP datagrams and MAC addresses are placed at the head of MAC frames. After an IP packet is encapsulated as a MAC frame, the IP address in the packet is invisible to the data link layer.

ARP protocol

The IP address is mapped to the MAC address. Each host has an ARP cache to store ARP tables. ARP is used to dynamically maintain the ARP table. Working principle: Host A checks whether host B’s MAC address is available in the ARP cache before sending an IP packet to host B on the local LAN. If yes, you can find out the corresponding hardware address, write the hardware address into the MAC frame, and then send the MAC frame to the hardware address over the LAN.

IP datagram format

An IP packet consists of a header and data. The header is divided into a fixed part and a variable part.

IP datagram fragmentation

Maximum transmission unit MTU

The upper limit of data that a link layer data frame can encapsulate.

The MTU of the Ethernet is 1500 bytes

The total length is 1B

The slice offset is in 8B

The head length is 4B

RIP

RIP is a distributed routing protocol based on distance vector. Its biggest advantage is simplicity.

The characteristics of the RIP

  1. Exchange information only with neighboring routers.
  2. The information the router exchanges is all the information the current router knows, namely its own routing table.
  3. Routing information is exchanged at fixed intervals.

OSPF protocol

OSPF is a typical representative of distributed link-state routing algorithm.

Router Composition

Routing and packet forwarding

Comparison of routers and Ethernet switches

A router is a store-and-forward packet switch that forwards packets using network layer addresses. Although a switch is also a store-and-forward switch, it differs from a router in that it forwards packets using MAC addresses. A switch is a Layer 2 packet switch and a router is a Layer 3 packet switch.

V. ๐ŸŸ Transport layer

Function of transport layer

Logical communication between processes, reuse and reuse, error detection, connection-oriented TCP and connection-oriented UDP

Question and answer:

What should the recipient do when receiving an incorrect UDP user data report?

Discard without notifying the sender.

The main differences between TCP and UDP.

TCP provides a connection-oriented, reliable byte stream service with flow control and congestion control functions. UDP provides a connectionless, unreliable datagram service with no traffic control or congestion control.

Why is there a header length field in TCP headers but not in UDP headers?

The TCP header has options in addition to the fixed length part, so the length of the TCP header is variable. The length of the UDP header is fixed.

If all links in the Internet provided reliable transport services, would TCP reliable transport services be completely redundant? Why is that?

The TCP reliable transport service is not redundant. Because in the process of end-to-end data transmission is not all the mistakes from the packet transport across the link than super errors, such as the packet discard router due to network congestion, the router can lead to a malfunction in the forwarding grouping end-to-end data transmission errors, these are impossible to solve by the link layer and reliable data transmission, This must be addressed by reliable data transfer services at the end-to-end transport layer.

Why use the three-way handshake?

The purpose of the three-way handshake is to establish a reliable communication channel. When it comes to communication, it simply means the sending and receiving of data. The main purpose of the three-way handshake is to confirm that the sending and receiving of data is normal.

Can congestion be solved by simply adding resources?

Congestion control is a global process that involves all hosts, all routers, and all factors associated with reducing network traffic performance. The essence of congestion is often a mismatch between parts of the system. The problem will not be solved until all the parts are balanced. Increased resources do not guarantee a solution to congestion. For example, if the cache capacity of a node is too small, the group will be discarded because there is no cache space. If the cache capacity is extended to a very large size, all the packets can be queued on the cache queue, resulting in a very long queue waiting time. As a result, groups will be retransmitted due to timeout, and the retransmitted groups will continue to queue, making the situation worse. This example also shows that increasing resources does not guarantee a solution to congestion.

Problem sets

Let the maximum window used by TCP be 64 KB, that is 64๏‚ด1024 bytes, and the bandwidth of the transmission channel can be considered unlimited. If the average round-trip delay of the packet segment is 20 ms, what is the maximum swallowing capacity that can be obtained?

The communication channel bandwidth is 1 Gbit/s, and the end-to-end delay is 10 ms. The TCP sending window is 65535 bytes. Ask: What is the maximum throughput that is possible? What is the utilization of the channel?

Transmission delay = Data length/channel bandwidth =65535 * 8bit/1Gb/s=0.52428 * 10-3s=0.52428ms;

Propagation round-trip delay =2 * 10=20ms (sending data and receiving confirmation);

Therefore, for every window size traffic that is sent,

Total delay = transmission delay + propagation round-trip delay = 0.52428+20=20.52428ms.

So 1000/20.52428 Windows per second,

So the maximum data throughput =65536*8* (1000/20.52428) =25544769bit/s=25.5Mb/s

Channel utilization ratio = 25.5Mb/sรท1000Mb/sโ‰ˆ2.55%

๐Ÿฅ— application layer

The function of the DNS

DNS is a naming system used on the Internet to convert host names with specific meanings that are easy for people to remember into IP addresses that are easy for machines to process.

HTTP

Non-persistent connections and persistent connections (HTTP/1.1 support) For non-persistent connections, a separate TCP connection is required for each web element object to be transferred. The so-called persistent connection means that the world Wide Web server still maintains the connection after sending a response, so that the same client and server can continue to send subsequent HTTP request and response packets on this connection.

Email service SMTP and POP protocol

Simple Mail Transfer Protocol (SMTP) is a reliable and efficient email transfer protocol that controls the exchange of information between two SMTP processes that communicate with each other. SMTP uses a TCP connection and port number 25. The post office protocol is a very simple but limited mail reading protocol. It is now in its third version, POP3.

The function of the FTP

FTP provides interactive access, allowing customers to specify the type and format of files, and allowing access to files. FTP provides the following functions:

  1. Provides file transfer capability between different host systems.
  2. This section describes how to manage files on the remote FTP server through user permission management.
  3. The ability to provide public file sharing over anonymous FTP.

TELNET

Telnet, a member of the TCP/IP protocol family, is the standard protocol and main method for remote Internet login services.

DHCP

DHCP (Dynamic Host Configuration Protocol) is a LAN network protocol. The IP address range is controlled by the server. When a client logs in to the server, it automatically obtains the IP address and subnet mask assigned by the server.