1. Services provided by the network layer: virtual circuit services and datagram services

  2. Internet Layer protocol IP:

    • Internet Layer protocol IP matching protocol:

      • Address Resolution Protocol (ARP);
      • Internet Control Message Protocol (ICMP);
      • Internet Group Management Protocol (IGMP)
    • Virtual Internet:

      • The intermediate device used by the physical layer is called a repeater
      • The intermediate devices used by the data link layer are called Bridges
      • The intermediate devices used by the network layer are called routers
      • The intermediate device gateway used above the network layer is called a gateway.
    • 2.1. IP address of classification:

      • Class A IP address: Class A IP address The network number of the check is 126. The IP address whose network number field is all 0 is a reserved address, which means the local network. The network ID is 127. The network id is reserved for communication between processes on the local host in the local software Loopback test.

        The maximum number of hosts with class A IP address is 224-2. The host ID field containing all zeros indicates that the IP address is A single network address connected to the host. All 1s indicate all hosts on the network.

      • Class B IP address: The number of class B IP addresses is 214-1, and the maximum number of hosts is 216-2

      • Class C IP address: The number of class C IP addresses is 221-1, and the number of hosts is 28-2

        Network class Maximum number of networks that can be assigned The first assignable network number The last assignable network number Maximum number of hosts
        A 272 – 1 126 2242 –
        B 214 – 1 129.1 191.255 2162 –
        C 221 – 1 192.0.1 223.255.255 282 –
      • IP address features:

        • Each IP address consists of a network number and a host number. When IP addresses are assigned, only network numbers are assigned. The router forwards packets according to the network number connected to the destination host.
        • An IP address and is an interface that identifies a host and a link. There should be several IP addresses to connect to several networks. A router, for example, should have at least two different IP addresses.
    • 2.2 IP address and Hardware Address: The physical address is used by the data link layer and the physical layer, while the IP address is used by the network layer and other layers, which is a logical address (IP address is realized by software).

      Only IP datagrams can be seen on IP layer abstract Internet. The router selects routes only according to the network number of the DESTINATION IP address. At the data link layer, only MAC frames are visible. The IP layer hides the intricate details of the underlying layer.

    • 2.3. Address Resolution ARP: Each host has an ARP cache, which maps the IP addresses of hosts and routers on the local LAN to hardware addresses. ARP addresses the mapping between IP addresses and hardware addresses of hosts or routers on the same LAN.

    • 2.4. Format of IP datagram:

      • Version: 4 bits
      • Header length: unit: word (32 bits). The fixed length of the IP header is 20 bytes, so the minimum length of the IP header is 5 and the maximum length is 15. That is, the maximum length of the IP header is 60 bytes.
      • Differentiated services: Generally not applicable
      • Total length: sum of header and data length, in bytes. If the total length exceeds the MTU of data link layer frames, datagrams need to be fragmented.
      • Identity: When a datagram is fragmented, the identity field is copied to the identity field of all datagrams. The same value of the identity field enables the fragmented datagrams to be correctly reassembled into the original datagrams.
      • Mark:
        • The lowest flag is marked as More Fragment (MF). MF = 1 indicates that there are further fragmented datagrams. MF = 0 means this last datagram.
        • The middle bit of the flag is marked as DF(Don’t Fragment). Fragments are allowed only when DF is 0.
      • Slice offset: The relative starting position of a slice in the original group. The unit is 8 bytes.
      • Lifetime: The maximum number of routers a datagram can pass through in an interconnection.
      • Protocol: Upper-level protocol
      • Header checksum: Dividing the head into a 16-bit sequence of bits, performing inverse arithmetic (that is, xor, with two ones carried) to add up all 16-bit sequences of bits, and then inverting the sum.
    • 2.5. IP Layer forwarding packet flow:

      • The IP address D of the destination host is extracted from the header of the data packet, and the destination network address is obtained as N.
      • If N is a network address directly connected to this router, direct delivery is carried out. Otherwise deliver indirectly.
      • If there is a specific host route whose destination address is D in the routing table, the datagram is transmitted to the next-hop router named in the routing table. Otherwise, go to the next step.
      • If there is a route to network N in the routing table, the datagram is transmitted to the next-hop router named in the routing table. Otherwise, go to the next step.
      • If there is a default route in the routing table, the datagram is transmitted to the default router named in the routing table. Otherwise, go to the next step.
      • Forwarding packet error reported.
  3. Dividing subnets and constructing hypernets:

    • 3.1. Subnets: Divide multiple physical networks in a unit into subnets. Externally it still behaves as a network. All IP datagrams sent from other networks to a host in the unit are still based on the destination network number of IP datagrams to find the router connected to the unit’s network. After receiving the IP packet, the router finds the destination subnet based on the destination network number and subnet number and delivers the IP packet to the destination host.

    A router finds a subnet based on its subnet mask. All networks must use subnet masks. If a network does not have subnets, the default subnet mask is used.

    • 3.2 Forwarding of groups when using subnets:
      • Extracts the destination IP address D from the header of the received datagram.
      • Determine whether it is direct delivery first. Check the networks directly connected to the router one by one: use the subnet mask of each network and D bit by bit to see whether the result matches the corresponding network address. If matched, the group is delivered directly; Otherwise, perform indirect delivery and go to the next step.
      • If there is a specific host route whose destination address is D in the routing table, the datagram is transmitted to the next-hop router named in the routing table. Otherwise, go to the next step.
      • For each row in the routing table, with the subnet mask and D bitwise phase, the result is N. If N matches the destination network address of the line, the datagram is transmitted to the next-hop router specified in the line. Otherwise, go to the next step.
      • If there is a default route in the routing table, the datagram is transmitted to the default router specified in the routing table. Otherwise, go to the next step.
      • Forwarding packet error reported.
    • 3.3 Unclassified addressing CIDR:
      • Network prefix: An IP address is divided into a network prefix and a host NUMBER.
      • Longest prefix matching: When matching the routing table, the route with the longest network prefix should be selected from the matching result.
      • Use binary clues to find routing tables: Binary clues speed up lookups.
  4. Internet Control Message Protocol ICMP:

    • ICMP Packet format:

    • ICMP Packet types: ICMP error report packet, ICMP query packet.

      ICMP Packet Types The value of the type ICMP Packet type
      Error report message 3 Out of reach
      Error report message 11 For more than
      Error report message 12 Parameters of the problem
      Error report message 5 Change the routing
      Ask a message 8 or 0 Echo the request or reply
      Ask a message 13 or 14 Timestamp request or reply
    • ICMP Error packet format: An ICMP error report packet is composed of the header of the received IP packet for error reporting and the first 8 bytes of the data field as ICMP packet fields, and the first 8 bytes of the corresponding ICMP error report packet. The first 8 bytes of the data field of the received datagram are extracted to obtain the port number of the transport layer and the serial number of the packet sent at the transport layer.

  5. Routing protocols for the Internet:

    • 5.1. Internal Gateway Protocol RIP:

      • RIP definition: Routing Information Protocol (RIP) is a distributed Routing Protocol based on distance vector. The RIP distance is also called the Hop count. A RIP path can contain a maximum of 15 routers.
      • RIP features:
        • Exchange information only with neighboring routers
        • The router exchanges all the information that the router currently knows, that is, its current routing table.
        • Routing information is exchanged at fixed intervals.
      • RIP algorithm:
        • In a RIP packet sent from a neighboring router whose IP address is X, all the items in the packet are modified first. The address in the next hop field is changed to X, and the values of all distance fields are increased by 1. Each item has three data: to the destination network N, the distance is D, and the next-hop router is X.
        • Perform the following steps for each item in the modified RIP packet: If the destination network N does not exist in the original routing table, add the item to the routing table. Otherwise, if the next-hop router address is X, the received item is replaced with the item in the original routing table. Otherwise, if the distance D in the received item is less than the distance in the routing table, it is updated. Otherwise, do nothing.
        • If the updated routing table of the adjacent route is not received within 3 minutes, the adjacent router is recorded as unreachable, that is, the distance is set to 16.
      • The FORMAT of RIP packets is as follows: RIP transmits user datagram UDP at the transport layer. The maximum length of a RIP packet is 504 bytes. RIP propagates good news quickly but bad news slowly.
    • 5.2. OSPF internal Gateway protocol:

      • Features of Open Shortest Path First (OSPF)
        • Sends information to all routers in the autonomous system.

        • The information sent is the link status of all routers adjacent to the local router. The link status refers to the routers adjacent to the local router and the metric of the link.

        • The router uses flooding to send information to all routers only when the link status changes.

        • All routers eventually build a link-State database, which is a topology map of the entire network. This topology is consistent throughout the network.

      • OSPF packet format: OSPF directly uses IP datagrams for transmission.

      • OSPF group types:
        • Type 1, greeting (Hello) grouping, used to discover and maintain the accessibility of neighboring stations.
        • Type 2: Database Description group, which provides summary information of all link state items in its link state Database to neighboring stations.
        • Type 3: Link State Request group, which sends detailed information about certain Link State items to the other party.
        • Type 4, Link State Update group, using flood mode to Update the Link State of the whole network.
        • Type 5, Link State Acknowledgment packet, Acknowledgment of a Link update packet.
    • 5.3. External Gateway Protocol BGP:

      • Reasons for using the external gateway protocol:
        • The large scale of the Internet makes it difficult to select routes between ass. If the link state protocol is used, calculating the shortest path takes too long, and the internal routing protocols of autonomous systems may be different.
        • Policies must be considered when selecting routes between ass.
      • BGP use: Each AS selects at least one router AS the BGP spokesperson of the AS. To exchange routing information between a BGP spokesperson and the BGP spokesperson of another AS, a TCP connection is established and BGP packets are exchanged on this connection to establish a BGP session. BGP sessions are used to exchange routing information.
      • Type of BGP packets:
        • OPEN message: used to establish a relationship with an adjacent BGP spokesperson to initialize communication.
        • UPDATE packet: advertises information about a route and lists multiple routes to be deleted.
        • KEEPALIVE message: used to periodically confirm the connectivity of neighboring stations.
        • NOTIFICATION message: Used to send detected errors.
  6. Router composition:

    • 5.1. Structure of router: The overall structure of router can be divided into two parts: routing part and packet forwarding part. The routing table contains only the mapping from the destination network to the next hop, and the packet is derived from the routing table. The forwarding table must contain the information necessary for forwarding, that is, the mapping from the destination network to the output port and some MAC addresses.
  7. IPv6:

    • IPv6 notation: Colon hexadecimal notation, which can be replaced by a pair of colons when there is a sequence of zeros.
    • Transition from IPv4 to IPv6:
      • Dual-stack: A dual-stack host supports both IPv4 and IPv6 and has two IP addresses: IPv6 and IPv4.
      • Tunneling: Converts IPv6 datagrams into the data portion of IPv4 datagrams.
  8. Reference: [1] : Computer networks