Skip to content

Lab · Computer Networking (CCNA level)

Lab: check a clinic's IP address sheet

Labbeginner· about 1.5 hours· 5 steps

The brief

A diagnostic clinic in Pune keeps its device addresses in a sheet, and some PCs cannot reach the internet. Write the IPv4 maths yourself (masks, network and broadcast addresses, host ranges, same-subnet checks), then use it to find every wrong entry in the sheet.

Why it matters

Wrong masks, a PC given the broadcast address and a gateway in another subnet are the most common causes of "this one PC has no internet" tickets in small offices. Network support engineers spot them by doing exactly this maths, and IP address management (IPAM) tools run the same checks on thousands of addresses.

Skills you practise

  • binary and the 32-bit address
  • subnet masks and prefix length
  • network and broadcast addresses
  • usable host range
  • same-subnet test
  • auditing an address list

What you will have at the end

ip_check.py: a tested IPv4 calculator written without libraries, and the list of five wrong entries in the clinic's sheet with the fix for each.

How it is marked (rubric, 100 points)
Correct mathsEvery function passes its checks, including /30, /32 and the broken mask.45
Audit resultAll five wrong devices are found with the right reason, and the correct ones are not listed.25
Readable codeEach function reuses the earlier ones instead of repeating the bit maths.15
Can explain the fixesYou can say the right setting for each wrong device (for example CCTV-NVR needs the mask 255.255.255.0).15

0/5 steps done

Step 1 of 5

Turn a mask into a prefix length

mask_to_prefix("255.255.255.192") returns 26, and a broken mask such as 255.0.255.0 returns None.

A subnet mask is 32 bits: ones for the network part, then zeros for the host part. /26 is the same mask written as "26 ones". to_int() is given: it turns the dotted mask into one number, and format(n, "032b") writes it as 32 binary digits.

Count the ones. But first check the mask is real: if a 0 is ever followed by a 1 (the text "01" appears in the bits), the ones are not all together, and the mask is invalid.

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.