Determining subnet mask based on number of hosts - networking

During preparation for an exam I came over two questions that didn't make sense to me.
"You are planning to subnet IPv4 addresses to use on a global network. The design must support creating two separate networks that allows for support up to 1000 hosts and maximize the number of networks that are avaible.
You need to identify the subnets that meet these requirements."
Network 1:
1. 172.16.0.0/5
2. 172.16.0.0/6
3. 172.16.0.0/8
Network 2:
1. 10.0.0.0/14
2. 10.0.0.0/16
3. 10.0.0.0/20
The correct answers are 2) for Network 1 and 1) for Network 2, but the calculations are not presented as a part of the solutions. I've been trying for a few days to work it out, but something in my brain seems to have crashed.
I'd be grateful if anyone could show me how to work from network ID, netmask and number hosts to determine which netmask is the best and provides the most subnets.

10101100 00010000 00000000 000000
is the binary representation of the IP address 172.16.0.0.
the subnet must be done in such a way so that atleast 1000 hosts can be allocated.
We cannot touch the 172 and 16 address as it belongs to a different class.
now looking at
00 00 00 00 and 00 00 00 00
if we subnet the 1st 6 places it will leading to
11 11 11 00 00 00 00 00 to 11 11 11 11 11 11 11 11
which is 172.16.252.0 to 172.16.255.255 giving us 256*4 = approx 1000 hosts
hence we subnet using 172.16.0.0/6 but not others as it may lead to shortage or excess present available hosts
Hope its helpful for the other but consider class as the second question belong to different class

Related

Arduino - how to change TFmini's measure unit to mm

I'm making a 3D scanner using TFMini-S Lidar alone with Arduino Uno. The Lidar default to cm, but I want to use mm instead. However everywhere I look, I can't find any clear way to do it. After reading the documentation, I discovered the TFMini is factory programed to use cm. But it also mentions that there are commands that can change the unit to mm.
The value of distance output Dist may vary with the output unit, which is cm by default. If the
unit of distance is changed to the unit-mm via an instruction, and the PC software will be unable
to identify it, and so the unit of “④TIME LINE CHART” will still be cm. For example, the actual
TFmini measurement is 1m, the distance value of TFmini is 1000 in mm, the value read by the
PC software also is 1000, but the unit will not change and still display cm.
And this is all I can find about how to do that from some other website:
TFmin LiDAR sensor has updated with the output unit mm to cm now. There is the configuration commands that can set the output unit by your need:
“Changes to the mm: send 42 57 02 00 00 0 01, 02 to enter configuration mode, then send 42 57 02 00 00 00 00 1A;
Change to cm: send 42 57 02 00 00 0 01, 02 to enter configuration mode, then send 42 57 02 00 00 00 01 1A.”
I'm a beginner to Arduino and I'm not sure how to send those configuration commands. If there are similar resources, please let me know. Any help would be greatly appreciated.
Solution found from TFMini-Plus library, but it works with TFMini-S/TFMini as well.
The "STANDARD_FORMAT_MM" command will set the measure unit to mm, but make sure to save using "SAVE_SETTINGS" command. Refer to the Github example code for your own project.
Big thanks to the creator of that Github repo.

Intel Hex - Converting 03 record type to 05 and vice versa

I am trying to write an Intex HEX parser. It seems that there are two styles for extended addresses (allowing you to address memory larger than 64 kB), and that these two styles shouldn't be mixed in the same file:
Segment Addressing
Linear Addressing
I want to write a parser that will take Intel HEX in any of the above two styles, and output in any of the above styles.
I've got a handle on all the record types except for 03 (Start Segment Address) and 05 (Start Linear Address). My assumption, based on the wikipedia article is that for the following record of type 03 (ignore dashes - just to aid annotation):
:04-0000-03-00003800-C1
|_1|___2|_3|_______4|_5|
where:
1 - 04 -> byte count
2 - 0000 -> address
3 - 03 -> record type (Start Segment Address)
4 - 00003800 -> data
5 - C1 -> checksum
If I were to convert this into a 05 type record type, would be:
:0400000500003800BF
Where I just simply take the IP address (last 2 data bytes) of the 03 record and set that to the data field for the 05 type, padded with 0000; completely ignoring the first 2 bytes of the data section of the 03 record (which in this example is 0000).
Is this correct? Am I making any faulty assumptions / missing the point entirely?

