0
0
Computer Networksknowledge~10 mins

CIDR notation in Computer Networks - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to represent the CIDR notation for the IP address 192.168.1.0 with a subnet mask of 24 bits.

Computer Networks
cidr = "192.168.1.0/[1]"
Drag options to blanks, or click blank then click option'
A16
B8
C32
D24
Attempts:
3 left
💡 Hint
Common Mistakes
Using the subnet mask in decimal form instead of the number of bits.
Confusing the number of bits with the number of octets.
2fill in blank
medium

Complete the code to calculate the number of possible hosts in a subnet given the CIDR prefix length.

Computer Networks
hosts = 2**(32 - [1]) - 2
Drag options to blanks, or click blank then click option'
A24
B16
C28
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to subtract 2 for network and broadcast addresses.
Using the prefix length directly instead of subtracting from 32.
3fill in blank
hard

Fix the error in the code that converts a CIDR prefix length to a subnet mask in dotted decimal format.

Computer Networks
subnet_mask = '.'.join(str((0xffffffff << (32 - [1]) >> i) & 0xff) for i in [24,16,8,0])
Drag options to blanks, or click blank then click option'
Amask_length
Bcidr
Cprefix_length
Dsubnet_bits
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined variable names.
Mixing variable names that represent different concepts.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps CIDR prefixes to their subnet masks in dotted decimal format for prefixes 24 and 16.

Computer Networks
cidr_to_mask = {prefix: '.'.join(str((0xffffffff << (32 - prefix) >> i) & 0xff) for i in [1]) for prefix in [2]
Drag options to blanks, or click blank then click option'
A[24, 16, 8, 0]
B[16, 24]
C[0, 8, 16, 24]
D[8, 16]
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of bit shifts.
Using incorrect prefix lists.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps CIDR prefixes to the number of hosts available in each subnet for prefixes 28, 26, and 24.

Computer Networks
hosts_per_subnet = {prefix: 2**(32 - [1]) - [2] for prefix in [3]
Drag options to blanks, or click blank then click option'
Aprefix
B2
C[28, 26, 24]
D32
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name for the prefix.
Forgetting to subtract 2 from the total hosts.
Using incorrect prefix lists.