Computer network study notes-network layer

Network layer

1. Functions of the network layer

  1. Heterogeneous network interconnection
  2. Routing and forwarding
  3. Congestion control

2、IPv4

Insert picture description here

name Number of digits occupied Description
version 4 version number
Header length 4 Take 32 bits as the unit, the maximum value is 60B, the commonly used is 20B
Total length 16 Refers to the length of the sum of the header and the data, in bytes, so the maximum length of the datagram is 2^16 -1 = 65535B. The maximum transmission unit (MTU) of an Ethernet frame is 1500B, so when an IP datagram is encapsulated into a frame, the total length of the datagram (header + data) must not exceed the MTU
Logo 16 Counter, +1 every time a datagram is generated. When the length of a datagram exceeds the MTU, it must be fragmented. At this time, each datagram fragment is copied once the identification number
Sign 3 The lowest bit is MF. When MF=1, it means there are fragments. MF=0 means this is the last fragment; the middle bit is DF. Fragmentation is allowed only when DF=0
Slice offset 13 It points out the relative position of a piece in the original packet after a longer packet is fragmented. The fragment offset is in units of 8 bytes, that is, the length of each fragment must be an integer multiple of 8B (64 bits)
First checksum 16 Only check the header of the packet, not the data part
Time to Live (TTL) 8 Each time the router forwards a packet, TTL-1
protocol 8 6 stands for TCP, 17 stands for UDP
Source address field 32 Sender IP address
Destination address field 32 Destination address

2.1, IPv4 address and NAT

2.1.1, IPv4 address

Insert picture description here

IP address Address segment Maximum network available The first available network number The last available network number Maximum number of hosts in each network
Class A 1-126 2^7-2 1 126 2^24-2
Type B 128-191 2^14-1 128.1 192.255 2^16-2
Type C 192-223 2^21-1 192.0.1 223.255.255 2^8-2
Class D 224-239

Among the various types of IP addresses, some IP addresses have special uses and do not need to be used as the host's IP address:

No need to be the IP address of the host
The host number is all 0 Represents the network itself
The host number is all 1 Broadcast address of this network
127.0.0.0 Reserved as the loop self-check address, this address represents any host itself, the IP datagram whose destination address is the loopback address will never appear on any network
32 bits are all 0s That is, 0.0.0.0 means this host on this network
32 bits are all 1s That is, 255.255.255.255 represents the broadcast address of the entire TCP/IP network, also known as the restricted broadcast address; due to the router's isolation of the broadcast domain, 255.255.255.255 is equivalent to the broadcast address of the network

2.1.2, Network Address Translation (NAT)

Network address translation (NAT) refers to the conversion of private network addresses (such as Intranet) to public addresses (such as Internet) , thereby hiding the internally managed IP address from the outside.

For network security, the IP address is designated as a private address, and the private IP address is only used for LAN . The private IP cannot be connected to the Internet, and the private address must be converted to a legal global IP address in the Internet through the gateway using NAT before it can be used on the Internet .

Private IP address network segment
Class A 1 class A network segment 10.0.0.0-10.255.255.255
Type B 16 Class B network segments 172.16.0.0-172.31.255.255
Type C 256 Class C network segments 192.168.0.0-192.168.255.255

NAT router

2.1.3, subnet division and subnet mask, CIDR

1. Subnetting

Divide the host number as the subnet number.

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

2. Subnet mask

The subnet mask is used to express the borrowing of the host number in the original network .

The IP address and the corresponding subnet mask are "ANDed" bit by bit to get the corresponding network address.

3. Non-classified inter-domain routing (CIDR)

CIDR is an IP address division method that eliminates the traditional A, B, and C network divisions based on the variable-length subnet mask, and can realize the supernet construction with software support.

CIDR allows the subnet number to be all 0 or all 1.

2.1.4、ARP、DHCP与ICMP

1.地址解析协议(ARP)

在IP网络的网络层只使用IP地址来完成寻址,而IP分组转发到达目标网络后,改为在目标网络LAN中通过数据链路层的MAC地址以广播方式寻址

路由器不仅有多个IP地址,也可以有多个MAC地址。

地址解析协议(ARP)就可以完成IP地址到MAC地址之间的映射

2、动态主机配置协议(DHCP)

动态主机配置协议(DHCP)常用语给主机动态地分配IP地址,是应用层协议,基于UDP

3、网际控制报文协议(ICMP)

使用ICMP来让主机或路由器报告差错和异常情况。ICMP是IP层协议

ICMP报文的种类有两种:ICMP差错报告报文ICMP询问报文


3、路由协议

协议 RIP(路由信息协议) OSPF(开放最短路径优先协议) BGP(边界网关协议)
类型 内部 内部 外部
路由算法 距离-向量 链路状态 路径-向量
传递协议 UDP IP TCP
路径选择 跳数最少 代价最低 较好,非最佳
交换结点 和本结点相邻的路由器 网络中的所有路由器 和本结点相邻的路由器
交换内容 当前本路由器知道的全部信息,即整个路由表 与本路由器相邻的所有路由器的链路状态 首次,整个路由表
非首次,有变化的部分
存在的问题 慢收敛,“坏消息传的慢”

4、中继设备

层次 中继设备 特点
物理层中继设备 中继器、集线器(Hub) 用来连接两个(中继器)或多个(Hub)速率相同且数据链路层协议相同的网段,任何时刻只能有一个结点通过公共信道发送数据
数据链路层中继设备 网桥或交换机 The bridge can interconnect different physical layers, different MAC sublayers, and different speed Ethernets, and can isolate the collision domain. The
switch allows multiple nodes to communicate concurrently. Each port will not decrease due to the increase of port nodes. The total bandwidth of the switch will increase with the increase of port nodes, generally working in full-duplex mode
Network layer relay equipment router Can isolate broadcast domain
Relay equipment above the network layer Gateway

Guess you like

Origin blog.csdn.net/qq_36879493/article/details/107835971
Recommended