MeshProtocolSimulator
1.0.0
|
Go to the documentation of this file.
18 #include "JSON_helper.h"
48 bool Begin(std::string scenarioPath, std::string loggerPath,
int autoPause = -1,
bool logOnly_ =
false,
bool rawOutput_ =
false);
58 inline bool Begin(std::string loggerPath,
bool autoPause =
true,
bool logOnly_ =
false,
bool rawOutput_ =
false) {
59 return Begin(
"", loggerPath, autoPause, logOnly_, rawOutput_);
69 inline bool Begin(
bool autoPause =
true,
bool logOnly_ =
false,
bool rawOutput_ =
false) {
70 return Begin(
"",
"", autoPause, logOnly_, rawOutput_);
95 return beginCalled &&
Paused;
131 bool InvokeNetScan(MeshMAC currentNodeAddress, uint32_t timeout);
147 bool InvokeConnect(MeshMAC currentNodeAddress, MeshMAC networkBSSID);
155 bool InvokeConnect(
int currentNodeIndex, MeshMAC networkBSSID);
211 bool InvokeSend(MeshMAC senderNodeAddress, MeshMAC destNodeAddress,
const char* message, uint8_t size);
221 bool InvokeSend(
int senderNodeIndex,
int destNodeIndex,
const char* message, uint8_t size);
231 bool InvokeSend(MeshMAC senderNodeAddress, MeshMAC destNodeAddress,
const uint8_t* message, uint16_t messageLength);
241 bool InvokeSend(
int senderNodeIndex,
int destNodeIndex,
const uint8_t* message, uint16_t messageLength);
251 bool InvokePing(MeshMAC senderNodeAddress, MeshMAC destNodeAddress, uint32_t timeout, int16_t testDataLength = 0);
261 bool InvokePing(
int senderNodeIndex,
int destNodeIndex, uint32_t timeout, int16_t testDataLength = 0);
443 std::chrono::nanoseconds
runUntil = std::chrono::nanoseconds::zero();
458 std::chrono::nanoseconds
lastSentTime = std::chrono::nanoseconds::zero();
486 friend Simulation_RFI;
493 bool beginCalled =
false;
std::chrono::seconds SimulationLimit
Maximum simulation limit in seconds. After this time, simulation is aborted.
Definition: Emulator.h:118
std::chrono::nanoseconds runUntil
Time, the simulation will run until and after that time it is paused.
Definition: Emulator.h:443
bool AutoPause
True to auto pause simulation after 1 second of inactivity.
Definition: Emulator.h:101
void End()
Ends simulation. This has to be called when logging is enabled.
Definition: Emulator.cpp:168
const NodeConnections * GetConnectionsPtr()
Pointer to array with network connections. Connections can be set from scenario file or can be set to...
Definition: Emulator.h:350
TableType
This enum represents type of table of buffer used in MeshNet.
Definition: Emulator_helpers.h:33
int ConnectionsCount
Count of connections in network.
Definition: Emulator.h:408
Structure, that runs simulation for one node in network and contains some info about that node.
Definition: Emulator_helpers.h:420
This file contains helper classes or structured for Emulator class.
std::chrono::seconds ElapsedTimeUntilLastPause
Time, that elapsed until last pause except time, when simulation was paused.
Definition: Emulator.h:433
bool Begin(std::string loggerPath, bool autoPause=true, bool logOnly_=false, bool rawOutput_=false)
Starts simulation.
Definition: Emulator.h:58
bool InvokePing(MeshMAC senderNodeAddress, MeshMAC destNodeAddress, uint32_t timeout, int16_t testDataLength=0)
Invokes ping packet.
Definition: Emulator.cpp:395
std::chrono::nanoseconds lastSentTime
Time, when message was sent last.
Definition: Emulator.h:458
bool InvokeNetworkDrop(MeshMAC gatewayNodeAddress, bool forced)
Invokes network drop. This can be called only by gateway node.
Definition: Emulator.cpp:351
Emulator()
Constructor.
Definition: Emulator.cpp:12
const static NodeConnections DefaultNodeConnections[9]
Default node connections, when connections are not specified in JSON scenario file....
Definition: Emulator.h:337
bool InvokeNetScan(MeshMAC currentNodeAddress, uint32_t timeout)
Invokes network scan on specified node.
Definition: Emulator.cpp:293
bool RawOutput
True to print raw output for computer.
Definition: Emulator.h:463
int indexOfNode(MeshNet *node)
Gets index of node in nodeSimulators by MeshNet pointer.
Definition: Emulator.cpp:522
bool AbortThreads
True to abort all threads.
Definition: Emulator.h:473
int GetNodesCount()
Count of nodes in network. This value is established when begin() is called.
Definition: Emulator.h:357
const NodeConnections * Connections
Pointer to array with network connections.
Definition: Emulator.h:413
std::chrono::nanoseconds GetMinSimulationTime()
Minimum simulation time elapsed in nanoseconds.
Definition: Emulator.h:378
void Handle()
Processes main simulation loop.
Definition: Emulator.cpp:195
~Emulator()
Destructor.
Definition: Emulator.cpp:16
std::mutex Mutex
Global mutex for current class variables.
Definition: Emulator.h:311
int GetConnectionsCount()
Count of connections between nodes in network.
Definition: Emulator.h:342
std::chrono::nanoseconds maxSimulationTime
Maximum simulation time elapsed in nanoseconds.
Definition: Emulator.h:453
bool TablePrint(MeshMAC nodeAddress, TableType table)
Prints table of selected node.
Definition: Emulator.cpp:416
bool Begin(std::string scenarioPath, std::string loggerPath, int autoPause=-1, bool logOnly_=false, bool rawOutput_=false)
Starts simulation.
Definition: Emulator.cpp:21
std::chrono::nanoseconds GetMaxSimulationTime()
Maximum simulation time elapsed in nanoseconds.
Definition: Emulator.h:385
This class emulates virtual wireless environment for MeshNet nodes (MNodes) with virtual radios....
Definition: Emulator.h:26
bool ResumeUntil(std::chrono::nanoseconds time)
Resumes simulation until specified time.
Definition: Emulator.cpp:487
std::chrono::seconds GetElapsedTime()
Gets real time, that elapsed during simulation except moments when simulation was paused.
Definition: Emulator.cpp:513
bool InvokeSend(MeshMAC senderNodeAddress, MeshMAC destNodeAddress, const char *message, uint8_t size)
Invokes selected node to send message.
Definition: Emulator.cpp:365
void Resume()
Resumes simulation.
Definition: Emulator.cpp:466
int NodesCount
Count of nodes in network. This value is established when begin() is called.
Definition: Emulator.h:418
bool InvokeConnect(MeshMAC currentNodeAddress, MeshMAC networkBSSID)
Invokes node connection to specified node.
Definition: Emulator.cpp:308
bool isRawOutput()
True if output to cout should be in raw for, which can be easily read by computer in another applicat...
Definition: Emulator.h:392
bool logOnly
True to redirect logs to file only.
Definition: Emulator.h:468
bool InvokeDisconnect(MeshMAC currentNodeAddress)
Invokes node disconnection.
Definition: Emulator.cpp:322
bool isLogOnly()
True if output to console is disabled and only logs has to be done. This can be true only if logger i...
Definition: Emulator.h:399
NodeSimulator * nodeSimulators
Array with node simulators for each node. This value is established when begin() is called using Conn...
Definition: Emulator.h:423
bool isPaused()
Returns true if simulation is paused.
Definition: Emulator.h:94
std::chrono::nanoseconds minSimulationTime
Minimum simulation time elapsed in nanoseconds.
Definition: Emulator.h:448
NodeSimulator * GetNodeSimulatorsPtr()
Array with node simulators for each node. Simulators are created when begin() is called and destructe...
Definition: Emulator.h:365
Definition: JSON_helper.h:37
Definition: JSON_helper.h:280
bool SimulationStarted()
Checks if simulation was started by calling begin().
Definition: Emulator.h:82
This structure represents link connection between two nodes. Nodes are indentified by it's MeshMAC ad...
Definition: Emulator_helpers.h:47
JSONScenarioReader scenarioReader
JSON scenario reader.
Definition: Emulator.h:483
bool InvokeNodeDisconnectRequest(MeshMAC gatewayNodeAddress, MeshMAC nodeToDisconnect)
Invokes node disconnection request. This can be called only by gateway node.
Definition: Emulator.cpp:337
JSONLogsWriter logger
Output logger.
Definition: Emulator.h:478
bool Begin(bool autoPause=true, bool logOnly_=false, bool rawOutput_=false)
Starts simulation.
Definition: Emulator.h:69
std::mutex StreamMutex
Global mutex for stream.
Definition: Emulator.h:316
void Pause()
Pauses simulation.
Definition: Emulator.cpp:444
std::chrono::system_clock::time_point SimulationResumeTime
Time, when simulation was last resumed.
Definition: Emulator.h:428
bool Paused
True to pause simulation or when simulation is paused.
Definition: Emulator.h:438