Implement the following in Classless IP Addressing in C
programming
(b) Implement Subnetting Concepts
Subnetting concept with C can be acheived using below code. Please execute and feel free to comment if you have any doubts.
I have attached the screenshot for the same at the end.
==========================================================================
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) {
printf(" Simple IP Subnet Calculator By dumiku ");
int IP1, IP2, IP3, IP4, CIDR, bitborrowed, bitremained, subnet,
host, mask, blocksize;
char class;
//Request User input
printf("Please enter IP address in the form of "0.0.0.0": ");
scanf("%i.%i.%i.%i", &IP1, &IP2, &IP3, &IP4);
//Check if IP is valide
do
{
if((IP1 >255 || IP2 >255 || IP3 >255 || IP4 >255) ||
(IP1 == 127 || IP1 == 191 || IP1 == 255) || (IP1 == 0 &&
IP2 == 0 && IP3 == 0 && IP4 == 0))
{
printf(" Warning!! IP address invalid, please enter a valid IP
address: ");
scanf("%d.%d.%d.%d", &IP1, &IP2, &IP3, &IP4);
}
}while((IP1 >255 || IP2 >255 || IP3 >255 || IP4 >255)
|| (IP1 == 127 || IP1 == 191 || IP1 == 255) || (IP1 == 0 &&
IP2 == 0 && IP3 == 0 && IP4 == 0));
//If IP valid ask for CIDR
printf("Enter CIDR in the format of decimal CIDR: ");
scanf("%d", &CIDR);
do{
//CHeck if CIDR is valid
if(CIDR > 32 || CIDR == 0)
{
printf("Invalid CIDR, please enter a valid CIDR: ");
scanf("%d", &CIDR);
}
}while(CIDR > 32);
//Let's determine IP class
if(IP1 <=170) {
class = 'A';
}else if(IP1 <=190) {
class = 'B';
}else {
class = 'C';
}
// Let find the number of bits borrowed
switch (class) {
case 'A':
if(CIDR >= 8) {
bitborrowed = CIDR - 8;
}else {
bitborrowed = 8 - CIDR;
}
break;
case 'B':
if(CIDR >= 16) {
bitborrowed = CIDR - 16;
}else {
bitborrowed = 16 - CIDR;
}
break;
case 'C':
if(CIDR >= 24) {
bitborrowed = CIDR - 24;
}else {
bitborrowed = 24 -CIDR;
}
}
//Let Find the number of bits that remained
switch (class) {
case 'A':
bitremained = 32 - CIDR;
break;
case 'B':
bitremained = 32 -CIDR;
break;
case 'C':
bitremained = 32 -CIDR;
break;
}
//Now Let Calculate the number of Subnets
subnet = pow(2,bitborrowed);
//And then we calculate the number of usable hosts
host = pow(2, bitremained)-2;
//Here we determine the block size
switch(bitborrowed) {
case 1:
blocksize = 128;
break;
case 2:
blocksize = 64;
break;
case 3:
blocksize = 32;
break;
case 4:
blocksize = 16;
break;
case 5:
blocksize = 8;
break;
case 6:
blocksize = 4;
break;
case 7:
blocksize = 2;
break;
case 8:
blocksize = 1;
break;
}
printf("Here is your Result: ");
printf("your IP %i.%i.%i.%i/%i is of class %c ",
IP1,IP2,IP3,IP4,CIDR,class);
printf("Number of bit borrowed is: %d ", bitborrowed);
printf("Number of bits remained is: %d ", bitremained);
printf("Subnet: %d ", subnet);
printf("host: %d ", host);
printf("blocksize: %d ", blocksize);
return (0);
}
===============================================================================================

Implement the following in Classless IP Addressing in C programming (b) Implement Subnetting Concepts
Implement the following in Classless IP Addressing in C programming using decimal number system (a) Compute First Address, Last address and Number of address from given IP address and mask
For what reason do hosts use ICMP? A error reporting B IP addressing С IP tunneling D subnetting
in classless addressing, what is the value of the prefix length(n) if the size of the block(N) is one of the following? a) N=1 b) N=1024 c) N=2^32
Subnet A Subnet B FO/6 PC-A Golo>< 601 R1 Fo/S PC-B $1 Develop the IPv4 Addressing Scheme Given an IP address and mask of 209.165.201.0/24 (address / mask), design an IP addressing scheme that satisfies the following requirements. Work out the subnetting details and: 1. Fill in the Subnetting table with subnets details (20 points) 2. Fill in the Devices Addressing table (5.5 points) Subnet Number of Hosts Subnel A 40 Subnet B 120 Subnet C 5 Subnet D 12...
Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and routing Internet Protocol packets. Classless Inter-Domain Routing allocates address space to Internet service providers and end users on any address bit boundary, instead of on 8-bit segments. CIDR notation is a syntax of specifying IP addresses and their associated routing prefix. It appends a slash character to the address and the decimal number of leading bits of the routing prefix. 192.168.100.0/24 represents the given IPv4 address and its...
In a class B subnet, we know the IP address of one of the hosts and the subnet mask as given below: IP Address: 188.48.82.176 Subnet mask: 255.255.255.248 1) What is the first valid host address in the subnet? (in dotted decimal) 2) What is the last valid address in the subnet? (in dotted decimal) 3) What is the subnet network address? (in dotted decimal) 4) What is the subnet broadcast address? (in dotted decimal) 5) What is the number...
Network IP Addressing Network Layout of 2 networks Given an IP address and mask of 172.23.29.0/24, design an IP addressing scheme that satisfies the following requirements. Subnet B Specification This network requires space for 62 machines plus the router Number of bits in the subnet Blank 1 IP mask (binary) Blank 2 New IP mask (decimal) Blank 3 Maximum number of usable subnets of this size when using this mask (including the 0th subnet) Blank 4 Number of usable hosts...
Given an IP address and mask of 192.168.1.0 255.255.255.0 (address / mask) subnet A has 55 hosts subnet b has 112 hosts The 0th subnet is not used. (Do not use 192.168.1.0) (Subnetting Help) Subnet A Specification Student Input Number of Network bits in the subnet mask New Subnet mask (decimal) Number of usable hosts IP Subnet (Network ID) First IP Host address Last IP Host address (Subnetting Help) Subnet B Specification Student Input Number of Network bits in the...
Step 2. Basic IP addressing. Task: Use the IP address chart and your knowledge of IP address classes to answer the following questions l. What is the decimal and binary range of the first octet of all possible Class B IP addresses? Decimal: From: To: Binary: 2. Which octet(s) represent the network portion of a Class C IP address? 3. Which octet(s) represent the host portion of a Class A IP address? Io: Step 3. Determine the host and network...
Part 1: Develop the IPV4 Addressing Scheme Given an IP address and mask of 192.168.1.0 /24 (address / mask), design an IP addressing scheme that satisfies the following requirements Subnet Number of Hosts Subnet A 20 Subnet B 60 Use subnet zero for the first subnet. No subnet calculators are allowed Host computers will use the last IP address in the subnet. The network router will use the first usable host address. The switch will use the second usable host...