The IP address
IP acts on the network layer in the OSI reference model and serves as a unique identifier in terminal communication to facilitate the determination of data transfer target.
IP addresses are classified into IPv4 and IPv6 addresses. The familiar and popular IP address for most users is IPv4, which is expressed in dotted decimal notation, for example, ==192.168.23.4==, ==117.43.56.3==, etc. IPv6 digits is big, is a 128 – bit, length is four times as large as IPv4, and its representation is partitioned the eight groups of four hexadecimal number, for example: 5 f05:2000-80 AD: 5800-0058:0800-2023:1 d71, between each patch is done with: separated. If the IPv6 and port Numbers are used together, may appear such circumstance: http://2001:0db8:85a3:08d3:1319:8a2e:0370:7344:443/
So can’t distinguish the port number and address, so I use this way to represent an address and port number: http:// [2001:0 db8:85 a3:08 d3:1319:8 a2e: 0370:7344) : 443 /
IP addressing
In a 32-bit IPv4 address, one consecutive bit is called the network number and the other is called the host number.
The network number is used to indicate the network zone in which the host is located, and the host number is used to identify the specific host in the current network. So when addressing, you can identify a host in the network and the specific address in the network area!
Ipv4 classification
In IPV4, network addresses can be divided into five classes: CLASS A, Class B, class C, Class D, class E;
- Class A: The network number contains eight digits. The first digit is always
0
, the next consecutive 7 bits can be set freely; The host number is 24 bits. Address range:0.0.0.0 ~ 127.255.255.255
; Because the minimum value of class B is the value whose first two digits are 10 and then all zeros, that is, 128.0.0.0; The following address range is followed by the analogy; - Class B: The network number contains 16 digits. The first two digits are fixed
1 0
, the next 14 consecutive bits can be set freely; The host number is 16 bits. - Class C: The network number contains 24 digits. The first three digits are fixed as
1 1 0
, the following consecutive 21 bits can be set freely; The host number is 8 bits. - Class D: is a multicast address, consisting of 32 bits. The first four bits are fixed as
1 1 1 0
; - E class:Is a reserved address. The first four digits are fixed to
1 1 1 1 1;
Class A, B, and C addresses are mostly unicast addresses, so they can be used for interface assignment.
Take class A address, because the class A address network number eight, the first fixed is zero, then the rest of the seven are free distribution, and host number digits is 24, then there is 2 ^ 24 host number, which means A kind of address can be allocated 2 ^ 7 regional network, each network area can have 2 ^ 24 host.
Since IP addresses are divided into five categories, what are their address ranges?
Subnet addressing
In some special scenarios, if the number of hosts in a region can not meet the actual needs, for example, if we need the number of hosts within the bearable range under the C class network; There will be a shortage of IP; On the other hand, if we are in A class network area, but the host is only A few, then it will cause waste, it is A waste of waste! So we adopted the method of subnet addressing to solve this problem.
The so-called subnet addressing is to divide a category of subnet into multiple subnet areas, each area has its own corresponding subnet number and host number; For example, the network number of class B network has 16 bits, and the host number has 16 bits. We can divide the 16-bit host number into 8-bit network number and 8-bit host number. In this way, the class B network is divided into many subnets, which is more suitable for our actual production environment.
Subnet mask
Determine where the network/subnet part of an IP address ends and the host part begins; The length of the subnet mask is the same as that of the IP address (32 bits in IPV4 and 128 bits in ipv6). For IPV4, the subnet mask is also expressed in dotted decimal notation. When the subnet mask is represented in binary, the structure is very simple and easy to remember, consisting of a sequence of 1’s from the left, followed by a sequence of 0’s until the end. The length of consecutive 1 is called prefix length, which is expressed by/length
Decimal representation | The prefix length | Binary representation |
---|---|---|
128.0.0.0 | / 1 | 10000000 00000000 00000000 00000000 |
255.0.0.0 | / 8 | 11111111 00000000 00000000 00000000 |
255.192.0.0 | / 10 | 11111111 11000000 00000000 00000000 |
255.255.0.0 | / 16 | 11111111 11111111 00000000 00000000 |
255.255.254.0 | / 23 | 11111111 11111111 11111110 00000000 |
255.255.255.224 | / 27 | 11111111 11111111 11111111 11100000 |
255.255.255.255 | / 32 | 11111111 11111111 11111111 11111111 |
Subnet mask Bit 1 Indicates the network/subnet part of the IP address. For example, if the host bit of a class B network is divided into eight sub-network numbers and eight host bit numbers, a subnet mask of 16+8=24 is set in advance, that is, 255.255.255.0, indicating that the first 24 bits are the network/subnet part. When processing an IP address, the router will manually check the subnet mask first, and then calculate the IP address and the subnet mask to obtain the subnet area to which the IP address belongs. For example, if the IP address 128.32.1.14 is the 8 sub-network number and 8 bit host number, you can obtain 128.32.1.0 by calculating with the subnet mask 255.255.255.0. You can find that the IP address belongs to the same network segment as 128.32.1.14, that is, in the same subnet.
In practice, the length of the subnet mask is variable. We can set the length of the subnet mask according to the number of hosts needed to support.
The broadcast address
A broadcast address is an address that is specifically used for simultaneous transmission to all workstations in the network. When using [TCP/IP](baike.baidu.com/item/TCP%2F… Protocol /2116790), IP addresses whose host IDS are all 1 are broadcast addresses, and broadcast packets are transmitted to all computers involved in the host ID segment. Simply put, the number with the largest value in the subnet segment is the broadcast address. So how to get this address, is to invert all the bits of the subnet mask, and then with the IP in the subnet or operation results in a broadcast address.