Computer network network layer virtual circuit service datagram service IPV4 address overview dotted decimal notation subnet mask IP datagram sending and forwarding process routing protocol routing information protocol RIP OSPF protocol ICMP protocol

Network layer

1. Overview of the network layer

The main task of the network layer is to realize network interconnection, and then realize the transmission of data packets between various networks

2. Two services provided by the network layer

1. Connection-oriented virtual circuit service

(1) Reliable communication is guaranteed by the network
(2) A network layer connection must be established-virtual circuit (there is no real physical connection)
(3) Both communication parties send packets along the established virtual circuit
(4) Destination host The address of is only used in the connection establishment phase, and then the header of each packet only needs to carry the number of a virtual circuit
(5) After the communication is over, the previously established virtual circuit needs to be released
as shown in the figure:
Insert picture description here

2. Connectionless datagram service

(1) Reliable communication is guaranteed by the user host
(2) There is no need to establish a network layer connection
(3) Each packet can take a different path
(4) The header of each packet must carry the complete address of the destination host
(5) This The packets transmitted by this kind of communication may have errors, loss, repetition and out of sequence
as shown in the figure:
Insert picture description here

3. Comparison of the two services

Insert picture description here

Note: The Internet with TCP/IP structure provides datagram services

Three, IPv4 address overview

1. IP address concept

(1) IP address is the address used by hosts and routers on the Internet. It is used to identify two parts of information:
① Network number: used to distinguish different networks. Different networks have different network numbers. The network of each host on the same network Same number (routers are connected to different networks)
② Host number: Identifies different hosts on the same network (or router interfaces), and different hosts have different host numbers

2. IPv4 address concept

The IPv4 address is to assign a 32-bit identifier that is unique throughout the world to the interface of each host or router on the Internet

3. Dotted decimal notation

Insert picture description here

Four, the three stages of IPv4 addressing method

1. Classified addressing

Insert picture description here

(1) Detailed explanation of Class A address

Insert picture description here

(2) Detailed explanation of class B address

Insert picture description here

(3) Detailed explanation of class C address
Insert picture description here

(4) Note

Insert picture description here

(5) Practice

Insert picture description here

2. Subnetting

That is, borrow a part from the host number as the subnet number
(1) The
32-bit subnet mask of the subnet mask can indicate that the host number is borrowed several bits as the subnet number
① The subnet mask uses consecutive bits 1 to correspond to the network Number and subnet number
② The subnet mask uses consecutive bits 0 to correspond to the host number
③ The IPv4 address and its corresponding subnet mask are ANDed to get the network address of the subnet where the IPv4 address is located

Insert picture description here

(2) Practice

Insert picture description here
Insert picture description here

(3) The default subnet mask
Insert picture description here

3. Unclassified addressing

CIDR (Unclassified Addressing) eliminates the traditional concept of Class A, Class B, and Class C addresses and subnetting

CIDR uses slash notation: add a slash "/" after the IPv4 address, and write the number of bits occupied by the network prefix after the slash
(the network prefix refers to the part of the subnet mask 1)

For example:
Insert picture description here

Example 1:

Insert picture description here

Route aggregation (construct supernet):

Insert picture description here

note:

  1. The longer the network prefix, the smaller the address block and the more specific the route
  2. If multiple routes are available when forwarding a packet, the one with the longest network prefix is ​​selected, which is called the longest prefix match

Five, IPv4 address application planning

Given an ipv4 address block, how to divide it into several smaller address blocks

(1) Fixed-length subnet mask
Insert picture description here
Insert picture description here
Insert picture description here

Disadvantages:
①Only 2n subnets can be allocated, causing a waste of subnets
②The number of ip addresses in each subnet is the same, causing waste, such as N5 only requires 4 ip addresses

(2) Variable length subnet mask

Insert picture description here

Insert picture description here

(3) Comparison of the two

Insert picture description here

Six, IP datagram sending and forwarding process

  1. The grouping and forwarding process of ip datagram includes the following two parts:

(1) Host sends ip datagram
(2) Router forwards ip datagram

  1. There are two types of ip datagram forwarding:

(1) Direct delivery from the same network
(2) Indirect delivery from different networks: forwarding with the help of routers

  1. The detailed process is as follows:

Insert picture description here
Insert picture description here

Insert picture description here

  1. note

