IPv4 and IPv6

The following details the differences between IPv4 and IPv6.

IPv4

IPv4, also known as Internet Protocol Version 4, consists of 32 bits (4 bytes) and is usually displayed in base 10, such as 192.168.0.1.

For IP communication, the IP header is added to the data. The IPv4 header is shown as follows:

  • Version: 4 bits, such as 0100… = Version :4 indicates IPv4 and 0110 indicates IPv6.
  • Header length: consists of 4 bits in 4 bytes, so the maximum header length is 60 bytes (15 * 4).
  • Service type: 8 bytes, 3 are priority fields, 4 are TOS fields (minimum latency, maximum throughput, maximum reliability, minimum cost), and the last one is undefined but must be set to 0
  • Total length: 16 bits indicates the total number of bytes in the IP header and data.
  • Identifier: 16 bits used to distinguish each fragment in a datagram. Each fragment identifier is the same.
  • Flag: three bits, representing the information to be sharded.
  • Slice displacement: indicates the offset distance between data transmitted in a fragment. It is also the relative position of data in a fragment in the original data. Generally, the offset is in the unit of 8 bytes
  • TTL: consists of 8 bits. Each time it passes through a router, the TTL is reduced by 1 and discarded until it reaches 0.
  • Protocol: Consists of eight bits, indicating which protocol the next IP header belongs to.
  • Header checksum: 16 bits, each time the router checks whether the header is broken.
  • Source Address: indicates the IP address of the sender.
  • Destination ADDRESS: IP address of the receiving end.
  • Padding: Adjusts the header length to a multiple of 32 bits by padding 0.
  • Data: packet data.

IPv6 based

IPv6, also known as Internet Protocol Version 6, was designed to address the exhaustion of IPv4 addresses.

IPv6 consists of 128 bits, usually written as 8 16-bit bytes, which can form 3.40 * 10^38 addresses, enough to assign addresses to all hosts and routes.

The format of IPv6 and IPv4 is different. If the format is hexadecimal, the format consists of eight 16-bit bits, for example:

FEDC:BA98:7654:3210:FEDC:BA98:7654:3210

If successive zeros occur in the binary representation, it can be written as

1080::8:800:200C:417A

IPv6 structure

Similar to IPv4, IPv6 is identified by the first few bits of an IP address.

  • Global unicast address: a unique address in the world. It is the most commonly used address for communication on the Internet. The first 64 bits are the network id and the last 64 bits are the host ID.
  • Link-local unicast address: an address that communicates on the same data link. (Without router) (1111 110)
  • Unique local address: an address that is not connected to the Internet but is connected to a private network. To improve security, networks communicate through NAT or gateway. (1111 1110 10)

IPv6 first

The IPv6 header is shown as follows:

IPv6 eliminates the header checksum field to reduce router stress. In addition, shard processing identifiers are now optional.

  • Version: Consistent with IPv4.
  • Traffic class: Basically consistent with the TOS field in IPv4.
  • Flow label: 20 bits for quality of service control.
  • Payload length: Refers to the length of the data portion.
  • Next header: Consistent with IPv4 protocols.
  • Hop Limit: The value is the same as the TTL in IPv4.
  • Source Address: indicates the IP address of the sender.
  • Destination address: IP address of the receiving end.

IPv6 shard

IPv6 fragment processing is allocated to the sending host, but the router does not fragment. The function of fragment processing is path MTU discovery.

Path MTU discovery is different from traditional router sharding, which is based on the maximum transmission unit (MTU) that a router can carry on different data links. In the path MTU discovery mode, the sender sends a packet that is forbidden to fragment. When the router needs to fragment the packet, it throws away the packet and returns an ICMP message to the host. The next time the host fragments the PACKET according to the MTU value notified by the ICMP, and then obtains the most suitable MTU.

Routing control

If only the IP address is used, network communication cannot be carried out. During communication, information about the next router or host is needed, and this information is recorded by the routing control table.

Routing control table

The routing control table records the network address and the router address that should be sent next. When receiving an IP packet, the router analyzes the destination address in the header and searches the control table for records that have the same network address as the changed IP address to find the next router address to be sent. If there are multiple records with the same network address, the most consistent (that is, the number of the same number of digits) will be selected.

Routing address types are classified as follows:

  • Default route: an address that matches any destination address, usually marked 0.0.0.0/0
  • Host address: Indicates that the entire IP address is a host address instead of a network address
  • Loopback address: localhost or 127.0.0.1. When using this address, packets do not flow to the network.

Aggregation of routing control tables

As more hosts and routers are connected, more network addresses are recorded in the ROUTING control table. Therefore, aggregation must be performed at this time.

For example, 192.168.2.0/24 and 192.168.3.0/24 can be aggregated into 192.168.2.0/23, which can reduce the size of the routing table and reduce the search time.

Write in the last

Come on, come on

Diagram to TCP/IP

This will be updated irregularly as a recent long-term goal.