Question: #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);
};
 #include #include class Packet { private: int sourceId; int destId; std::string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!