Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include class Packet { private: int sourceId; int destId; std::string message; size _ t hash; public: Packet ( ) ; Packet ( int sourceId,

#include
#include
class Packet
{
private:
int sourceId;
int destId;
std::string message;
size_t hash;
public:
Packet();
Packet(int sourceId, int destId, std::string message);
int getSourceId();
int getDestId();
std::string getMessage();
bool checkIntegrity();
void corrupt();
};
enum class MacPacketType
{
Empty,
Message,
Success,
Failure
};
class MacPacket
{
private:
MacPacketType type;
int macSourceId;
int macDestId;
std::vector path;
Packet packet;
public:
MacPacket();
MacPacket(MacPacketType type, int macSourceId, int macDestId, std::vector& path, Packet& packet);
static MacPacket createMessagePacket(int macSourceId, int macDestId, std::vector& path, Packet& packet);
static MacPacket createSuccessPacket(int macSourceId, int macDestId, std::vector& path);
static MacPacket createFailurePacket(int macSourceId, int macDestId, std::vector& path);
MacPacketType getType();
int getMacSourceId();
int getMacDestId();
std::vector& getPath();
Packet& getPacket();
};
class Node
{
private:
int id;
std::vector neighbors;
MacPacket buffer;
public:
Node();
Node(int id, std::vector& neighbors);
int getId();
std::vector& getNeighbors();
MacPacket receive(MacPacket packet);
};
class Network
{
private:
std::vector nodes;
float corruptionRate;
Node* getNode(int id);
std::vector calculatePath(int source, int destination);
public:
Network(float corruptionRate);
void addNode(int id, std::vector& neighbors);
void removeNode(int id);
void simulate(Packet packet);
};
image text in transcribed

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

What attracts you to our graduate program specifically?

Answered: 1 week ago