Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 2(C++) Due: 10 March 2018 by 11:55 PM Progam needs to be in C++ In Project 1 we laid the foundation of what will

Project 2(C++) Due: 10 March 2018 by 11:55 PM

Progam needs to be in C++

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 Java 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

We will use this queue of packets in Project 3 to begin routing packets between network objects and begin to simulate communication between network objects.

(Project 1 Q&A given below, already done, Proj 3 is not given to us yet)

Project 1(This was the question for project 1 and the code that i submitted is below this)

Due: February 14, 2018 at 11:55 PM

This project lays the foundation for a series of programs which address various problems in computer networking. Before diving into the complex problems, it is important to build experience with the programming language and techniques we will use to solve them. As demonstrated in class, the syntax of C++ is very similar to Java, so establishing a level of comfort while exercising problem-solving skills is emphasized here rather than minutiae of the language. Those details will be incorporated into later projects through application. Keep in mind that there are many resources to learn the syntactic details of C++. The required and recommended textbooks listed in the Syllabus and the class slides are good resources. Using the internet to find additional resources is encouraged, however the policy on plagiarism is clear and very strict. Do not copy and submit code which is not your own.

Problem Description

This phase of the project will establish two classes. Their specific implementation details are flexible, but they should meet the following requirements:

NetworkObject

This class called NetworkObject defines the abstract properties of an element of our network. Additional capabilities will be added to classes derived from this base class in order to power future projects.

The class should contain at least the following private variables:

int objectId

The class should contain at least the following public methods:

NetworkObject(int objectId)

Constructor which sets the objectId when an object is created.

int getObjectId()

Returns the objectId variable

Server

This class is a dummy derived class to which we will add complexity in future projects. The class should inherit from the NetworkObject class (we will go into detail about inheritance in the 2/10 lecture). For now, it requires no additional functionality beyond a constructor method.

Other Requirements

In your main function, choose a way to store a number of NetworkObject objects. This may be an array, a vector, a linked list, etc, it is your design choice at this stage. The main function should then instantiate some objects and then print their objectIds using the functions and classes created above.

The code i used for Project 1

#include

using namespace std;

class NetworkObject

//beginning Network Object class definition

{

public:

//Constructor

NetworkObject(int objId): objectId(objId){

}

//Parameterized constructor

NetworkObject();

//returns objectId

int getObjectId(){

return objectId;

}

private:

//private member

int objectId;

};

//server class constructor is called from networkobject class parameterized constructor

class Server : public NetworkObject

{

public:

Server(int objId): NetworkObject(objId){}

};

int main()

{

//declare 6 NetworkObjects with id 4,8,16, 32, 64, 128.

NetworkObject at[6] = {{4}, {8}, {16}, {32}, {64}, {128}};

for(int i=0; i<6;i++)

{

//prints the object IDs of the network objects

cout << "Object ID of Network Object: "<< at[i].getObjectId() << endl;

}

}

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

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions