Question: Programming Exercise: Network Scanner Problem Statement: You are tasked with developing a Python program that scans a range of IP addresses in a given subnet

Programming Exercise: Network Scanner
Problem Statement:
You are tasked with developing a Python program that scans a range of IP addresses in a given
subnet to determine which hosts are active and reachable on the network. The program should
output a list of active hosts along with their IP addresses.
Requirements:
1. The program should take as input a subnet in CIDR notation (e.g.,192.168.1.0/24) Use
your local subnet for this exercise. 192.168 is the example here. representing the range of
IP addresses to scan. Figure out subnet
2. Implement a function named scan network(subnet) that scans the specified subnet for active
hosts.
3. Use ICMP ping requests to determine if a host is reachable. You can use the ping utility or
Pythons ping library to send ICMP echo requests.
4. The function should return a list of tuples, where each tuple contains the hostname and IP
address of an active host.
5. Display the list of active hosts in the console output.
6. You may use os, platform, subprocess, ipaddress, socket or any other module available to get
this assignment done.
Example:
python scan network(192.168.1.0/24)
Active hosts:
Hostname: host1, IP: 192.168.1.1
Hostname: host2, IP: 192.168.1.10
Hostname: host3, IP: 192.168.1.20
Page 1
Additional Guidelines:
- Handle errors gracefully and provide informative error messages if the input subnet is invalid or if
there are any issues with network connectivity. - Ensure that the program runs efficiently and doesnt
cause excessive network traffic or delays. - You may use any external libraries or modules that are
necessary for the implementation. - Document your code clearly, including function descriptions
and any assumptions made.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!