Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your job is to do the following: 1. Using the template, assign the correct values to byte1 byte2, byte3, byte4 using the bit shift and

image text in transcribed

Your job is to do the following: 1. Using the template, assign the correct values to byte1 byte2, byte3, byte4 using the bit shift and bitwise AND operators, combined with the lastByteMask. 2. Then, generate a SubNet mask by using the lastByteMask and the bitwise NOT) operator, and store it in the variable subnetMask. This will result in a SubNet mask of OxFFFFFF00 for this problem. Please note that bitwise NOT is a unary operator that takes a single argument 3. Using the AND & operator and the SubNet mask, generate the network addresses for IPAddr and localAddress and store the results in variables networkAddress1 and networkAddress2. 4. Using the network addresses, bitwise XOR (9) operator, and if /else, determine if the packet came from the local network. If the XOR of the two network addresses is o print the packet is from the local network. ". Otherwise, print 'The packet is not from the local network. ". Example output: Please input the IP Address: 2130706433 Subnet mask: Oxffffff00 The IP address is: 127.0.0.1 The packet is not from the local network. LAB ACTIVITY 3.23.1: IP Address Conversion main.c Load default template... i #include 2 #include // Used to create variables of uint32_t data type 4 int main(void) 51 // uint32_t specifies a 4 byte (32 bit) unsigned // integer, whose size of 4 bytes remains fixed // across all machines. uint32_t IPAddr, bytel, byte2, byte3, byte4; uint32_t lastByteMask = exeeeeeeFF; uint32_t localAddress = 3232235777; uint32_t subnetMask, networkAddressi, networkAddress2; printf("Please input the IP Address: "); scanf("%u", SIPAddr); /* Generate Subnet Mask from lastByteMask using the bitwise NOT here */ Your job is to do the following: 1. Using the template, assign the correct values to byte1 byte2, byte3, byte4 using the bit shift and bitwise AND operators, combined with the lastByteMask. 2. Then, generate a SubNet mask by using the lastByteMask and the bitwise NOT) operator, and store it in the variable subnetMask. This will result in a SubNet mask of OxFFFFFF00 for this problem. Please note that bitwise NOT is a unary operator that takes a single argument 3. Using the AND & operator and the SubNet mask, generate the network addresses for IPAddr and localAddress and store the results in variables networkAddress1 and networkAddress2. 4. Using the network addresses, bitwise XOR (9) operator, and if /else, determine if the packet came from the local network. If the XOR of the two network addresses is o print the packet is from the local network. ". Otherwise, print 'The packet is not from the local network. ". Example output: Please input the IP Address: 2130706433 Subnet mask: Oxffffff00 The IP address is: 127.0.0.1 The packet is not from the local network. LAB ACTIVITY 3.23.1: IP Address Conversion main.c Load default template... i #include 2 #include // Used to create variables of uint32_t data type 4 int main(void) 51 // uint32_t specifies a 4 byte (32 bit) unsigned // integer, whose size of 4 bytes remains fixed // across all machines. uint32_t IPAddr, bytel, byte2, byte3, byte4; uint32_t lastByteMask = exeeeeeeFF; uint32_t localAddress = 3232235777; uint32_t subnetMask, networkAddressi, networkAddress2; printf("Please input the IP Address: "); scanf("%u", SIPAddr); /* Generate Subnet Mask from lastByteMask using the bitwise NOT here */

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago