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

Talk about the corresponding relationship between IP address and subnet mask, as well as binary and decimal detailed explanation!

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

Share

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

Hello, everyone. I am the Fan who led you to grow up.

The structure of the IP address:

# length is 32 bit; first

# structure-network bit + host bit

Subnet mask:

-effect

Distinguish between network bits and host bits in IP addresses

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

Units in the network:

Bit, bit per bit, the smallest unit in the network

A 0 means 1 bit; a 1, also means 1bit

If it is 01, it means 2 bit

1Byte, bytes, equivalent to 8 bit

1Kbit, 1000bit

1Mbit (mega), 1000Kbit

1Gbit (Gee), 1000Mbit

1Tbit,1000Gbit

1Pbit,1000Tbit

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 may or may not cross; (understand only)

Well, first of all, as we all know, IP addresses and subnet masks appear in pairs.

For example: 192.168.1.1 255.255.255.0

This is the familiar IP address, but in fact, this kind of IP address is for people to see, and one is for machines.

This is binary.

Like the IP address above (192.168.1.1 I use X here to represent-> X.X.X.X)

Each X represents one byte, and each byte is actually eight bit translating 192.168.1.1 255.255.255.255.0 into binary, that is, 1100 0000.1010 1000.0000 0001.0000 0001 subnet mask is 1111 1111.1111 1111.1111 1111.0000 0000. First of all, you would like to ask the first question why the subnet mask corresponding to 192.168.1.1 corresponds to 255.255.255.0, which I mentioned in my previous blog. IP addresses are divided into four categories, and the default subnet mask of type 4 is 255.255.255.0, but this is not absolute. You can change the subnetting technology later, just write down the corresponding IP addresses of the four categories.

Let's talk about the binary system first:

To put it bluntly, the binary system means that there are only two numbers, a 0 and a 1. Let's take a bit as an example.

For example: 0000 0000 this is for the machine, the number it represents is converted to the decimal system (for people to see) is 0

So if I want to show people 1 as binary, how do I represent-0000 0001, which represents a byte 1, and if it is 192.168.20.1 0000 0001, it represents one of them?

If I am 192.168.20.2, how can the IP address be represented in binary?

It's very simple. 0000 0001 this is 1. As mentioned earlier, there are only two digits in binary, a 0, and a 1, which is now understood according to the primary school arithmetic formula, whether it is right for us to add a bit to the previous number every time we get to 10. The binary system is a carry from one to two, which is very simple.

0000 0001 into one-> 0000 0010, which is for 2.

Then again, what if I want to show 3?

On the basis of 2 0000 0010-> 0000 0011

If it means 4, does it add another 1?

On the basis of 3, 0000 0011 I need to add 1 to carry, then the last one is rounded, and the second to last place is going to enter, then it becomes

0000 0100-> this is 4 0000 0101 Murray 5 0000 0110-6

I think at this point, we all understand how binary is converted, which is nothing more than carrying from 10 to 2.

But in fact, in this case, it is nothing but a lot of trouble.

Because if 192.168.123.254 this IP address, we have to convert to 4 bytes, each byte eight bit binary is very troublesome, here to teach you something similar to multiplication formula-8421 yards

So we know that each byte is eight bit, and an IP address has four bytes.

What is it if our eight bit are all 1s?

1111 1111

Let's correspond one by one first.

1111 1111 (2-ary means 255)

128 64 32 16 8 4 2 1 (decimal for 255)

Each previous bit is a multiple of 2 plus 1, knowing this corresponding relationship, let's give a simple example.

128.64.32.16 (decimal) for example, this is how an IP address is converted to binary, and directly correspond to the 8421 code above.

1000 0000.0100 0000.0010 0000.0001 0000 (binary)

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

The biggest one in the IP address is the power of 2 to the 7th, so remember that the power of 2 to the 7th will know how to transform it. It really doesn't work, when it needs to be converted.

1111 1111 (2-ary means 255)

128 64 32 16 8 4 2 1 (decimal for 255)

Just write out the corresponding table relation and OK it, and transform it one by one.

Conversion mechanism, then there is a hexadecimal conversion, friends who need to know can add me QQ.

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