Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads four integer values corresponding to an IP address a1.a2.a3.a4 (IPv4), and determines whether the values form a valid IP address,

Write a program that reads four integer values corresponding to an IP address "a1.a2.a3.a4" (IPv4), and determines whether the values form a valid IP address, the class of this IP address, and whether or not the values correspond to a reserved IP address space. Your program shall define and use the following functions: is_valid_ip(a1, a2, a3, a4): This function returns True if the address a1.a2.a3.a4 is valid; otherwise, the function returns False. The parameters a1, a2, a3 and a4 form a valid IP address if a1 is between 1 and 255, and the rest of the values are between 0 and 255, both included. determine_ip_class(a1): By providing the a1 component of an IP address, this function return one of the classes below depending on the range a1 falls in: Class Range ----------------- "A" 1 - 127 "B" 128 - 191 "C" 192 - 223 "D" 224 - 239 "E" 240 - 255 is_private_ip(a1, a2, a3, a4): This function returns True if the address a1.a2.a3.a4 falls in one of the address ranges below, considered Private IP Addresses; otherwise the function returns False. Private IP Address ------------------------------- 10.0.0.0 - 10.255.255.255 127.0.0.0 - 127.255.255.255 172.16.0.0 - 172.31.255.255 192.88.99.0 - 192.88.99.255 192.168.0.0 - 192.168.255.255 ------------------------------- main(): This function coordinates all the actions in the program: it asks the user for the components of an IP address, and determines whether it is valid or not. If it is valid, the program also shows the class of the IP address, and whether or not it is considered a private address.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions