Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Darnay-Network Engineering-understanding of IP address and the method of converting binary to Decimal

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The overall content of this article includes the following parts:

Brief introduction of IP address

The role of IP address

Representation of IP address

Conversion between base 2 and base 10

The structure of the IP address

Subnet mask

Management of IP address

Classification of IP addresses

Problems with IP addr

IP address solution

A brief introduction to the IP address:

Any device that can access the Internet must have an IP address, and every IP address means that everyone must have a name.

What common IP addresses look like, such as the default address for TP-Link wireless routes: 192.168.1.1

The role of the IP address:

Within a certain range, a unique logo, a device for surfing the Internet; (all devices that need to surf the Internet must have an IP address.)

The representation of the IP address:

The computer can only recognize binary, so the IP address in the computer is represented by binary (10101010 01010010 01001011 10100111).

In the human world, using dotted decimal is more convenient for viewing and recording (X.X.X.X), where X represents a decimal number

Each X corresponds to 8 binaries; each X corresponds to 1 byte; the value range of X is 0Mur255.

Conversion between base 2 and base 10

1. Positive integers are converted to binary. The main points must be kept in mind: divide two to take the remainder, then arrange them in reverse order, and fill in zero in the high position.

In other words, divide the positive decimal number by two, and then divide the quotient by two, and then know that the quotient is zero or temporarily, then mark the remainder of each step next to it, and finally write it backwards, and the high zero is OK. Alas, let's give an example, for example, 42 is converted to binary, the remainder is 010101, and the reverse is 101010. If it is written in the form of an IP address, it needs the preceding bit complement 00101010.

2, integer binary to decimal: for example, binary 1101, converted to decimal is: 1x 2 (1-1) + 0-2 (2-1) + 1-2 (3-1) + 1-2 (4-1) = 1-0-4-8-13 from the lowest bit (rightmost), the number on the bit is multiplied by the weight of the bit, and the weight is the number of digits of 2 minus one power. For example, the second place is the (2-1) power of 2, which is 2; the 8th place is 2, and the (8-1) power of 2 is 128. Add up all the values.

The calculation results of the commonly used 2 ^ N power

2 to the power of 0 = 1

1 to the power of 2 = 2

2 to the second power = 4

2 to the third power = 8

2 to the fourth power = 16

2 to the 5th power = 32

6 to the power of 2 = 64

2 to the power of 7 = 128

2 to the power of 8 = 256

2 to the power of 9 = 512

2 to the power of 10 = 1024

2 to the power of 16 = 65536

2 to the power of 32 = 4294967296

The structure of the IP address:

# length is 32 bit

# structure: network bits + host bits (distinguishing network bits from host bits by subnet mask)

For example: 192.168.1.1

Subnet mask:

-effect

Distinguish the network bits from the host bits in the IP address, and must correspond to the IP address one by one and appear in pairs.

-represents

Pure binary

The range of values for dotted decimal (y.y.y.y)-> y is 0-255.

/ n (n indicates how many 1s are in the subnet mask)

-functional implementation

The bit in the IP address corresponding to 1 in the subnet mask is called the network bit

The bit in the IP address corresponding to 0 in the subnet mask is called the host bit

For example:

IP: 10101101 11001111 10010001 00001011

Mask: 11111111 11111111 11111111 00000000

-Features

# one-to-one correspondence with IP address

# 1 and 0 are always continuous and will not cross

# the left side is always 1, the right side is always 0

Related confusing concepts:

-inverse mask (inverse-mask)

Just change the ones and zeros in the mask to each other.

-wildcard (wildcard bits)

0 and 1 can cross or not cross.

Classification of IP addresses:

Goal: in order to facilitate the management of IP addresses

Principle: look at the first few fixed bit of the first byte in the IP address

0000 0000.X.X.X

The first byte of A, the first bit, if it is 0, it is called Class A.

The decimal system is 0-127. The default mask is 255.0.0.0.

0000 0000-> 0

0111 1111-> 127

The first byte of B, the first two bit, if it is 10, it is called Class B.

The decimal system is 128-191 default mask 255.255.0.0

1000 0000-> 128

1011 1111-> 191

The first byte of C, the first three bit, if it is 110, it is called Class C.

192-223 default mask 255.255.255.0

1100 0000-> 192

1101 1111-> 223

The first byte of D, the first four bit, if it is 1110, it is called Class D.

224-239 No mask

The rest of E is Class E.

240-255 laboratory reserved for use

Special IP address (not available-cannot be configured on network devices)

# Network address

-effect

Represents a range / area and does not represent any device

-definition

The host bits in the IP address, all 0. The IP is called a network address.

# broadcast address

-effect

Represents all devices in a range / area

-definition

The host bits in the IP address, all 1. The IP is called a broadcast address.

Addresses starting with 0 and 127 cannot be directly configured on the device

For example:

192.168.1.255

255.255.0.0

1100 0000.1010 1000.0000 0001.1111 1111

1111 1111.1111 1111.0000 0000.0000 0000

192.168.1.255 255.255.255.0-> this address is not available

192.168.1.255 255.255.0.0-- > this address can be used

Problems with IP addresses:

Insufficient IP address space

Waste of IP addresses, further resulting in insufficient available address space

For example:

192.168.1.1 / 24

Network address: 192.168.1.0 Universe 24

Broadcast address: 192.168.1.255ax 24

The network segment contains 256 addresses; (2 to the power of 8)

The available addresses of the gateway are 256-2mm 254.

Purpose:

The endless use of IP addresses in a network segment cannot be assigned to other departments. So these addresses are regarded as "wasteful".

Solutions for IP addresses:

1. Private address / public address

(NAT:network address translation)-Network address Translation

-definition:

Any organization, organization or unit can have a free and reused IP address space; if you use this type of IP address, you cannot surf the Internet.

Private IP address of Class A:

10.0.0.0-10.255.255.255 (10.0.0.0Universe 8)

Private IP address of Class B:

172.16.0.0-172.31.255.255 (172.16.0.0amp 12)

Private IP address of Class C:

192.168.0.0-192.168.255.255 (192.168.0.0amp 16)

Private IP address of Class D:

239.0.0.0-239.255.255.255 (239.0.0.0 Universe 8)

What is written in blue for the area can be another expression of the subnet mask: / n (n indicates how many 1s are in the subnet mask)

2. Subnetting

3 、 IPv6

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report