Skip to content

Instantly share code, notes, and snippets.

@bajeluk
Last active May 3, 2016 09:41
Show Gist options
  • Save bajeluk/e8a30b1df8dd1d6374b37309478614f2 to your computer and use it in GitHub Desktop.
Save bajeluk/e8a30b1df8dd1d6374b37309478614f2 to your computer and use it in GitHub Desktop.

Computer networks and Operating systems @UCL

Test 3

1. (9 points) There are two devices on a network with IP addresses 192.168.23.86/28 and 192.168.23.109/28. Change the network configuration in order them to be able to directly communicate to each other

(a) via changing the first IP address

(b) via changing the second IP address

(c) via changing the network mask

Perform the changes in a way to maximal save the number of used IP addresses, i.e. use the smallest possible subnet in (c)).

2. (5 points) For which networks is the address 192.168.217.127 a broadcast address? Answer in the format xxx.xxx.xxx.xxx/yy.

3. (9 points) For each following address, write down the network address, the broadcast address and the network mask (in the format xxx.xxx.xxx.xxx)

  • 192.168.1.139/25
  • 12.5.4.0/10
  • 137.14.11.58/21

4. (12 points) Consider you are the network administrator of an institution with roughly 150 computers and you were given IP addresses in a range 82.122.87.0/24. Perform the division of your network in three subnets (i.e. individual L3 networks) in order to most save the available IP addresses. The parts of your network will be separated by one router and these three parts shall contain 100, 30 and 16 computers. Write down (i) network address/netmask, (ii) range of available IP addresses, and (iii) broadcast address for each of these three networks.

Solution

Exercise 1

There are two devices on a network with IP addresses 192.168.23.86/28 and 192.168.23.109/28. Change the network configuration in order them to be able to directly communicate to each other (a) via changing the first IP address, (b) via changing the second IP address, (c) via changing the network mask. Perform the changes in a way to maximal save the number of used IP addresses, i.e. use the smallest possible subnet in (c)).

192.168.23.86/28 -- network mask is 28 bits long which means that the division between the network part (netID) and the device part (devID) is placed in the last octet/byte (since 28 > 24). Therefore, let's write 86 (the last octet/byte) in binary: 86(d) = 01010110(b). We can see that four (28 - 24) leftmost bits 0101 will still belong to the netID.

We analyze the second address 192.168.23.109/28 in the same manner: 192.168.23.109 = 192.168.23.[01101101(b)], where the last netID bits are 0110 -- the four leftmost bits since the netmask is again /28.

Because the netID's of the two IP addresses are different, the devices are not in the same network and so they could not communicate with each other (without a router between them).

(a) The change of the first IP address has to result in the netID which will be identical to the second IP address' netID. In this example, all we need is to change the 3rd and 4th bit (of the last octet), i.e. onto the address 192.168.23.[01100110(b)] = 192.168.23.102 and as we did not ended up in the already used IP address, we are done.

(b) Change of the second address can be performed analogically onto 192.168.23.[01011101(b)] = 192.168.23.93.

(c) New network mask has to be the length of the longest common prefix of both the netID's which are identical. We can see from the binary representation that the addresses differs first on the third bit of the last octet. The new network mask has to be therefore (at most) /26 which corresponds to 255.255.255.[11000000(b)] = 255.255.255.192. This longest possible netmask is the right answer because we were asked to save the available IP addresses (the longer the netmask the smaller the subnet).

Exercise 2

For which networks is the address 192.168.217.127 a broadcast address? Answer in the format xxx.xxx.xxx.xxx/yy.

Let's rewrite the IP address 192.168.217.127 in binary. It is enough to rewrite the first such octet from right that contains in its binary representation at least one zero -- broadcast address has to have in its binary representation continuously all ones from right.

In this case, this most interesting octet is already the first from right: 127(d) = 01111111(b) has the highest zero bit. The address x.x.x.127 will be a broadcast address for the following networks (network address have in the devID all zeros):

  • 192.168.217.[00000000(b)] = 192.168.217.0/25
  • 192.168.217.[01000000(b)] = 192.168.217.64/26
  • 192.168.217.[01100000(b)] = 192.168.217.96/27
  • 192.168.217.[01110000(b)] = 192.168.217.112/28
  • 192.168.217.[01111000(b)] = 192.168.217.120/29
  • 192.168.217.[01111100(b)] = 192.168.217.124/30

Subnet /31 practically does not exist (there are no free addresses for devices) and /32 is unicast, so we do not need to handle these two.

Exercise 3

For each following address, write down the network address, the broadcast address and the network mask (in the format xxx.xxx.xxx.xxx)

  • 192.168.1.139/25
  • 12.5.4.0/10
  • 137.14.11.58/21

Only for the third address 137.14.11.58/21. The network mask /21 defines the division between netID and devID in the third octet (16 < 21 < 24). Rewritten it in the binary representation we see 137.14.[00001011(b)].58 where the first 5 bits belong to the netID -- all the answers can be already derived from that:

  network (devID = 0):            137. 14.[00001000(b)].  0  =  137. 14.  8.  0/21
  broadcast (devID = 1):          137. 14.[00001111(b)].255  =  137. 14. 15.255
  netmask (netID = 1, devID = 0): 255.255.[11111000(b)].  0  =  255.255.248.  0

Exercise 4

Consider you are the network administrator of an institution with roughly 150 computers and you were given IP addresses in a range 82.122.87.0/24. Perform the division of your network in three subnets (i.e. individual L3 networks) in order to most save the available IP addresses. The parts of your network will be separated by one router and these three parts shall contain 100, 30 and 16 computers. Write down (i) network address/netmask, (ii) range of available IP addresses, and (iii) broadcast address for each of these three networks.

The network 82.122.87.0/24 contains 256 IP addresses which we should divide most effectively. It is a good practise to start from the largest subnet and follow to smaller ones.

The most important fact in such CIDR/VLSM subnet divisions is that we can divide the networks only into parts of size of powers of 2 (4, 8, 16, 32, 64,...). Further, the divisions of the address ranges have to follow the corresponding borders of powers of 2: we cannot, for example, assign a subnet /26 of size 64 starting from the address x.x.x.160 [10100000(b)] -- it would cross the 64-boundary at x.x.x.192 [11000000(b)]. We can start the /26 subnets only at x.x.x.0, x.x.x.64, x.x.x.128 or x.x.x.192. Therefore, in this particular example (does not apply to all Exercise 4), we have to let the addresses 160--191 unused and start the /26 subnet at x.x.x.192.

  • net1: 100 PC's, therefore we need /25 network which contains 128 IP addresses out of which 126 are for devices, one for network and one for broadcast address. The addresses are therefore

    • net: 82.122.87.0/25
    • range: 82.122.87.1--82.122.87.126
    • BC: 82.122.87.127
  • net2: 30 PC's; the network /27 with its 32 IP addresses is not enough. Even though there are 30 IP addresses for PC's above two reserved for network and broadcast, it is very practical to reserve the first IP address (82.122.87.129 in this case) for the IP address of the router's network device belonging to this net2. As a result, we shall use /26 network which has already 64 different IP addresses. The answers are

    • net: 82.122.87.128/26
    • range: 82.122.87.129--82.122.87.190
    • BC: 82.122.87.191
  • net3: 16 PC's, so the /27 network is enough and the answers are:

    • net: 82.122.87.192/27
    • range: 82.122.87.193--82.122.87.222
    • BC: 82.122.87.223

You can use a pencil and a calculator (including on a PC) for the test -- it is advisable those calculators which can transfer from decimal to binary and vice versa. The standard Windows calculator in its "scientific mode" can do that.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment