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:
- Routing and Packet Forwarding [Optimal Path]
- Heterogeneous network interconnection
- Congestion control
Data exchange mode
Circuit switching
The telephone network
Phase:
- Establish a connection
- communication
- Release the connection
Features: Exclusive resources
Advantages:
- Low communication delay
- The orderly transfer
- There is no conflict
- Strong real time
Disadvantages:
- Establishing a connection takes a long time
- Exclusive line, low efficiency
- Flexibility is poor
- Error free control ability
Message switching
Packet: Indicates the total information sent by the source application
Store and forward
Advantages:
- No connection required
- Storage and forwarding, dynamic allocation of lines
- High line reliability
- High line utilization
- Multi-objective service
Disadvantages:
- There is a store-and-forward delay
- 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:
- No connection required
- Storage and forwarding, dynamic allocation of lines
- High line reliability
- High line utilization
- Compared with packet switching, storage management is easier
Disadvantages:
- There is a store-and-forward delay
- Additional information is required
- 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
- Establish a connection (virtual circuit establishment)
- Data transmission: full duplex communication
- Release connection (virtual circuit release)
To compare
- Both packet switching and packet switching use store-and-forward
- 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
- 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
- Application layer: packets
- Transport layer: packet segment
- Network layer: IP datagrams and packets
- Data link layer: frames
- Physical layer: bit stream
Routing algorithm
Best route: Best is only a reasonable choice based on a specific requirement
Classification:
-
Static routing algorithm (non-adaptive routing algorithm) : Manually configured by the administrator
Route update is slow and not applicable to large networks
-
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
-
Global: OSPF is the link-state routing algorithm
All routers have complete network topology and link cost information
-
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:
- Internal gateway IGP: RIP and OSPF used in an AS
- 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
- Exchange information only with neighboring routers
- The information a router exchanges is its own routing table
- 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:
- The IP address space usage is low
- 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:
- The destination IP address was extracted
- Direct delivery
- Host-specific routing
- Check whether there are paths in the routing table
- The default route is 0.0.0.0
- Discard. A forwarding packet error is reported
Form the hypernet (non-classification addressing method) CIDR
Classless interzone routing CIDR:
-
Eliminates the traditional class A, B, C address and subnet division concept
-
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
- If there are corresponding entries, the MAC frame is written
- 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:
- Host A sends the PACKET to host B on the local network: Use ARP to find host B’s MAC address
- Host A sends ARP to host B on another network to find the MAC address of A router (gateway) on the local network
- The router sends ARP to host A on the local network to find host A’s MAC address
- 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:
-
Static configuration
IP address, subnet mask, and default gateway
-
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:
- Error (or exception) reporting -> Sending specific ICMP packets
- Network search
ICMP error message
- Endpoint unreachable: Sending an endpoint unreachable message to a source when the router or host fails to deliver a datagram (undeliverable)
- Source point suppression: data is lost due to congestion
- If the time exceeds: TTL=0
- Parameter problem: header field problem
- Change route (redirect) : Worth better route
ICMP error packets should not be sent:
- ICMP error packets are no longer sent
- ICMP error report packets are not sent for all subsequent datagram slices of the first fragmented datagram
- ICMP error report packets are not sent for datagrams with multicast addresses
- 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
- Echo request and reply packets: PING. Test whether the destination station is reachable and understand its related status
- Timestamp request and reply message: Clock synchronization and time measurement
- Mask address request and reply packets
- Router query and notification messages
application
- PING: Tests the connectivity between two hosts. ICMP echo request and reply packets are used
- 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
- IPv6 extends addresses from 32-bit (4B) to 128-bit (16B)
- IPv6 Removes the checksum field of Ipv4 to reduce the processing time per hop
- 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
- IPv6 supports plug and play and does not require DHCP
- The length of the IPv6 header must be a multiple of 8B, and that of the IPv4 header must be a multiple of 4B
- IPv6 can only be on host chips, IPv4 can be on routers and host chips
- 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
- Dual-stack protocol: Enable both IPv4 and IPv6 protocols on a device
- The tunnel technology
IP multicast
Three modes of propagation for IP datagrams
- Unicast: point-to-point
- Broadcast: Point to all points
- 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