Subnet Mask - How to segment three separate networks?

I'm trying to understand subnet masks. I was given the question below and chose the answer of /30 since it seems that each subnet needs only one host IP. /31 was not a possible answer. However, the answer is /29. Can anyone clarify why that is correct?
"Which of the following would the security engineer set as the subnet mask for the servers below to utilize host addresses on separate broadcast domains?"
Server 1: 192.168.100.6
Server 2: 192.168.100.9
Server 3: 192.169.100.20
Convert everything to binary:
6 = 00000110
9 = 00001001
20 = 00010100
OK, so mask of 29:
29 = 00011101
30 = 00011110
The only difference between those two is which of the two lower-order bits of 6 and 9 you examine.
So I'd agree with you that, without further information, either 29 or 30 is a valid answer.
A /29 mask provides 6 usable addresses and creates the following subnets.
192.169.100.0 - 192.169.100.7
192.169.100.8 - 192.169.100.15
192.169.100.16 - 192.169.100.23
A /30 mask provides 2 usable addresses and creates the following subnets
192.169.100.0 - 192.169.100.3
192.169.100.4 - 192.169.100.7
192.169.100.8 - 192.169.100.11
192.169.100.12 - 192.169.100.15
192.169.100.16 - 192.169.100.19
192.169.100.20 - 192.169.100.23
So /30 isn't an option because the 192.169.100.20/30 is a network address and not usable as server IP address. /29 is the correct answer!

Understanding subnetting

Assume your company is given an address of 200.5.16.0/24, 5 subnets are required.
I found that:
Binary: 1111111.11111111.11111111.111000
Decimal: 255.255.255.224
Create a table that contains the network addresses of the subnets created within your network? Write down the Network Addresses, 1st and 2nd valid IP addresses in CIDR
(table displayed in below link)
http://gyazo.com/d93608e491c5197b21d0d64c34c3904a
Can someone do the first few for me and explain the process on how to do it? Thanks
The process of dividing a network into smaller network sections is called subnetting. This can be useful for many different purposes and helps isolate groups of hosts together and deal with them easily.
Each address space is divided into a network portion and a host portion. The amount the address that each of these take up is dependent on the class that the address belongs to. For instance, for class C addresses, the first 3 octets are used to describe the network. For the address 192.168.0.15, the 192.168.0 portion describes the network and the 15 describes the host.
By default, each network has only one subnet, which contains all of the host addresses defined within. A netmask is basically a specification of the amount of address bits that are used for the network portion. A subnet mask is another netmask within used to further divide the network.
Each bit of the address that is considered significant for describing the network should be represented as a "1" in the netmask.
For more details, please r
http://www.cisco.com/c/en/us/support/docs/ip/routing-information-protocol-rip/13788-3.html
You already figured out that with this mask 1111111.11111111.11111111.11100000 you can create 5 networks, just put numbers in them:
Mask: 11100000
Subnetworks:
00000000 = 0
00100000 = 32
01000000 = 64
01100000 = 96
10000000 = 128
10100000 = 160 - 192
The problem here is that you are not using the upper 64 addresses (192-255).
Alternative
You can make 4 subnetworks and split the last one:
Mask: 11000000
Subnetworks:
00000000 = 0
01000000 = 64
10000000 = 128
11000000 = 192 (split this one)
Subnetwork: 200.5.16.192/26
Mask: 11100000
Subnetworks:
11000000 = 192
11100000 = 224