The router does not forward broadcast ip datagrams, which means that the router is isolated from the broadcast domain

Seven, static routing configuration and possible routing loop problems

  1. Static routing configuration means that the user or administrator manually configures the routing table

(1) This method is simple and has low overhead, but cannot adapt to changes in network status in time
(2) Generally only used in small-scale networks

  1. Possible routing loop problems caused by static routing configuration

(1) Configuration error

Insert picture description here

(2) Aggregate non-existent networks

Insert picture description here

Solution: Use black hole routing and set the network that does not exist in the aggregated network as black hole routing. If the data that conforms to this network goes or not, it is discarded.

(3) Network failure

Insert picture description here

Solution: Add a black hole route for the faulty network

8. Overview of routing protocol

1. Comparison of static routing and dynamic routing

Insert picture description here

2. Common routing protocols

(1) Interior gateway protocol: routing information protocol RIP, open shortest path first OSPF
(2) exterior gateway protocol: BGP

Insert picture description here

Nine, the basic working principle of the routing information protocol RIP

  1. RIP requires each router in the autonomous system to maintain a distance vector from itself to every other network in the autonomous system

  2. RIP uses hop count as a unit of measurement to measure the distance to the destination network

(1) The distance from the router to the directly connected network is defined as 1
(2) The distance from the router to the non-directly connected network is defined as the number of routers passed by plus 1
(3) A path can only contain up to 15 routers, and the distance is equal to 16. Equivalent to unreachable
Insert picture description here

  1. RIP considers a good route to be a route with a short distance, that is, the route with the least number of routers.

Insert picture description here

  1. When there are multiple equal-distance routes to the destination network, equal-cost load balancing can be performed: the traffic is evenly distributed to multiple equal-cost routes

  2. RIP contains three main points

(1) Only exchange information with neighboring routers
(2) Exchange information is its own routing table
(3) Exchange information periodically

  1. The basic working process of RIP
    (1) When the router first starts to work, it only knows that the distance to the directly connected network is 1
    (2) Each router only periodically exchanges and updates routing information with neighboring routers
    (3) Several times After the exchange and update, each router knows the shortest distance and next hop of each network in the autonomous system

  2. RIP update routing entry rules

Insert picture description here

10. The basic working principle of Open Shortest Path First OSPF

  1. OSPF neighboring routers exchange greeting packets to establish and maintain neighbor relationships

  2. The sending period of the hello packet is 10 seconds. If the hello packet from the neighbor router is not received in 40 seconds, the router is considered unreachable

  3. Every router that uses OSPF will generate a link state advertisement LSA. The LSA contains the following:

(1) Link status information of directly connected networks
(2) Link status information of neighbor routers

  1. The LSA is encapsulated in the link state update packet LSU and sent by the flooding method: the packet will be forwarded from all its interfaces

  2. Each router using OSPF has a link state database LSDB, which is used to store LSA

  3. By flooding each router to send LSU packets encapsulated with its own LSA, the LSDB of each router will eventually be consistent
    Insert picture description here

  4. Each router using OSPF performs shortest path first SPF calculation based on LSDB, and constructs each shortest path to other routers, that is, constructs their own routing table

  5. The basic working principle of OSPF

Insert picture description here
Insert picture description here

Insert picture description here

  1. OSPF divides an autonomous system into several smaller areas called areas
    Insert picture description here

  2. note

(1) OSPF is based on the link state, not based on the distance vector like RIP
(2) OSPF uses the SPF algorithm to calculate routes, which ensures that no routing loops will occur.

11. The header format of the ipv4 datagram

Insert picture description here

12. Internet Control Message Protocol ICMP

  1. In order to more effectively forward ip datagrams and improve the chance of successful delivery, the Internet Control Message Protocol ICMP is used at the Internet layer

  2. The host or router uses ICMP to send error report messages and query messages

  3. ICMP error report messages are encapsulated in IP datagrams and sent

  4. There are five types of ICMP error report messages

(1) End point unreachable
Insert picture description here

(2) Source point suppression

Insert picture description here

(3) Time exceeded
Insert picture description here

(4) Parameter issues

Insert picture description here

(5) Change routing

Insert picture description here

  1. ICMP error report messages should not be sent in the following situations

Insert picture description here

  1. ICMP application examples

(1) Packet network detection

Insert picture description here

(2) Trace route

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49343190/article/details/112487252