Ad-Hoc Network Simulation In this homework, you are going to simulate an Ad-Hoc Network. Your simulation...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Ad-Hoc Network Simulation In this homework, you are going to simulate an Ad-Hoc Network. Your simulation will have two layers with acknowledgment and resending. A header file is provided for your use. DO NOT CHANGE ANYTHING IN THE HEADER FILE INCLUDING ITS NAME OTHERWISE YOUR HOMEWORK WILL NOT BE GRADED. Packet Class 1. Write a hash function for the packet class. Its calculation should include sourceId, destId and message. 2. Implement the constructors for the packet class. Constructors should calculate the hash value and assign it to the member parameter. 3. Implement the functions getSourceId, get DestId, getMessage. 4. Implement the function checkIntegrity. It should recalculate the hash value and compare it to the member parameter. It should return false if the values do not match. 5. Implement the function corrupt. It should change a random character in the message to a random ASCII character. MacPacket Class 1. Implement the constructors. The default constructor should assign MacPacketType:: Empty as type. 2. Implement the static functions which are shorthands for creating certain types of mac packets. 3. Implement the functions getType, getMacSourceId, getMacDestId, getPath, getPacket. Node Class 1. Implement the constructors. The default constructor should assign the id value as zero. Throughout this project, node id zero will be considered as the invalid id/empty value. 2. Implement the functions getId and getNeighbors. 3. Implement the function receive. It should receive a packet and process it accordingly. It should log the events according to the sample output given. a. If the received packet is a message packet and it is not corrupted, it should save the packet to the buffer and send it to the next receiver. If this node is the final destination, it should send an acknowledgment/success packet backwards through the path. b. If the received packet is a message packet and it is corrupted, it should request a resending. Network Class 1. Implement the constructor and functions getNode, addNode, removeNode. All connections are two-way, hence addNode should add the new node as a neighbor to the already existing nodes. removeNode should remove the reference from the other nodes. c. If the received packet is a success packet, it should save the packet to the buffer and send it to the next receiver. If this node is the source, it should return an empty mac packet to end the simulation. d. If the received packet is an error packet, it should resend the previous packet in the buffer. 2. Implement the function calculatePath. It should calculate the shortest path from source to destination and return a vector of nodes along the path. 3. Implement the simulate function. Main Function 1 a. Calculate the path for the message to take. b. In an infinite loop, send the packet to the destination node. If the response is an empty packet, end the simulation. If the response is a message packet, corrupt the message with the given probability (Hint: (float) std::rand () / RAND_MAX < corruptionRate). 1. Create the network given below. 3 2 XD 4 5 6 7 Ad-Hoc Network Simulation In this homework, you are going to simulate an Ad-Hoc Network. Your simulation will have two layers with acknowledgment and resending. A header file is provided for your use. DO NOT CHANGE ANYTHING IN THE HEADER FILE INCLUDING ITS NAME OTHERWISE YOUR HOMEWORK WILL NOT BE GRADED. Packet Class 1. Write a hash function for the packet class. Its calculation should include sourceId, destId and message. 2. Implement the constructors for the packet class. Constructors should calculate the hash value and assign it to the member parameter. 3. Implement the functions getSourceId, get DestId, getMessage. 4. Implement the function checkIntegrity. It should recalculate the hash value and compare it to the member parameter. It should return false if the values do not match. 5. Implement the function corrupt. It should change a random character in the message to a random ASCII character. MacPacket Class 1. Implement the constructors. The default constructor should assign MacPacketType:: Empty as type. 2. Implement the static functions which are shorthands for creating certain types of mac packets. 3. Implement the functions getType, getMacSourceId, getMacDestId, getPath, getPacket. Node Class 1. Implement the constructors. The default constructor should assign the id value as zero. Throughout this project, node id zero will be considered as the invalid id/empty value. 2. Implement the functions getId and getNeighbors. 3. Implement the function receive. It should receive a packet and process it accordingly. It should log the events according to the sample output given. a. If the received packet is a message packet and it is not corrupted, it should save the packet to the buffer and send it to the next receiver. If this node is the final destination, it should send an acknowledgment/success packet backwards through the path. b. If the received packet is a message packet and it is corrupted, it should request a resending. Network Class 1. Implement the constructor and functions getNode, addNode, removeNode. All connections are two-way, hence addNode should add the new node as a neighbor to the already existing nodes. removeNode should remove the reference from the other nodes. c. If the received packet is a success packet, it should save the packet to the buffer and send it to the next receiver. If this node is the source, it should return an empty mac packet to end the simulation. d. If the received packet is an error packet, it should resend the previous packet in the buffer. 2. Implement the function calculatePath. It should calculate the shortest path from source to destination and return a vector of nodes along the path. 3. Implement the simulate function. Main Function 1 a. Calculate the path for the message to take. b. In an infinite loop, send the packet to the destination node. If the response is an empty packet, end the simulation. If the response is a message packet, corrupt the message with the given probability (Hint: (float) std::rand () / RAND_MAX < corruptionRate). 1. Create the network given below. 3 2 XD 4 5 6 7
Expert Answer:
Answer rating: 100% (QA)
Packet Class Implement the hash function using a suitable hashing algorithm eg SHA256 Implement the ... View the full answer
Related Book For
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Define variable. Also discuss variable initialization.
-
Jonczyk Company is considering two different, mutually exclusive capital expenditure proposals. Project A will cost $395,000, has an expected useful life of 10 years, a salvage value of zero, and is...
-
How do epigenetic modifications, such as DNA methylation and histone acetylation, regulate gene expression patterns in multicellular organisms, and what are the implications for development,...
-
Under what circumstances should a healthcare professional self-insure?
-
At the beginning of 2014, Krypton Inc. reporting a deferred tax liability of $80,000. At the end of 2014, the related cumulative temporary difference amounts to $300,000 and it will reverse evenly...
-
1. Mariam plan to paint her patio with water sealant. a) Determine the area of the patio to be painted? Round your answer to the nearest tenth of square feet. (5 points) 6 m =2.5 m b) One can of...
-
XYZ is a calendar-year corporation that began business on January 1, 2017. For 2017, it reported the following information in its current year audited income statement. Notes with important tax...
-
The sum of degrees of a graph is ALWAYS even. In a simple, connected graph on 6 vertices, the degrees of 5 vertices are 1, 2, 3, 4, 5 respectively. What is the degree of the 6th vertex? Draw the...
-
True or False? O(N) is called log time.
-
In reviews and inspections, what is being reviewed or inspected?
-
What is the difference between an object and an object class? Give some examples.
-
The order of sorting an array of N items using one of the better sorting algorithms such as Quicksort. 1. O(1) 2. O(logN) 3. O(N) 4. O(N logN) 5. O(N*N) 6. O(N*N*N)
-
Given the following function: 1. Is there a constraint on the values that can be passed as a parameter for this function to answer the Smaller-Caller Question? 2. Is Func(7) a good call? If so, what...
-
Design across Section of Carying Q = 1-8 m /sec Design by using clayly soil channel S = 20 cm km, n = 0015. factor. a a section Z=1 V=0.9 m/s
-
Match the following. Answers may be used more than once: Measurement Method A. Amortized cost B. Equity method C. Acquisition method and consolidation D. Fair value method Reporting Method 1. Less...
-
The Pierce Company manufactures drill bits. The production of the drill bits occurs in lots of 1000 units. Due to the intense competition in the industry and the correspondingly low prices, Pierce...
-
A local pharmacy has two checkout stations available to its customers: a regular checkout station and an express checkout station. Customers with six or fewer items are assumed to join the express...
-
During the next two months an automobile manufacturer must meet (on time) the following demands for trucks and cars: month 1, 400 trucks and 800 cars; month 2, 300 trucks and 300 cars. During each...
-
A typical timber wolf has a mass of \(40 \mathrm{~kg}\), a typical jackrabbit a mass of \(2.5 \mathrm{~kg}\). Given the scaling law presented in the passage, we'd expect the specific metabolic rate...
-
A standard gold bar stored at Fort Knox, Kentucky, is 7.00 inches long, 3.63 inches wide, and 1.75 inches tall. Gold has a density of \(19,300 \mathrm{~kg} / \mathrm{m}^{3}\). What is the mass of...
-
A typical timber wolf has a mass of \(40 \mathrm{~kg}\), a typical jackrabbit a mass of \(2.5 \mathrm{~kg}\). Given the scaling law presented in the passage, we'd expect the wolf to use times more...
Study smarter with the SolutionInn App