function

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. Routing and Packet Forwarding [Optimal Path]
  2. Heterogeneous network interconnection
  3. Congestion control

Data exchange mode

Circuit switching

The telephone network

Phase:

  1. Establish a connection
  2. communication
  3. Release the connection

Features: Exclusive resources

Advantages:

  1. Low communication delay
  2. The orderly transfer
  3. There is no conflict
  4. Strong real time

Disadvantages:

  1. Establishing a connection takes a long time
  2. Exclusive line, low efficiency
  3. Flexibility is poor
  4. Error free control ability

Message switching

Packet: Indicates the total information sent by the source application

Store and forward

Advantages:

  1. No connection required
  2. Storage and forwarding, dynamic allocation of lines
  3. High line reliability
  4. High line utilization
  5. Multi-objective service

Disadvantages:

  1. There is a store-and-forward delay
  2. The size of packets varies, requiring large cache space on network nodes

Packet switching

Grouping: To divide large data blocks into smaller data blocks

Advantages:

  1. No connection required
  2. Storage and forwarding, dynamic allocation of lines
  3. High line reliability
  4. High line utilization
  5. Compared with packet switching, storage management is easier

Disadvantages:

  1. There is a store-and-forward delay
  2. Additional information is required
  3. If the order is out of order to the destination host, the group must be sorted and reassembled

Datagram mode

Connectionless service for the network layer (uncertain transport path)

  • There is no connection
  • Each packet carries the source address and destination address
  • The router forwards packets according to their destination addresses

Virtual circuit mode

Provide connection services for the network layer (determine transport paths)

Sending unit: packet

Ensure the order of arrival of the packets

Communication process

  1. Establish a connection (virtual circuit establishment)
  2. Data transmission: full duplex communication
  3. Release connection (virtual circuit release)

To compare

  1. Both packet switching and packet switching use store-and-forward
  2. Circuit switching is selected when the data transmission is large and the transmission time is much longer than the call. Circuit switched transmission delay is minimum
  3. From the view of channel utilization, packet switching and packet switching are better than circuit switching, and packet switching has smaller delay

Transport unit noun

  1. Application layer: packets
  2. Transport layer: packet segment
  3. Network layer: IP datagrams and packets
  4. Data link layer: frames
  5. Physical layer: bit stream

Routing algorithm

Best route: Best is only a reasonable choice based on a specific requirement

Classification:

  1. Static routing algorithm (non-adaptive routing algorithm) : Manually configured by the administrator

    Route update is slow and not applicable to large networks

  2. Dynamic routing algorithm (adaptive routing algorithm) : Routers exchange information and optimize routing entries based on the routing algorithm

    Fast route update, suitable for large networks

    The complexity of the algorithm increases the network burden

    1. Global: OSPF is the link-state routing algorithm

      All routers have complete network topology and link cost information

    2. Distance vector routing algorithm RIP

      A router only knows the physical neighbors and link costs

Hierarchical routing protocols: Avoid the large size of the Internet, many organizations do not want their routing protocols known to the outside world, but still want access to the Internet

  • Autonomous System (AS) : A group of routers managed by a single technology

Routing protocol:

  1. Internal gateway IGP: RIP and OSPF used in an AS
  2. External gateway protocol EGP: BGP used between ass

RIP

Distributed routing protocol based on distance vector

RIP requires each router on the network to maintain a unique record of the best distance from itself to each other

A RIP route can contain a maximum of 15 routers. Therefore, a distance of 16 indicates that the network is unreachable

RIP is only applicable to small Internet

  1. Exchange information only with neighboring routers
  2. The information a router exchanges is its own routing table
  3. Routing information is exchanged every 30 seconds

Distance vector algorithm

Good news travels fast, but bad news travels slowly

OSPF protocol

Use a distributed link state protocol

Link state routing algorithm

The IP datagram

The length of the fixed part is 20B

  • Version: IPv4 / IPv6
  • Head length: unit: 4B, minimum: 5
  • Distinguish services: Indicate what type of service is expected
  • Total length: header + data, in unit 1B
  • TTL: indicates the shelf life of IP packets. Passes through a router -1, becomes 0 and is discarded
  • Protocol: The protocol for the data part
  • Head inspection and: check only the head
  • Source IP address and destination IP address: 32-bit
  • Optional fields: 0-40B, Troubleshooting, measurement, safety
  • Fill: all zeros, fill the head with a multiple of 4B

MTU: indicates the upper limit of data that can be encapsulated by a data frame at the link layer

The MTU of the Ethernet is 1500 bytes

If the MTU value exceeds the MTU value, fragments are generated

  • Identity: Shards of the same datagram use the same identity

  • Sign: Only 2 bits are meaningful

    • Middle bit DF: 1 (sharding is forbidden), 0 (sharding is allowed)
    • Minimum is MF: 1 (shard after), 0 (last shard)
  • Slice offset: indicates the relative position of a slice in the original group after a long slice is sharded. We have 8B units

    Each shard except the last shard must be an integer multiple of 8B in length

IPv4

IP compilation stage

IP address of the class

IP address: a 32-bit / 4-byte identifier unique in the world that identifies the interface of the router host

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

Dotted decimal

IP address of the classification:

Special IP address:

Private IP address:

Network address translation NAT

The router does not forward any datagrams whose destination address is a private IP address

NAT: Installs NAT software (NAT router) on a router connected to the Internet on a private network and has at least one external global IP address

Subnets

Weaknesses of classified IP addresses:

  1. The IP address space usage is low
  2. The two-tier IP address is not flexible

External networks do not see the subnets in the local unit, but the external networks are still a network

The subnet mask and IP address are bitwise matched to obtain the subnet address