Calculating range of IPs from subnet mask

Say, I have a subnet of 255.255.255.242 and I have a known IP within that subnet say 192.168.1.101.
Now the way I calculate the range of IPs is this:
In the subnet mask, find the first octet that is not a 255. In my example, its the 4th octet, and its 242. So take 256 and subtract 242, which gives us 14. So we now know that these networks, the 192.168.1.x networks, all have a range of 14. So just start listing them...
192.168.1.0
192.168.1.14
192.168.1.28
....42
....56
....70
....84
....98
....112
Here we can stop. My address, 192.168.1.101 falls into the .98 network. .98 encompasses all ip addresses from 192.168.1.98 to 192.168.1.111, because we know that 192.168.1.112 starts the next network.
I want to confirm, whether this is the right and the easiest process to do so.
A netmask is a series of 1 bits. The bits must be sequential with no 0 gaps. Anything using a 1 bit is part of the network, anything remaining is valid for host assignment within that network. A 255.255.255.224 has 27 "1" bits, which means it's a /27 network.
To calculate this right, you need to convert IPs to a numeric representation. For example, 255.255.255.224 is 11111111 11111111 11111111 11100000 which is 4294967264. 192.168.1.101 is 3232235877 (11000000 10101000 00000001 01100101).
If you take the IP and bitwise AND it with the netmask, that gives you the network address. This is the bottom end of the range:
11111111 11111111 11111111 11100000 (mask)
11000000 10101000 00000001 01100101 (ip)
-----------------------------------
11000000 10101000 00000001 01100000 = 192.168.1.96 (network address)
The complement (bitwise NOT) of the mask gives you the size of the range:
00000000 00000000 00000000 00011111 = 31
Thus, the range for that IP is between 192.168.1.96 - 192.168.1.127. (127 = 96 + 31)
Thanks to both of you Joe and dig_123 but, Joe's answer could have been clarified with a /28 subnetinstead of the stated /27 witch would have been closer to his example and fallen between 92-112.
so, Joe if I get your point right you are saying that you take the subnetted octet; determine the increment bit value and add it to the subnet value in the SN octet, this should give the range and provide the values for the Network, first host, last host, and broadcast addresses. Is that correct? i.e. in my example the 4th octet would be a 240 and the increment would be 16. Since the value in the 4th octet is 96, it falls within the calculated range for a 16 bit increment, in fact it falls between 96 and 112 which is one of the 16 bit ranges so we can conclude that our network address for this example is:
0-15
15-31
32-47
48-63
64-79
80-95
96-111
112-127
128
NW 192.168.1.96 /28
1st 192.168.1.97 /28
Last 192.168.1.110 /28
Bcast 192.168.1.111 /28
To add something to Joe's answer: if you want to do the operations more programmatically (assumes knowledge on bitwise operators).
You already know that only the last number will change, but this method could be used in a slightly different way for other cases as I show later.
Number from mask: 224
Number from IP: 101
Using e.g. python or your favourite calculator program:
Start address byte: 224 & 101 = 96
End address byte: (~224 & 255) | 96 = 127
(~224 & 255) just sets to one every bit that wasn't one in 244 (that is, the last 5 bits); OR'ing the result with 96 just copies the first 3 bits from the first address.
So, the result is the expected: 192.168.1.96 - 192.168.1.127.
If the mask ends before the last number there is a very similar procedure; let's do an example:
Let's use 255.224.0.0 as mask, and the same IP address (192.168.1.101).
Again there is only one number to take care of, which is now the one in second position: 168.
Start address byte: 224 & 168 = 160
End address byte: (~224 & 255) | 160 = 191
Now, the number on the left (first position) remains the same (192) and the rest of the numbers on the right range from 0 to 255 (depending on what they ask, it may also be from 1 to 254).
So the solution would be: 192.160.0.0 - 192.191.255.255

Resources