CIDR understanding and IP maximum address prefix matching

Source: Internet
Author: User

What is 1.CIDR?

Non-class inter-domain routing (CIDR) addressing scheme

Discard the traditional class-based address assignment, allow the use of any length of address prefix, effectively improve the utilization of the address space. is an IP plus a netmask, but this mask is not a previous 3 values (Class A: 8,b class: 16,c class: 24), but 0-32 random value. For example: 208.12.128.0/17 2. How to understand the CIDR format can be understood as a line segment from 0 to (2^32-1) long. The Mask 32 represents the point of N IP, and the number n is 2^32. Mask 31 represents n small segment 1, each segment 1 contains 2 (2^ (32-31)) IP points, the number n is 2^31. The Mask 30 represents n small segment 2, each segment 2 contains 4 (2^ (32-30)) IP points, 2 small segment 1 (2^ (31-30)), and the quantity n is 2^30. And so on, can be the image of "scale". 3. The relationship between each CIDR 1. See 208.12.16/24208.12.21/24 2. See 208.12.16/24208.12.17/24 3. Contains 208.12.21/24208.12.16/20why can't 2 CIDR intersect? 2 CIDR assumptions are IP1/MASK1,IP2/MASK2.MASK3 = (Mask1 > Mask2)? MASK2:MASK1;IP1/(MASK3) and ip2/(MASK3) are only equal and unequal in 2 cases. Unequal: Absent or similar: the image can be imagined as "scale", in which there is no intersection. 4.ip maximum address prefix match 1. The exhaustive method is known as an IP hypothesis for 208.12.16.188 lookup hash table, key for (IP & mask) where mask is reduced from 32 to 0 the worst time complexity =o () *hash find 2. The longest prefix matching IP address is a 32bit number that constructs a bit prefix tree for the longest prefix match. Worst time complexity =o (32) 3.2 points of the linear table find out each CIDR (IP & Mask) value, sorted by this value (from small to large) when you want to query an IP address, assume Ip1, find the first value of >IP1, the value to the left of this value is assumed (ip2 & Mask2) determine if ip1 & Mask2 is =IP2 (you can judge the superset of this IP segment as needed, and when building a linear table, the superset relationship can be drawn). The worst time complexity is =o (LG (n)), and N is the number of CIDR.

CIDR understanding and IP maximum address prefix matching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.