Question
C++ HELP In Project 1 we laid the foundation of what will become a simple network packet transmission simulation. This project will build upon this
C++ HELP
In Project 1 we laid the foundation of what will become a simple network packet transmission simulation. This project will build upon this foundation, utilizing a queue structure to store atomic packets of data which will travel across the network. The advantage of a queue is that, once a routing system is constructed in Project 3, latency will naturally be minimized as packets are essentially prioritized by wait time. Please construct the following class, defined in a file named Packet.h, and define the function bodies in a separate Packet.cpp file: Packet This class should contain the following private variables. You should define public functions which get and set the values of these variables. An integer called targetID An integer called sourceID A string called data Network Object This class (from Project 1) should be modified to contain a private queue variable called packets. I'm trusting that you will recall the form of a FIFO queue from CSC 220 Data Structures. For those who do not recall, the queue will be an easy subject to Google and learn about. How you decide to implement the queue is up to you, so long as it functions according to the normal FIFO expectations of a queue and stores packet objects. More accurately, you will find that storing pointers to packet objects will be far superior than the actual packet object. As we discussed in class, the power of the pointer is in its ability to reference large objects in a compact, easily accessed way.
Project 1 codes
#include
class NetworkObject { private: int objectId;//private member public: NetworkObject(int oid): objectId(oid){}//constructor
int getObjectId()//returns objectId { return objectId; } };
class Server : public NetworkObject//derived from NetworkObject { public: Server(int oid): NetworkObject(oid){} };
int main() { NetworkObject a[4] = {{1}, {2}, {3}, {4}};//declare 4 NetworkObjects with id 1,2,3 and 4.
for(int i=0;i<4;i++) { //prints the object IDs of the 4 objects printf("Object ID of Network Object #%d: %d ", i+1, a[i].getObjectId()); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started