4.1 Overview of the Network Layer
The main function of the network layer is to transfer packets from the source end to the destination end and provide communication services for different hosts on the packet switching network. The unit of transmission at the network layer is the datagram.
The functions of the network layer are as follows:
- Routing and packet forwarding
- Interconnection of heterogeneous networks (router)
- Congestion control
4.1.1 Data exchange mode
-
Transmission units at all levels
- Application layer: packets
- Transport layer: packet segment
- Network layer: IP datagrams, packets
- Data link layer: frames
- Physical layer: bits
-
Why data exchange?
See chapter 1 for comparison of circuit switching and packet switching.
-
Circuit switching
Two telephones can be connected to each other only by a pair of wires.
N telephones are connected in pairs with N(n-1)/2 pairs of wires. When the number of telephones is large, the number of wire pairs required by this connection is proportional to the square of the number of telephones.
Circuit switching features:
- Circuit switching must be connection-oriented.
- Exclusive resources
Three stages of circuit switching:
- Establish a connection
- communication
- Release the connection
Advantages of circuit switching:
- Time delay is small
- The orderly transfer
- There is no conflict
- Strong real time
Circuit switching disadvantages:
- Establishing a connection takes a long time
- This results in low utilization of communication lines.
- Flexibility is poor
- No error correction ability
-
Message switching
-
Packet switching
Packet switching can be done in two ways
-
Datagram mode: provides connectionless services for the network layer.
- Connectionless service: the transmission path of packets is not determined in advance. Each packet determines the transmission path independently. The transmission path of different packets may be different.
-
Virtual circuit mode: Provides connection services for the network layer.
- Connection service: first determine the transmission path for the packet (establish the connection), and then transfer the packet along the path. The packet transmission path is the same, and the connection is removed after the transmission.
-
Comparison of datagram and virtual circuit modes:
-
-
Three ways to compare
4.2 Routing Algorithm and Routing Protocol
-
classification
- Static routing algorithm (non-adaptive routing algorithm) : The administrator manually configures the route information
- Dynamic routing algorithm (adaptive routing algorithm) : Routers exchange information and optimize the routing table based on the routing algorithm
- Global: The link-status routing algorithm is OSPF. All routers have complete network topology and link cost information
- Dispersion: RIP is a distance vector routing algorithm. Routers only know the physical neighbors and link costs
-
Hierarchical routing protocol
The reason:
- The Internet is too big
- Many organizations do not want their routing protocol known to the outside world, but want access to the Internet
4.2.1 RIP and distance Vector Algorithm
RIP is a distributed routing protocol based on distance vector. It is the protocol standard of the Internet.
RIP requires each router on a network to maintain a unique optimal distance from itself to each other’s destination network.
-
Who does RIP exchange with? How often do you switch? In exchange for what?
-
Distance vector algorithm
Problem sets:
-
Format of RIP Packets
-
Slow convergence: Good news is transmitted quickly and bad news is transmitted slowly
4.2.2 OSPF and Link-state Algorithm
OSPF: Open shortest priority protocol. Open indicates that the OSPF protocol is not controlled by a vendor and is published publicly. Shortest first refers to the use of Dijkstra’s shortest path algorithm SPF.
Features of OSPF:
- Broadcast: Each router sends a message to all neighboring routers.
- The transmitted information is the link state of all neighboring routers.
- The message is sent only when the link status transmission changes.
-
Link state routing algorithm
-
OSPF area
-
OSPF packet
Holdings BGP protocol
BFP is a routing and forwarding protocol between AS areas.
4.2.4 Comparison of three routing protocols
4.3 IP
4.3.1 IP datagram format
- Version: IPv4 or IPv6
- Head length: unit is 4B, minimum is 5
- Distinguish services: What services are expected
- Total length: header + data, in unit 1B
- Flag, flag, slice offset: IP packet fragment
- TTL: indicates the shelf life of IP packets. After router -1, it will be discarded if it becomes 0
- Protocol: The protocol for the data part.
- TCP: 6
- UDP: 17
- Head inspection and: check only the head
- Source address
- The destination address
- Optional part: Generally not selected
4.3.2 IP datagram Fragmentation
-
Maximum transmission unit MTU
-
The IP datagram
- The unit of total length is 1B
- The unit of slice offset is 8B
- The length of the head is 4B
Tip: One (total length) eight pieces (piece offset) of jewelry (head length)
Examples:
4.3.2 IPv4 address
Historical phase of an IP address
- IP address of the class
- Subnets
- Constructing a hypernet (unclassified addressing)
-
IP address of the class
- Three Lans (orange) with the same IP address and the same network number
- LAN1:222.1.3.0
- LAN2:222.1.1.0
- LAN3:222.1.2.0
- There are three routers, and each interface of the router has an IP address
- Three Lans (orange) with the same IP address and the same network number
ABCDE class IP address
Special IP address
Private IP address
4.3.3 Network Address Translation NAT
4.3.4 Subnets and Subnet masks
Weaknesses of classified IP addresses: The UTILIZATION of the IP address space is low
-
subnetting
-
Subnet mask
-
Forwarding a group when using a subnet
4.3.5 Unclassified addressing CIDR
-
Super net
-
Longest prefix matching
When using CIDR, a lookup of the routing table may yield several matches, and the route with the longest network prefix should be selected. The longer the prefix, the smaller the address block and the more specific the route.
Problem sets:
IP address 192.168.5.0/24: the network number is the first 24 digits
If the subnet mask 255.255.255.248:248 => 11111000, the subnet ID is 25 to 29 digits, and the host ID is the last three digits
So the answer is A
4.3.6 ARP
-
The process of sending data
Case 1: Belong to the same LAN
- Packets are divided into packet segments
- IP addresses are added to packet segments to form packets
- Group add MAC address to form frame
- If the MAC address of the destination IP address is not known, a broadcast message is sent to all IP addresses on the LAN
- If the destination IP address exists on the LAN, the system returns its MAC address to the source IP address
- Source Destination IP Address MAC address of the received destination IP address
- Frames are converted to bitstreams for transmission
Case 2: They belong to different Lans
- Packets are divided into packet segments
- IP addresses are added to packet segments to form packets
- Group add MAC address to form frame
- If the source IP address and destination IP address are in different network segments, the system queries the MAC address of the default gateway
- Frames are converted to bitstreams for transmission
-
ARP protocol
4.3.7 DHCP protocol
-
How does a host obtain an IP address?
- Static configuration
- The IP address
- Subnet mask
- The default gateway
- Dynamic configuration
- Static configuration
-
DHCP protocol
4.3.8 ICMP protocol
-
ICMP Error Report packets (5 types)
-
ICMP Error report packet data field
-
ICMP error report packets are not sent
-
ICMP query message
-
The application of ICMP
4.4 IPv6
- Solve the problem that 32-bit IPv4 address space is used up
- Improved header format
-
IPv6 data Format
-
IPv6 and IPv4
-
An IPv6 address
-
Basic IPv6 address type
- Unicast: one-to-one communication. The source address and destination address can be used
- Multicast: one-to-many communication, can be the destination address
- Unicast: a communication of one to more than one clock, which can be the destination address
-
Policy for the transition from IPv4 to IPv6
4.5 Transmission mode of IP datagram
-
IP Multicast address
4.6 mobile IP
-
Related terms
-
Mobile IP communication process
4.7 Network Layer Devices
- The router
- Input port processing of packets received on a line
- Output port A line to which packets transmitted by switching structures are sent
- The difference between three layers of equipment
- Routing table and routing forwarding