Question: Write a simple C/C++ console application that will printout the network class information (Class A,B,C,D,E), the subnet broadcast address, and subnet network address for an
Write a simple C/C++ console application that will printout the network class information (Class A,B,C,D,E), the subnet broadcast address, and subnet network address for an entered particular network address/subnet mask. Upon execution the program will request an IP V4 address in the form a.b.c.d/e. The program will then display what class the address is within, if it is a private address or loopback, the broadcast address, network address, and the subnet mask in the form x.x.x.x. The program must contain a structure or/and a union. An IP v4 address is an unsigned 32bit integer. Represented as a.b.c.d. where the a is the most significant byte (unsigned char), b the next significant byte, c is a lower significant byte, and d is the least significant. a, b, c, and d are all values ranging from 0255. e represents the subnet mask and is in the range 032. This value indicates the number of consecutive 1 s from the MSB to build the subnet mask. Example of e: /24 = 24 leading 1s which equates to a subnet mask of 255.255.255.0 or 11111111111111111111111100000000. The network address can be obtained by ANDing the given address with the subnet mask. The broadcast address can be obtained by inverting the subnet mask then ORing it with the address. Class Address Range Supports Class A 0.0.0.0 to 127.255.255.255 Supports 16 million addresses on each of 128 (0127) networks. Class B 128.0.0.0 to 191.255.255.255 Supports 65,000 addresses on each of 16,000 networks. Class C 192.0.0.0 to 223.255.255.255 Supports 256 addresses on each of 2 million networks. Class D 224.0.0.0 to 239.255.255.255 (former class D) Reserved for multicast groups. Class E 240.0.0.0 to 255.255.255.255 (former class E) Reserved for Research and Development Purposes. Private Addresses 10.0.0.0 10.255.255.255 172.16.0.0 172.31.255.255 192.168.0.0 192.168.255.255 Loopback Addresses 127.0.0.0 127.255.255.255 The Microsoft scanf_s() routine doesnt support reading in an unsigned char integer so a type cast will have to be used something like the following code where an unsigned int is cast to an unsigned char. unsigned int a,b,c,d,e; scanf_s("%d.%d.%d.%d/%d",&a,&b,&c,&d,&e);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