Router forwarding packet algorithm:

  1. The destination IP address was extracted
  2. Direct delivery
  3. Host-specific routing
  4. Check whether there are paths in the routing table
  5. The default route is 0.0.0.0
  6. Discard. A forwarding packet error is reported

Form the hypernet (non-classification addressing method) CIDR

Classless interzone routing CIDR:

  1. Eliminates the traditional class A, B, C address and subnet division concept

  2. Fuse the subnet address and subnet mask to facilitate subnets

CIDR: The IP address followed by a “/” and then the number of digits of the network prefix (which can be of any length) (128.14.32.0/20)

CIDR address block: Consecutive IP addresses with the same network prefix form a CIDR address block

Address mask (subnet mask)

The aggregation of multiple subnets into a larger subnet is called forming a hypernet, or route aggregation

Method: Shorten the network prefix

Longest prefix matching: When using CIDR, searching the routing table may yield several matches. Choose the route with the longest network prefix. The longer the prefix, the smaller the address block and the more specific the route

ARP protocol

The MAC address must be used when transmitting the data frame on the link of the real network

ARP: Maps the IP address of a host or router to a MAC address. Figure out where to jump next

ARP protocol usage process:

  • Check ARP cache
    1. If there are corresponding entries, the MAC frame is written
    2. If no, the ARP request packet is encapsulated and broadcast with a frame whose destination MAC address is FF-ff-ff-ff-FF. All hosts on the same LAN can receive the ARP request packet. After receiving the request, the destination host unicast an ARP response packet to the source host, and the source host writes the mapping to the ARP cache (updated every 10-20 minutes).

Four typical ARP scenarios are as follows:

  1. Host A sends the PACKET to host B on the local network: Use ARP to find host B’s MAC address
  2. Host A sends ARP to host B on another network to find the MAC address of A router (gateway) on the local network
  3. The router sends ARP to host A on the local network to find host A’s MAC address
  4. Router to host on another network A: Use ARP to find the MAC of A router on the local network

ARP is automatically implemented

DHCP protocol

The host obtains an IP address:

  1. Static configuration

    IP address, subnet mask, and default gateway

  2. Dynamic configuration

Dynamic Host Configuration Protocol DHCP is an application-layer protocol that uses C/S mode. The client and server communicate with each other in broadcast mode based on UDP

DHCP provides a plug and play networking mechanism. A host can dynamically obtain an IP address, subnet mask, default gateway, DNS server name, and IP address from a server, enabling address reuse, mobile users to join the network, and IP address renewal

The ICMP protocol

ICMP supports hosts or routers:

  1. Error (or exception) reporting -> Sending specific ICMP packets
  2. Network search

ICMP error message

  1. Endpoint unreachable: Sending an endpoint unreachable message to a source when the router or host fails to deliver a datagram (undeliverable)
  2. Source point suppression: data is lost due to congestion
  3. If the time exceeds: TTL=0
  4. Parameter problem: header field problem
  5. Change route (redirect) : Worth better route

ICMP error packets should not be sent:

  1. ICMP error packets are no longer sent
  2. ICMP error report packets are not sent for all subsequent datagram slices of the first fragmented datagram
  3. ICMP error report packets are not sent for datagrams with multicast addresses
  4. ICMP error report packets are not sent for datagrams with a special address (127.0.0.0 or 0.0.0.0)

ICMP query message

  1. Echo request and reply packets: PING. Test whether the destination station is reachable and understand its related status
  2. Timestamp request and reply message: Clock synchronization and time measurement
  3. Mask address request and reply packets
  4. Router query and notification messages

application

  1. PING: Tests the connectivity between two hosts. ICMP echo request and reply packets are used
  2. Traceroute: Traces the path of a packet from the source to the destination using ICMP time-out error messages

IPv6

The 32-bit IPv4 address space is used up. Procedure

CIDR and NAT treat the symptoms rather than the root causes

IPv6 fundamentally solves the problem of address exhaustion

format

  • Version: Specifies the protocol version, always 6
  • Priority: Distinguishes the categories and priorities of datagrams
  • Stream label: All datagrams belonging to the same stream have the same stream label
  • Payload length: Length of extension header and data
  • Next header: Identifies the next extension header or upper-layer protocol header
  • Hop limit: TTL equivalent to IPv4

IPv6 and IPv4

  1. IPv6 extends addresses from 32-bit (4B) to 128-bit (16B)
  2. IPv6 Removes the checksum field of Ipv4 to reduce the processing time per hop
  3. IPv6 removes IPv4 optional fields from the header and becomes an extended header. The router usually does not check the extension header, which greatly improves the processing efficiency of the router
  4. IPv6 supports plug and play and does not require DHCP
  5. The length of the IPv6 header must be a multiple of 8B, and that of the IPv4 header must be a multiple of 4B
  6. IPv6 can only be on host chips, IPv4 can be on routers and host chips
  7. ICMPv6: Additional packet type is Too Large

representation

Common form: colon hexadecimal notation

Compressed form

Basic IPv6 address type

  • Unicast: One-to-one communication can be the source address + destination address
  • Multicast: One-to-many communication can be the destination address
  • Multicast: a one-to-many communication that can be used as the destination address

The transition to IPv4

  1. Dual-stack protocol: Enable both IPv4 and IPv6 protocols on a device
  2. The tunnel technology

IP multicast

Three modes of propagation for IP datagrams

  1. Unicast: point-to-point
  2. Broadcast: Point to all points
  3. Multicast: Point-to-multipoint

Network layer device

Router: A dedicated computer with multiple input and output ports whose job is to forward packets

  • Router: A network segment that can interconnect two different network layer protocols
  • Bridge: Connects two different network segments at the physical layer and link layer
  • Hub: Can interconnect two physical layer different network segments