1. Several terminologies:
Address:
Subnet:
Subnet mask: A 32-bit combination used to describe which portion of an adress refers to the subnet and which part refers to the host.
Interface: A network connection
Net ID:
Host ID:
Subnetwork ID:
2. IP Address:
An IP address is an adress used in order to uniquely identify a device on an IP network. It is made up of 32 binary bits which can be divisible into a network portion and host portion with the help of a subnet mask. 32-bits are brokern into 4 octets(8 bits = 1 octet), for example: 172.16.81.00 = 10101100 | 00010000 | 01010001 | 00000000
There are five different classes of networks, A to E. Classes D and E are reserved.
Given an IP address, its class can be dertermined from the three high-order bits(the three left-most bits in the first octet.)
Class A: the first one bit is zero, and the first one byte is used to NetID, the rest bytes are Node ID. The range of Class A address is 1.0.0.0 - 127.255.255.255). where is 0.0.0.0 ?
0 x x x x x x x |---------------------------------the rest 24 bits------------------|
Class B: the first two bits are 10, and the first two bytes are used to NetID,the rest bytes are Node ID.
1 0 x x x x x x x x x x x x x x |--------------------------the rest 16 bits------|
Class C: the first three bits are 110, and the first three bytes are used to NetID, the rest byte is Node ID.
1 1 0 x x x x x x x x x x x x x x x x x x x x x |-----------the rest 8 bits----|
Class D: the first four bits are 1110, and the first four bytes are used to NetID.
1 1 1 0 |-------------------------the rest 28 bits reserved ----------------------|
Class E: the first four bits are 1111, and the first four bytes are used to NetID.
1 1 1 1 |-------------------------the rest 28 bits reserved ----------------------|
3. Network Mask:
A network mask is a 32-bit binary mask used to divide an IP address into subnets and specify the network‘s available hosts. Class A ,B, C networks have default maskes, also known as natural masks.
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0
The mask is to help determin which part of IP address is Net ID and which part is host ID.
Any address bits which have corresponding mask bits set to 1 represents the network ID; Any address bits which have conresppinging mask bits set to 0 represents the host ID.
4. Subnetting:
In order to create multiple logical networks that exist within a single Class A , B, or C network, we need subnetting.
By extending the default mask (255.255.255.0) to be (255.255.224), we have taken three bits(indicated by ""host) from the original host portion and used them to make subnets. Totally we can make 8 subnets from these three bits with the remaining 5 bits for host ID bits. Each subnet can have up to 32 host addresses, 30 of which can actually be assigned to a device since host ids of all zeros or all ones are not allowed.
For exampel, given a class C network of 204.170.4.0 which has a natural mask of 255.255.255.0. Now a given a extended mask 255.255.224.0. So the 8 subnets are:
204.170.4.0 255.255.255.224 host address range from 1 to 30.
204.170.4.32 255.255.255.224 host address range from 33 to 62
204.170.4.64 255.255.255.224 host address range from
204.170.4.96 255.255.255.224 host address range from
204.170.4.128 255.255.255.224 host address range from
204.170.4.160 255.255.255.224 host address range from
204.170.4.192 255.255.255.224 host address range from
204.170.4.224 255.255.255.224 host address range from
There is another way to denote the mask. One is 255.255.255.224 and another way is /27. The second way is called CIDR(), prefix/length.
For example, 204.17.5.32/27 denotes the network 204.17.5.32 255.255.255.224
5. Determing how many subnets and available hosts/devices in each subnet
how many subnets are there in each Class network? Depending on how many bits are borrowed from the host bits. 2^n, n means the bits that ‘s used for subnetting.
how many hosts/devices in each subnet? Depending on how many bits are used for host. 2^m-2, m bits are used for host
For example, Class B network, given a mask of 255.255.248.0(/21), then we can calculate that 2^5 subnets available, and 2^11 host addresses and 2^11 -2 can be assigned to devices.
7. Given the address/mask, and determin the subnet
原文地址:https://www.cnblogs.com/sarah-zhang/p/12105250.html